Merge pull request #103 from TheBlueMatt/main
[ldk-java] / ts / bindings.c.body
1 #include "js-wasm.h"
2 #include <stdatomic.h>
3 #include <lightning.h>
4
5 // These should be provided...somehow...
6 void *memset(void *s, int c, size_t n);
7 void *memcpy(void *dest, const void *src, size_t n);
8 int memcmp(const void *s1, const void *s2, size_t n);
9
10 extern void __attribute__((noreturn)) abort(void);
11 static inline void assert(bool expression) {
12         if (!expression) { abort(); }
13 }
14
15 uint32_t __attribute__((export_name("test_bigint_pass_deadbeef0badf00d"))) test_bigint_pass_deadbeef0badf00d(uint64_t val) {
16         return val == 0xdeadbeef0badf00dULL;
17 }
18
19
20 void *malloc(size_t size);
21 void free(void *ptr);
22
23 #define MALLOC(a, _) malloc(a)
24 #define do_MALLOC(a, _b, _c) malloc(a)
25 #define FREE(p) if ((unsigned long)(p) > 4096) { free(p); }
26 #define DO_ASSERT(a) (void)(a)
27 #define CHECK(a)
28 #define CHECK_ACCESS(p)
29 #define CHECK_INNER_FIELD_ACCESS_OR_NULL(v)
30
31 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
32 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
33 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
34 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
35
36 _Static_assert(sizeof(void*) == 4, "Pointers mut be 32 bits");
37
38 #define DECL_ARR_TYPE(ty, name) \
39         struct name##array { \
40                 uint32_t arr_len; \
41                 ty elems[]; \
42         }; \
43         typedef struct name##array * name##Array; \
44         static inline name##Array init_##name##Array(size_t arr_len, int lineno) { \
45                 name##Array arr = (name##Array)do_MALLOC(arr_len * sizeof(ty) + sizeof(uint32_t), #name" array init", lineno); \
46                 arr->arr_len = arr_len; \
47                 return arr; \
48         }
49
50 DECL_ARR_TYPE(int64_t, int64_t);
51 DECL_ARR_TYPE(int8_t, int8_t);
52 DECL_ARR_TYPE(uint32_t, uint32_t);
53 DECL_ARR_TYPE(void*, ptr);
54 DECL_ARR_TYPE(char, char);
55 typedef charArray jstring;
56
57 static inline jstring str_ref_to_ts(const char* chars, size_t len) {
58         charArray arr = init_charArray(len, __LINE__);
59         memcpy(arr->elems, chars, len);
60         return arr;
61 }
62 static inline LDKStr str_ref_to_owned_c(const jstring str) {
63         char* newchars = MALLOC(str->arr_len + 1, "String chars");
64         memcpy(newchars, str->elems, str->arr_len);
65         newchars[str->arr_len] = 0;
66         LDKStr res = {
67                 .chars = newchars,
68                 .len = str->arr_len,
69                 .chars_is_owned = true
70         };
71         return res;
72 }
73
74 typedef bool jboolean;
75
76 uint32_t __attribute__((export_name("TS_malloc"))) TS_malloc(uint32_t size) {
77         return (uint32_t)MALLOC(size, "JS-Called malloc");
78 }
79 void __attribute__((export_name("TS_free"))) TS_free(uint32_t ptr) {
80         FREE((void*)ptr);
81 }
82
83 jstring __attribute__((export_name("TS_get_ldk_c_bindings_version"))) TS_get_ldk_c_bindings_version() {
84         const char *res = check_get_ldk_bindings_version();
85         if (res == NULL) return NULL;
86         return str_ref_to_ts(res, strlen(res));
87 }
88 jstring __attribute__((export_name("TS_get_ldk_version"))) get_ldk_version() {
89         const char *res = check_get_ldk_version();
90         if (res == NULL) return NULL;
91         return str_ref_to_ts(res, strlen(res));
92 }
93 #include "version.c"
94 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
95 static inline LDKAccessError LDKAccessError_from_js(int32_t ord) {
96         switch (ord) {
97                 case 0: return LDKAccessError_UnknownChain;
98                 case 1: return LDKAccessError_UnknownTx;
99         }
100         abort();
101 }
102 static inline int32_t LDKAccessError_to_js(LDKAccessError val) {
103         switch (val) {
104                 case LDKAccessError_UnknownChain: return 0;
105                 case LDKAccessError_UnknownTx: return 1;
106                 default: abort();
107         }
108 }
109 static inline LDKCOption_NoneZ LDKCOption_NoneZ_from_js(int32_t ord) {
110         switch (ord) {
111                 case 0: return LDKCOption_NoneZ_Some;
112                 case 1: return LDKCOption_NoneZ_None;
113         }
114         abort();
115 }
116 static inline int32_t LDKCOption_NoneZ_to_js(LDKCOption_NoneZ val) {
117         switch (val) {
118                 case LDKCOption_NoneZ_Some: return 0;
119                 case LDKCOption_NoneZ_None: return 1;
120                 default: abort();
121         }
122 }
123 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_js(int32_t ord) {
124         switch (ord) {
125                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
126                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
127         }
128         abort();
129 }
130 static inline int32_t LDKChannelMonitorUpdateErr_to_js(LDKChannelMonitorUpdateErr val) {
131         switch (val) {
132                 case LDKChannelMonitorUpdateErr_TemporaryFailure: return 0;
133                 case LDKChannelMonitorUpdateErr_PermanentFailure: return 1;
134                 default: abort();
135         }
136 }
137 static inline LDKConfirmationTarget LDKConfirmationTarget_from_js(int32_t ord) {
138         switch (ord) {
139                 case 0: return LDKConfirmationTarget_Background;
140                 case 1: return LDKConfirmationTarget_Normal;
141                 case 2: return LDKConfirmationTarget_HighPriority;
142         }
143         abort();
144 }
145 static inline int32_t LDKConfirmationTarget_to_js(LDKConfirmationTarget val) {
146         switch (val) {
147                 case LDKConfirmationTarget_Background: return 0;
148                 case LDKConfirmationTarget_Normal: return 1;
149                 case LDKConfirmationTarget_HighPriority: return 2;
150                 default: abort();
151         }
152 }
153 static inline LDKCreationError LDKCreationError_from_js(int32_t ord) {
154         switch (ord) {
155                 case 0: return LDKCreationError_DescriptionTooLong;
156                 case 1: return LDKCreationError_RouteTooLong;
157                 case 2: return LDKCreationError_TimestampOutOfBounds;
158                 case 3: return LDKCreationError_InvalidAmount;
159                 case 4: return LDKCreationError_MissingRouteHints;
160         }
161         abort();
162 }
163 static inline int32_t LDKCreationError_to_js(LDKCreationError val) {
164         switch (val) {
165                 case LDKCreationError_DescriptionTooLong: return 0;
166                 case LDKCreationError_RouteTooLong: return 1;
167                 case LDKCreationError_TimestampOutOfBounds: return 2;
168                 case LDKCreationError_InvalidAmount: return 3;
169                 case LDKCreationError_MissingRouteHints: return 4;
170                 default: abort();
171         }
172 }
173 static inline LDKCurrency LDKCurrency_from_js(int32_t ord) {
174         switch (ord) {
175                 case 0: return LDKCurrency_Bitcoin;
176                 case 1: return LDKCurrency_BitcoinTestnet;
177                 case 2: return LDKCurrency_Regtest;
178                 case 3: return LDKCurrency_Simnet;
179                 case 4: return LDKCurrency_Signet;
180         }
181         abort();
182 }
183 static inline int32_t LDKCurrency_to_js(LDKCurrency val) {
184         switch (val) {
185                 case LDKCurrency_Bitcoin: return 0;
186                 case LDKCurrency_BitcoinTestnet: return 1;
187                 case LDKCurrency_Regtest: return 2;
188                 case LDKCurrency_Simnet: return 3;
189                 case LDKCurrency_Signet: return 4;
190                 default: abort();
191         }
192 }
193 static inline LDKIOError LDKIOError_from_js(int32_t ord) {
194         switch (ord) {
195                 case 0: return LDKIOError_NotFound;
196                 case 1: return LDKIOError_PermissionDenied;
197                 case 2: return LDKIOError_ConnectionRefused;
198                 case 3: return LDKIOError_ConnectionReset;
199                 case 4: return LDKIOError_ConnectionAborted;
200                 case 5: return LDKIOError_NotConnected;
201                 case 6: return LDKIOError_AddrInUse;
202                 case 7: return LDKIOError_AddrNotAvailable;
203                 case 8: return LDKIOError_BrokenPipe;
204                 case 9: return LDKIOError_AlreadyExists;
205                 case 10: return LDKIOError_WouldBlock;
206                 case 11: return LDKIOError_InvalidInput;
207                 case 12: return LDKIOError_InvalidData;
208                 case 13: return LDKIOError_TimedOut;
209                 case 14: return LDKIOError_WriteZero;
210                 case 15: return LDKIOError_Interrupted;
211                 case 16: return LDKIOError_Other;
212                 case 17: return LDKIOError_UnexpectedEof;
213         }
214         abort();
215 }
216 static inline int32_t LDKIOError_to_js(LDKIOError val) {
217         switch (val) {
218                 case LDKIOError_NotFound: return 0;
219                 case LDKIOError_PermissionDenied: return 1;
220                 case LDKIOError_ConnectionRefused: return 2;
221                 case LDKIOError_ConnectionReset: return 3;
222                 case LDKIOError_ConnectionAborted: return 4;
223                 case LDKIOError_NotConnected: return 5;
224                 case LDKIOError_AddrInUse: return 6;
225                 case LDKIOError_AddrNotAvailable: return 7;
226                 case LDKIOError_BrokenPipe: return 8;
227                 case LDKIOError_AlreadyExists: return 9;
228                 case LDKIOError_WouldBlock: return 10;
229                 case LDKIOError_InvalidInput: return 11;
230                 case LDKIOError_InvalidData: return 12;
231                 case LDKIOError_TimedOut: return 13;
232                 case LDKIOError_WriteZero: return 14;
233                 case LDKIOError_Interrupted: return 15;
234                 case LDKIOError_Other: return 16;
235                 case LDKIOError_UnexpectedEof: return 17;
236                 default: abort();
237         }
238 }
239 static inline LDKLevel LDKLevel_from_js(int32_t ord) {
240         switch (ord) {
241                 case 0: return LDKLevel_Gossip;
242                 case 1: return LDKLevel_Trace;
243                 case 2: return LDKLevel_Debug;
244                 case 3: return LDKLevel_Info;
245                 case 4: return LDKLevel_Warn;
246                 case 5: return LDKLevel_Error;
247         }
248         abort();
249 }
250 static inline int32_t LDKLevel_to_js(LDKLevel val) {
251         switch (val) {
252                 case LDKLevel_Gossip: return 0;
253                 case LDKLevel_Trace: return 1;
254                 case LDKLevel_Debug: return 2;
255                 case LDKLevel_Info: return 3;
256                 case LDKLevel_Warn: return 4;
257                 case LDKLevel_Error: return 5;
258                 default: abort();
259         }
260 }
261 static inline LDKNetwork LDKNetwork_from_js(int32_t ord) {
262         switch (ord) {
263                 case 0: return LDKNetwork_Bitcoin;
264                 case 1: return LDKNetwork_Testnet;
265                 case 2: return LDKNetwork_Regtest;
266                 case 3: return LDKNetwork_Signet;
267         }
268         abort();
269 }
270 static inline int32_t LDKNetwork_to_js(LDKNetwork val) {
271         switch (val) {
272                 case LDKNetwork_Bitcoin: return 0;
273                 case LDKNetwork_Testnet: return 1;
274                 case LDKNetwork_Regtest: return 2;
275                 case LDKNetwork_Signet: return 3;
276                 default: abort();
277         }
278 }
279 static inline LDKRecipient LDKRecipient_from_js(int32_t ord) {
280         switch (ord) {
281                 case 0: return LDKRecipient_Node;
282                 case 1: return LDKRecipient_PhantomNode;
283         }
284         abort();
285 }
286 static inline int32_t LDKRecipient_to_js(LDKRecipient val) {
287         switch (val) {
288                 case LDKRecipient_Node: return 0;
289                 case LDKRecipient_PhantomNode: return 1;
290                 default: abort();
291         }
292 }
293 static inline LDKSecp256k1Error LDKSecp256k1Error_from_js(int32_t ord) {
294         switch (ord) {
295                 case 0: return LDKSecp256k1Error_IncorrectSignature;
296                 case 1: return LDKSecp256k1Error_InvalidMessage;
297                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
298                 case 3: return LDKSecp256k1Error_InvalidSignature;
299                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
300                 case 5: return LDKSecp256k1Error_InvalidSharedSecret;
301                 case 6: return LDKSecp256k1Error_InvalidRecoveryId;
302                 case 7: return LDKSecp256k1Error_InvalidTweak;
303                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
304                 case 9: return LDKSecp256k1Error_InvalidPublicKeySum;
305                 case 10: return LDKSecp256k1Error_InvalidParityValue;
306         }
307         abort();
308 }
309 static inline int32_t LDKSecp256k1Error_to_js(LDKSecp256k1Error val) {
310         switch (val) {
311                 case LDKSecp256k1Error_IncorrectSignature: return 0;
312                 case LDKSecp256k1Error_InvalidMessage: return 1;
313                 case LDKSecp256k1Error_InvalidPublicKey: return 2;
314                 case LDKSecp256k1Error_InvalidSignature: return 3;
315                 case LDKSecp256k1Error_InvalidSecretKey: return 4;
316                 case LDKSecp256k1Error_InvalidSharedSecret: return 5;
317                 case LDKSecp256k1Error_InvalidRecoveryId: return 6;
318                 case LDKSecp256k1Error_InvalidTweak: return 7;
319                 case LDKSecp256k1Error_NotEnoughMemory: return 8;
320                 case LDKSecp256k1Error_InvalidPublicKeySum: return 9;
321                 case LDKSecp256k1Error_InvalidParityValue: return 10;
322                 default: abort();
323         }
324 }
325 static inline LDKSemanticError LDKSemanticError_from_js(int32_t ord) {
326         switch (ord) {
327                 case 0: return LDKSemanticError_NoPaymentHash;
328                 case 1: return LDKSemanticError_MultiplePaymentHashes;
329                 case 2: return LDKSemanticError_NoDescription;
330                 case 3: return LDKSemanticError_MultipleDescriptions;
331                 case 4: return LDKSemanticError_NoPaymentSecret;
332                 case 5: return LDKSemanticError_MultiplePaymentSecrets;
333                 case 6: return LDKSemanticError_InvalidFeatures;
334                 case 7: return LDKSemanticError_InvalidRecoveryId;
335                 case 8: return LDKSemanticError_InvalidSignature;
336                 case 9: return LDKSemanticError_ImpreciseAmount;
337         }
338         abort();
339 }
340 static inline int32_t LDKSemanticError_to_js(LDKSemanticError val) {
341         switch (val) {
342                 case LDKSemanticError_NoPaymentHash: return 0;
343                 case LDKSemanticError_MultiplePaymentHashes: return 1;
344                 case LDKSemanticError_NoDescription: return 2;
345                 case LDKSemanticError_MultipleDescriptions: return 3;
346                 case LDKSemanticError_NoPaymentSecret: return 4;
347                 case LDKSemanticError_MultiplePaymentSecrets: return 5;
348                 case LDKSemanticError_InvalidFeatures: return 6;
349                 case LDKSemanticError_InvalidRecoveryId: return 7;
350                 case LDKSemanticError_InvalidSignature: return 8;
351                 case LDKSemanticError_ImpreciseAmount: return 9;
352                 default: abort();
353         }
354 }
355 static inline LDKSiPrefix LDKSiPrefix_from_js(int32_t ord) {
356         switch (ord) {
357                 case 0: return LDKSiPrefix_Milli;
358                 case 1: return LDKSiPrefix_Micro;
359                 case 2: return LDKSiPrefix_Nano;
360                 case 3: return LDKSiPrefix_Pico;
361         }
362         abort();
363 }
364 static inline int32_t LDKSiPrefix_to_js(LDKSiPrefix val) {
365         switch (val) {
366                 case LDKSiPrefix_Milli: return 0;
367                 case LDKSiPrefix_Micro: return 1;
368                 case LDKSiPrefix_Nano: return 2;
369                 case LDKSiPrefix_Pico: return 3;
370                 default: abort();
371         }
372 }
373 uint32_t __attribute__((export_name("TS_LDKBech32Error_ty_from_ptr"))) TS_LDKBech32Error_ty_from_ptr(uint32_t ptr) {
374         LDKBech32Error *obj = (LDKBech32Error*)(ptr & ~1);
375         switch(obj->tag) {
376                 case LDKBech32Error_MissingSeparator: return 0;
377                 case LDKBech32Error_InvalidChecksum: return 1;
378                 case LDKBech32Error_InvalidLength: return 2;
379                 case LDKBech32Error_InvalidChar: return 3;
380                 case LDKBech32Error_InvalidData: return 4;
381                 case LDKBech32Error_InvalidPadding: return 5;
382                 case LDKBech32Error_MixedCase: return 6;
383                 default: abort();
384         }
385 }
386 int32_t __attribute__((export_name("TS_LDKBech32Error_InvalidChar_get_invalid_char"))) TS_LDKBech32Error_InvalidChar_get_invalid_char(uint32_t ptr) {
387         LDKBech32Error *obj = (LDKBech32Error*)(ptr & ~1);
388         assert(obj->tag == LDKBech32Error_InvalidChar);
389                         int32_t invalid_char_conv = obj->invalid_char;
390         return invalid_char_conv;
391 }
392 int8_t __attribute__((export_name("TS_LDKBech32Error_InvalidData_get_invalid_data"))) TS_LDKBech32Error_InvalidData_get_invalid_data(uint32_t ptr) {
393         LDKBech32Error *obj = (LDKBech32Error*)(ptr & ~1);
394         assert(obj->tag == LDKBech32Error_InvalidData);
395                         int8_t invalid_data_conv = obj->invalid_data;
396         return invalid_data_conv;
397 }
398 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
399         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
400         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
401         return ret;
402 }
403 struct LDKCVec_u8Z TxOut_get_script_pubkey (struct LDKTxOut* thing) {   return CVec_u8Z_clone(&thing->script_pubkey);}int8_tArray  __attribute__((export_name("TS_TxOut_get_script_pubkey"))) TS_TxOut_get_script_pubkey(uint32_t thing) {
404         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
405         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
406         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
407         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
408         CVec_u8Z_free(ret_var);
409         return ret_arr;
410 }
411
412 uint64_t TxOut_get_value (struct LDKTxOut* thing) {     return thing->value;}int64_t  __attribute__((export_name("TS_TxOut_get_value"))) TS_TxOut_get_value(uint32_t thing) {
413         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
414         int64_t ret_conv = TxOut_get_value(thing_conv);
415         return ret_conv;
416 }
417
418 static inline void CResult_NoneNoneZ_get_ok(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
419 CHECK(owner->result_ok);
420         return *owner->contents.result;
421 }
422 void  __attribute__((export_name("TS_CResult_NoneNoneZ_get_ok"))) TS_CResult_NoneNoneZ_get_ok(uint32_t owner) {
423         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
424         CResult_NoneNoneZ_get_ok(owner_conv);
425 }
426
427 static inline void CResult_NoneNoneZ_get_err(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
428 CHECK(!owner->result_ok);
429         return *owner->contents.err;
430 }
431 void  __attribute__((export_name("TS_CResult_NoneNoneZ_get_err"))) TS_CResult_NoneNoneZ_get_err(uint32_t owner) {
432         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
433         CResult_NoneNoneZ_get_err(owner_conv);
434 }
435
436 static inline struct LDKCounterpartyCommitmentSecrets CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
437 CHECK(owner->result_ok);
438         return CounterpartyCommitmentSecrets_clone(&*owner->contents.result);
439 }
440 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(uint32_t owner) {
441         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(owner & ~1);
442         LDKCounterpartyCommitmentSecrets ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(owner_conv);
443         uint32_t ret_ref = 0;
444         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
445         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
446         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
447         ret_ref = (uintptr_t)ret_var.inner;
448         if (ret_var.is_owned) {
449                 ret_ref |= 1;
450         }
451         return ret_ref;
452 }
453
454 static inline struct LDKDecodeError CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
455 CHECK(!owner->result_ok);
456         return DecodeError_clone(&*owner->contents.err);
457 }
458 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(uint32_t owner) {
459         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(owner & ~1);
460         LDKDecodeError ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(owner_conv);
461         uint32_t ret_ref = 0;
462         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
463         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
464         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
465         ret_ref = (uintptr_t)ret_var.inner;
466         if (ret_var.is_owned) {
467                 ret_ref |= 1;
468         }
469         return ret_ref;
470 }
471
472 static inline struct LDKSecretKey CResult_SecretKeyErrorZ_get_ok(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
473 CHECK(owner->result_ok);
474         return *owner->contents.result;
475 }
476 int8_tArray  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_get_ok"))) TS_CResult_SecretKeyErrorZ_get_ok(uint32_t owner) {
477         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
478         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
479         memcpy(ret_arr->elems, CResult_SecretKeyErrorZ_get_ok(owner_conv).bytes, 32);
480         return ret_arr;
481 }
482
483 static inline enum LDKSecp256k1Error CResult_SecretKeyErrorZ_get_err(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
484 CHECK(!owner->result_ok);
485         return *owner->contents.err;
486 }
487 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_get_err"))) TS_CResult_SecretKeyErrorZ_get_err(uint32_t owner) {
488         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
489         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_SecretKeyErrorZ_get_err(owner_conv));
490         return ret_conv;
491 }
492
493 static inline struct LDKPublicKey CResult_PublicKeyErrorZ_get_ok(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
494 CHECK(owner->result_ok);
495         return *owner->contents.result;
496 }
497 int8_tArray  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_get_ok"))) TS_CResult_PublicKeyErrorZ_get_ok(uint32_t owner) {
498         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
499         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
500         memcpy(ret_arr->elems, CResult_PublicKeyErrorZ_get_ok(owner_conv).compressed_form, 33);
501         return ret_arr;
502 }
503
504 static inline enum LDKSecp256k1Error CResult_PublicKeyErrorZ_get_err(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
505 CHECK(!owner->result_ok);
506         return *owner->contents.err;
507 }
508 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_get_err"))) TS_CResult_PublicKeyErrorZ_get_err(uint32_t owner) {
509         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
510         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_PublicKeyErrorZ_get_err(owner_conv));
511         return ret_conv;
512 }
513
514 static inline struct LDKTxCreationKeys CResult_TxCreationKeysDecodeErrorZ_get_ok(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
515 CHECK(owner->result_ok);
516         return TxCreationKeys_clone(&*owner->contents.result);
517 }
518 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_get_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_get_ok(uint32_t owner) {
519         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
520         LDKTxCreationKeys ret_var = CResult_TxCreationKeysDecodeErrorZ_get_ok(owner_conv);
521         uint32_t ret_ref = 0;
522         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
523         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
524         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
525         ret_ref = (uintptr_t)ret_var.inner;
526         if (ret_var.is_owned) {
527                 ret_ref |= 1;
528         }
529         return ret_ref;
530 }
531
532 static inline struct LDKDecodeError CResult_TxCreationKeysDecodeErrorZ_get_err(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
533 CHECK(!owner->result_ok);
534         return DecodeError_clone(&*owner->contents.err);
535 }
536 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_get_err"))) TS_CResult_TxCreationKeysDecodeErrorZ_get_err(uint32_t owner) {
537         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
538         LDKDecodeError ret_var = CResult_TxCreationKeysDecodeErrorZ_get_err(owner_conv);
539         uint32_t ret_ref = 0;
540         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
541         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
542         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
543         ret_ref = (uintptr_t)ret_var.inner;
544         if (ret_var.is_owned) {
545                 ret_ref |= 1;
546         }
547         return ret_ref;
548 }
549
550 static inline struct LDKChannelPublicKeys CResult_ChannelPublicKeysDecodeErrorZ_get_ok(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
551 CHECK(owner->result_ok);
552         return ChannelPublicKeys_clone(&*owner->contents.result);
553 }
554 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_get_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_get_ok(uint32_t owner) {
555         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
556         LDKChannelPublicKeys ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_ok(owner_conv);
557         uint32_t ret_ref = 0;
558         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
559         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
560         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
561         ret_ref = (uintptr_t)ret_var.inner;
562         if (ret_var.is_owned) {
563                 ret_ref |= 1;
564         }
565         return ret_ref;
566 }
567
568 static inline struct LDKDecodeError CResult_ChannelPublicKeysDecodeErrorZ_get_err(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
569 CHECK(!owner->result_ok);
570         return DecodeError_clone(&*owner->contents.err);
571 }
572 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_get_err"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_get_err(uint32_t owner) {
573         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
574         LDKDecodeError ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_err(owner_conv);
575         uint32_t ret_ref = 0;
576         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
577         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
578         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
579         ret_ref = (uintptr_t)ret_var.inner;
580         if (ret_var.is_owned) {
581                 ret_ref |= 1;
582         }
583         return ret_ref;
584 }
585
586 static inline struct LDKTxCreationKeys CResult_TxCreationKeysErrorZ_get_ok(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
587 CHECK(owner->result_ok);
588         return TxCreationKeys_clone(&*owner->contents.result);
589 }
590 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_get_ok"))) TS_CResult_TxCreationKeysErrorZ_get_ok(uint32_t owner) {
591         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
592         LDKTxCreationKeys ret_var = CResult_TxCreationKeysErrorZ_get_ok(owner_conv);
593         uint32_t ret_ref = 0;
594         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
595         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
596         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
597         ret_ref = (uintptr_t)ret_var.inner;
598         if (ret_var.is_owned) {
599                 ret_ref |= 1;
600         }
601         return ret_ref;
602 }
603
604 static inline enum LDKSecp256k1Error CResult_TxCreationKeysErrorZ_get_err(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
605 CHECK(!owner->result_ok);
606         return *owner->contents.err;
607 }
608 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_get_err"))) TS_CResult_TxCreationKeysErrorZ_get_err(uint32_t owner) {
609         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
610         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_TxCreationKeysErrorZ_get_err(owner_conv));
611         return ret_conv;
612 }
613
614 uint32_t __attribute__((export_name("TS_LDKCOption_u32Z_ty_from_ptr"))) TS_LDKCOption_u32Z_ty_from_ptr(uint32_t ptr) {
615         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
616         switch(obj->tag) {
617                 case LDKCOption_u32Z_Some: return 0;
618                 case LDKCOption_u32Z_None: return 1;
619                 default: abort();
620         }
621 }
622 int32_t __attribute__((export_name("TS_LDKCOption_u32Z_Some_get_some"))) TS_LDKCOption_u32Z_Some_get_some(uint32_t ptr) {
623         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
624         assert(obj->tag == LDKCOption_u32Z_Some);
625                         int32_t some_conv = obj->some;
626         return some_conv;
627 }
628 static inline struct LDKHTLCOutputInCommitment CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
629 CHECK(owner->result_ok);
630         return HTLCOutputInCommitment_clone(&*owner->contents.result);
631 }
632 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(uint32_t owner) {
633         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
634         LDKHTLCOutputInCommitment ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(owner_conv);
635         uint32_t ret_ref = 0;
636         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
637         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
638         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
639         ret_ref = (uintptr_t)ret_var.inner;
640         if (ret_var.is_owned) {
641                 ret_ref |= 1;
642         }
643         return ret_ref;
644 }
645
646 static inline struct LDKDecodeError CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
647 CHECK(!owner->result_ok);
648         return DecodeError_clone(&*owner->contents.err);
649 }
650 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(uint32_t owner) {
651         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
652         LDKDecodeError ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(owner_conv);
653         uint32_t ret_ref = 0;
654         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
655         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
656         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
657         ret_ref = (uintptr_t)ret_var.inner;
658         if (ret_var.is_owned) {
659                 ret_ref |= 1;
660         }
661         return ret_ref;
662 }
663
664 static inline struct LDKCounterpartyChannelTransactionParameters CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
665 CHECK(owner->result_ok);
666         return CounterpartyChannelTransactionParameters_clone(&*owner->contents.result);
667 }
668 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t owner) {
669         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
670         LDKCounterpartyChannelTransactionParameters ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
671         uint32_t ret_ref = 0;
672         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
673         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
674         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
675         ret_ref = (uintptr_t)ret_var.inner;
676         if (ret_var.is_owned) {
677                 ret_ref |= 1;
678         }
679         return ret_ref;
680 }
681
682 static inline struct LDKDecodeError CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
683 CHECK(!owner->result_ok);
684         return DecodeError_clone(&*owner->contents.err);
685 }
686 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(uint32_t owner) {
687         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
688         LDKDecodeError ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
689         uint32_t ret_ref = 0;
690         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
691         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
692         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
693         ret_ref = (uintptr_t)ret_var.inner;
694         if (ret_var.is_owned) {
695                 ret_ref |= 1;
696         }
697         return ret_ref;
698 }
699
700 static inline struct LDKChannelTransactionParameters CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
701 CHECK(owner->result_ok);
702         return ChannelTransactionParameters_clone(&*owner->contents.result);
703 }
704 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t owner) {
705         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
706         LDKChannelTransactionParameters ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
707         uint32_t ret_ref = 0;
708         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
709         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
710         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
711         ret_ref = (uintptr_t)ret_var.inner;
712         if (ret_var.is_owned) {
713                 ret_ref |= 1;
714         }
715         return ret_ref;
716 }
717
718 static inline struct LDKDecodeError CResult_ChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
719 CHECK(!owner->result_ok);
720         return DecodeError_clone(&*owner->contents.err);
721 }
722 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_err"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_err(uint32_t owner) {
723         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
724         LDKDecodeError ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
725         uint32_t ret_ref = 0;
726         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
727         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
728         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
729         ret_ref = (uintptr_t)ret_var.inner;
730         if (ret_var.is_owned) {
731                 ret_ref |= 1;
732         }
733         return ret_ref;
734 }
735
736 static inline struct LDKHolderCommitmentTransaction CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
737 CHECK(owner->result_ok);
738         return HolderCommitmentTransaction_clone(&*owner->contents.result);
739 }
740 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(uint32_t owner) {
741         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
742         LDKHolderCommitmentTransaction ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
743         uint32_t ret_ref = 0;
744         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
745         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
746         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
747         ret_ref = (uintptr_t)ret_var.inner;
748         if (ret_var.is_owned) {
749                 ret_ref |= 1;
750         }
751         return ret_ref;
752 }
753
754 static inline struct LDKDecodeError CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
755 CHECK(!owner->result_ok);
756         return DecodeError_clone(&*owner->contents.err);
757 }
758 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(uint32_t owner) {
759         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
760         LDKDecodeError ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
761         uint32_t ret_ref = 0;
762         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
763         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
764         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
765         ret_ref = (uintptr_t)ret_var.inner;
766         if (ret_var.is_owned) {
767                 ret_ref |= 1;
768         }
769         return ret_ref;
770 }
771
772 static inline struct LDKBuiltCommitmentTransaction CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
773 CHECK(owner->result_ok);
774         return BuiltCommitmentTransaction_clone(&*owner->contents.result);
775 }
776 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(uint32_t owner) {
777         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
778         LDKBuiltCommitmentTransaction ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
779         uint32_t ret_ref = 0;
780         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
781         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
782         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
783         ret_ref = (uintptr_t)ret_var.inner;
784         if (ret_var.is_owned) {
785                 ret_ref |= 1;
786         }
787         return ret_ref;
788 }
789
790 static inline struct LDKDecodeError CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
791 CHECK(!owner->result_ok);
792         return DecodeError_clone(&*owner->contents.err);
793 }
794 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(uint32_t owner) {
795         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
796         LDKDecodeError ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
797         uint32_t ret_ref = 0;
798         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
799         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
800         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
801         ret_ref = (uintptr_t)ret_var.inner;
802         if (ret_var.is_owned) {
803                 ret_ref |= 1;
804         }
805         return ret_ref;
806 }
807
808 static inline struct LDKTrustedClosingTransaction *CResult_TrustedClosingTransactionNoneZ_get_ok(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
809 CHECK(owner->result_ok);
810         return &*owner->contents.result;
811 }
812 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_get_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_get_ok(uint32_t owner) {
813         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
814         LDKTrustedClosingTransaction ret_var = *CResult_TrustedClosingTransactionNoneZ_get_ok(owner_conv);
815         uint32_t ret_ref = 0;
816         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
817         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
818         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
819         ret_ref = (uintptr_t)ret_var.inner & ~1;
820         return ret_ref;
821 }
822
823 static inline void CResult_TrustedClosingTransactionNoneZ_get_err(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
824 CHECK(!owner->result_ok);
825         return *owner->contents.err;
826 }
827 void  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_get_err"))) TS_CResult_TrustedClosingTransactionNoneZ_get_err(uint32_t owner) {
828         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
829         CResult_TrustedClosingTransactionNoneZ_get_err(owner_conv);
830 }
831
832 static inline struct LDKCommitmentTransaction CResult_CommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
833 CHECK(owner->result_ok);
834         return CommitmentTransaction_clone(&*owner->contents.result);
835 }
836 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_get_ok(uint32_t owner) {
837         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
838         LDKCommitmentTransaction ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
839         uint32_t ret_ref = 0;
840         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
841         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
842         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
843         ret_ref = (uintptr_t)ret_var.inner;
844         if (ret_var.is_owned) {
845                 ret_ref |= 1;
846         }
847         return ret_ref;
848 }
849
850 static inline struct LDKDecodeError CResult_CommitmentTransactionDecodeErrorZ_get_err(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
851 CHECK(!owner->result_ok);
852         return DecodeError_clone(&*owner->contents.err);
853 }
854 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_CommitmentTransactionDecodeErrorZ_get_err(uint32_t owner) {
855         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
856         LDKDecodeError ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_err(owner_conv);
857         uint32_t ret_ref = 0;
858         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
859         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
860         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
861         ret_ref = (uintptr_t)ret_var.inner;
862         if (ret_var.is_owned) {
863                 ret_ref |= 1;
864         }
865         return ret_ref;
866 }
867
868 static inline struct LDKTrustedCommitmentTransaction *CResult_TrustedCommitmentTransactionNoneZ_get_ok(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
869 CHECK(owner->result_ok);
870         return &*owner->contents.result;
871 }
872 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_get_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_get_ok(uint32_t owner) {
873         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
874         LDKTrustedCommitmentTransaction ret_var = *CResult_TrustedCommitmentTransactionNoneZ_get_ok(owner_conv);
875         uint32_t ret_ref = 0;
876         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
877         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
878         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
879         ret_ref = (uintptr_t)ret_var.inner & ~1;
880         return ret_ref;
881 }
882
883 static inline void CResult_TrustedCommitmentTransactionNoneZ_get_err(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
884 CHECK(!owner->result_ok);
885         return *owner->contents.err;
886 }
887 void  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_get_err"))) TS_CResult_TrustedCommitmentTransactionNoneZ_get_err(uint32_t owner) {
888         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
889         CResult_TrustedCommitmentTransactionNoneZ_get_err(owner_conv);
890 }
891
892 static inline struct LDKCVec_SignatureZ CResult_CVec_SignatureZNoneZ_get_ok(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
893 CHECK(owner->result_ok);
894         return *owner->contents.result;
895 }
896 ptrArray  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_get_ok"))) TS_CResult_CVec_SignatureZNoneZ_get_ok(uint32_t owner) {
897         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
898         LDKCVec_SignatureZ ret_var = CResult_CVec_SignatureZNoneZ_get_ok(owner_conv);
899         ptrArray ret_arr = NULL;
900         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
901         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
902         for (size_t m = 0; m < ret_var.datalen; m++) {
903                 int8_tArray ret_conv_12_arr = init_int8_tArray(64, __LINE__);
904                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compact_form, 64);
905                 ret_arr_ptr[m] = ret_conv_12_arr;
906         }
907         
908         return ret_arr;
909 }
910
911 static inline void CResult_CVec_SignatureZNoneZ_get_err(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
912 CHECK(!owner->result_ok);
913         return *owner->contents.err;
914 }
915 void  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_get_err"))) TS_CResult_CVec_SignatureZNoneZ_get_err(uint32_t owner) {
916         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
917         CResult_CVec_SignatureZNoneZ_get_err(owner_conv);
918 }
919
920 static inline struct LDKShutdownScript CResult_ShutdownScriptDecodeErrorZ_get_ok(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
921 CHECK(owner->result_ok);
922         return ShutdownScript_clone(&*owner->contents.result);
923 }
924 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_get_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_get_ok(uint32_t owner) {
925         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
926         LDKShutdownScript ret_var = CResult_ShutdownScriptDecodeErrorZ_get_ok(owner_conv);
927         uint32_t ret_ref = 0;
928         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
929         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
930         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
931         ret_ref = (uintptr_t)ret_var.inner;
932         if (ret_var.is_owned) {
933                 ret_ref |= 1;
934         }
935         return ret_ref;
936 }
937
938 static inline struct LDKDecodeError CResult_ShutdownScriptDecodeErrorZ_get_err(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
939 CHECK(!owner->result_ok);
940         return DecodeError_clone(&*owner->contents.err);
941 }
942 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_get_err"))) TS_CResult_ShutdownScriptDecodeErrorZ_get_err(uint32_t owner) {
943         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
944         LDKDecodeError ret_var = CResult_ShutdownScriptDecodeErrorZ_get_err(owner_conv);
945         uint32_t ret_ref = 0;
946         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
947         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
948         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
949         ret_ref = (uintptr_t)ret_var.inner;
950         if (ret_var.is_owned) {
951                 ret_ref |= 1;
952         }
953         return ret_ref;
954 }
955
956 static inline struct LDKShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
957 CHECK(owner->result_ok);
958         return ShutdownScript_clone(&*owner->contents.result);
959 }
960 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(uint32_t owner) {
961         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
962         LDKShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(owner_conv);
963         uint32_t ret_ref = 0;
964         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
965         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
966         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
967         ret_ref = (uintptr_t)ret_var.inner;
968         if (ret_var.is_owned) {
969                 ret_ref |= 1;
970         }
971         return ret_ref;
972 }
973
974 static inline struct LDKInvalidShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
975 CHECK(!owner->result_ok);
976         return InvalidShutdownScript_clone(&*owner->contents.err);
977 }
978 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_err"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(uint32_t owner) {
979         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
980         LDKInvalidShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(owner_conv);
981         uint32_t ret_ref = 0;
982         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
983         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
984         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
985         ret_ref = (uintptr_t)ret_var.inner;
986         if (ret_var.is_owned) {
987                 ret_ref |= 1;
988         }
989         return ret_ref;
990 }
991
992 static inline struct LDKRouteHop CResult_RouteHopDecodeErrorZ_get_ok(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
993 CHECK(owner->result_ok);
994         return RouteHop_clone(&*owner->contents.result);
995 }
996 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_get_ok"))) TS_CResult_RouteHopDecodeErrorZ_get_ok(uint32_t owner) {
997         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
998         LDKRouteHop ret_var = CResult_RouteHopDecodeErrorZ_get_ok(owner_conv);
999         uint32_t ret_ref = 0;
1000         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1001         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1002         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1003         ret_ref = (uintptr_t)ret_var.inner;
1004         if (ret_var.is_owned) {
1005                 ret_ref |= 1;
1006         }
1007         return ret_ref;
1008 }
1009
1010 static inline struct LDKDecodeError CResult_RouteHopDecodeErrorZ_get_err(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
1011 CHECK(!owner->result_ok);
1012         return DecodeError_clone(&*owner->contents.err);
1013 }
1014 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_get_err"))) TS_CResult_RouteHopDecodeErrorZ_get_err(uint32_t owner) {
1015         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
1016         LDKDecodeError ret_var = CResult_RouteHopDecodeErrorZ_get_err(owner_conv);
1017         uint32_t ret_ref = 0;
1018         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1019         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1020         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1021         ret_ref = (uintptr_t)ret_var.inner;
1022         if (ret_var.is_owned) {
1023                 ret_ref |= 1;
1024         }
1025         return ret_ref;
1026 }
1027
1028 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1029         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1030         for (size_t i = 0; i < ret.datalen; i++) {
1031                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1032         }
1033         return ret;
1034 }
1035 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
1036         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
1037         for (size_t i = 0; i < ret.datalen; i++) {
1038                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
1039         }
1040         return ret;
1041 }
1042 static inline struct LDKRoute CResult_RouteDecodeErrorZ_get_ok(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
1043 CHECK(owner->result_ok);
1044         return Route_clone(&*owner->contents.result);
1045 }
1046 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_get_ok"))) TS_CResult_RouteDecodeErrorZ_get_ok(uint32_t owner) {
1047         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
1048         LDKRoute ret_var = CResult_RouteDecodeErrorZ_get_ok(owner_conv);
1049         uint32_t ret_ref = 0;
1050         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1051         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1052         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1053         ret_ref = (uintptr_t)ret_var.inner;
1054         if (ret_var.is_owned) {
1055                 ret_ref |= 1;
1056         }
1057         return ret_ref;
1058 }
1059
1060 static inline struct LDKDecodeError CResult_RouteDecodeErrorZ_get_err(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
1061 CHECK(!owner->result_ok);
1062         return DecodeError_clone(&*owner->contents.err);
1063 }
1064 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_get_err"))) TS_CResult_RouteDecodeErrorZ_get_err(uint32_t owner) {
1065         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
1066         LDKDecodeError ret_var = CResult_RouteDecodeErrorZ_get_err(owner_conv);
1067         uint32_t ret_ref = 0;
1068         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1069         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1070         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1071         ret_ref = (uintptr_t)ret_var.inner;
1072         if (ret_var.is_owned) {
1073                 ret_ref |= 1;
1074         }
1075         return ret_ref;
1076 }
1077
1078 static inline struct LDKRouteParameters CResult_RouteParametersDecodeErrorZ_get_ok(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1079 CHECK(owner->result_ok);
1080         return RouteParameters_clone(&*owner->contents.result);
1081 }
1082 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_get_ok"))) TS_CResult_RouteParametersDecodeErrorZ_get_ok(uint32_t owner) {
1083         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
1084         LDKRouteParameters ret_var = CResult_RouteParametersDecodeErrorZ_get_ok(owner_conv);
1085         uint32_t ret_ref = 0;
1086         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1087         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1088         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1089         ret_ref = (uintptr_t)ret_var.inner;
1090         if (ret_var.is_owned) {
1091                 ret_ref |= 1;
1092         }
1093         return ret_ref;
1094 }
1095
1096 static inline struct LDKDecodeError CResult_RouteParametersDecodeErrorZ_get_err(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1097 CHECK(!owner->result_ok);
1098         return DecodeError_clone(&*owner->contents.err);
1099 }
1100 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_get_err"))) TS_CResult_RouteParametersDecodeErrorZ_get_err(uint32_t owner) {
1101         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
1102         LDKDecodeError ret_var = CResult_RouteParametersDecodeErrorZ_get_err(owner_conv);
1103         uint32_t ret_ref = 0;
1104         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1105         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1106         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1107         ret_ref = (uintptr_t)ret_var.inner;
1108         if (ret_var.is_owned) {
1109                 ret_ref |= 1;
1110         }
1111         return ret_ref;
1112 }
1113
1114 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
1115         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
1116         for (size_t i = 0; i < ret.datalen; i++) {
1117                 ret.data[i] = RouteHint_clone(&orig->data[i]);
1118         }
1119         return ret;
1120 }
1121 uint32_t __attribute__((export_name("TS_LDKCOption_u64Z_ty_from_ptr"))) TS_LDKCOption_u64Z_ty_from_ptr(uint32_t ptr) {
1122         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1123         switch(obj->tag) {
1124                 case LDKCOption_u64Z_Some: return 0;
1125                 case LDKCOption_u64Z_None: return 1;
1126                 default: abort();
1127         }
1128 }
1129 int64_t __attribute__((export_name("TS_LDKCOption_u64Z_Some_get_some"))) TS_LDKCOption_u64Z_Some_get_some(uint32_t ptr) {
1130         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1131         assert(obj->tag == LDKCOption_u64Z_Some);
1132                         int64_t some_conv = obj->some;
1133         return some_conv;
1134 }
1135 static inline struct LDKPaymentParameters CResult_PaymentParametersDecodeErrorZ_get_ok(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1136 CHECK(owner->result_ok);
1137         return PaymentParameters_clone(&*owner->contents.result);
1138 }
1139 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_get_ok"))) TS_CResult_PaymentParametersDecodeErrorZ_get_ok(uint32_t owner) {
1140         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1141         LDKPaymentParameters ret_var = CResult_PaymentParametersDecodeErrorZ_get_ok(owner_conv);
1142         uint32_t ret_ref = 0;
1143         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1144         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1145         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1146         ret_ref = (uintptr_t)ret_var.inner;
1147         if (ret_var.is_owned) {
1148                 ret_ref |= 1;
1149         }
1150         return ret_ref;
1151 }
1152
1153 static inline struct LDKDecodeError CResult_PaymentParametersDecodeErrorZ_get_err(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1154 CHECK(!owner->result_ok);
1155         return DecodeError_clone(&*owner->contents.err);
1156 }
1157 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_get_err"))) TS_CResult_PaymentParametersDecodeErrorZ_get_err(uint32_t owner) {
1158         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1159         LDKDecodeError ret_var = CResult_PaymentParametersDecodeErrorZ_get_err(owner_conv);
1160         uint32_t ret_ref = 0;
1161         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1162         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1163         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1164         ret_ref = (uintptr_t)ret_var.inner;
1165         if (ret_var.is_owned) {
1166                 ret_ref |= 1;
1167         }
1168         return ret_ref;
1169 }
1170
1171 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
1172         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
1173         for (size_t i = 0; i < ret.datalen; i++) {
1174                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
1175         }
1176         return ret;
1177 }
1178 static inline struct LDKRouteHint CResult_RouteHintDecodeErrorZ_get_ok(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1179 CHECK(owner->result_ok);
1180         return RouteHint_clone(&*owner->contents.result);
1181 }
1182 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_get_ok"))) TS_CResult_RouteHintDecodeErrorZ_get_ok(uint32_t owner) {
1183         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1184         LDKRouteHint ret_var = CResult_RouteHintDecodeErrorZ_get_ok(owner_conv);
1185         uint32_t ret_ref = 0;
1186         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1187         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1188         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1189         ret_ref = (uintptr_t)ret_var.inner;
1190         if (ret_var.is_owned) {
1191                 ret_ref |= 1;
1192         }
1193         return ret_ref;
1194 }
1195
1196 static inline struct LDKDecodeError CResult_RouteHintDecodeErrorZ_get_err(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1197 CHECK(!owner->result_ok);
1198         return DecodeError_clone(&*owner->contents.err);
1199 }
1200 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_get_err"))) TS_CResult_RouteHintDecodeErrorZ_get_err(uint32_t owner) {
1201         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1202         LDKDecodeError ret_var = CResult_RouteHintDecodeErrorZ_get_err(owner_conv);
1203         uint32_t ret_ref = 0;
1204         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1205         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1206         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1207         ret_ref = (uintptr_t)ret_var.inner;
1208         if (ret_var.is_owned) {
1209                 ret_ref |= 1;
1210         }
1211         return ret_ref;
1212 }
1213
1214 static inline struct LDKRouteHintHop CResult_RouteHintHopDecodeErrorZ_get_ok(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1215 CHECK(owner->result_ok);
1216         return RouteHintHop_clone(&*owner->contents.result);
1217 }
1218 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_get_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_get_ok(uint32_t owner) {
1219         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1220         LDKRouteHintHop ret_var = CResult_RouteHintHopDecodeErrorZ_get_ok(owner_conv);
1221         uint32_t ret_ref = 0;
1222         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1223         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1224         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1225         ret_ref = (uintptr_t)ret_var.inner;
1226         if (ret_var.is_owned) {
1227                 ret_ref |= 1;
1228         }
1229         return ret_ref;
1230 }
1231
1232 static inline struct LDKDecodeError CResult_RouteHintHopDecodeErrorZ_get_err(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1233 CHECK(!owner->result_ok);
1234         return DecodeError_clone(&*owner->contents.err);
1235 }
1236 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_get_err"))) TS_CResult_RouteHintHopDecodeErrorZ_get_err(uint32_t owner) {
1237         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1238         LDKDecodeError ret_var = CResult_RouteHintHopDecodeErrorZ_get_err(owner_conv);
1239         uint32_t ret_ref = 0;
1240         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1241         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1242         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1243         ret_ref = (uintptr_t)ret_var.inner;
1244         if (ret_var.is_owned) {
1245                 ret_ref |= 1;
1246         }
1247         return ret_ref;
1248 }
1249
1250 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1251         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1252         for (size_t i = 0; i < ret.datalen; i++) {
1253                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1254         }
1255         return ret;
1256 }
1257 static inline struct LDKRoute CResult_RouteLightningErrorZ_get_ok(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1258 CHECK(owner->result_ok);
1259         return Route_clone(&*owner->contents.result);
1260 }
1261 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_get_ok"))) TS_CResult_RouteLightningErrorZ_get_ok(uint32_t owner) {
1262         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1263         LDKRoute ret_var = CResult_RouteLightningErrorZ_get_ok(owner_conv);
1264         uint32_t ret_ref = 0;
1265         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1266         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1267         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1268         ret_ref = (uintptr_t)ret_var.inner;
1269         if (ret_var.is_owned) {
1270                 ret_ref |= 1;
1271         }
1272         return ret_ref;
1273 }
1274
1275 static inline struct LDKLightningError CResult_RouteLightningErrorZ_get_err(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1276 CHECK(!owner->result_ok);
1277         return LightningError_clone(&*owner->contents.err);
1278 }
1279 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_get_err"))) TS_CResult_RouteLightningErrorZ_get_err(uint32_t owner) {
1280         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1281         LDKLightningError ret_var = CResult_RouteLightningErrorZ_get_err(owner_conv);
1282         uint32_t ret_ref = 0;
1283         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1284         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1285         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1286         ret_ref = (uintptr_t)ret_var.inner;
1287         if (ret_var.is_owned) {
1288                 ret_ref |= 1;
1289         }
1290         return ret_ref;
1291 }
1292
1293 uint32_t __attribute__((export_name("TS_LDKPaymentPurpose_ty_from_ptr"))) TS_LDKPaymentPurpose_ty_from_ptr(uint32_t ptr) {
1294         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1295         switch(obj->tag) {
1296                 case LDKPaymentPurpose_InvoicePayment: return 0;
1297                 case LDKPaymentPurpose_SpontaneousPayment: return 1;
1298                 default: abort();
1299         }
1300 }
1301 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_InvoicePayment_get_payment_preimage"))) TS_LDKPaymentPurpose_InvoicePayment_get_payment_preimage(uint32_t ptr) {
1302         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1303         assert(obj->tag == LDKPaymentPurpose_InvoicePayment);
1304                         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
1305                         memcpy(payment_preimage_arr->elems, obj->invoice_payment.payment_preimage.data, 32);
1306         return payment_preimage_arr;
1307 }
1308 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_InvoicePayment_get_payment_secret"))) TS_LDKPaymentPurpose_InvoicePayment_get_payment_secret(uint32_t ptr) {
1309         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1310         assert(obj->tag == LDKPaymentPurpose_InvoicePayment);
1311                         int8_tArray payment_secret_arr = init_int8_tArray(32, __LINE__);
1312                         memcpy(payment_secret_arr->elems, obj->invoice_payment.payment_secret.data, 32);
1313         return payment_secret_arr;
1314 }
1315 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_SpontaneousPayment_get_spontaneous_payment"))) TS_LDKPaymentPurpose_SpontaneousPayment_get_spontaneous_payment(uint32_t ptr) {
1316         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1317         assert(obj->tag == LDKPaymentPurpose_SpontaneousPayment);
1318                         int8_tArray spontaneous_payment_arr = init_int8_tArray(32, __LINE__);
1319                         memcpy(spontaneous_payment_arr->elems, obj->spontaneous_payment.data, 32);
1320         return spontaneous_payment_arr;
1321 }
1322 static inline struct LDKPaymentPurpose CResult_PaymentPurposeDecodeErrorZ_get_ok(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
1323 CHECK(owner->result_ok);
1324         return PaymentPurpose_clone(&*owner->contents.result);
1325 }
1326 uint32_t  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_get_ok"))) TS_CResult_PaymentPurposeDecodeErrorZ_get_ok(uint32_t owner) {
1327         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(owner & ~1);
1328         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
1329         *ret_copy = CResult_PaymentPurposeDecodeErrorZ_get_ok(owner_conv);
1330         uint32_t ret_ref = (uintptr_t)ret_copy;
1331         return ret_ref;
1332 }
1333
1334 static inline struct LDKDecodeError CResult_PaymentPurposeDecodeErrorZ_get_err(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
1335 CHECK(!owner->result_ok);
1336         return DecodeError_clone(&*owner->contents.err);
1337 }
1338 uint32_t  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_get_err"))) TS_CResult_PaymentPurposeDecodeErrorZ_get_err(uint32_t owner) {
1339         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(owner & ~1);
1340         LDKDecodeError ret_var = CResult_PaymentPurposeDecodeErrorZ_get_err(owner_conv);
1341         uint32_t ret_ref = 0;
1342         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1343         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1344         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1345         ret_ref = (uintptr_t)ret_var.inner;
1346         if (ret_var.is_owned) {
1347                 ret_ref |= 1;
1348         }
1349         return ret_ref;
1350 }
1351
1352 uint32_t __attribute__((export_name("TS_LDKClosureReason_ty_from_ptr"))) TS_LDKClosureReason_ty_from_ptr(uint32_t ptr) {
1353         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1354         switch(obj->tag) {
1355                 case LDKClosureReason_CounterpartyForceClosed: return 0;
1356                 case LDKClosureReason_HolderForceClosed: return 1;
1357                 case LDKClosureReason_CooperativeClosure: return 2;
1358                 case LDKClosureReason_CommitmentTxConfirmed: return 3;
1359                 case LDKClosureReason_FundingTimedOut: return 4;
1360                 case LDKClosureReason_ProcessingError: return 5;
1361                 case LDKClosureReason_DisconnectedPeer: return 6;
1362                 case LDKClosureReason_OutdatedChannelManager: return 7;
1363                 default: abort();
1364         }
1365 }
1366 jstring __attribute__((export_name("TS_LDKClosureReason_CounterpartyForceClosed_get_peer_msg"))) TS_LDKClosureReason_CounterpartyForceClosed_get_peer_msg(uint32_t ptr) {
1367         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1368         assert(obj->tag == LDKClosureReason_CounterpartyForceClosed);
1369                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
1370                         jstring peer_msg_conv = str_ref_to_ts(peer_msg_str.chars, peer_msg_str.len);
1371         return peer_msg_conv;
1372 }
1373 jstring __attribute__((export_name("TS_LDKClosureReason_ProcessingError_get_err"))) TS_LDKClosureReason_ProcessingError_get_err(uint32_t ptr) {
1374         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1375         assert(obj->tag == LDKClosureReason_ProcessingError);
1376                         LDKStr err_str = obj->processing_error.err;
1377                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
1378         return err_conv;
1379 }
1380 uint32_t __attribute__((export_name("TS_LDKCOption_ClosureReasonZ_ty_from_ptr"))) TS_LDKCOption_ClosureReasonZ_ty_from_ptr(uint32_t ptr) {
1381         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
1382         switch(obj->tag) {
1383                 case LDKCOption_ClosureReasonZ_Some: return 0;
1384                 case LDKCOption_ClosureReasonZ_None: return 1;
1385                 default: abort();
1386         }
1387 }
1388 uint32_t __attribute__((export_name("TS_LDKCOption_ClosureReasonZ_Some_get_some"))) TS_LDKCOption_ClosureReasonZ_Some_get_some(uint32_t ptr) {
1389         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
1390         assert(obj->tag == LDKCOption_ClosureReasonZ_Some);
1391                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
1392         return some_ref;
1393 }
1394 static inline struct LDKCOption_ClosureReasonZ CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
1395 CHECK(owner->result_ok);
1396         return COption_ClosureReasonZ_clone(&*owner->contents.result);
1397 }
1398 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(uint32_t owner) {
1399         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
1400         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
1401         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(owner_conv);
1402         uint32_t ret_ref = (uintptr_t)ret_copy;
1403         return ret_ref;
1404 }
1405
1406 static inline struct LDKDecodeError CResult_COption_ClosureReasonZDecodeErrorZ_get_err(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
1407 CHECK(!owner->result_ok);
1408         return DecodeError_clone(&*owner->contents.err);
1409 }
1410 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_err"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_err(uint32_t owner) {
1411         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
1412         LDKDecodeError ret_var = CResult_COption_ClosureReasonZDecodeErrorZ_get_err(owner_conv);
1413         uint32_t ret_ref = 0;
1414         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1415         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1416         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1417         ret_ref = (uintptr_t)ret_var.inner;
1418         if (ret_var.is_owned) {
1419                 ret_ref |= 1;
1420         }
1421         return ret_ref;
1422 }
1423
1424 uint32_t __attribute__((export_name("TS_LDKNetworkUpdate_ty_from_ptr"))) TS_LDKNetworkUpdate_ty_from_ptr(uint32_t ptr) {
1425         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1426         switch(obj->tag) {
1427                 case LDKNetworkUpdate_ChannelUpdateMessage: return 0;
1428                 case LDKNetworkUpdate_ChannelFailure: return 1;
1429                 case LDKNetworkUpdate_NodeFailure: return 2;
1430                 default: abort();
1431         }
1432 }
1433 uint32_t __attribute__((export_name("TS_LDKNetworkUpdate_ChannelUpdateMessage_get_msg"))) TS_LDKNetworkUpdate_ChannelUpdateMessage_get_msg(uint32_t ptr) {
1434         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1435         assert(obj->tag == LDKNetworkUpdate_ChannelUpdateMessage);
1436                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
1437                         uint32_t msg_ref = 0;
1438                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1439                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1440                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1441                         msg_ref = (uintptr_t)msg_var.inner & ~1;
1442         return msg_ref;
1443 }
1444 int64_t __attribute__((export_name("TS_LDKNetworkUpdate_ChannelFailure_get_short_channel_id"))) TS_LDKNetworkUpdate_ChannelFailure_get_short_channel_id(uint32_t ptr) {
1445         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1446         assert(obj->tag == LDKNetworkUpdate_ChannelFailure);
1447                         int64_t short_channel_id_conv = obj->channel_failure.short_channel_id;
1448         return short_channel_id_conv;
1449 }
1450 jboolean __attribute__((export_name("TS_LDKNetworkUpdate_ChannelFailure_get_is_permanent"))) TS_LDKNetworkUpdate_ChannelFailure_get_is_permanent(uint32_t ptr) {
1451         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1452         assert(obj->tag == LDKNetworkUpdate_ChannelFailure);
1453                         jboolean is_permanent_conv = obj->channel_failure.is_permanent;
1454         return is_permanent_conv;
1455 }
1456 int8_tArray __attribute__((export_name("TS_LDKNetworkUpdate_NodeFailure_get_node_id"))) TS_LDKNetworkUpdate_NodeFailure_get_node_id(uint32_t ptr) {
1457         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1458         assert(obj->tag == LDKNetworkUpdate_NodeFailure);
1459                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
1460                         memcpy(node_id_arr->elems, obj->node_failure.node_id.compressed_form, 33);
1461         return node_id_arr;
1462 }
1463 jboolean __attribute__((export_name("TS_LDKNetworkUpdate_NodeFailure_get_is_permanent"))) TS_LDKNetworkUpdate_NodeFailure_get_is_permanent(uint32_t ptr) {
1464         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1465         assert(obj->tag == LDKNetworkUpdate_NodeFailure);
1466                         jboolean is_permanent_conv = obj->node_failure.is_permanent;
1467         return is_permanent_conv;
1468 }
1469 uint32_t __attribute__((export_name("TS_LDKCOption_NetworkUpdateZ_ty_from_ptr"))) TS_LDKCOption_NetworkUpdateZ_ty_from_ptr(uint32_t ptr) {
1470         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
1471         switch(obj->tag) {
1472                 case LDKCOption_NetworkUpdateZ_Some: return 0;
1473                 case LDKCOption_NetworkUpdateZ_None: return 1;
1474                 default: abort();
1475         }
1476 }
1477 uint32_t __attribute__((export_name("TS_LDKCOption_NetworkUpdateZ_Some_get_some"))) TS_LDKCOption_NetworkUpdateZ_Some_get_some(uint32_t ptr) {
1478         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
1479         assert(obj->tag == LDKCOption_NetworkUpdateZ_Some);
1480                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
1481         return some_ref;
1482 }
1483 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_ty_from_ptr"))) TS_LDKSpendableOutputDescriptor_ty_from_ptr(uint32_t ptr) {
1484         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1485         switch(obj->tag) {
1486                 case LDKSpendableOutputDescriptor_StaticOutput: return 0;
1487                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: return 1;
1488                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: return 2;
1489                 default: abort();
1490         }
1491 }
1492 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticOutput_get_outpoint"))) TS_LDKSpendableOutputDescriptor_StaticOutput_get_outpoint(uint32_t ptr) {
1493         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1494         assert(obj->tag == LDKSpendableOutputDescriptor_StaticOutput);
1495                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1496                         uint32_t outpoint_ref = 0;
1497                         CHECK((((uintptr_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1498                         CHECK((((uintptr_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1499                         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
1500                         outpoint_ref = (uintptr_t)outpoint_var.inner & ~1;
1501         return outpoint_ref;
1502 }
1503 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticOutput_get_output"))) TS_LDKSpendableOutputDescriptor_StaticOutput_get_output(uint32_t ptr) {
1504         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1505         assert(obj->tag == LDKSpendableOutputDescriptor_StaticOutput);
1506                         uint32_t output_ref = ((uintptr_t)&obj->static_output.output) | 1;
1507         return (uint32_t)output_ref;
1508 }
1509 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_DelayedPaymentOutput_get_delayed_payment_output"))) TS_LDKSpendableOutputDescriptor_DelayedPaymentOutput_get_delayed_payment_output(uint32_t ptr) {
1510         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1511         assert(obj->tag == LDKSpendableOutputDescriptor_DelayedPaymentOutput);
1512                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
1513                         uint32_t delayed_payment_output_ref = 0;
1514                         CHECK((((uintptr_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1515                         CHECK((((uintptr_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1516                         CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
1517                         delayed_payment_output_ref = (uintptr_t)delayed_payment_output_var.inner & ~1;
1518         return delayed_payment_output_ref;
1519 }
1520 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticPaymentOutput_get_static_payment_output"))) TS_LDKSpendableOutputDescriptor_StaticPaymentOutput_get_static_payment_output(uint32_t ptr) {
1521         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1522         assert(obj->tag == LDKSpendableOutputDescriptor_StaticPaymentOutput);
1523                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
1524                         uint32_t static_payment_output_ref = 0;
1525                         CHECK((((uintptr_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1526                         CHECK((((uintptr_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1527                         CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
1528                         static_payment_output_ref = (uintptr_t)static_payment_output_var.inner & ~1;
1529         return static_payment_output_ref;
1530 }
1531 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1532         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1533         for (size_t i = 0; i < ret.datalen; i++) {
1534                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1535         }
1536         return ret;
1537 }
1538 uint32_t __attribute__((export_name("TS_LDKEvent_ty_from_ptr"))) TS_LDKEvent_ty_from_ptr(uint32_t ptr) {
1539         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1540         switch(obj->tag) {
1541                 case LDKEvent_FundingGenerationReady: return 0;
1542                 case LDKEvent_PaymentReceived: return 1;
1543                 case LDKEvent_PaymentClaimed: return 2;
1544                 case LDKEvent_PaymentSent: return 3;
1545                 case LDKEvent_PaymentFailed: return 4;
1546                 case LDKEvent_PaymentPathSuccessful: return 5;
1547                 case LDKEvent_PaymentPathFailed: return 6;
1548                 case LDKEvent_PendingHTLCsForwardable: return 7;
1549                 case LDKEvent_SpendableOutputs: return 8;
1550                 case LDKEvent_PaymentForwarded: return 9;
1551                 case LDKEvent_ChannelClosed: return 10;
1552                 case LDKEvent_DiscardFunding: return 11;
1553                 case LDKEvent_OpenChannelRequest: return 12;
1554                 default: abort();
1555         }
1556 }
1557 int8_tArray __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_temporary_channel_id"))) TS_LDKEvent_FundingGenerationReady_get_temporary_channel_id(uint32_t ptr) {
1558         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1559         assert(obj->tag == LDKEvent_FundingGenerationReady);
1560                         int8_tArray temporary_channel_id_arr = init_int8_tArray(32, __LINE__);
1561                         memcpy(temporary_channel_id_arr->elems, obj->funding_generation_ready.temporary_channel_id.data, 32);
1562         return temporary_channel_id_arr;
1563 }
1564 int8_tArray __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_counterparty_node_id"))) TS_LDKEvent_FundingGenerationReady_get_counterparty_node_id(uint32_t ptr) {
1565         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1566         assert(obj->tag == LDKEvent_FundingGenerationReady);
1567                         int8_tArray counterparty_node_id_arr = init_int8_tArray(33, __LINE__);
1568                         memcpy(counterparty_node_id_arr->elems, obj->funding_generation_ready.counterparty_node_id.compressed_form, 33);
1569         return counterparty_node_id_arr;
1570 }
1571 int64_t __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_channel_value_satoshis"))) TS_LDKEvent_FundingGenerationReady_get_channel_value_satoshis(uint32_t ptr) {
1572         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1573         assert(obj->tag == LDKEvent_FundingGenerationReady);
1574                         int64_t channel_value_satoshis_conv = obj->funding_generation_ready.channel_value_satoshis;
1575         return channel_value_satoshis_conv;
1576 }
1577 int8_tArray __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_output_script"))) TS_LDKEvent_FundingGenerationReady_get_output_script(uint32_t ptr) {
1578         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1579         assert(obj->tag == LDKEvent_FundingGenerationReady);
1580                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
1581                         int8_tArray output_script_arr = init_int8_tArray(output_script_var.datalen, __LINE__);
1582                         memcpy(output_script_arr->elems, output_script_var.data, output_script_var.datalen);
1583         return output_script_arr;
1584 }
1585 int64_t __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_user_channel_id"))) TS_LDKEvent_FundingGenerationReady_get_user_channel_id(uint32_t ptr) {
1586         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1587         assert(obj->tag == LDKEvent_FundingGenerationReady);
1588                         int64_t user_channel_id_conv = obj->funding_generation_ready.user_channel_id;
1589         return user_channel_id_conv;
1590 }
1591 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_payment_hash"))) TS_LDKEvent_PaymentReceived_get_payment_hash(uint32_t ptr) {
1592         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1593         assert(obj->tag == LDKEvent_PaymentReceived);
1594                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1595                         memcpy(payment_hash_arr->elems, obj->payment_received.payment_hash.data, 32);
1596         return payment_hash_arr;
1597 }
1598 int64_t __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_amount_msat"))) TS_LDKEvent_PaymentReceived_get_amount_msat(uint32_t ptr) {
1599         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1600         assert(obj->tag == LDKEvent_PaymentReceived);
1601                         int64_t amount_msat_conv = obj->payment_received.amount_msat;
1602         return amount_msat_conv;
1603 }
1604 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_purpose"))) TS_LDKEvent_PaymentReceived_get_purpose(uint32_t ptr) {
1605         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1606         assert(obj->tag == LDKEvent_PaymentReceived);
1607                         uint32_t purpose_ref = ((uintptr_t)&obj->payment_received.purpose) | 1;
1608         return purpose_ref;
1609 }
1610 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentClaimed_get_payment_hash"))) TS_LDKEvent_PaymentClaimed_get_payment_hash(uint32_t ptr) {
1611         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1612         assert(obj->tag == LDKEvent_PaymentClaimed);
1613                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1614                         memcpy(payment_hash_arr->elems, obj->payment_claimed.payment_hash.data, 32);
1615         return payment_hash_arr;
1616 }
1617 int64_t __attribute__((export_name("TS_LDKEvent_PaymentClaimed_get_amount_msat"))) TS_LDKEvent_PaymentClaimed_get_amount_msat(uint32_t ptr) {
1618         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1619         assert(obj->tag == LDKEvent_PaymentClaimed);
1620                         int64_t amount_msat_conv = obj->payment_claimed.amount_msat;
1621         return amount_msat_conv;
1622 }
1623 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentClaimed_get_purpose"))) TS_LDKEvent_PaymentClaimed_get_purpose(uint32_t ptr) {
1624         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1625         assert(obj->tag == LDKEvent_PaymentClaimed);
1626                         uint32_t purpose_ref = ((uintptr_t)&obj->payment_claimed.purpose) | 1;
1627         return purpose_ref;
1628 }
1629 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_id"))) TS_LDKEvent_PaymentSent_get_payment_id(uint32_t ptr) {
1630         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1631         assert(obj->tag == LDKEvent_PaymentSent);
1632                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1633                         memcpy(payment_id_arr->elems, obj->payment_sent.payment_id.data, 32);
1634         return payment_id_arr;
1635 }
1636 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_preimage"))) TS_LDKEvent_PaymentSent_get_payment_preimage(uint32_t ptr) {
1637         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1638         assert(obj->tag == LDKEvent_PaymentSent);
1639                         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
1640                         memcpy(payment_preimage_arr->elems, obj->payment_sent.payment_preimage.data, 32);
1641         return payment_preimage_arr;
1642 }
1643 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_hash"))) TS_LDKEvent_PaymentSent_get_payment_hash(uint32_t ptr) {
1644         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1645         assert(obj->tag == LDKEvent_PaymentSent);
1646                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1647                         memcpy(payment_hash_arr->elems, obj->payment_sent.payment_hash.data, 32);
1648         return payment_hash_arr;
1649 }
1650 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentSent_get_fee_paid_msat"))) TS_LDKEvent_PaymentSent_get_fee_paid_msat(uint32_t ptr) {
1651         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1652         assert(obj->tag == LDKEvent_PaymentSent);
1653                         uint32_t fee_paid_msat_ref = ((uintptr_t)&obj->payment_sent.fee_paid_msat) | 1;
1654         return fee_paid_msat_ref;
1655 }
1656 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentFailed_get_payment_id"))) TS_LDKEvent_PaymentFailed_get_payment_id(uint32_t ptr) {
1657         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1658         assert(obj->tag == LDKEvent_PaymentFailed);
1659                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1660                         memcpy(payment_id_arr->elems, obj->payment_failed.payment_id.data, 32);
1661         return payment_id_arr;
1662 }
1663 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentFailed_get_payment_hash"))) TS_LDKEvent_PaymentFailed_get_payment_hash(uint32_t ptr) {
1664         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1665         assert(obj->tag == LDKEvent_PaymentFailed);
1666                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1667                         memcpy(payment_hash_arr->elems, obj->payment_failed.payment_hash.data, 32);
1668         return payment_hash_arr;
1669 }
1670 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_payment_id"))) TS_LDKEvent_PaymentPathSuccessful_get_payment_id(uint32_t ptr) {
1671         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1672         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1673                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1674                         memcpy(payment_id_arr->elems, obj->payment_path_successful.payment_id.data, 32);
1675         return payment_id_arr;
1676 }
1677 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_payment_hash"))) TS_LDKEvent_PaymentPathSuccessful_get_payment_hash(uint32_t ptr) {
1678         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1679         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1680                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1681                         memcpy(payment_hash_arr->elems, obj->payment_path_successful.payment_hash.data, 32);
1682         return payment_hash_arr;
1683 }
1684 uint32_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_path"))) TS_LDKEvent_PaymentPathSuccessful_get_path(uint32_t ptr) {
1685         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1686         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1687                         LDKCVec_RouteHopZ path_var = obj->payment_path_successful.path;
1688                         uint32_tArray path_arr = NULL;
1689                         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
1690                         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
1691                         for (size_t k = 0; k < path_var.datalen; k++) {
1692                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1693                                 uint32_t path_conv_10_ref = 0;
1694                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1695                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1696                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1697                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
1698                                 path_arr_ptr[k] = path_conv_10_ref;
1699                         }
1700                         
1701         return path_arr;
1702 }
1703 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_payment_id"))) TS_LDKEvent_PaymentPathFailed_get_payment_id(uint32_t ptr) {
1704         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1705         assert(obj->tag == LDKEvent_PaymentPathFailed);
1706                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1707                         memcpy(payment_id_arr->elems, obj->payment_path_failed.payment_id.data, 32);
1708         return payment_id_arr;
1709 }
1710 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_payment_hash"))) TS_LDKEvent_PaymentPathFailed_get_payment_hash(uint32_t ptr) {
1711         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1712         assert(obj->tag == LDKEvent_PaymentPathFailed);
1713                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1714                         memcpy(payment_hash_arr->elems, obj->payment_path_failed.payment_hash.data, 32);
1715         return payment_hash_arr;
1716 }
1717 jboolean __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_rejected_by_dest"))) TS_LDKEvent_PaymentPathFailed_get_rejected_by_dest(uint32_t ptr) {
1718         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1719         assert(obj->tag == LDKEvent_PaymentPathFailed);
1720                         jboolean rejected_by_dest_conv = obj->payment_path_failed.rejected_by_dest;
1721         return rejected_by_dest_conv;
1722 }
1723 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_network_update"))) TS_LDKEvent_PaymentPathFailed_get_network_update(uint32_t ptr) {
1724         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1725         assert(obj->tag == LDKEvent_PaymentPathFailed);
1726                         uint32_t network_update_ref = ((uintptr_t)&obj->payment_path_failed.network_update) | 1;
1727         return network_update_ref;
1728 }
1729 jboolean __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_all_paths_failed"))) TS_LDKEvent_PaymentPathFailed_get_all_paths_failed(uint32_t ptr) {
1730         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1731         assert(obj->tag == LDKEvent_PaymentPathFailed);
1732                         jboolean all_paths_failed_conv = obj->payment_path_failed.all_paths_failed;
1733         return all_paths_failed_conv;
1734 }
1735 uint32_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_path"))) TS_LDKEvent_PaymentPathFailed_get_path(uint32_t ptr) {
1736         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1737         assert(obj->tag == LDKEvent_PaymentPathFailed);
1738                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
1739                         uint32_tArray path_arr = NULL;
1740                         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
1741                         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
1742                         for (size_t k = 0; k < path_var.datalen; k++) {
1743                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1744                                 uint32_t path_conv_10_ref = 0;
1745                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1746                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1747                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1748                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
1749                                 path_arr_ptr[k] = path_conv_10_ref;
1750                         }
1751                         
1752         return path_arr;
1753 }
1754 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_short_channel_id"))) TS_LDKEvent_PaymentPathFailed_get_short_channel_id(uint32_t ptr) {
1755         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1756         assert(obj->tag == LDKEvent_PaymentPathFailed);
1757                         uint32_t short_channel_id_ref = ((uintptr_t)&obj->payment_path_failed.short_channel_id) | 1;
1758         return short_channel_id_ref;
1759 }
1760 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_retry"))) TS_LDKEvent_PaymentPathFailed_get_retry(uint32_t ptr) {
1761         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1762         assert(obj->tag == LDKEvent_PaymentPathFailed);
1763                         LDKRouteParameters retry_var = obj->payment_path_failed.retry;
1764                         uint32_t retry_ref = 0;
1765                         if ((uintptr_t)retry_var.inner > 4096) {
1766                                 CHECK((((uintptr_t)retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1767                                 CHECK((((uintptr_t)&retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1768                         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_var);
1769                                 retry_ref = (uintptr_t)retry_var.inner & ~1;
1770                         }
1771         return retry_ref;
1772 }
1773 int64_t __attribute__((export_name("TS_LDKEvent_PendingHTLCsForwardable_get_time_forwardable"))) TS_LDKEvent_PendingHTLCsForwardable_get_time_forwardable(uint32_t ptr) {
1774         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1775         assert(obj->tag == LDKEvent_PendingHTLCsForwardable);
1776                         int64_t time_forwardable_conv = obj->pending_htl_cs_forwardable.time_forwardable;
1777         return time_forwardable_conv;
1778 }
1779 uint32_tArray __attribute__((export_name("TS_LDKEvent_SpendableOutputs_get_outputs"))) TS_LDKEvent_SpendableOutputs_get_outputs(uint32_t ptr) {
1780         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1781         assert(obj->tag == LDKEvent_SpendableOutputs);
1782                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
1783                         uint32_tArray outputs_arr = NULL;
1784                         outputs_arr = init_uint32_tArray(outputs_var.datalen, __LINE__);
1785                         uint32_t *outputs_arr_ptr = (uint32_t*)(((uint8_t*)outputs_arr) + 4);
1786                         for (size_t b = 0; b < outputs_var.datalen; b++) {
1787                                 uint32_t outputs_conv_27_ref = ((uintptr_t)&outputs_var.data[b]) | 1;
1788                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
1789                         }
1790                         
1791         return outputs_arr;
1792 }
1793 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_prev_channel_id"))) TS_LDKEvent_PaymentForwarded_get_prev_channel_id(uint32_t ptr) {
1794         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1795         assert(obj->tag == LDKEvent_PaymentForwarded);
1796                         int8_tArray prev_channel_id_arr = init_int8_tArray(32, __LINE__);
1797                         memcpy(prev_channel_id_arr->elems, obj->payment_forwarded.prev_channel_id.data, 32);
1798         return prev_channel_id_arr;
1799 }
1800 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_next_channel_id"))) TS_LDKEvent_PaymentForwarded_get_next_channel_id(uint32_t ptr) {
1801         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1802         assert(obj->tag == LDKEvent_PaymentForwarded);
1803                         int8_tArray next_channel_id_arr = init_int8_tArray(32, __LINE__);
1804                         memcpy(next_channel_id_arr->elems, obj->payment_forwarded.next_channel_id.data, 32);
1805         return next_channel_id_arr;
1806 }
1807 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_fee_earned_msat"))) TS_LDKEvent_PaymentForwarded_get_fee_earned_msat(uint32_t ptr) {
1808         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1809         assert(obj->tag == LDKEvent_PaymentForwarded);
1810                         uint32_t fee_earned_msat_ref = ((uintptr_t)&obj->payment_forwarded.fee_earned_msat) | 1;
1811         return fee_earned_msat_ref;
1812 }
1813 jboolean __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_claim_from_onchain_tx"))) TS_LDKEvent_PaymentForwarded_get_claim_from_onchain_tx(uint32_t ptr) {
1814         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1815         assert(obj->tag == LDKEvent_PaymentForwarded);
1816                         jboolean claim_from_onchain_tx_conv = obj->payment_forwarded.claim_from_onchain_tx;
1817         return claim_from_onchain_tx_conv;
1818 }
1819 int8_tArray __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_channel_id"))) TS_LDKEvent_ChannelClosed_get_channel_id(uint32_t ptr) {
1820         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1821         assert(obj->tag == LDKEvent_ChannelClosed);
1822                         int8_tArray channel_id_arr = init_int8_tArray(32, __LINE__);
1823                         memcpy(channel_id_arr->elems, obj->channel_closed.channel_id.data, 32);
1824         return channel_id_arr;
1825 }
1826 int64_t __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_user_channel_id"))) TS_LDKEvent_ChannelClosed_get_user_channel_id(uint32_t ptr) {
1827         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1828         assert(obj->tag == LDKEvent_ChannelClosed);
1829                         int64_t user_channel_id_conv = obj->channel_closed.user_channel_id;
1830         return user_channel_id_conv;
1831 }
1832 uint32_t __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_reason"))) TS_LDKEvent_ChannelClosed_get_reason(uint32_t ptr) {
1833         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1834         assert(obj->tag == LDKEvent_ChannelClosed);
1835                         uint32_t reason_ref = ((uintptr_t)&obj->channel_closed.reason) | 1;
1836         return reason_ref;
1837 }
1838 int8_tArray __attribute__((export_name("TS_LDKEvent_DiscardFunding_get_channel_id"))) TS_LDKEvent_DiscardFunding_get_channel_id(uint32_t ptr) {
1839         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1840         assert(obj->tag == LDKEvent_DiscardFunding);
1841                         int8_tArray channel_id_arr = init_int8_tArray(32, __LINE__);
1842                         memcpy(channel_id_arr->elems, obj->discard_funding.channel_id.data, 32);
1843         return channel_id_arr;
1844 }
1845 int8_tArray __attribute__((export_name("TS_LDKEvent_DiscardFunding_get_transaction"))) TS_LDKEvent_DiscardFunding_get_transaction(uint32_t ptr) {
1846         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1847         assert(obj->tag == LDKEvent_DiscardFunding);
1848                         LDKTransaction transaction_var = obj->discard_funding.transaction;
1849                         int8_tArray transaction_arr = init_int8_tArray(transaction_var.datalen, __LINE__);
1850                         memcpy(transaction_arr->elems, transaction_var.data, transaction_var.datalen);
1851         return transaction_arr;
1852 }
1853 int8_tArray __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_temporary_channel_id"))) TS_LDKEvent_OpenChannelRequest_get_temporary_channel_id(uint32_t ptr) {
1854         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1855         assert(obj->tag == LDKEvent_OpenChannelRequest);
1856                         int8_tArray temporary_channel_id_arr = init_int8_tArray(32, __LINE__);
1857                         memcpy(temporary_channel_id_arr->elems, obj->open_channel_request.temporary_channel_id.data, 32);
1858         return temporary_channel_id_arr;
1859 }
1860 int8_tArray __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_counterparty_node_id"))) TS_LDKEvent_OpenChannelRequest_get_counterparty_node_id(uint32_t ptr) {
1861         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1862         assert(obj->tag == LDKEvent_OpenChannelRequest);
1863                         int8_tArray counterparty_node_id_arr = init_int8_tArray(33, __LINE__);
1864                         memcpy(counterparty_node_id_arr->elems, obj->open_channel_request.counterparty_node_id.compressed_form, 33);
1865         return counterparty_node_id_arr;
1866 }
1867 int64_t __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_funding_satoshis"))) TS_LDKEvent_OpenChannelRequest_get_funding_satoshis(uint32_t ptr) {
1868         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1869         assert(obj->tag == LDKEvent_OpenChannelRequest);
1870                         int64_t funding_satoshis_conv = obj->open_channel_request.funding_satoshis;
1871         return funding_satoshis_conv;
1872 }
1873 int64_t __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_push_msat"))) TS_LDKEvent_OpenChannelRequest_get_push_msat(uint32_t ptr) {
1874         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1875         assert(obj->tag == LDKEvent_OpenChannelRequest);
1876                         int64_t push_msat_conv = obj->open_channel_request.push_msat;
1877         return push_msat_conv;
1878 }
1879 uint32_t __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_channel_type"))) TS_LDKEvent_OpenChannelRequest_get_channel_type(uint32_t ptr) {
1880         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1881         assert(obj->tag == LDKEvent_OpenChannelRequest);
1882                         LDKChannelTypeFeatures channel_type_var = obj->open_channel_request.channel_type;
1883                         uint32_t channel_type_ref = 0;
1884                         CHECK((((uintptr_t)channel_type_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1885                         CHECK((((uintptr_t)&channel_type_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1886                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_var);
1887                         channel_type_ref = (uintptr_t)channel_type_var.inner & ~1;
1888         return channel_type_ref;
1889 }
1890 uint32_t __attribute__((export_name("TS_LDKCOption_EventZ_ty_from_ptr"))) TS_LDKCOption_EventZ_ty_from_ptr(uint32_t ptr) {
1891         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
1892         switch(obj->tag) {
1893                 case LDKCOption_EventZ_Some: return 0;
1894                 case LDKCOption_EventZ_None: return 1;
1895                 default: abort();
1896         }
1897 }
1898 uint32_t __attribute__((export_name("TS_LDKCOption_EventZ_Some_get_some"))) TS_LDKCOption_EventZ_Some_get_some(uint32_t ptr) {
1899         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
1900         assert(obj->tag == LDKCOption_EventZ_Some);
1901                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
1902         return some_ref;
1903 }
1904 static inline struct LDKCOption_EventZ CResult_COption_EventZDecodeErrorZ_get_ok(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
1905 CHECK(owner->result_ok);
1906         return COption_EventZ_clone(&*owner->contents.result);
1907 }
1908 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_get_ok"))) TS_CResult_COption_EventZDecodeErrorZ_get_ok(uint32_t owner) {
1909         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
1910         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
1911         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_ok(owner_conv);
1912         uint32_t ret_ref = (uintptr_t)ret_copy;
1913         return ret_ref;
1914 }
1915
1916 static inline struct LDKDecodeError CResult_COption_EventZDecodeErrorZ_get_err(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
1917 CHECK(!owner->result_ok);
1918         return DecodeError_clone(&*owner->contents.err);
1919 }
1920 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_get_err"))) TS_CResult_COption_EventZDecodeErrorZ_get_err(uint32_t owner) {
1921         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
1922         LDKDecodeError ret_var = CResult_COption_EventZDecodeErrorZ_get_err(owner_conv);
1923         uint32_t ret_ref = 0;
1924         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1925         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1926         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1927         ret_ref = (uintptr_t)ret_var.inner;
1928         if (ret_var.is_owned) {
1929                 ret_ref |= 1;
1930         }
1931         return ret_ref;
1932 }
1933
1934 uint32_t __attribute__((export_name("TS_LDKErrorAction_ty_from_ptr"))) TS_LDKErrorAction_ty_from_ptr(uint32_t ptr) {
1935         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1936         switch(obj->tag) {
1937                 case LDKErrorAction_DisconnectPeer: return 0;
1938                 case LDKErrorAction_IgnoreError: return 1;
1939                 case LDKErrorAction_IgnoreAndLog: return 2;
1940                 case LDKErrorAction_IgnoreDuplicateGossip: return 3;
1941                 case LDKErrorAction_SendErrorMessage: return 4;
1942                 case LDKErrorAction_SendWarningMessage: return 5;
1943                 default: abort();
1944         }
1945 }
1946 uint32_t __attribute__((export_name("TS_LDKErrorAction_DisconnectPeer_get_msg"))) TS_LDKErrorAction_DisconnectPeer_get_msg(uint32_t ptr) {
1947         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1948         assert(obj->tag == LDKErrorAction_DisconnectPeer);
1949                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
1950                         uint32_t msg_ref = 0;
1951                         if ((uintptr_t)msg_var.inner > 4096) {
1952                                 CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1953                                 CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1954                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1955                                 msg_ref = (uintptr_t)msg_var.inner & ~1;
1956                         }
1957         return msg_ref;
1958 }
1959 uint32_t __attribute__((export_name("TS_LDKErrorAction_IgnoreAndLog_get_ignore_and_log"))) TS_LDKErrorAction_IgnoreAndLog_get_ignore_and_log(uint32_t ptr) {
1960         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1961         assert(obj->tag == LDKErrorAction_IgnoreAndLog);
1962                         uint32_t ignore_and_log_conv = LDKLevel_to_js(obj->ignore_and_log);
1963         return ignore_and_log_conv;
1964 }
1965 uint32_t __attribute__((export_name("TS_LDKErrorAction_SendErrorMessage_get_msg"))) TS_LDKErrorAction_SendErrorMessage_get_msg(uint32_t ptr) {
1966         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1967         assert(obj->tag == LDKErrorAction_SendErrorMessage);
1968                         LDKErrorMessage msg_var = obj->send_error_message.msg;
1969                         uint32_t msg_ref = 0;
1970                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1971                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1972                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1973                         msg_ref = (uintptr_t)msg_var.inner & ~1;
1974         return msg_ref;
1975 }
1976 uint32_t __attribute__((export_name("TS_LDKErrorAction_SendWarningMessage_get_msg"))) TS_LDKErrorAction_SendWarningMessage_get_msg(uint32_t ptr) {
1977         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1978         assert(obj->tag == LDKErrorAction_SendWarningMessage);
1979                         LDKWarningMessage msg_var = obj->send_warning_message.msg;
1980                         uint32_t msg_ref = 0;
1981                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1982                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1983                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1984                         msg_ref = (uintptr_t)msg_var.inner & ~1;
1985         return msg_ref;
1986 }
1987 uint32_t __attribute__((export_name("TS_LDKErrorAction_SendWarningMessage_get_log_level"))) TS_LDKErrorAction_SendWarningMessage_get_log_level(uint32_t ptr) {
1988         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1989         assert(obj->tag == LDKErrorAction_SendWarningMessage);
1990                         uint32_t log_level_conv = LDKLevel_to_js(obj->send_warning_message.log_level);
1991         return log_level_conv;
1992 }
1993 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_ty_from_ptr"))) TS_LDKMessageSendEvent_ty_from_ptr(uint32_t ptr) {
1994         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
1995         switch(obj->tag) {
1996                 case LDKMessageSendEvent_SendAcceptChannel: return 0;
1997                 case LDKMessageSendEvent_SendOpenChannel: return 1;
1998                 case LDKMessageSendEvent_SendFundingCreated: return 2;
1999                 case LDKMessageSendEvent_SendFundingSigned: return 3;
2000                 case LDKMessageSendEvent_SendChannelReady: return 4;
2001                 case LDKMessageSendEvent_SendAnnouncementSignatures: return 5;
2002                 case LDKMessageSendEvent_UpdateHTLCs: return 6;
2003                 case LDKMessageSendEvent_SendRevokeAndACK: return 7;
2004                 case LDKMessageSendEvent_SendClosingSigned: return 8;
2005                 case LDKMessageSendEvent_SendShutdown: return 9;
2006                 case LDKMessageSendEvent_SendChannelReestablish: return 10;
2007                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: return 11;
2008                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: return 12;
2009                 case LDKMessageSendEvent_BroadcastChannelUpdate: return 13;
2010                 case LDKMessageSendEvent_SendChannelUpdate: return 14;
2011                 case LDKMessageSendEvent_HandleError: return 15;
2012                 case LDKMessageSendEvent_SendChannelRangeQuery: return 16;
2013                 case LDKMessageSendEvent_SendShortIdsQuery: return 17;
2014                 case LDKMessageSendEvent_SendReplyChannelRange: return 18;
2015                 case LDKMessageSendEvent_SendGossipTimestampFilter: return 19;
2016                 default: abort();
2017         }
2018 }
2019 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendAcceptChannel_get_node_id"))) TS_LDKMessageSendEvent_SendAcceptChannel_get_node_id(uint32_t ptr) {
2020         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2021         assert(obj->tag == LDKMessageSendEvent_SendAcceptChannel);
2022                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2023                         memcpy(node_id_arr->elems, obj->send_accept_channel.node_id.compressed_form, 33);
2024         return node_id_arr;
2025 }
2026 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendAcceptChannel_get_msg"))) TS_LDKMessageSendEvent_SendAcceptChannel_get_msg(uint32_t ptr) {
2027         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2028         assert(obj->tag == LDKMessageSendEvent_SendAcceptChannel);
2029                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
2030                         uint32_t msg_ref = 0;
2031                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2032                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2033                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2034                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2035         return msg_ref;
2036 }
2037 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendOpenChannel_get_node_id"))) TS_LDKMessageSendEvent_SendOpenChannel_get_node_id(uint32_t ptr) {
2038         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2039         assert(obj->tag == LDKMessageSendEvent_SendOpenChannel);
2040                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2041                         memcpy(node_id_arr->elems, obj->send_open_channel.node_id.compressed_form, 33);
2042         return node_id_arr;
2043 }
2044 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendOpenChannel_get_msg"))) TS_LDKMessageSendEvent_SendOpenChannel_get_msg(uint32_t ptr) {
2045         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2046         assert(obj->tag == LDKMessageSendEvent_SendOpenChannel);
2047                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
2048                         uint32_t msg_ref = 0;
2049                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2050                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2051                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2052                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2053         return msg_ref;
2054 }
2055 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingCreated_get_node_id"))) TS_LDKMessageSendEvent_SendFundingCreated_get_node_id(uint32_t ptr) {
2056         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2057         assert(obj->tag == LDKMessageSendEvent_SendFundingCreated);
2058                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2059                         memcpy(node_id_arr->elems, obj->send_funding_created.node_id.compressed_form, 33);
2060         return node_id_arr;
2061 }
2062 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingCreated_get_msg"))) TS_LDKMessageSendEvent_SendFundingCreated_get_msg(uint32_t ptr) {
2063         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2064         assert(obj->tag == LDKMessageSendEvent_SendFundingCreated);
2065                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
2066                         uint32_t msg_ref = 0;
2067                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2068                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2069                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2070                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2071         return msg_ref;
2072 }
2073 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingSigned_get_node_id"))) TS_LDKMessageSendEvent_SendFundingSigned_get_node_id(uint32_t ptr) {
2074         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2075         assert(obj->tag == LDKMessageSendEvent_SendFundingSigned);
2076                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2077                         memcpy(node_id_arr->elems, obj->send_funding_signed.node_id.compressed_form, 33);
2078         return node_id_arr;
2079 }
2080 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingSigned_get_msg"))) TS_LDKMessageSendEvent_SendFundingSigned_get_msg(uint32_t ptr) {
2081         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2082         assert(obj->tag == LDKMessageSendEvent_SendFundingSigned);
2083                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
2084                         uint32_t msg_ref = 0;
2085                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2086                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2087                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2088                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2089         return msg_ref;
2090 }
2091 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReady_get_node_id"))) TS_LDKMessageSendEvent_SendChannelReady_get_node_id(uint32_t ptr) {
2092         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2093         assert(obj->tag == LDKMessageSendEvent_SendChannelReady);
2094                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2095                         memcpy(node_id_arr->elems, obj->send_channel_ready.node_id.compressed_form, 33);
2096         return node_id_arr;
2097 }
2098 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReady_get_msg"))) TS_LDKMessageSendEvent_SendChannelReady_get_msg(uint32_t ptr) {
2099         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2100         assert(obj->tag == LDKMessageSendEvent_SendChannelReady);
2101                         LDKChannelReady msg_var = obj->send_channel_ready.msg;
2102                         uint32_t msg_ref = 0;
2103                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2104                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2105                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2106                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2107         return msg_ref;
2108 }
2109 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_node_id"))) TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_node_id(uint32_t ptr) {
2110         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2111         assert(obj->tag == LDKMessageSendEvent_SendAnnouncementSignatures);
2112                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2113                         memcpy(node_id_arr->elems, obj->send_announcement_signatures.node_id.compressed_form, 33);
2114         return node_id_arr;
2115 }
2116 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_msg"))) TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_msg(uint32_t ptr) {
2117         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2118         assert(obj->tag == LDKMessageSendEvent_SendAnnouncementSignatures);
2119                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
2120                         uint32_t msg_ref = 0;
2121                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2122                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2123                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2124                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2125         return msg_ref;
2126 }
2127 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_UpdateHTLCs_get_node_id"))) TS_LDKMessageSendEvent_UpdateHTLCs_get_node_id(uint32_t ptr) {
2128         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2129         assert(obj->tag == LDKMessageSendEvent_UpdateHTLCs);
2130                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2131                         memcpy(node_id_arr->elems, obj->update_htl_cs.node_id.compressed_form, 33);
2132         return node_id_arr;
2133 }
2134 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_UpdateHTLCs_get_updates"))) TS_LDKMessageSendEvent_UpdateHTLCs_get_updates(uint32_t ptr) {
2135         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2136         assert(obj->tag == LDKMessageSendEvent_UpdateHTLCs);
2137                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
2138                         uint32_t updates_ref = 0;
2139                         CHECK((((uintptr_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2140                         CHECK((((uintptr_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2141                         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
2142                         updates_ref = (uintptr_t)updates_var.inner & ~1;
2143         return updates_ref;
2144 }
2145 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendRevokeAndACK_get_node_id"))) TS_LDKMessageSendEvent_SendRevokeAndACK_get_node_id(uint32_t ptr) {
2146         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2147         assert(obj->tag == LDKMessageSendEvent_SendRevokeAndACK);
2148                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2149                         memcpy(node_id_arr->elems, obj->send_revoke_and_ack.node_id.compressed_form, 33);
2150         return node_id_arr;
2151 }
2152 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendRevokeAndACK_get_msg"))) TS_LDKMessageSendEvent_SendRevokeAndACK_get_msg(uint32_t ptr) {
2153         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2154         assert(obj->tag == LDKMessageSendEvent_SendRevokeAndACK);
2155                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
2156                         uint32_t msg_ref = 0;
2157                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2158                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2159                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2160                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2161         return msg_ref;
2162 }
2163 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendClosingSigned_get_node_id"))) TS_LDKMessageSendEvent_SendClosingSigned_get_node_id(uint32_t ptr) {
2164         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2165         assert(obj->tag == LDKMessageSendEvent_SendClosingSigned);
2166                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2167                         memcpy(node_id_arr->elems, obj->send_closing_signed.node_id.compressed_form, 33);
2168         return node_id_arr;
2169 }
2170 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendClosingSigned_get_msg"))) TS_LDKMessageSendEvent_SendClosingSigned_get_msg(uint32_t ptr) {
2171         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2172         assert(obj->tag == LDKMessageSendEvent_SendClosingSigned);
2173                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
2174                         uint32_t msg_ref = 0;
2175                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2176                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2177                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2178                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2179         return msg_ref;
2180 }
2181 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendShutdown_get_node_id"))) TS_LDKMessageSendEvent_SendShutdown_get_node_id(uint32_t ptr) {
2182         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2183         assert(obj->tag == LDKMessageSendEvent_SendShutdown);
2184                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2185                         memcpy(node_id_arr->elems, obj->send_shutdown.node_id.compressed_form, 33);
2186         return node_id_arr;
2187 }
2188 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendShutdown_get_msg"))) TS_LDKMessageSendEvent_SendShutdown_get_msg(uint32_t ptr) {
2189         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2190         assert(obj->tag == LDKMessageSendEvent_SendShutdown);
2191                         LDKShutdown msg_var = obj->send_shutdown.msg;
2192                         uint32_t msg_ref = 0;
2193                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2194                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2195                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2196                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2197         return msg_ref;
2198 }
2199 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReestablish_get_node_id"))) TS_LDKMessageSendEvent_SendChannelReestablish_get_node_id(uint32_t ptr) {
2200         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2201         assert(obj->tag == LDKMessageSendEvent_SendChannelReestablish);
2202                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2203                         memcpy(node_id_arr->elems, obj->send_channel_reestablish.node_id.compressed_form, 33);
2204         return node_id_arr;
2205 }
2206 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReestablish_get_msg"))) TS_LDKMessageSendEvent_SendChannelReestablish_get_msg(uint32_t ptr) {
2207         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2208         assert(obj->tag == LDKMessageSendEvent_SendChannelReestablish);
2209                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
2210                         uint32_t msg_ref = 0;
2211                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2212                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2213                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2214                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2215         return msg_ref;
2216 }
2217 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_msg"))) TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_msg(uint32_t ptr) {
2218         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2219         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelAnnouncement);
2220                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
2221                         uint32_t msg_ref = 0;
2222                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2223                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2224                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2225                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2226         return msg_ref;
2227 }
2228 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_update_msg"))) TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_update_msg(uint32_t ptr) {
2229         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2230         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelAnnouncement);
2231                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
2232                         uint32_t update_msg_ref = 0;
2233                         CHECK((((uintptr_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2234                         CHECK((((uintptr_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2235                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
2236                         update_msg_ref = (uintptr_t)update_msg_var.inner & ~1;
2237         return update_msg_ref;
2238 }
2239 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastNodeAnnouncement_get_msg"))) TS_LDKMessageSendEvent_BroadcastNodeAnnouncement_get_msg(uint32_t ptr) {
2240         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2241         assert(obj->tag == LDKMessageSendEvent_BroadcastNodeAnnouncement);
2242                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
2243                         uint32_t msg_ref = 0;
2244                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2245                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2246                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2247                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2248         return msg_ref;
2249 }
2250 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelUpdate_get_msg"))) TS_LDKMessageSendEvent_BroadcastChannelUpdate_get_msg(uint32_t ptr) {
2251         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2252         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelUpdate);
2253                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
2254                         uint32_t msg_ref = 0;
2255                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2256                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2257                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2258                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2259         return msg_ref;
2260 }
2261 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelUpdate_get_node_id"))) TS_LDKMessageSendEvent_SendChannelUpdate_get_node_id(uint32_t ptr) {
2262         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2263         assert(obj->tag == LDKMessageSendEvent_SendChannelUpdate);
2264                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2265                         memcpy(node_id_arr->elems, obj->send_channel_update.node_id.compressed_form, 33);
2266         return node_id_arr;
2267 }
2268 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelUpdate_get_msg"))) TS_LDKMessageSendEvent_SendChannelUpdate_get_msg(uint32_t ptr) {
2269         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2270         assert(obj->tag == LDKMessageSendEvent_SendChannelUpdate);
2271                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
2272                         uint32_t msg_ref = 0;
2273                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2274                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2275                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2276                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2277         return msg_ref;
2278 }
2279 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_HandleError_get_node_id"))) TS_LDKMessageSendEvent_HandleError_get_node_id(uint32_t ptr) {
2280         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2281         assert(obj->tag == LDKMessageSendEvent_HandleError);
2282                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2283                         memcpy(node_id_arr->elems, obj->handle_error.node_id.compressed_form, 33);
2284         return node_id_arr;
2285 }
2286 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_HandleError_get_action"))) TS_LDKMessageSendEvent_HandleError_get_action(uint32_t ptr) {
2287         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2288         assert(obj->tag == LDKMessageSendEvent_HandleError);
2289                         uint32_t action_ref = ((uintptr_t)&obj->handle_error.action) | 1;
2290         return action_ref;
2291 }
2292 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelRangeQuery_get_node_id"))) TS_LDKMessageSendEvent_SendChannelRangeQuery_get_node_id(uint32_t ptr) {
2293         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2294         assert(obj->tag == LDKMessageSendEvent_SendChannelRangeQuery);
2295                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2296                         memcpy(node_id_arr->elems, obj->send_channel_range_query.node_id.compressed_form, 33);
2297         return node_id_arr;
2298 }
2299 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelRangeQuery_get_msg"))) TS_LDKMessageSendEvent_SendChannelRangeQuery_get_msg(uint32_t ptr) {
2300         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2301         assert(obj->tag == LDKMessageSendEvent_SendChannelRangeQuery);
2302                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
2303                         uint32_t msg_ref = 0;
2304                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2305                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2306                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2307                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2308         return msg_ref;
2309 }
2310 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendShortIdsQuery_get_node_id"))) TS_LDKMessageSendEvent_SendShortIdsQuery_get_node_id(uint32_t ptr) {
2311         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2312         assert(obj->tag == LDKMessageSendEvent_SendShortIdsQuery);
2313                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2314                         memcpy(node_id_arr->elems, obj->send_short_ids_query.node_id.compressed_form, 33);
2315         return node_id_arr;
2316 }
2317 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendShortIdsQuery_get_msg"))) TS_LDKMessageSendEvent_SendShortIdsQuery_get_msg(uint32_t ptr) {
2318         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2319         assert(obj->tag == LDKMessageSendEvent_SendShortIdsQuery);
2320                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
2321                         uint32_t msg_ref = 0;
2322                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2323                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2324                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2325                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2326         return msg_ref;
2327 }
2328 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendReplyChannelRange_get_node_id"))) TS_LDKMessageSendEvent_SendReplyChannelRange_get_node_id(uint32_t ptr) {
2329         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2330         assert(obj->tag == LDKMessageSendEvent_SendReplyChannelRange);
2331                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2332                         memcpy(node_id_arr->elems, obj->send_reply_channel_range.node_id.compressed_form, 33);
2333         return node_id_arr;
2334 }
2335 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendReplyChannelRange_get_msg"))) TS_LDKMessageSendEvent_SendReplyChannelRange_get_msg(uint32_t ptr) {
2336         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2337         assert(obj->tag == LDKMessageSendEvent_SendReplyChannelRange);
2338                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
2339                         uint32_t msg_ref = 0;
2340                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2341                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2342                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2343                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2344         return msg_ref;
2345 }
2346 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendGossipTimestampFilter_get_node_id"))) TS_LDKMessageSendEvent_SendGossipTimestampFilter_get_node_id(uint32_t ptr) {
2347         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2348         assert(obj->tag == LDKMessageSendEvent_SendGossipTimestampFilter);
2349                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2350                         memcpy(node_id_arr->elems, obj->send_gossip_timestamp_filter.node_id.compressed_form, 33);
2351         return node_id_arr;
2352 }
2353 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendGossipTimestampFilter_get_msg"))) TS_LDKMessageSendEvent_SendGossipTimestampFilter_get_msg(uint32_t ptr) {
2354         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2355         assert(obj->tag == LDKMessageSendEvent_SendGossipTimestampFilter);
2356                         LDKGossipTimestampFilter msg_var = obj->send_gossip_timestamp_filter.msg;
2357                         uint32_t msg_ref = 0;
2358                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2359                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2360                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2361                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2362         return msg_ref;
2363 }
2364 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
2365         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
2366         for (size_t i = 0; i < ret.datalen; i++) {
2367                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
2368         }
2369         return ret;
2370 }
2371 static inline struct LDKTxOut CResult_TxOutAccessErrorZ_get_ok(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
2372 CHECK(owner->result_ok);
2373         return TxOut_clone(&*owner->contents.result);
2374 }
2375 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_get_ok"))) TS_CResult_TxOutAccessErrorZ_get_ok(uint32_t owner) {
2376         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
2377         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
2378         *ret_ref = CResult_TxOutAccessErrorZ_get_ok(owner_conv);
2379         return (uint32_t)ret_ref;
2380 }
2381
2382 static inline enum LDKAccessError CResult_TxOutAccessErrorZ_get_err(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
2383 CHECK(!owner->result_ok);
2384         return AccessError_clone(&*owner->contents.err);
2385 }
2386 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_get_err"))) TS_CResult_TxOutAccessErrorZ_get_err(uint32_t owner) {
2387         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
2388         uint32_t ret_conv = LDKAccessError_to_js(CResult_TxOutAccessErrorZ_get_err(owner_conv));
2389         return ret_conv;
2390 }
2391
2392 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
2393         return owner->a;
2394 }
2395 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_get_a"))) TS_C2Tuple_usizeTransactionZ_get_a(uint32_t owner) {
2396         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
2397         uint32_t ret_conv = C2Tuple_usizeTransactionZ_get_a(owner_conv);
2398         return ret_conv;
2399 }
2400
2401 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
2402         return owner->b;
2403 }
2404 int8_tArray  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_get_b"))) TS_C2Tuple_usizeTransactionZ_get_b(uint32_t owner) {
2405         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
2406         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(owner_conv);
2407         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
2408         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
2409         return ret_arr;
2410 }
2411
2412 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
2413         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
2414         for (size_t i = 0; i < ret.datalen; i++) {
2415                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
2416         }
2417         return ret;
2418 }
2419 static inline LDKCVec_TxidZ CVec_TxidZ_clone(const LDKCVec_TxidZ *orig) {
2420         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
2421         for (size_t i = 0; i < ret.datalen; i++) {
2422                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
2423         }
2424         return ret;
2425 }
2426 static inline void CResult_NoneChannelMonitorUpdateErrZ_get_ok(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
2427 CHECK(owner->result_ok);
2428         return *owner->contents.result;
2429 }
2430 void  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_get_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_get_ok(uint32_t owner) {
2431         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
2432         CResult_NoneChannelMonitorUpdateErrZ_get_ok(owner_conv);
2433 }
2434
2435 static inline enum LDKChannelMonitorUpdateErr CResult_NoneChannelMonitorUpdateErrZ_get_err(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
2436 CHECK(!owner->result_ok);
2437         return ChannelMonitorUpdateErr_clone(&*owner->contents.err);
2438 }
2439 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_get_err"))) TS_CResult_NoneChannelMonitorUpdateErrZ_get_err(uint32_t owner) {
2440         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
2441         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(CResult_NoneChannelMonitorUpdateErrZ_get_err(owner_conv));
2442         return ret_conv;
2443 }
2444
2445 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_ty_from_ptr"))) TS_LDKMonitorEvent_ty_from_ptr(uint32_t ptr) {
2446         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
2447         switch(obj->tag) {
2448                 case LDKMonitorEvent_HTLCEvent: return 0;
2449                 case LDKMonitorEvent_CommitmentTxConfirmed: return 1;
2450                 case LDKMonitorEvent_UpdateCompleted: return 2;
2451                 case LDKMonitorEvent_UpdateFailed: return 3;
2452                 default: abort();
2453         }
2454 }
2455 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_HTLCEvent_get_htlc_event"))) TS_LDKMonitorEvent_HTLCEvent_get_htlc_event(uint32_t ptr) {
2456         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
2457         assert(obj->tag == LDKMonitorEvent_HTLCEvent);
2458                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
2459                         uint32_t htlc_event_ref = 0;
2460                         CHECK((((uintptr_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2461                         CHECK((((uintptr_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2462                         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
2463                         htlc_event_ref = (uintptr_t)htlc_event_var.inner & ~1;
2464         return htlc_event_ref;
2465 }
2466 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_CommitmentTxConfirmed_get_commitment_tx_confirmed"))) TS_LDKMonitorEvent_CommitmentTxConfirmed_get_commitment_tx_confirmed(uint32_t ptr) {
2467         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
2468         assert(obj->tag == LDKMonitorEvent_CommitmentTxConfirmed);
2469                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
2470                         uint32_t commitment_tx_confirmed_ref = 0;
2471                         CHECK((((uintptr_t)commitment_tx_confirmed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2472                         CHECK((((uintptr_t)&commitment_tx_confirmed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2473                         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_confirmed_var);
2474                         commitment_tx_confirmed_ref = (uintptr_t)commitment_tx_confirmed_var.inner & ~1;
2475         return commitment_tx_confirmed_ref;
2476 }
2477 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateCompleted_get_funding_txo"))) TS_LDKMonitorEvent_UpdateCompleted_get_funding_txo(uint32_t ptr) {
2478         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
2479         assert(obj->tag == LDKMonitorEvent_UpdateCompleted);
2480                         LDKOutPoint funding_txo_var = obj->update_completed.funding_txo;
2481                         uint32_t funding_txo_ref = 0;
2482                         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2483                         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2484                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
2485                         funding_txo_ref = (uintptr_t)funding_txo_var.inner & ~1;
2486         return funding_txo_ref;
2487 }
2488 int64_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateCompleted_get_monitor_update_id"))) TS_LDKMonitorEvent_UpdateCompleted_get_monitor_update_id(uint32_t ptr) {
2489         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
2490         assert(obj->tag == LDKMonitorEvent_UpdateCompleted);
2491                         int64_t monitor_update_id_conv = obj->update_completed.monitor_update_id;
2492         return monitor_update_id_conv;
2493 }
2494 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateFailed_get_update_failed"))) TS_LDKMonitorEvent_UpdateFailed_get_update_failed(uint32_t ptr) {
2495         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
2496         assert(obj->tag == LDKMonitorEvent_UpdateFailed);
2497                         LDKOutPoint update_failed_var = obj->update_failed;
2498                         uint32_t update_failed_ref = 0;
2499                         CHECK((((uintptr_t)update_failed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2500                         CHECK((((uintptr_t)&update_failed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2501                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_failed_var);
2502                         update_failed_ref = (uintptr_t)update_failed_var.inner & ~1;
2503         return update_failed_ref;
2504 }
2505 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
2506         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
2507         for (size_t i = 0; i < ret.datalen; i++) {
2508                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
2509         }
2510         return ret;
2511 }
2512 static inline struct LDKOutPoint C2Tuple_OutPointCVec_MonitorEventZZ_get_a(LDKC2Tuple_OutPointCVec_MonitorEventZZ *NONNULL_PTR owner){
2513         return OutPoint_clone(&owner->a);
2514 }
2515 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointCVec_MonitorEventZZ_get_a"))) TS_C2Tuple_OutPointCVec_MonitorEventZZ_get_a(uint32_t owner) {
2516         LDKC2Tuple_OutPointCVec_MonitorEventZZ* owner_conv = (LDKC2Tuple_OutPointCVec_MonitorEventZZ*)(owner & ~1);
2517         LDKOutPoint ret_var = C2Tuple_OutPointCVec_MonitorEventZZ_get_a(owner_conv);
2518         uint32_t ret_ref = 0;
2519         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2520         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2521         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2522         ret_ref = (uintptr_t)ret_var.inner;
2523         if (ret_var.is_owned) {
2524                 ret_ref |= 1;
2525         }
2526         return ret_ref;
2527 }
2528
2529 static inline struct LDKCVec_MonitorEventZ C2Tuple_OutPointCVec_MonitorEventZZ_get_b(LDKC2Tuple_OutPointCVec_MonitorEventZZ *NONNULL_PTR owner){
2530         return CVec_MonitorEventZ_clone(&owner->b);
2531 }
2532 uint32_tArray  __attribute__((export_name("TS_C2Tuple_OutPointCVec_MonitorEventZZ_get_b"))) TS_C2Tuple_OutPointCVec_MonitorEventZZ_get_b(uint32_t owner) {
2533         LDKC2Tuple_OutPointCVec_MonitorEventZZ* owner_conv = (LDKC2Tuple_OutPointCVec_MonitorEventZZ*)(owner & ~1);
2534         LDKCVec_MonitorEventZ ret_var = C2Tuple_OutPointCVec_MonitorEventZZ_get_b(owner_conv);
2535         uint32_tArray ret_arr = NULL;
2536         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
2537         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
2538         for (size_t o = 0; o < ret_var.datalen; o++) {
2539                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
2540                 *ret_conv_14_copy = ret_var.data[o];
2541                 uint32_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
2542                 ret_arr_ptr[o] = ret_conv_14_ref;
2543         }
2544         
2545         FREE(ret_var.data);
2546         return ret_arr;
2547 }
2548
2549 static inline LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ CVec_C2Tuple_OutPointCVec_MonitorEventZZZ_clone(const LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ *orig) {
2550         LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorEventZZ) * orig->datalen, "LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ clone bytes"), .datalen = orig->datalen };
2551         for (size_t i = 0; i < ret.datalen; i++) {
2552                 ret.data[i] = C2Tuple_OutPointCVec_MonitorEventZZ_clone(&orig->data[i]);
2553         }
2554         return ret;
2555 }
2556 uint32_t __attribute__((export_name("TS_LDKCOption_C2Tuple_usizeTransactionZZ_ty_from_ptr"))) TS_LDKCOption_C2Tuple_usizeTransactionZZ_ty_from_ptr(uint32_t ptr) {
2557         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
2558         switch(obj->tag) {
2559                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: return 0;
2560                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: return 1;
2561                 default: abort();
2562         }
2563 }
2564 uint32_t __attribute__((export_name("TS_LDKCOption_C2Tuple_usizeTransactionZZ_Some_get_some"))) TS_LDKCOption_C2Tuple_usizeTransactionZZ_Some_get_some(uint32_t ptr) {
2565         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
2566         assert(obj->tag == LDKCOption_C2Tuple_usizeTransactionZZ_Some);
2567                         LDKC2Tuple_usizeTransactionZ* some_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
2568                         *some_conv = obj->some;
2569                         *some_conv = C2Tuple_usizeTransactionZ_clone(some_conv);
2570         return ((uint32_t)some_conv);
2571 }
2572 static inline struct LDKFixedPenaltyScorer CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
2573 CHECK(owner->result_ok);
2574         return FixedPenaltyScorer_clone(&*owner->contents.result);
2575 }
2576 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_ok"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(uint32_t owner) {
2577         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
2578         LDKFixedPenaltyScorer ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(owner_conv);
2579         uint32_t ret_ref = 0;
2580         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2581         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2582         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2583         ret_ref = (uintptr_t)ret_var.inner;
2584         if (ret_var.is_owned) {
2585                 ret_ref |= 1;
2586         }
2587         return ret_ref;
2588 }
2589
2590 static inline struct LDKDecodeError CResult_FixedPenaltyScorerDecodeErrorZ_get_err(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
2591 CHECK(!owner->result_ok);
2592         return DecodeError_clone(&*owner->contents.err);
2593 }
2594 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_err"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_err(uint32_t owner) {
2595         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
2596         LDKDecodeError ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_err(owner_conv);
2597         uint32_t ret_ref = 0;
2598         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2599         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2600         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2601         ret_ref = (uintptr_t)ret_var.inner;
2602         if (ret_var.is_owned) {
2603                 ret_ref |= 1;
2604         }
2605         return ret_ref;
2606 }
2607
2608 typedef struct LDKLogger_JCalls {
2609         atomic_size_t refcnt;
2610         uint32_t instance_ptr;
2611 } LDKLogger_JCalls;
2612 static void LDKLogger_JCalls_free(void* this_arg) {
2613         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2614         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2615                 FREE(j_calls);
2616         }
2617 }
2618 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
2619         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2620         LDKRecord record_var = *record;
2621         uint32_t record_ref = 0;
2622         record_var = Record_clone(&record_var);
2623         CHECK((((uintptr_t)record_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2624         CHECK((((uintptr_t)&record_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2625         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
2626         record_ref = (uintptr_t)record_var.inner;
2627         if (record_var.is_owned) {
2628                 record_ref |= 1;
2629         }
2630         js_invoke_function_1(j_calls->instance_ptr, 0, (uint32_t)record_ref);
2631 }
2632 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
2633         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
2634         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2635 }
2636 static inline LDKLogger LDKLogger_init (JSValue o) {
2637         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
2638         atomic_init(&calls->refcnt, 1);
2639         calls->instance_ptr = o;
2640
2641         LDKLogger ret = {
2642                 .this_arg = (void*) calls,
2643                 .log = log_LDKLogger_jcall,
2644                 .free = LDKLogger_JCalls_free,
2645         };
2646         return ret;
2647 }
2648 long  __attribute__((export_name("TS_LDKLogger_new"))) TS_LDKLogger_new(JSValue o) {
2649         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
2650         *res_ptr = LDKLogger_init(o);
2651         return (long)res_ptr;
2652 }
2653 static inline struct LDKProbabilisticScorer *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
2654 CHECK(owner->result_ok);
2655         return &*owner->contents.result;
2656 }
2657 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_get_ok"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_get_ok(uint32_t owner) {
2658         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(owner & ~1);
2659         LDKProbabilisticScorer ret_var = *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(owner_conv);
2660         uint32_t ret_ref = 0;
2661         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2662         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2663         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2664         ret_ref = (uintptr_t)ret_var.inner & ~1;
2665         return ret_ref;
2666 }
2667
2668 static inline struct LDKDecodeError CResult_ProbabilisticScorerDecodeErrorZ_get_err(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
2669 CHECK(!owner->result_ok);
2670         return DecodeError_clone(&*owner->contents.err);
2671 }
2672 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_get_err"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_get_err(uint32_t owner) {
2673         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(owner & ~1);
2674         LDKDecodeError ret_var = CResult_ProbabilisticScorerDecodeErrorZ_get_err(owner_conv);
2675         uint32_t ret_ref = 0;
2676         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2677         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2678         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2679         ret_ref = (uintptr_t)ret_var.inner;
2680         if (ret_var.is_owned) {
2681                 ret_ref |= 1;
2682         }
2683         return ret_ref;
2684 }
2685
2686 static inline struct LDKInitFeatures CResult_InitFeaturesDecodeErrorZ_get_ok(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
2687 CHECK(owner->result_ok);
2688         return InitFeatures_clone(&*owner->contents.result);
2689 }
2690 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_get_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2691         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
2692         LDKInitFeatures ret_var = CResult_InitFeaturesDecodeErrorZ_get_ok(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 LDKDecodeError CResult_InitFeaturesDecodeErrorZ_get_err(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
2705 CHECK(!owner->result_ok);
2706         return DecodeError_clone(&*owner->contents.err);
2707 }
2708 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_get_err"))) TS_CResult_InitFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2709         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
2710         LDKDecodeError ret_var = CResult_InitFeaturesDecodeErrorZ_get_err(owner_conv);
2711         uint32_t ret_ref = 0;
2712         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2713         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2714         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2715         ret_ref = (uintptr_t)ret_var.inner;
2716         if (ret_var.is_owned) {
2717                 ret_ref |= 1;
2718         }
2719         return ret_ref;
2720 }
2721
2722 static inline struct LDKChannelFeatures CResult_ChannelFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
2723 CHECK(owner->result_ok);
2724         return ChannelFeatures_clone(&*owner->contents.result);
2725 }
2726 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_get_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2727         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
2728         LDKChannelFeatures ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_ok(owner_conv);
2729         uint32_t ret_ref = 0;
2730         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2731         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2732         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2733         ret_ref = (uintptr_t)ret_var.inner;
2734         if (ret_var.is_owned) {
2735                 ret_ref |= 1;
2736         }
2737         return ret_ref;
2738 }
2739
2740 static inline struct LDKDecodeError CResult_ChannelFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
2741 CHECK(!owner->result_ok);
2742         return DecodeError_clone(&*owner->contents.err);
2743 }
2744 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_get_err"))) TS_CResult_ChannelFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2745         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
2746         LDKDecodeError ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_err(owner_conv);
2747         uint32_t ret_ref = 0;
2748         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2749         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2750         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2751         ret_ref = (uintptr_t)ret_var.inner;
2752         if (ret_var.is_owned) {
2753                 ret_ref |= 1;
2754         }
2755         return ret_ref;
2756 }
2757
2758 static inline struct LDKNodeFeatures CResult_NodeFeaturesDecodeErrorZ_get_ok(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2759 CHECK(owner->result_ok);
2760         return NodeFeatures_clone(&*owner->contents.result);
2761 }
2762 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_get_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2763         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
2764         LDKNodeFeatures ret_var = CResult_NodeFeaturesDecodeErrorZ_get_ok(owner_conv);
2765         uint32_t ret_ref = 0;
2766         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2767         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2768         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2769         ret_ref = (uintptr_t)ret_var.inner;
2770         if (ret_var.is_owned) {
2771                 ret_ref |= 1;
2772         }
2773         return ret_ref;
2774 }
2775
2776 static inline struct LDKDecodeError CResult_NodeFeaturesDecodeErrorZ_get_err(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2777 CHECK(!owner->result_ok);
2778         return DecodeError_clone(&*owner->contents.err);
2779 }
2780 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_get_err"))) TS_CResult_NodeFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2781         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
2782         LDKDecodeError ret_var = CResult_NodeFeaturesDecodeErrorZ_get_err(owner_conv);
2783         uint32_t ret_ref = 0;
2784         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2785         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2786         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2787         ret_ref = (uintptr_t)ret_var.inner;
2788         if (ret_var.is_owned) {
2789                 ret_ref |= 1;
2790         }
2791         return ret_ref;
2792 }
2793
2794 static inline struct LDKInvoiceFeatures CResult_InvoiceFeaturesDecodeErrorZ_get_ok(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
2795 CHECK(owner->result_ok);
2796         return InvoiceFeatures_clone(&*owner->contents.result);
2797 }
2798 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_get_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2799         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
2800         LDKInvoiceFeatures ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_ok(owner_conv);
2801         uint32_t ret_ref = 0;
2802         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2803         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2804         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2805         ret_ref = (uintptr_t)ret_var.inner;
2806         if (ret_var.is_owned) {
2807                 ret_ref |= 1;
2808         }
2809         return ret_ref;
2810 }
2811
2812 static inline struct LDKDecodeError CResult_InvoiceFeaturesDecodeErrorZ_get_err(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
2813 CHECK(!owner->result_ok);
2814         return DecodeError_clone(&*owner->contents.err);
2815 }
2816 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_get_err"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2817         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
2818         LDKDecodeError ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_err(owner_conv);
2819         uint32_t ret_ref = 0;
2820         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2821         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2822         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2823         ret_ref = (uintptr_t)ret_var.inner;
2824         if (ret_var.is_owned) {
2825                 ret_ref |= 1;
2826         }
2827         return ret_ref;
2828 }
2829
2830 static inline struct LDKChannelTypeFeatures CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2831 CHECK(owner->result_ok);
2832         return ChannelTypeFeatures_clone(&*owner->contents.result);
2833 }
2834 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2835         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
2836         LDKChannelTypeFeatures ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(owner_conv);
2837         uint32_t ret_ref = 0;
2838         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2839         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2840         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2841         ret_ref = (uintptr_t)ret_var.inner;
2842         if (ret_var.is_owned) {
2843                 ret_ref |= 1;
2844         }
2845         return ret_ref;
2846 }
2847
2848 static inline struct LDKDecodeError CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2849 CHECK(!owner->result_ok);
2850         return DecodeError_clone(&*owner->contents.err);
2851 }
2852 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_err"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2853         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
2854         LDKDecodeError ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(owner_conv);
2855         uint32_t ret_ref = 0;
2856         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2857         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2858         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2859         ret_ref = (uintptr_t)ret_var.inner;
2860         if (ret_var.is_owned) {
2861                 ret_ref |= 1;
2862         }
2863         return ret_ref;
2864 }
2865
2866 static inline struct LDKNodeId CResult_NodeIdDecodeErrorZ_get_ok(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
2867 CHECK(owner->result_ok);
2868         return NodeId_clone(&*owner->contents.result);
2869 }
2870 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_get_ok"))) TS_CResult_NodeIdDecodeErrorZ_get_ok(uint32_t owner) {
2871         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
2872         LDKNodeId ret_var = CResult_NodeIdDecodeErrorZ_get_ok(owner_conv);
2873         uint32_t ret_ref = 0;
2874         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2875         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2876         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2877         ret_ref = (uintptr_t)ret_var.inner;
2878         if (ret_var.is_owned) {
2879                 ret_ref |= 1;
2880         }
2881         return ret_ref;
2882 }
2883
2884 static inline struct LDKDecodeError CResult_NodeIdDecodeErrorZ_get_err(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
2885 CHECK(!owner->result_ok);
2886         return DecodeError_clone(&*owner->contents.err);
2887 }
2888 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_get_err"))) TS_CResult_NodeIdDecodeErrorZ_get_err(uint32_t owner) {
2889         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
2890         LDKDecodeError ret_var = CResult_NodeIdDecodeErrorZ_get_err(owner_conv);
2891         uint32_t ret_ref = 0;
2892         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2893         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2894         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2895         ret_ref = (uintptr_t)ret_var.inner;
2896         if (ret_var.is_owned) {
2897                 ret_ref |= 1;
2898         }
2899         return ret_ref;
2900 }
2901
2902 static inline struct LDKCOption_NetworkUpdateZ CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
2903 CHECK(owner->result_ok);
2904         return COption_NetworkUpdateZ_clone(&*owner->contents.result);
2905 }
2906 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(uint32_t owner) {
2907         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
2908         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
2909         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(owner_conv);
2910         uint32_t ret_ref = (uintptr_t)ret_copy;
2911         return ret_ref;
2912 }
2913
2914 static inline struct LDKDecodeError CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
2915 CHECK(!owner->result_ok);
2916         return DecodeError_clone(&*owner->contents.err);
2917 }
2918 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_err"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(uint32_t owner) {
2919         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
2920         LDKDecodeError ret_var = CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(owner_conv);
2921         uint32_t ret_ref = 0;
2922         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2923         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2924         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2925         ret_ref = (uintptr_t)ret_var.inner;
2926         if (ret_var.is_owned) {
2927                 ret_ref |= 1;
2928         }
2929         return ret_ref;
2930 }
2931
2932 typedef struct LDKAccess_JCalls {
2933         atomic_size_t refcnt;
2934         uint32_t instance_ptr;
2935 } LDKAccess_JCalls;
2936 static void LDKAccess_JCalls_free(void* this_arg) {
2937         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
2938         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2939                 FREE(j_calls);
2940         }
2941 }
2942 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
2943         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
2944         int8_tArray genesis_hash_arr = init_int8_tArray(32, __LINE__);
2945         memcpy(genesis_hash_arr->elems, *genesis_hash, 32);
2946         int64_t short_channel_id_conv = short_channel_id;
2947         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 1, (uint32_t)genesis_hash_arr, (uint32_t)short_channel_id_conv);
2948         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
2949         CHECK_ACCESS(ret_ptr);
2950         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
2951         FREE((void*)ret);
2952         return ret_conv;
2953 }
2954 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
2955         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
2956         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2957 }
2958 static inline LDKAccess LDKAccess_init (JSValue o) {
2959         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
2960         atomic_init(&calls->refcnt, 1);
2961         calls->instance_ptr = o;
2962
2963         LDKAccess ret = {
2964                 .this_arg = (void*) calls,
2965                 .get_utxo = get_utxo_LDKAccess_jcall,
2966                 .free = LDKAccess_JCalls_free,
2967         };
2968         return ret;
2969 }
2970 long  __attribute__((export_name("TS_LDKAccess_new"))) TS_LDKAccess_new(JSValue o) {
2971         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
2972         *res_ptr = LDKAccess_init(o);
2973         return (long)res_ptr;
2974 }
2975 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) {
2976         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
2977         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
2978         LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
2979         unsigned char genesis_hash_arr[32];
2980         CHECK(genesis_hash->arr_len == 32);
2981         memcpy(genesis_hash_arr, genesis_hash->elems, 32); FREE(genesis_hash);
2982         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
2983         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
2984         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
2985         return (uint32_t)ret_conv;
2986 }
2987
2988 uint32_t __attribute__((export_name("TS_LDKCOption_AccessZ_ty_from_ptr"))) TS_LDKCOption_AccessZ_ty_from_ptr(uint32_t ptr) {
2989         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
2990         switch(obj->tag) {
2991                 case LDKCOption_AccessZ_Some: return 0;
2992                 case LDKCOption_AccessZ_None: return 1;
2993                 default: abort();
2994         }
2995 }
2996 uint32_t __attribute__((export_name("TS_LDKCOption_AccessZ_Some_get_some"))) TS_LDKCOption_AccessZ_Some_get_some(uint32_t ptr) {
2997         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
2998         assert(obj->tag == LDKCOption_AccessZ_Some);
2999                         LDKAccess* some_ret = MALLOC(sizeof(LDKAccess), "LDKAccess");
3000                         *some_ret = obj->some;
3001                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
3002                         if ((*some_ret).free == LDKAccess_JCalls_free) {
3003                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
3004                                 LDKAccess_JCalls_cloned(&(*some_ret));
3005                         }
3006         return (uint32_t)some_ret;
3007 }
3008 static inline bool CResult_boolLightningErrorZ_get_ok(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
3009 CHECK(owner->result_ok);
3010         return *owner->contents.result;
3011 }
3012 jboolean  __attribute__((export_name("TS_CResult_boolLightningErrorZ_get_ok"))) TS_CResult_boolLightningErrorZ_get_ok(uint32_t owner) {
3013         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
3014         jboolean ret_conv = CResult_boolLightningErrorZ_get_ok(owner_conv);
3015         return ret_conv;
3016 }
3017
3018 static inline struct LDKLightningError CResult_boolLightningErrorZ_get_err(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
3019 CHECK(!owner->result_ok);
3020         return LightningError_clone(&*owner->contents.err);
3021 }
3022 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_get_err"))) TS_CResult_boolLightningErrorZ_get_err(uint32_t owner) {
3023         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
3024         LDKLightningError ret_var = CResult_boolLightningErrorZ_get_err(owner_conv);
3025         uint32_t ret_ref = 0;
3026         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3027         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3028         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3029         ret_ref = (uintptr_t)ret_var.inner;
3030         if (ret_var.is_owned) {
3031                 ret_ref |= 1;
3032         }
3033         return ret_ref;
3034 }
3035
3036 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
3037         return ChannelAnnouncement_clone(&owner->a);
3038 }
3039 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(uint32_t owner) {
3040         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
3041         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(owner_conv);
3042         uint32_t ret_ref = 0;
3043         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3044         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3045         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3046         ret_ref = (uintptr_t)ret_var.inner;
3047         if (ret_var.is_owned) {
3048                 ret_ref |= 1;
3049         }
3050         return ret_ref;
3051 }
3052
3053 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
3054         return ChannelUpdate_clone(&owner->b);
3055 }
3056 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(uint32_t owner) {
3057         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
3058         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(owner_conv);
3059         uint32_t ret_ref = 0;
3060         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3061         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3062         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3063         ret_ref = (uintptr_t)ret_var.inner;
3064         if (ret_var.is_owned) {
3065                 ret_ref |= 1;
3066         }
3067         return ret_ref;
3068 }
3069
3070 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
3071         return ChannelUpdate_clone(&owner->c);
3072 }
3073 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(uint32_t owner) {
3074         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
3075         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(owner_conv);
3076         uint32_t ret_ref = 0;
3077         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3078         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3079         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3080         ret_ref = (uintptr_t)ret_var.inner;
3081         if (ret_var.is_owned) {
3082                 ret_ref |= 1;
3083         }
3084         return ret_ref;
3085 }
3086
3087 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
3088         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
3089         for (size_t i = 0; i < ret.datalen; i++) {
3090                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
3091         }
3092         return ret;
3093 }
3094 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
3095         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
3096         for (size_t i = 0; i < ret.datalen; i++) {
3097                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
3098         }
3099         return ret;
3100 }
3101 static inline void CResult_NoneLightningErrorZ_get_ok(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
3102 CHECK(owner->result_ok);
3103         return *owner->contents.result;
3104 }
3105 void  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_get_ok"))) TS_CResult_NoneLightningErrorZ_get_ok(uint32_t owner) {
3106         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
3107         CResult_NoneLightningErrorZ_get_ok(owner_conv);
3108 }
3109
3110 static inline struct LDKLightningError CResult_NoneLightningErrorZ_get_err(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
3111 CHECK(!owner->result_ok);
3112         return LightningError_clone(&*owner->contents.err);
3113 }
3114 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_get_err"))) TS_CResult_NoneLightningErrorZ_get_err(uint32_t owner) {
3115         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
3116         LDKLightningError ret_var = CResult_NoneLightningErrorZ_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 LDKChannelUpdateInfo CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
3129 CHECK(owner->result_ok);
3130         return ChannelUpdateInfo_clone(&*owner->contents.result);
3131 }
3132 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_ok"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(uint32_t owner) {
3133         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
3134         LDKChannelUpdateInfo ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(owner_conv);
3135         uint32_t ret_ref = 0;
3136         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3137         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3138         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3139         ret_ref = (uintptr_t)ret_var.inner;
3140         if (ret_var.is_owned) {
3141                 ret_ref |= 1;
3142         }
3143         return ret_ref;
3144 }
3145
3146 static inline struct LDKDecodeError CResult_ChannelUpdateInfoDecodeErrorZ_get_err(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
3147 CHECK(!owner->result_ok);
3148         return DecodeError_clone(&*owner->contents.err);
3149 }
3150 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_err"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_err(uint32_t owner) {
3151         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
3152         LDKDecodeError ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_err(owner_conv);
3153         uint32_t ret_ref = 0;
3154         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3155         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3156         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3157         ret_ref = (uintptr_t)ret_var.inner;
3158         if (ret_var.is_owned) {
3159                 ret_ref |= 1;
3160         }
3161         return ret_ref;
3162 }
3163
3164 static inline struct LDKChannelInfo CResult_ChannelInfoDecodeErrorZ_get_ok(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
3165 CHECK(owner->result_ok);
3166         return ChannelInfo_clone(&*owner->contents.result);
3167 }
3168 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_get_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_get_ok(uint32_t owner) {
3169         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
3170         LDKChannelInfo ret_var = CResult_ChannelInfoDecodeErrorZ_get_ok(owner_conv);
3171         uint32_t ret_ref = 0;
3172         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3173         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3174         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3175         ret_ref = (uintptr_t)ret_var.inner;
3176         if (ret_var.is_owned) {
3177                 ret_ref |= 1;
3178         }
3179         return ret_ref;
3180 }
3181
3182 static inline struct LDKDecodeError CResult_ChannelInfoDecodeErrorZ_get_err(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
3183 CHECK(!owner->result_ok);
3184         return DecodeError_clone(&*owner->contents.err);
3185 }
3186 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_get_err"))) TS_CResult_ChannelInfoDecodeErrorZ_get_err(uint32_t owner) {
3187         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
3188         LDKDecodeError ret_var = CResult_ChannelInfoDecodeErrorZ_get_err(owner_conv);
3189         uint32_t ret_ref = 0;
3190         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3191         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3192         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3193         ret_ref = (uintptr_t)ret_var.inner;
3194         if (ret_var.is_owned) {
3195                 ret_ref |= 1;
3196         }
3197         return ret_ref;
3198 }
3199
3200 static inline struct LDKRoutingFees CResult_RoutingFeesDecodeErrorZ_get_ok(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
3201 CHECK(owner->result_ok);
3202         return RoutingFees_clone(&*owner->contents.result);
3203 }
3204 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_get_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_get_ok(uint32_t owner) {
3205         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
3206         LDKRoutingFees ret_var = CResult_RoutingFeesDecodeErrorZ_get_ok(owner_conv);
3207         uint32_t ret_ref = 0;
3208         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3209         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3210         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3211         ret_ref = (uintptr_t)ret_var.inner;
3212         if (ret_var.is_owned) {
3213                 ret_ref |= 1;
3214         }
3215         return ret_ref;
3216 }
3217
3218 static inline struct LDKDecodeError CResult_RoutingFeesDecodeErrorZ_get_err(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
3219 CHECK(!owner->result_ok);
3220         return DecodeError_clone(&*owner->contents.err);
3221 }
3222 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_get_err"))) TS_CResult_RoutingFeesDecodeErrorZ_get_err(uint32_t owner) {
3223         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
3224         LDKDecodeError ret_var = CResult_RoutingFeesDecodeErrorZ_get_err(owner_conv);
3225         uint32_t ret_ref = 0;
3226         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3227         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3228         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3229         ret_ref = (uintptr_t)ret_var.inner;
3230         if (ret_var.is_owned) {
3231                 ret_ref |= 1;
3232         }
3233         return ret_ref;
3234 }
3235
3236 uint32_t __attribute__((export_name("TS_LDKNetAddress_ty_from_ptr"))) TS_LDKNetAddress_ty_from_ptr(uint32_t ptr) {
3237         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3238         switch(obj->tag) {
3239                 case LDKNetAddress_IPv4: return 0;
3240                 case LDKNetAddress_IPv6: return 1;
3241                 case LDKNetAddress_OnionV2: return 2;
3242                 case LDKNetAddress_OnionV3: return 3;
3243                 default: abort();
3244         }
3245 }
3246 int8_tArray __attribute__((export_name("TS_LDKNetAddress_IPv4_get_addr"))) TS_LDKNetAddress_IPv4_get_addr(uint32_t ptr) {
3247         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3248         assert(obj->tag == LDKNetAddress_IPv4);
3249                         int8_tArray addr_arr = init_int8_tArray(4, __LINE__);
3250                         memcpy(addr_arr->elems, obj->i_pv4.addr.data, 4);
3251         return addr_arr;
3252 }
3253 int16_t __attribute__((export_name("TS_LDKNetAddress_IPv4_get_port"))) TS_LDKNetAddress_IPv4_get_port(uint32_t ptr) {
3254         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3255         assert(obj->tag == LDKNetAddress_IPv4);
3256                         int16_t port_conv = obj->i_pv4.port;
3257         return port_conv;
3258 }
3259 int8_tArray __attribute__((export_name("TS_LDKNetAddress_IPv6_get_addr"))) TS_LDKNetAddress_IPv6_get_addr(uint32_t ptr) {
3260         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3261         assert(obj->tag == LDKNetAddress_IPv6);
3262                         int8_tArray addr_arr = init_int8_tArray(16, __LINE__);
3263                         memcpy(addr_arr->elems, obj->i_pv6.addr.data, 16);
3264         return addr_arr;
3265 }
3266 int16_t __attribute__((export_name("TS_LDKNetAddress_IPv6_get_port"))) TS_LDKNetAddress_IPv6_get_port(uint32_t ptr) {
3267         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3268         assert(obj->tag == LDKNetAddress_IPv6);
3269                         int16_t port_conv = obj->i_pv6.port;
3270         return port_conv;
3271 }
3272 int8_tArray __attribute__((export_name("TS_LDKNetAddress_OnionV2_get_onion_v2"))) TS_LDKNetAddress_OnionV2_get_onion_v2(uint32_t ptr) {
3273         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3274         assert(obj->tag == LDKNetAddress_OnionV2);
3275                         int8_tArray onion_v2_arr = init_int8_tArray(12, __LINE__);
3276                         memcpy(onion_v2_arr->elems, obj->onion_v2.data, 12);
3277         return onion_v2_arr;
3278 }
3279 int8_tArray __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_ed25519_pubkey"))) TS_LDKNetAddress_OnionV3_get_ed25519_pubkey(uint32_t ptr) {
3280         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3281         assert(obj->tag == LDKNetAddress_OnionV3);
3282                         int8_tArray ed25519_pubkey_arr = init_int8_tArray(32, __LINE__);
3283                         memcpy(ed25519_pubkey_arr->elems, obj->onion_v3.ed25519_pubkey.data, 32);
3284         return ed25519_pubkey_arr;
3285 }
3286 int16_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_checksum"))) TS_LDKNetAddress_OnionV3_get_checksum(uint32_t ptr) {
3287         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3288         assert(obj->tag == LDKNetAddress_OnionV3);
3289                         int16_t checksum_conv = obj->onion_v3.checksum;
3290         return checksum_conv;
3291 }
3292 int8_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_version"))) TS_LDKNetAddress_OnionV3_get_version(uint32_t ptr) {
3293         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3294         assert(obj->tag == LDKNetAddress_OnionV3);
3295                         int8_t version_conv = obj->onion_v3.version;
3296         return version_conv;
3297 }
3298 int16_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_port"))) TS_LDKNetAddress_OnionV3_get_port(uint32_t ptr) {
3299         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3300         assert(obj->tag == LDKNetAddress_OnionV3);
3301                         int16_t port_conv = obj->onion_v3.port;
3302         return port_conv;
3303 }
3304 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
3305         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
3306         for (size_t i = 0; i < ret.datalen; i++) {
3307                 ret.data[i] = NetAddress_clone(&orig->data[i]);
3308         }
3309         return ret;
3310 }
3311 static inline struct LDKNodeAnnouncementInfo CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
3312 CHECK(owner->result_ok);
3313         return NodeAnnouncementInfo_clone(&*owner->contents.result);
3314 }
3315 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(uint32_t owner) {
3316         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
3317         LDKNodeAnnouncementInfo ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(owner_conv);
3318         uint32_t ret_ref = 0;
3319         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3320         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3321         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3322         ret_ref = (uintptr_t)ret_var.inner;
3323         if (ret_var.is_owned) {
3324                 ret_ref |= 1;
3325         }
3326         return ret_ref;
3327 }
3328
3329 static inline struct LDKDecodeError CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
3330 CHECK(!owner->result_ok);
3331         return DecodeError_clone(&*owner->contents.err);
3332 }
3333 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_err"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(uint32_t owner) {
3334         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
3335         LDKDecodeError ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(owner_conv);
3336         uint32_t ret_ref = 0;
3337         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3338         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3339         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3340         ret_ref = (uintptr_t)ret_var.inner;
3341         if (ret_var.is_owned) {
3342                 ret_ref |= 1;
3343         }
3344         return ret_ref;
3345 }
3346
3347 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
3348         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
3349         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
3350         return ret;
3351 }
3352 static inline struct LDKNodeInfo CResult_NodeInfoDecodeErrorZ_get_ok(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
3353 CHECK(owner->result_ok);
3354         return NodeInfo_clone(&*owner->contents.result);
3355 }
3356 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_get_ok"))) TS_CResult_NodeInfoDecodeErrorZ_get_ok(uint32_t owner) {
3357         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
3358         LDKNodeInfo ret_var = CResult_NodeInfoDecodeErrorZ_get_ok(owner_conv);
3359         uint32_t ret_ref = 0;
3360         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3361         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3362         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3363         ret_ref = (uintptr_t)ret_var.inner;
3364         if (ret_var.is_owned) {
3365                 ret_ref |= 1;
3366         }
3367         return ret_ref;
3368 }
3369
3370 static inline struct LDKDecodeError CResult_NodeInfoDecodeErrorZ_get_err(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
3371 CHECK(!owner->result_ok);
3372         return DecodeError_clone(&*owner->contents.err);
3373 }
3374 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_get_err"))) TS_CResult_NodeInfoDecodeErrorZ_get_err(uint32_t owner) {
3375         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
3376         LDKDecodeError ret_var = CResult_NodeInfoDecodeErrorZ_get_err(owner_conv);
3377         uint32_t ret_ref = 0;
3378         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3379         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3380         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3381         ret_ref = (uintptr_t)ret_var.inner;
3382         if (ret_var.is_owned) {
3383                 ret_ref |= 1;
3384         }
3385         return ret_ref;
3386 }
3387
3388 static inline struct LDKNetworkGraph *CResult_NetworkGraphDecodeErrorZ_get_ok(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
3389 CHECK(owner->result_ok);
3390         return &*owner->contents.result;
3391 }
3392 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_get_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_get_ok(uint32_t owner) {
3393         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
3394         LDKNetworkGraph ret_var = *CResult_NetworkGraphDecodeErrorZ_get_ok(owner_conv);
3395         uint32_t ret_ref = 0;
3396         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3397         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3398         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3399         ret_ref = (uintptr_t)ret_var.inner & ~1;
3400         return ret_ref;
3401 }
3402
3403 static inline struct LDKDecodeError CResult_NetworkGraphDecodeErrorZ_get_err(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
3404 CHECK(!owner->result_ok);
3405         return DecodeError_clone(&*owner->contents.err);
3406 }
3407 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_get_err"))) TS_CResult_NetworkGraphDecodeErrorZ_get_err(uint32_t owner) {
3408         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
3409         LDKDecodeError ret_var = CResult_NetworkGraphDecodeErrorZ_get_err(owner_conv);
3410         uint32_t ret_ref = 0;
3411         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3412         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3413         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3414         ret_ref = (uintptr_t)ret_var.inner;
3415         if (ret_var.is_owned) {
3416                 ret_ref |= 1;
3417         }
3418         return ret_ref;
3419 }
3420
3421 uint32_t __attribute__((export_name("TS_LDKCOption_CVec_NetAddressZZ_ty_from_ptr"))) TS_LDKCOption_CVec_NetAddressZZ_ty_from_ptr(uint32_t ptr) {
3422         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
3423         switch(obj->tag) {
3424                 case LDKCOption_CVec_NetAddressZZ_Some: return 0;
3425                 case LDKCOption_CVec_NetAddressZZ_None: return 1;
3426                 default: abort();
3427         }
3428 }
3429 uint32_tArray __attribute__((export_name("TS_LDKCOption_CVec_NetAddressZZ_Some_get_some"))) TS_LDKCOption_CVec_NetAddressZZ_Some_get_some(uint32_t ptr) {
3430         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
3431         assert(obj->tag == LDKCOption_CVec_NetAddressZZ_Some);
3432                         LDKCVec_NetAddressZ some_var = obj->some;
3433                         uint32_tArray some_arr = NULL;
3434                         some_arr = init_uint32_tArray(some_var.datalen, __LINE__);
3435                         uint32_t *some_arr_ptr = (uint32_t*)(((uint8_t*)some_arr) + 4);
3436                         for (size_t m = 0; m < some_var.datalen; m++) {
3437                                 uint32_t some_conv_12_ref = ((uintptr_t)&some_var.data[m]) | 1;
3438                                 some_arr_ptr[m] = some_conv_12_ref;
3439                         }
3440                         
3441         return some_arr;
3442 }
3443 static inline struct LDKDelayedPaymentOutputDescriptor CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3444 CHECK(owner->result_ok);
3445         return DelayedPaymentOutputDescriptor_clone(&*owner->contents.result);
3446 }
3447 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
3448         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3449         LDKDelayedPaymentOutputDescriptor ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
3450         uint32_t ret_ref = 0;
3451         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3452         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3453         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3454         ret_ref = (uintptr_t)ret_var.inner;
3455         if (ret_var.is_owned) {
3456                 ret_ref |= 1;
3457         }
3458         return ret_ref;
3459 }
3460
3461 static inline struct LDKDecodeError CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3462 CHECK(!owner->result_ok);
3463         return DecodeError_clone(&*owner->contents.err);
3464 }
3465 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
3466         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3467         LDKDecodeError ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
3468         uint32_t ret_ref = 0;
3469         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3470         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3471         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3472         ret_ref = (uintptr_t)ret_var.inner;
3473         if (ret_var.is_owned) {
3474                 ret_ref |= 1;
3475         }
3476         return ret_ref;
3477 }
3478
3479 static inline struct LDKStaticPaymentOutputDescriptor CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3480 CHECK(owner->result_ok);
3481         return StaticPaymentOutputDescriptor_clone(&*owner->contents.result);
3482 }
3483 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
3484         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3485         LDKStaticPaymentOutputDescriptor ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
3486         uint32_t ret_ref = 0;
3487         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3488         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3489         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3490         ret_ref = (uintptr_t)ret_var.inner;
3491         if (ret_var.is_owned) {
3492                 ret_ref |= 1;
3493         }
3494         return ret_ref;
3495 }
3496
3497 static inline struct LDKDecodeError CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3498 CHECK(!owner->result_ok);
3499         return DecodeError_clone(&*owner->contents.err);
3500 }
3501 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
3502         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
3503         LDKDecodeError ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
3504         uint32_t ret_ref = 0;
3505         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3506         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3507         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3508         ret_ref = (uintptr_t)ret_var.inner;
3509         if (ret_var.is_owned) {
3510                 ret_ref |= 1;
3511         }
3512         return ret_ref;
3513 }
3514
3515 static inline struct LDKSpendableOutputDescriptor CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3516 CHECK(owner->result_ok);
3517         return SpendableOutputDescriptor_clone(&*owner->contents.result);
3518 }
3519 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
3520         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
3521         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
3522         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
3523         uint32_t ret_ref = (uintptr_t)ret_copy;
3524         return ret_ref;
3525 }
3526
3527 static inline struct LDKDecodeError CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
3528 CHECK(!owner->result_ok);
3529         return DecodeError_clone(&*owner->contents.err);
3530 }
3531 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
3532         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
3533         LDKDecodeError ret_var = CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(owner_conv);
3534         uint32_t ret_ref = 0;
3535         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3536         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3537         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3538         ret_ref = (uintptr_t)ret_var.inner;
3539         if (ret_var.is_owned) {
3540                 ret_ref |= 1;
3541         }
3542         return ret_ref;
3543 }
3544
3545 static inline LDKCVec_PaymentPreimageZ CVec_PaymentPreimageZ_clone(const LDKCVec_PaymentPreimageZ *orig) {
3546         LDKCVec_PaymentPreimageZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_PaymentPreimageZ clone bytes"), .datalen = orig->datalen };
3547         for (size_t i = 0; i < ret.datalen; i++) {
3548                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
3549         }
3550         return ret;
3551 }
3552 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
3553         return owner->a;
3554 }
3555 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_get_a"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_a(uint32_t owner) {
3556         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
3557         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
3558         memcpy(ret_arr->elems, C2Tuple_SignatureCVec_SignatureZZ_get_a(owner_conv).compact_form, 64);
3559         return ret_arr;
3560 }
3561
3562 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
3563         return owner->b;
3564 }
3565 ptrArray  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_get_b"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_b(uint32_t owner) {
3566         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
3567         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(owner_conv);
3568         ptrArray ret_arr = NULL;
3569         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
3570         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
3571         for (size_t m = 0; m < ret_var.datalen; m++) {
3572                 int8_tArray ret_conv_12_arr = init_int8_tArray(64, __LINE__);
3573                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compact_form, 64);
3574                 ret_arr_ptr[m] = ret_conv_12_arr;
3575         }
3576         
3577         return ret_arr;
3578 }
3579
3580 static inline struct LDKC2Tuple_SignatureCVec_SignatureZZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
3581 CHECK(owner->result_ok);
3582         return C2Tuple_SignatureCVec_SignatureZZ_clone(&*owner->contents.result);
3583 }
3584 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(uint32_t owner) {
3585         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
3586         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
3587         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(owner_conv);
3588         return ((uint32_t)ret_conv);
3589 }
3590
3591 static inline void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
3592 CHECK(!owner->result_ok);
3593         return *owner->contents.err;
3594 }
3595 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(uint32_t owner) {
3596         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
3597         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(owner_conv);
3598 }
3599
3600 static inline struct LDKSignature CResult_SignatureNoneZ_get_ok(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
3601 CHECK(owner->result_ok);
3602         return *owner->contents.result;
3603 }
3604 int8_tArray  __attribute__((export_name("TS_CResult_SignatureNoneZ_get_ok"))) TS_CResult_SignatureNoneZ_get_ok(uint32_t owner) {
3605         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
3606         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
3607         memcpy(ret_arr->elems, CResult_SignatureNoneZ_get_ok(owner_conv).compact_form, 64);
3608         return ret_arr;
3609 }
3610
3611 static inline void CResult_SignatureNoneZ_get_err(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
3612 CHECK(!owner->result_ok);
3613         return *owner->contents.err;
3614 }
3615 void  __attribute__((export_name("TS_CResult_SignatureNoneZ_get_err"))) TS_CResult_SignatureNoneZ_get_err(uint32_t owner) {
3616         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
3617         CResult_SignatureNoneZ_get_err(owner_conv);
3618 }
3619
3620 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_a(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
3621         return owner->a;
3622 }
3623 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_get_a"))) TS_C2Tuple_SignatureSignatureZ_get_a(uint32_t owner) {
3624         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
3625         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
3626         memcpy(ret_arr->elems, C2Tuple_SignatureSignatureZ_get_a(owner_conv).compact_form, 64);
3627         return ret_arr;
3628 }
3629
3630 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_b(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
3631         return owner->b;
3632 }
3633 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_get_b"))) TS_C2Tuple_SignatureSignatureZ_get_b(uint32_t owner) {
3634         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
3635         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
3636         memcpy(ret_arr->elems, C2Tuple_SignatureSignatureZ_get_b(owner_conv).compact_form, 64);
3637         return ret_arr;
3638 }
3639
3640 static inline struct LDKC2Tuple_SignatureSignatureZ CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
3641 CHECK(owner->result_ok);
3642         return C2Tuple_SignatureSignatureZ_clone(&*owner->contents.result);
3643 }
3644 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(uint32_t owner) {
3645         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
3646         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
3647         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(owner_conv);
3648         return ((uint32_t)ret_conv);
3649 }
3650
3651 static inline void CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
3652 CHECK(!owner->result_ok);
3653         return *owner->contents.err;
3654 }
3655 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_err"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(uint32_t owner) {
3656         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
3657         CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(owner_conv);
3658 }
3659
3660 static inline struct LDKSecretKey CResult_SecretKeyNoneZ_get_ok(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
3661 CHECK(owner->result_ok);
3662         return *owner->contents.result;
3663 }
3664 int8_tArray  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_get_ok"))) TS_CResult_SecretKeyNoneZ_get_ok(uint32_t owner) {
3665         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
3666         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3667         memcpy(ret_arr->elems, CResult_SecretKeyNoneZ_get_ok(owner_conv).bytes, 32);
3668         return ret_arr;
3669 }
3670
3671 static inline void CResult_SecretKeyNoneZ_get_err(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
3672 CHECK(!owner->result_ok);
3673         return *owner->contents.err;
3674 }
3675 void  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_get_err"))) TS_CResult_SecretKeyNoneZ_get_err(uint32_t owner) {
3676         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
3677         CResult_SecretKeyNoneZ_get_err(owner_conv);
3678 }
3679
3680 typedef struct LDKBaseSign_JCalls {
3681         atomic_size_t refcnt;
3682         uint32_t instance_ptr;
3683 } LDKBaseSign_JCalls;
3684 static void LDKBaseSign_JCalls_free(void* this_arg) {
3685         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3686         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3687                 FREE(j_calls);
3688         }
3689 }
3690 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
3691         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3692         int64_t idx_conv = idx;
3693         int8_tArray ret = (int8_tArray)js_invoke_function_1(j_calls->instance_ptr, 2, (uint32_t)idx_conv);
3694         LDKPublicKey ret_ref;
3695         CHECK(ret->arr_len == 33);
3696         memcpy(ret_ref.compressed_form, ret->elems, 33); FREE(ret);
3697         return ret_ref;
3698 }
3699 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
3700         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3701         int64_t idx_conv = idx;
3702         int8_tArray ret = (int8_tArray)js_invoke_function_1(j_calls->instance_ptr, 3, (uint32_t)idx_conv);
3703         LDKThirtyTwoBytes ret_ref;
3704         CHECK(ret->arr_len == 32);
3705         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
3706         return ret_ref;
3707 }
3708 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx, LDKCVec_PaymentPreimageZ preimages) {
3709         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3710         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
3711         uint32_t holder_tx_ref = 0;
3712         holder_tx_var = HolderCommitmentTransaction_clone(&holder_tx_var);
3713         CHECK((((uintptr_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3714         CHECK((((uintptr_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3715         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
3716         holder_tx_ref = (uintptr_t)holder_tx_var.inner;
3717         if (holder_tx_var.is_owned) {
3718                 holder_tx_ref |= 1;
3719         }
3720         LDKCVec_PaymentPreimageZ preimages_var = preimages;
3721         ptrArray preimages_arr = NULL;
3722         preimages_arr = init_ptrArray(preimages_var.datalen, __LINE__);
3723         int8_tArray *preimages_arr_ptr = (int8_tArray*)(((uint8_t*)preimages_arr) + 4);
3724         for (size_t m = 0; m < preimages_var.datalen; m++) {
3725                 int8_tArray preimages_conv_12_arr = init_int8_tArray(32, __LINE__);
3726                 memcpy(preimages_conv_12_arr->elems, preimages_var.data[m].data, 32);
3727                 preimages_arr_ptr[m] = preimages_conv_12_arr;
3728         }
3729         
3730         FREE(preimages_var.data);
3731         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 4, (uint32_t)holder_tx_ref, (uint32_t)preimages_arr);
3732         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3733         CHECK_ACCESS(ret_ptr);
3734         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
3735         FREE((void*)ret);
3736         return ret_conv;
3737 }
3738 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
3739         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3740         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 5);
3741         LDKThirtyTwoBytes ret_ref;
3742         CHECK(ret->arr_len == 32);
3743         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
3744         return ret_ref;
3745 }
3746 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx, LDKCVec_PaymentPreimageZ preimages) {
3747         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3748         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
3749         uint32_t commitment_tx_ref = 0;
3750         commitment_tx_var = CommitmentTransaction_clone(&commitment_tx_var);
3751         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3752         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3753         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
3754         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
3755         if (commitment_tx_var.is_owned) {
3756                 commitment_tx_ref |= 1;
3757         }
3758         LDKCVec_PaymentPreimageZ preimages_var = preimages;
3759         ptrArray preimages_arr = NULL;
3760         preimages_arr = init_ptrArray(preimages_var.datalen, __LINE__);
3761         int8_tArray *preimages_arr_ptr = (int8_tArray*)(((uint8_t*)preimages_arr) + 4);
3762         for (size_t m = 0; m < preimages_var.datalen; m++) {
3763                 int8_tArray preimages_conv_12_arr = init_int8_tArray(32, __LINE__);
3764                 memcpy(preimages_conv_12_arr->elems, preimages_var.data[m].data, 32);
3765                 preimages_arr_ptr[m] = preimages_conv_12_arr;
3766         }
3767         
3768         FREE(preimages_var.data);
3769         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 6, (uint32_t)commitment_tx_ref, (uint32_t)preimages_arr);
3770         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3771         CHECK_ACCESS(ret_ptr);
3772         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
3773         FREE((void*)ret);
3774         return ret_conv;
3775 }
3776 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
3777         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3778         int64_t idx_conv = idx;
3779         int8_tArray secret_arr = init_int8_tArray(32, __LINE__);
3780         memcpy(secret_arr->elems, *secret, 32);
3781         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 7, (uint32_t)idx_conv, (uint32_t)secret_arr);
3782         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3783         CHECK_ACCESS(ret_ptr);
3784         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
3785         FREE((void*)ret);
3786         return ret_conv;
3787 }
3788 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
3789         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3790         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
3791         uint32_t commitment_tx_ref = 0;
3792         commitment_tx_var = HolderCommitmentTransaction_clone(&commitment_tx_var);
3793         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3794         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3795         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
3796         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
3797         if (commitment_tx_var.is_owned) {
3798                 commitment_tx_ref |= 1;
3799         }
3800         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 8, (uint32_t)commitment_tx_ref);
3801         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3802         CHECK_ACCESS(ret_ptr);
3803         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
3804         FREE((void*)ret);
3805         return ret_conv;
3806 }
3807 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]) {
3808         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3809         LDKTransaction justice_tx_var = justice_tx;
3810         int8_tArray justice_tx_arr = init_int8_tArray(justice_tx_var.datalen, __LINE__);
3811         memcpy(justice_tx_arr->elems, justice_tx_var.data, justice_tx_var.datalen);
3812         Transaction_free(justice_tx_var);
3813         uint32_t input_conv = input;
3814         int64_t amount_conv = amount;
3815         int8_tArray per_commitment_key_arr = init_int8_tArray(32, __LINE__);
3816         memcpy(per_commitment_key_arr->elems, *per_commitment_key, 32);
3817         uint32_t ret = js_invoke_function_4(j_calls->instance_ptr, 9, (uint32_t)justice_tx_arr, (uint32_t)input_conv, (uint32_t)amount_conv, (uint32_t)per_commitment_key_arr);
3818         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3819         CHECK_ACCESS(ret_ptr);
3820         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3821         FREE((void*)ret);
3822         return ret_conv;
3823 }
3824 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) {
3825         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3826         LDKTransaction justice_tx_var = justice_tx;
3827         int8_tArray justice_tx_arr = init_int8_tArray(justice_tx_var.datalen, __LINE__);
3828         memcpy(justice_tx_arr->elems, justice_tx_var.data, justice_tx_var.datalen);
3829         Transaction_free(justice_tx_var);
3830         uint32_t input_conv = input;
3831         int64_t amount_conv = amount;
3832         int8_tArray per_commitment_key_arr = init_int8_tArray(32, __LINE__);
3833         memcpy(per_commitment_key_arr->elems, *per_commitment_key, 32);
3834         LDKHTLCOutputInCommitment htlc_var = *htlc;
3835         uint32_t htlc_ref = 0;
3836         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
3837         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3838         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3839         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
3840         htlc_ref = (uintptr_t)htlc_var.inner;
3841         if (htlc_var.is_owned) {
3842                 htlc_ref |= 1;
3843         }
3844         uint32_t ret = js_invoke_function_5(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);
3845         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3846         CHECK_ACCESS(ret_ptr);
3847         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3848         FREE((void*)ret);
3849         return ret_conv;
3850 }
3851 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) {
3852         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3853         LDKTransaction htlc_tx_var = htlc_tx;
3854         int8_tArray htlc_tx_arr = init_int8_tArray(htlc_tx_var.datalen, __LINE__);
3855         memcpy(htlc_tx_arr->elems, htlc_tx_var.data, htlc_tx_var.datalen);
3856         Transaction_free(htlc_tx_var);
3857         uint32_t input_conv = input;
3858         int64_t amount_conv = amount;
3859         int8_tArray per_commitment_point_arr = init_int8_tArray(33, __LINE__);
3860         memcpy(per_commitment_point_arr->elems, per_commitment_point.compressed_form, 33);
3861         LDKHTLCOutputInCommitment htlc_var = *htlc;
3862         uint32_t htlc_ref = 0;
3863         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
3864         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3865         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3866         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
3867         htlc_ref = (uintptr_t)htlc_var.inner;
3868         if (htlc_var.is_owned) {
3869                 htlc_ref |= 1;
3870         }
3871         uint32_t ret = js_invoke_function_5(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);
3872         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3873         CHECK_ACCESS(ret_ptr);
3874         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3875         FREE((void*)ret);
3876         return ret_conv;
3877 }
3878 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
3879         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3880         LDKClosingTransaction closing_tx_var = *closing_tx;
3881         uint32_t closing_tx_ref = 0;
3882         closing_tx_var = ClosingTransaction_clone(&closing_tx_var);
3883         CHECK((((uintptr_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3884         CHECK((((uintptr_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3885         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
3886         closing_tx_ref = (uintptr_t)closing_tx_var.inner;
3887         if (closing_tx_var.is_owned) {
3888                 closing_tx_ref |= 1;
3889         }
3890         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 12, (uint32_t)closing_tx_ref);
3891         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3892         CHECK_ACCESS(ret_ptr);
3893         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3894         FREE((void*)ret);
3895         return ret_conv;
3896 }
3897 LDKCResult_C2Tuple_SignatureSignatureZNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
3898         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3899         LDKUnsignedChannelAnnouncement msg_var = *msg;
3900         uint32_t msg_ref = 0;
3901         msg_var = UnsignedChannelAnnouncement_clone(&msg_var);
3902         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3903         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3904         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3905         msg_ref = (uintptr_t)msg_var.inner;
3906         if (msg_var.is_owned) {
3907                 msg_ref |= 1;
3908         }
3909         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 13, (uint32_t)msg_ref);
3910         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3911         CHECK_ACCESS(ret_ptr);
3912         LDKCResult_C2Tuple_SignatureSignatureZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(ret_ptr);
3913         FREE((void*)ret);
3914         return ret_conv;
3915 }
3916 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
3917         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3918         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
3919         uint32_t channel_parameters_ref = 0;
3920         channel_parameters_var = ChannelTransactionParameters_clone(&channel_parameters_var);
3921         CHECK((((uintptr_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3922         CHECK((((uintptr_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3923         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
3924         channel_parameters_ref = (uintptr_t)channel_parameters_var.inner;
3925         if (channel_parameters_var.is_owned) {
3926                 channel_parameters_ref |= 1;
3927         }
3928         js_invoke_function_1(j_calls->instance_ptr, 14, (uint32_t)channel_parameters_ref);
3929 }
3930 static void LDKBaseSign_JCalls_cloned(LDKBaseSign* new_obj) {
3931         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) new_obj->this_arg;
3932         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3933 }
3934 static inline LDKBaseSign LDKBaseSign_init (JSValue o, uint32_t pubkeys) {
3935         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
3936         atomic_init(&calls->refcnt, 1);
3937         calls->instance_ptr = o;
3938
3939         LDKChannelPublicKeys pubkeys_conv;
3940         pubkeys_conv.inner = (void*)(pubkeys & (~1));
3941         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
3942         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
3943
3944         LDKBaseSign ret = {
3945                 .this_arg = (void*) calls,
3946                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
3947                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
3948                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
3949                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
3950                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
3951                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
3952                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
3953                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
3954                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
3955                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
3956                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
3957                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
3958                 .ready_channel = ready_channel_LDKBaseSign_jcall,
3959                 .free = LDKBaseSign_JCalls_free,
3960                 .pubkeys = pubkeys_conv,
3961                 .set_pubkeys = NULL,
3962         };
3963         return ret;
3964 }
3965 long  __attribute__((export_name("TS_LDKBaseSign_new"))) TS_LDKBaseSign_new(JSValue o, uint32_t pubkeys) {
3966         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
3967         *res_ptr = LDKBaseSign_init(o, pubkeys);
3968         return (long)res_ptr;
3969 }
3970 int8_tArray  __attribute__((export_name("TS_BaseSign_get_per_commitment_point"))) TS_BaseSign_get_per_commitment_point(uint32_t this_arg, int64_t idx) {
3971         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3972         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3973         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3974         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
3975         memcpy(ret_arr->elems, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form, 33);
3976         return ret_arr;
3977 }
3978
3979 int8_tArray  __attribute__((export_name("TS_BaseSign_release_commitment_secret"))) TS_BaseSign_release_commitment_secret(uint32_t this_arg, int64_t idx) {
3980         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3981         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3982         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3983         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3984         memcpy(ret_arr->elems, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data, 32);
3985         return ret_arr;
3986 }
3987
3988 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) {
3989         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3990         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3991         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3992         LDKHolderCommitmentTransaction holder_tx_conv;
3993         holder_tx_conv.inner = (void*)(holder_tx & (~1));
3994         holder_tx_conv.is_owned = false;
3995         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
3996         LDKCVec_PaymentPreimageZ preimages_constr;
3997         preimages_constr.datalen = preimages->arr_len;
3998         if (preimages_constr.datalen > 0)
3999                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
4000         else
4001                 preimages_constr.data = NULL;
4002         int8_tArray* preimages_vals = (void*) preimages->elems /* XXX preimages leaks */;
4003         for (size_t m = 0; m < preimages_constr.datalen; m++) {
4004                 int8_tArray preimages_conv_12 = preimages_vals[m];
4005                 LDKThirtyTwoBytes preimages_conv_12_ref;
4006                 CHECK(preimages_conv_12->arr_len == 32);
4007                 memcpy(preimages_conv_12_ref.data, preimages_conv_12->elems, 32); FREE(preimages_conv_12);
4008                 preimages_constr.data[m] = preimages_conv_12_ref;
4009         }
4010         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
4011         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv, preimages_constr);
4012         return (uint32_t)ret_conv;
4013 }
4014
4015 int8_tArray  __attribute__((export_name("TS_BaseSign_channel_keys_id"))) TS_BaseSign_channel_keys_id(uint32_t this_arg) {
4016         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4017         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4018         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4019         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4020         memcpy(ret_arr->elems, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data, 32);
4021         return ret_arr;
4022 }
4023
4024 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) {
4025         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4026         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4027         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4028         LDKCommitmentTransaction commitment_tx_conv;
4029         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
4030         commitment_tx_conv.is_owned = false;
4031         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
4032         LDKCVec_PaymentPreimageZ preimages_constr;
4033         preimages_constr.datalen = preimages->arr_len;
4034         if (preimages_constr.datalen > 0)
4035                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
4036         else
4037                 preimages_constr.data = NULL;
4038         int8_tArray* preimages_vals = (void*) preimages->elems /* XXX preimages leaks */;
4039         for (size_t m = 0; m < preimages_constr.datalen; m++) {
4040                 int8_tArray preimages_conv_12 = preimages_vals[m];
4041                 LDKThirtyTwoBytes preimages_conv_12_ref;
4042                 CHECK(preimages_conv_12->arr_len == 32);
4043                 memcpy(preimages_conv_12_ref.data, preimages_conv_12->elems, 32); FREE(preimages_conv_12);
4044                 preimages_constr.data[m] = preimages_conv_12_ref;
4045         }
4046         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
4047         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv, preimages_constr);
4048         return (uint32_t)ret_conv;
4049 }
4050
4051 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) {
4052         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4053         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4054         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4055         unsigned char secret_arr[32];
4056         CHECK(secret->arr_len == 32);
4057         memcpy(secret_arr, secret->elems, 32); FREE(secret);
4058         unsigned char (*secret_ref)[32] = &secret_arr;
4059         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
4060         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
4061         return (uint32_t)ret_conv;
4062 }
4063
4064 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) {
4065         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4066         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4067         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4068         LDKHolderCommitmentTransaction commitment_tx_conv;
4069         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
4070         commitment_tx_conv.is_owned = false;
4071         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
4072         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
4073         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
4074         return (uint32_t)ret_conv;
4075 }
4076
4077 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) {
4078         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4079         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4080         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4081         LDKTransaction justice_tx_ref;
4082         justice_tx_ref.datalen = justice_tx->arr_len;
4083         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
4084         memcpy(justice_tx_ref.data, justice_tx->elems, justice_tx_ref.datalen); FREE(justice_tx);
4085         justice_tx_ref.data_is_owned = true;
4086         unsigned char per_commitment_key_arr[32];
4087         CHECK(per_commitment_key->arr_len == 32);
4088         memcpy(per_commitment_key_arr, per_commitment_key->elems, 32); FREE(per_commitment_key);
4089         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
4090         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4091         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
4092         return (uint32_t)ret_conv;
4093 }
4094
4095 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) {
4096         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4097         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4098         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4099         LDKTransaction justice_tx_ref;
4100         justice_tx_ref.datalen = justice_tx->arr_len;
4101         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
4102         memcpy(justice_tx_ref.data, justice_tx->elems, justice_tx_ref.datalen); FREE(justice_tx);
4103         justice_tx_ref.data_is_owned = true;
4104         unsigned char per_commitment_key_arr[32];
4105         CHECK(per_commitment_key->arr_len == 32);
4106         memcpy(per_commitment_key_arr, per_commitment_key->elems, 32); FREE(per_commitment_key);
4107         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
4108         LDKHTLCOutputInCommitment htlc_conv;
4109         htlc_conv.inner = (void*)(htlc & (~1));
4110         htlc_conv.is_owned = false;
4111         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
4112         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4113         *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);
4114         return (uint32_t)ret_conv;
4115 }
4116
4117 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) {
4118         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4119         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4120         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4121         LDKTransaction htlc_tx_ref;
4122         htlc_tx_ref.datalen = htlc_tx->arr_len;
4123         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
4124         memcpy(htlc_tx_ref.data, htlc_tx->elems, htlc_tx_ref.datalen); FREE(htlc_tx);
4125         htlc_tx_ref.data_is_owned = true;
4126         LDKPublicKey per_commitment_point_ref;
4127         CHECK(per_commitment_point->arr_len == 33);
4128         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
4129         LDKHTLCOutputInCommitment htlc_conv;
4130         htlc_conv.inner = (void*)(htlc & (~1));
4131         htlc_conv.is_owned = false;
4132         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
4133         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4134         *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);
4135         return (uint32_t)ret_conv;
4136 }
4137
4138 uint32_t  __attribute__((export_name("TS_BaseSign_sign_closing_transaction"))) TS_BaseSign_sign_closing_transaction(uint32_t this_arg, uint32_t closing_tx) {
4139         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4140         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4141         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4142         LDKClosingTransaction closing_tx_conv;
4143         closing_tx_conv.inner = (void*)(closing_tx & (~1));
4144         closing_tx_conv.is_owned = false;
4145         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
4146         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4147         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
4148         return (uint32_t)ret_conv;
4149 }
4150
4151 uint32_t  __attribute__((export_name("TS_BaseSign_sign_channel_announcement"))) TS_BaseSign_sign_channel_announcement(uint32_t this_arg, uint32_t msg) {
4152         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4153         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4154         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4155         LDKUnsignedChannelAnnouncement msg_conv;
4156         msg_conv.inner = (void*)(msg & (~1));
4157         msg_conv.is_owned = false;
4158         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
4159         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
4160         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
4161         return (uint32_t)ret_conv;
4162 }
4163
4164 void  __attribute__((export_name("TS_BaseSign_ready_channel"))) TS_BaseSign_ready_channel(uint32_t this_arg, uint32_t channel_parameters) {
4165         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4166         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4167         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4168         LDKChannelTransactionParameters channel_parameters_conv;
4169         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
4170         channel_parameters_conv.is_owned = false;
4171         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
4172         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
4173 }
4174
4175 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
4176         if (this_arg->set_pubkeys != NULL)
4177                 this_arg->set_pubkeys(this_arg);
4178         return this_arg->pubkeys;
4179 }
4180 uint32_t  __attribute__((export_name("TS_BaseSign_get_pubkeys"))) TS_BaseSign_get_pubkeys(uint32_t this_arg) {
4181         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4182         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4183         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
4184         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
4185         uint32_t ret_ref = 0;
4186         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4187         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4188         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4189         ret_ref = (uintptr_t)ret_var.inner;
4190         if (ret_var.is_owned) {
4191                 ret_ref |= 1;
4192         }
4193         return ret_ref;
4194 }
4195
4196 typedef struct LDKSign_JCalls {
4197         atomic_size_t refcnt;
4198         uint32_t instance_ptr;
4199         LDKBaseSign_JCalls* BaseSign;
4200 } LDKSign_JCalls;
4201 static void LDKSign_JCalls_free(void* this_arg) {
4202         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
4203         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4204                 FREE(j_calls);
4205         }
4206 }
4207 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
4208         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
4209         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 15);
4210         LDKCVec_u8Z ret_ref;
4211         ret_ref.datalen = ret->arr_len;
4212         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
4213         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
4214         return ret_ref;
4215 }
4216 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
4217         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
4218         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4219         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
4220 }
4221 static inline LDKSign LDKSign_init (JSValue o, JSValue BaseSign, uint32_t pubkeys) {
4222         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
4223         atomic_init(&calls->refcnt, 1);
4224         calls->instance_ptr = o;
4225
4226         LDKChannelPublicKeys pubkeys_conv;
4227         pubkeys_conv.inner = (void*)(pubkeys & (~1));
4228         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
4229         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
4230
4231         LDKSign ret = {
4232                 .this_arg = (void*) calls,
4233                 .write = write_LDKSign_jcall,
4234                 .cloned = LDKSign_JCalls_cloned,
4235                 .free = LDKSign_JCalls_free,
4236                 .BaseSign = LDKBaseSign_init(BaseSign, pubkeys),
4237         };
4238         calls->BaseSign = ret.BaseSign.this_arg;
4239         return ret;
4240 }
4241 long  __attribute__((export_name("TS_LDKSign_new"))) TS_LDKSign_new(JSValue o, JSValue BaseSign, uint32_t pubkeys) {
4242         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
4243         *res_ptr = LDKSign_init(o, BaseSign, pubkeys);
4244         return (long)res_ptr;
4245 }
4246 int8_tArray  __attribute__((export_name("TS_Sign_write"))) TS_Sign_write(uint32_t this_arg) {
4247         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4248         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4249         LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
4250         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
4251         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
4252         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
4253         CVec_u8Z_free(ret_var);
4254         return ret_arr;
4255 }
4256
4257 static inline struct LDKSign CResult_SignDecodeErrorZ_get_ok(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
4258 CHECK(owner->result_ok);
4259         return Sign_clone(&*owner->contents.result);
4260 }
4261 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_get_ok"))) TS_CResult_SignDecodeErrorZ_get_ok(uint32_t owner) {
4262         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
4263         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
4264         *ret_ret = CResult_SignDecodeErrorZ_get_ok(owner_conv);
4265         return (uint32_t)ret_ret;
4266 }
4267
4268 static inline struct LDKDecodeError CResult_SignDecodeErrorZ_get_err(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
4269 CHECK(!owner->result_ok);
4270         return DecodeError_clone(&*owner->contents.err);
4271 }
4272 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_get_err"))) TS_CResult_SignDecodeErrorZ_get_err(uint32_t owner) {
4273         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
4274         LDKDecodeError ret_var = CResult_SignDecodeErrorZ_get_err(owner_conv);
4275         uint32_t ret_ref = 0;
4276         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4277         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4278         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4279         ret_ref = (uintptr_t)ret_var.inner;
4280         if (ret_var.is_owned) {
4281                 ret_ref |= 1;
4282         }
4283         return ret_ref;
4284 }
4285
4286 static inline struct LDKRecoverableSignature CResult_RecoverableSignatureNoneZ_get_ok(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
4287 CHECK(owner->result_ok);
4288         return *owner->contents.result;
4289 }
4290 int8_tArray  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_get_ok"))) TS_CResult_RecoverableSignatureNoneZ_get_ok(uint32_t owner) {
4291         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
4292         int8_tArray ret_arr = init_int8_tArray(68, __LINE__);
4293         memcpy(ret_arr->elems, CResult_RecoverableSignatureNoneZ_get_ok(owner_conv).serialized_form, 68);
4294         return ret_arr;
4295 }
4296
4297 static inline void CResult_RecoverableSignatureNoneZ_get_err(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
4298 CHECK(!owner->result_ok);
4299         return *owner->contents.err;
4300 }
4301 void  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_get_err"))) TS_CResult_RecoverableSignatureNoneZ_get_err(uint32_t owner) {
4302         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
4303         CResult_RecoverableSignatureNoneZ_get_err(owner_conv);
4304 }
4305
4306 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
4307         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
4308         for (size_t i = 0; i < ret.datalen; i++) {
4309                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
4310         }
4311         return ret;
4312 }
4313 static inline struct LDKCVec_CVec_u8ZZ CResult_CVec_CVec_u8ZZNoneZ_get_ok(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
4314 CHECK(owner->result_ok);
4315         return CVec_CVec_u8ZZ_clone(&*owner->contents.result);
4316 }
4317 ptrArray  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_get_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_get_ok(uint32_t owner) {
4318         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
4319         LDKCVec_CVec_u8ZZ ret_var = CResult_CVec_CVec_u8ZZNoneZ_get_ok(owner_conv);
4320         ptrArray ret_arr = NULL;
4321         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
4322         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
4323         for (size_t m = 0; m < ret_var.datalen; m++) {
4324                 LDKCVec_u8Z ret_conv_12_var = ret_var.data[m];
4325                 int8_tArray ret_conv_12_arr = init_int8_tArray(ret_conv_12_var.datalen, __LINE__);
4326                 memcpy(ret_conv_12_arr->elems, ret_conv_12_var.data, ret_conv_12_var.datalen);
4327                 CVec_u8Z_free(ret_conv_12_var);
4328                 ret_arr_ptr[m] = ret_conv_12_arr;
4329         }
4330         
4331         FREE(ret_var.data);
4332         return ret_arr;
4333 }
4334
4335 static inline void CResult_CVec_CVec_u8ZZNoneZ_get_err(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
4336 CHECK(!owner->result_ok);
4337         return *owner->contents.err;
4338 }
4339 void  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_get_err"))) TS_CResult_CVec_CVec_u8ZZNoneZ_get_err(uint32_t owner) {
4340         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
4341         CResult_CVec_CVec_u8ZZNoneZ_get_err(owner_conv);
4342 }
4343
4344 static inline struct LDKInMemorySigner CResult_InMemorySignerDecodeErrorZ_get_ok(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
4345 CHECK(owner->result_ok);
4346         return InMemorySigner_clone(&*owner->contents.result);
4347 }
4348 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_get_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_get_ok(uint32_t owner) {
4349         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
4350         LDKInMemorySigner ret_var = CResult_InMemorySignerDecodeErrorZ_get_ok(owner_conv);
4351         uint32_t ret_ref = 0;
4352         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4353         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4354         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4355         ret_ref = (uintptr_t)ret_var.inner;
4356         if (ret_var.is_owned) {
4357                 ret_ref |= 1;
4358         }
4359         return ret_ref;
4360 }
4361
4362 static inline struct LDKDecodeError CResult_InMemorySignerDecodeErrorZ_get_err(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
4363 CHECK(!owner->result_ok);
4364         return DecodeError_clone(&*owner->contents.err);
4365 }
4366 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_get_err"))) TS_CResult_InMemorySignerDecodeErrorZ_get_err(uint32_t owner) {
4367         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
4368         LDKDecodeError ret_var = CResult_InMemorySignerDecodeErrorZ_get_err(owner_conv);
4369         uint32_t ret_ref = 0;
4370         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4371         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4372         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4373         ret_ref = (uintptr_t)ret_var.inner;
4374         if (ret_var.is_owned) {
4375                 ret_ref |= 1;
4376         }
4377         return ret_ref;
4378 }
4379
4380 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
4381         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
4382         for (size_t i = 0; i < ret.datalen; i++) {
4383                 ret.data[i] = TxOut_clone(&orig->data[i]);
4384         }
4385         return ret;
4386 }
4387 static inline struct LDKTransaction CResult_TransactionNoneZ_get_ok(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
4388 CHECK(owner->result_ok);
4389         return *owner->contents.result;
4390 }
4391 int8_tArray  __attribute__((export_name("TS_CResult_TransactionNoneZ_get_ok"))) TS_CResult_TransactionNoneZ_get_ok(uint32_t owner) {
4392         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
4393         LDKTransaction ret_var = CResult_TransactionNoneZ_get_ok(owner_conv);
4394         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
4395         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
4396         return ret_arr;
4397 }
4398
4399 static inline void CResult_TransactionNoneZ_get_err(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
4400 CHECK(!owner->result_ok);
4401         return *owner->contents.err;
4402 }
4403 void  __attribute__((export_name("TS_CResult_TransactionNoneZ_get_err"))) TS_CResult_TransactionNoneZ_get_err(uint32_t owner) {
4404         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
4405         CResult_TransactionNoneZ_get_err(owner_conv);
4406 }
4407
4408 uint32_t __attribute__((export_name("TS_LDKCOption_u16Z_ty_from_ptr"))) TS_LDKCOption_u16Z_ty_from_ptr(uint32_t ptr) {
4409         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
4410         switch(obj->tag) {
4411                 case LDKCOption_u16Z_Some: return 0;
4412                 case LDKCOption_u16Z_None: return 1;
4413                 default: abort();
4414         }
4415 }
4416 int16_t __attribute__((export_name("TS_LDKCOption_u16Z_Some_get_some"))) TS_LDKCOption_u16Z_Some_get_some(uint32_t ptr) {
4417         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
4418         assert(obj->tag == LDKCOption_u16Z_Some);
4419                         int16_t some_conv = obj->some;
4420         return some_conv;
4421 }
4422 uint32_t __attribute__((export_name("TS_LDKAPIError_ty_from_ptr"))) TS_LDKAPIError_ty_from_ptr(uint32_t ptr) {
4423         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4424         switch(obj->tag) {
4425                 case LDKAPIError_APIMisuseError: return 0;
4426                 case LDKAPIError_FeeRateTooHigh: return 1;
4427                 case LDKAPIError_RouteError: return 2;
4428                 case LDKAPIError_ChannelUnavailable: return 3;
4429                 case LDKAPIError_MonitorUpdateFailed: return 4;
4430                 case LDKAPIError_IncompatibleShutdownScript: return 5;
4431                 default: abort();
4432         }
4433 }
4434 jstring __attribute__((export_name("TS_LDKAPIError_APIMisuseError_get_err"))) TS_LDKAPIError_APIMisuseError_get_err(uint32_t ptr) {
4435         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4436         assert(obj->tag == LDKAPIError_APIMisuseError);
4437                         LDKStr err_str = obj->api_misuse_error.err;
4438                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
4439         return err_conv;
4440 }
4441 jstring __attribute__((export_name("TS_LDKAPIError_FeeRateTooHigh_get_err"))) TS_LDKAPIError_FeeRateTooHigh_get_err(uint32_t ptr) {
4442         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4443         assert(obj->tag == LDKAPIError_FeeRateTooHigh);
4444                         LDKStr err_str = obj->fee_rate_too_high.err;
4445                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
4446         return err_conv;
4447 }
4448 int32_t __attribute__((export_name("TS_LDKAPIError_FeeRateTooHigh_get_feerate"))) TS_LDKAPIError_FeeRateTooHigh_get_feerate(uint32_t ptr) {
4449         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4450         assert(obj->tag == LDKAPIError_FeeRateTooHigh);
4451                         int32_t feerate_conv = obj->fee_rate_too_high.feerate;
4452         return feerate_conv;
4453 }
4454 jstring __attribute__((export_name("TS_LDKAPIError_RouteError_get_err"))) TS_LDKAPIError_RouteError_get_err(uint32_t ptr) {
4455         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4456         assert(obj->tag == LDKAPIError_RouteError);
4457                         LDKStr err_str = obj->route_error.err;
4458                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
4459         return err_conv;
4460 }
4461 jstring __attribute__((export_name("TS_LDKAPIError_ChannelUnavailable_get_err"))) TS_LDKAPIError_ChannelUnavailable_get_err(uint32_t ptr) {
4462         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4463         assert(obj->tag == LDKAPIError_ChannelUnavailable);
4464                         LDKStr err_str = obj->channel_unavailable.err;
4465                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
4466         return err_conv;
4467 }
4468 uint32_t __attribute__((export_name("TS_LDKAPIError_IncompatibleShutdownScript_get_script"))) TS_LDKAPIError_IncompatibleShutdownScript_get_script(uint32_t ptr) {
4469         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
4470         assert(obj->tag == LDKAPIError_IncompatibleShutdownScript);
4471                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
4472                         uint32_t script_ref = 0;
4473                         CHECK((((uintptr_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4474                         CHECK((((uintptr_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4475                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
4476                         script_ref = (uintptr_t)script_var.inner & ~1;
4477         return script_ref;
4478 }
4479 static inline void CResult_NoneAPIErrorZ_get_ok(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
4480 CHECK(owner->result_ok);
4481         return *owner->contents.result;
4482 }
4483 void  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_get_ok"))) TS_CResult_NoneAPIErrorZ_get_ok(uint32_t owner) {
4484         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
4485         CResult_NoneAPIErrorZ_get_ok(owner_conv);
4486 }
4487
4488 static inline struct LDKAPIError CResult_NoneAPIErrorZ_get_err(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
4489 CHECK(!owner->result_ok);
4490         return APIError_clone(&*owner->contents.err);
4491 }
4492 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_get_err"))) TS_CResult_NoneAPIErrorZ_get_err(uint32_t owner) {
4493         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
4494         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4495         *ret_copy = CResult_NoneAPIErrorZ_get_err(owner_conv);
4496         uint32_t ret_ref = (uintptr_t)ret_copy;
4497         return ret_ref;
4498 }
4499
4500 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
4501         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
4502         for (size_t i = 0; i < ret.datalen; i++) {
4503                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
4504         }
4505         return ret;
4506 }
4507 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
4508         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
4509         for (size_t i = 0; i < ret.datalen; i++) {
4510                 ret.data[i] = APIError_clone(&orig->data[i]);
4511         }
4512         return ret;
4513 }
4514 static inline struct LDKThirtyTwoBytes CResult__u832APIErrorZ_get_ok(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
4515 CHECK(owner->result_ok);
4516         return ThirtyTwoBytes_clone(&*owner->contents.result);
4517 }
4518 int8_tArray  __attribute__((export_name("TS_CResult__u832APIErrorZ_get_ok"))) TS_CResult__u832APIErrorZ_get_ok(uint32_t owner) {
4519         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
4520         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4521         memcpy(ret_arr->elems, CResult__u832APIErrorZ_get_ok(owner_conv).data, 32);
4522         return ret_arr;
4523 }
4524
4525 static inline struct LDKAPIError CResult__u832APIErrorZ_get_err(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
4526 CHECK(!owner->result_ok);
4527         return APIError_clone(&*owner->contents.err);
4528 }
4529 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_get_err"))) TS_CResult__u832APIErrorZ_get_err(uint32_t owner) {
4530         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
4531         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4532         *ret_copy = CResult__u832APIErrorZ_get_err(owner_conv);
4533         uint32_t ret_ref = (uintptr_t)ret_copy;
4534         return ret_ref;
4535 }
4536
4537 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_ty_from_ptr"))) TS_LDKPaymentSendFailure_ty_from_ptr(uint32_t ptr) {
4538         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4539         switch(obj->tag) {
4540                 case LDKPaymentSendFailure_ParameterError: return 0;
4541                 case LDKPaymentSendFailure_PathParameterError: return 1;
4542                 case LDKPaymentSendFailure_AllFailedRetrySafe: return 2;
4543                 case LDKPaymentSendFailure_PartialFailure: return 3;
4544                 default: abort();
4545         }
4546 }
4547 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_ParameterError_get_parameter_error"))) TS_LDKPaymentSendFailure_ParameterError_get_parameter_error(uint32_t ptr) {
4548         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4549         assert(obj->tag == LDKPaymentSendFailure_ParameterError);
4550                         uint32_t parameter_error_ref = ((uintptr_t)&obj->parameter_error) | 1;
4551         return parameter_error_ref;
4552 }
4553 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PathParameterError_get_path_parameter_error"))) TS_LDKPaymentSendFailure_PathParameterError_get_path_parameter_error(uint32_t ptr) {
4554         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4555         assert(obj->tag == LDKPaymentSendFailure_PathParameterError);
4556                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
4557                         uint32_tArray path_parameter_error_arr = NULL;
4558                         path_parameter_error_arr = init_uint32_tArray(path_parameter_error_var.datalen, __LINE__);
4559                         uint32_t *path_parameter_error_arr_ptr = (uint32_t*)(((uint8_t*)path_parameter_error_arr) + 4);
4560                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
4561                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
4562                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
4563                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
4564                                 path_parameter_error_arr_ptr[w] = (uint32_t)path_parameter_error_conv_22_conv;
4565                         }
4566                         
4567         return path_parameter_error_arr;
4568 }
4569 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_AllFailedRetrySafe_get_all_failed_retry_safe"))) TS_LDKPaymentSendFailure_AllFailedRetrySafe_get_all_failed_retry_safe(uint32_t ptr) {
4570         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4571         assert(obj->tag == LDKPaymentSendFailure_AllFailedRetrySafe);
4572                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
4573                         uint32_tArray all_failed_retry_safe_arr = NULL;
4574                         all_failed_retry_safe_arr = init_uint32_tArray(all_failed_retry_safe_var.datalen, __LINE__);
4575                         uint32_t *all_failed_retry_safe_arr_ptr = (uint32_t*)(((uint8_t*)all_failed_retry_safe_arr) + 4);
4576                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
4577                                 uint32_t all_failed_retry_safe_conv_10_ref = ((uintptr_t)&all_failed_retry_safe_var.data[k]) | 1;
4578                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
4579                         }
4580                         
4581         return all_failed_retry_safe_arr;
4582 }
4583 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_results"))) TS_LDKPaymentSendFailure_PartialFailure_get_results(uint32_t ptr) {
4584         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4585         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
4586                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
4587                         uint32_tArray results_arr = NULL;
4588                         results_arr = init_uint32_tArray(results_var.datalen, __LINE__);
4589                         uint32_t *results_arr_ptr = (uint32_t*)(((uint8_t*)results_arr) + 4);
4590                         for (size_t w = 0; w < results_var.datalen; w++) {
4591                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
4592                                 *results_conv_22_conv = results_var.data[w];
4593                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
4594                                 results_arr_ptr[w] = (uint32_t)results_conv_22_conv;
4595                         }
4596                         
4597         return results_arr;
4598 }
4599 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_failed_paths_retry"))) TS_LDKPaymentSendFailure_PartialFailure_get_failed_paths_retry(uint32_t ptr) {
4600         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4601         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
4602                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
4603                         uint32_t failed_paths_retry_ref = 0;
4604                         if ((uintptr_t)failed_paths_retry_var.inner > 4096) {
4605                                 CHECK((((uintptr_t)failed_paths_retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4606                                 CHECK((((uintptr_t)&failed_paths_retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4607                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
4608                                 failed_paths_retry_ref = (uintptr_t)failed_paths_retry_var.inner & ~1;
4609                         }
4610         return failed_paths_retry_ref;
4611 }
4612 int8_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_payment_id"))) TS_LDKPaymentSendFailure_PartialFailure_get_payment_id(uint32_t ptr) {
4613         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
4614         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
4615                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
4616                         memcpy(payment_id_arr->elems, obj->partial_failure.payment_id.data, 32);
4617         return payment_id_arr;
4618 }
4619 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentSendFailureZ_get_ok(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
4620 CHECK(owner->result_ok);
4621         return ThirtyTwoBytes_clone(&*owner->contents.result);
4622 }
4623 int8_tArray  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_get_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_get_ok(uint32_t owner) {
4624         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
4625         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4626         memcpy(ret_arr->elems, CResult_PaymentIdPaymentSendFailureZ_get_ok(owner_conv).data, 32);
4627         return ret_arr;
4628 }
4629
4630 static inline struct LDKPaymentSendFailure CResult_PaymentIdPaymentSendFailureZ_get_err(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
4631 CHECK(!owner->result_ok);
4632         return PaymentSendFailure_clone(&*owner->contents.err);
4633 }
4634 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_get_err"))) TS_CResult_PaymentIdPaymentSendFailureZ_get_err(uint32_t owner) {
4635         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
4636         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
4637         *ret_copy = CResult_PaymentIdPaymentSendFailureZ_get_err(owner_conv);
4638         uint32_t ret_ref = (uintptr_t)ret_copy;
4639         return ret_ref;
4640 }
4641
4642 static inline void CResult_NonePaymentSendFailureZ_get_ok(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
4643 CHECK(owner->result_ok);
4644         return *owner->contents.result;
4645 }
4646 void  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_get_ok"))) TS_CResult_NonePaymentSendFailureZ_get_ok(uint32_t owner) {
4647         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
4648         CResult_NonePaymentSendFailureZ_get_ok(owner_conv);
4649 }
4650
4651 static inline struct LDKPaymentSendFailure CResult_NonePaymentSendFailureZ_get_err(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
4652 CHECK(!owner->result_ok);
4653         return PaymentSendFailure_clone(&*owner->contents.err);
4654 }
4655 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_get_err"))) TS_CResult_NonePaymentSendFailureZ_get_err(uint32_t owner) {
4656         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
4657         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
4658         *ret_copy = CResult_NonePaymentSendFailureZ_get_err(owner_conv);
4659         uint32_t ret_ref = (uintptr_t)ret_copy;
4660         return ret_ref;
4661 }
4662
4663 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
4664         return ThirtyTwoBytes_clone(&owner->a);
4665 }
4666 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_get_a"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_a(uint32_t owner) {
4667         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
4668         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4669         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentIdZ_get_a(owner_conv).data, 32);
4670         return ret_arr;
4671 }
4672
4673 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
4674         return ThirtyTwoBytes_clone(&owner->b);
4675 }
4676 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_get_b"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_b(uint32_t owner) {
4677         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
4678         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4679         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentIdZ_get_b(owner_conv).data, 32);
4680         return ret_arr;
4681 }
4682
4683 static inline struct LDKC2Tuple_PaymentHashPaymentIdZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
4684 CHECK(owner->result_ok);
4685         return C2Tuple_PaymentHashPaymentIdZ_clone(&*owner->contents.result);
4686 }
4687 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(uint32_t owner) {
4688         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
4689         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
4690         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(owner_conv);
4691         return ((uint32_t)ret_conv);
4692 }
4693
4694 static inline struct LDKPaymentSendFailure CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
4695 CHECK(!owner->result_ok);
4696         return PaymentSendFailure_clone(&*owner->contents.err);
4697 }
4698 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(uint32_t owner) {
4699         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
4700         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
4701         *ret_copy = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(owner_conv);
4702         uint32_t ret_ref = (uintptr_t)ret_copy;
4703         return ret_ref;
4704 }
4705
4706 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
4707         return ThirtyTwoBytes_clone(&owner->a);
4708 }
4709 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_get_a"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_a(uint32_t owner) {
4710         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
4711         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4712         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentSecretZ_get_a(owner_conv).data, 32);
4713         return ret_arr;
4714 }
4715
4716 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
4717         return ThirtyTwoBytes_clone(&owner->b);
4718 }
4719 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_get_b"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_b(uint32_t owner) {
4720         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
4721         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4722         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentSecretZ_get_b(owner_conv).data, 32);
4723         return ret_arr;
4724 }
4725
4726 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
4727 CHECK(owner->result_ok);
4728         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
4729 }
4730 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(uint32_t owner) {
4731         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
4732         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
4733         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(owner_conv);
4734         return ((uint32_t)ret_conv);
4735 }
4736
4737 static inline void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
4738 CHECK(!owner->result_ok);
4739         return *owner->contents.err;
4740 }
4741 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(uint32_t owner) {
4742         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
4743         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(owner_conv);
4744 }
4745
4746 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
4747 CHECK(owner->result_ok);
4748         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
4749 }
4750 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(uint32_t owner) {
4751         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
4752         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
4753         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(owner_conv);
4754         return ((uint32_t)ret_conv);
4755 }
4756
4757 static inline struct LDKAPIError CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
4758 CHECK(!owner->result_ok);
4759         return APIError_clone(&*owner->contents.err);
4760 }
4761 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(uint32_t owner) {
4762         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
4763         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4764         *ret_copy = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(owner_conv);
4765         uint32_t ret_ref = (uintptr_t)ret_copy;
4766         return ret_ref;
4767 }
4768
4769 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretNoneZ_get_ok(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
4770 CHECK(owner->result_ok);
4771         return ThirtyTwoBytes_clone(&*owner->contents.result);
4772 }
4773 int8_tArray  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_get_ok"))) TS_CResult_PaymentSecretNoneZ_get_ok(uint32_t owner) {
4774         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
4775         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4776         memcpy(ret_arr->elems, CResult_PaymentSecretNoneZ_get_ok(owner_conv).data, 32);
4777         return ret_arr;
4778 }
4779
4780 static inline void CResult_PaymentSecretNoneZ_get_err(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
4781 CHECK(!owner->result_ok);
4782         return *owner->contents.err;
4783 }
4784 void  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_get_err"))) TS_CResult_PaymentSecretNoneZ_get_err(uint32_t owner) {
4785         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
4786         CResult_PaymentSecretNoneZ_get_err(owner_conv);
4787 }
4788
4789 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretAPIErrorZ_get_ok(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
4790 CHECK(owner->result_ok);
4791         return ThirtyTwoBytes_clone(&*owner->contents.result);
4792 }
4793 int8_tArray  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_get_ok"))) TS_CResult_PaymentSecretAPIErrorZ_get_ok(uint32_t owner) {
4794         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
4795         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4796         memcpy(ret_arr->elems, CResult_PaymentSecretAPIErrorZ_get_ok(owner_conv).data, 32);
4797         return ret_arr;
4798 }
4799
4800 static inline struct LDKAPIError CResult_PaymentSecretAPIErrorZ_get_err(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
4801 CHECK(!owner->result_ok);
4802         return APIError_clone(&*owner->contents.err);
4803 }
4804 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_get_err"))) TS_CResult_PaymentSecretAPIErrorZ_get_err(uint32_t owner) {
4805         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
4806         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4807         *ret_copy = CResult_PaymentSecretAPIErrorZ_get_err(owner_conv);
4808         uint32_t ret_ref = (uintptr_t)ret_copy;
4809         return ret_ref;
4810 }
4811
4812 static inline struct LDKThirtyTwoBytes CResult_PaymentPreimageAPIErrorZ_get_ok(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
4813 CHECK(owner->result_ok);
4814         return ThirtyTwoBytes_clone(&*owner->contents.result);
4815 }
4816 int8_tArray  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_get_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_get_ok(uint32_t owner) {
4817         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
4818         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4819         memcpy(ret_arr->elems, CResult_PaymentPreimageAPIErrorZ_get_ok(owner_conv).data, 32);
4820         return ret_arr;
4821 }
4822
4823 static inline struct LDKAPIError CResult_PaymentPreimageAPIErrorZ_get_err(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
4824 CHECK(!owner->result_ok);
4825         return APIError_clone(&*owner->contents.err);
4826 }
4827 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_get_err"))) TS_CResult_PaymentPreimageAPIErrorZ_get_err(uint32_t owner) {
4828         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
4829         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4830         *ret_copy = CResult_PaymentPreimageAPIErrorZ_get_err(owner_conv);
4831         uint32_t ret_ref = (uintptr_t)ret_copy;
4832         return ret_ref;
4833 }
4834
4835 static inline struct LDKCounterpartyForwardingInfo CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
4836 CHECK(owner->result_ok);
4837         return CounterpartyForwardingInfo_clone(&*owner->contents.result);
4838 }
4839 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(uint32_t owner) {
4840         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
4841         LDKCounterpartyForwardingInfo ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(owner_conv);
4842         uint32_t ret_ref = 0;
4843         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4844         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4845         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4846         ret_ref = (uintptr_t)ret_var.inner;
4847         if (ret_var.is_owned) {
4848                 ret_ref |= 1;
4849         }
4850         return ret_ref;
4851 }
4852
4853 static inline struct LDKDecodeError CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
4854 CHECK(!owner->result_ok);
4855         return DecodeError_clone(&*owner->contents.err);
4856 }
4857 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(uint32_t owner) {
4858         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
4859         LDKDecodeError ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(owner_conv);
4860         uint32_t ret_ref = 0;
4861         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4862         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4863         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4864         ret_ref = (uintptr_t)ret_var.inner;
4865         if (ret_var.is_owned) {
4866                 ret_ref |= 1;
4867         }
4868         return ret_ref;
4869 }
4870
4871 static inline struct LDKChannelCounterparty CResult_ChannelCounterpartyDecodeErrorZ_get_ok(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
4872 CHECK(owner->result_ok);
4873         return ChannelCounterparty_clone(&*owner->contents.result);
4874 }
4875 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_get_ok"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_get_ok(uint32_t owner) {
4876         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
4877         LDKChannelCounterparty ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_ok(owner_conv);
4878         uint32_t ret_ref = 0;
4879         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4880         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4881         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4882         ret_ref = (uintptr_t)ret_var.inner;
4883         if (ret_var.is_owned) {
4884                 ret_ref |= 1;
4885         }
4886         return ret_ref;
4887 }
4888
4889 static inline struct LDKDecodeError CResult_ChannelCounterpartyDecodeErrorZ_get_err(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
4890 CHECK(!owner->result_ok);
4891         return DecodeError_clone(&*owner->contents.err);
4892 }
4893 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_get_err"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_get_err(uint32_t owner) {
4894         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
4895         LDKDecodeError ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_err(owner_conv);
4896         uint32_t ret_ref = 0;
4897         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4898         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4899         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4900         ret_ref = (uintptr_t)ret_var.inner;
4901         if (ret_var.is_owned) {
4902                 ret_ref |= 1;
4903         }
4904         return ret_ref;
4905 }
4906
4907 static inline struct LDKChannelDetails CResult_ChannelDetailsDecodeErrorZ_get_ok(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
4908 CHECK(owner->result_ok);
4909         return ChannelDetails_clone(&*owner->contents.result);
4910 }
4911 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_get_ok"))) TS_CResult_ChannelDetailsDecodeErrorZ_get_ok(uint32_t owner) {
4912         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
4913         LDKChannelDetails ret_var = CResult_ChannelDetailsDecodeErrorZ_get_ok(owner_conv);
4914         uint32_t ret_ref = 0;
4915         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4916         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4917         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4918         ret_ref = (uintptr_t)ret_var.inner;
4919         if (ret_var.is_owned) {
4920                 ret_ref |= 1;
4921         }
4922         return ret_ref;
4923 }
4924
4925 static inline struct LDKDecodeError CResult_ChannelDetailsDecodeErrorZ_get_err(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
4926 CHECK(!owner->result_ok);
4927         return DecodeError_clone(&*owner->contents.err);
4928 }
4929 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_get_err"))) TS_CResult_ChannelDetailsDecodeErrorZ_get_err(uint32_t owner) {
4930         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
4931         LDKDecodeError ret_var = CResult_ChannelDetailsDecodeErrorZ_get_err(owner_conv);
4932         uint32_t ret_ref = 0;
4933         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4934         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4935         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4936         ret_ref = (uintptr_t)ret_var.inner;
4937         if (ret_var.is_owned) {
4938                 ret_ref |= 1;
4939         }
4940         return ret_ref;
4941 }
4942
4943 static inline struct LDKPhantomRouteHints CResult_PhantomRouteHintsDecodeErrorZ_get_ok(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
4944 CHECK(owner->result_ok);
4945         return PhantomRouteHints_clone(&*owner->contents.result);
4946 }
4947 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_get_ok"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_get_ok(uint32_t owner) {
4948         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
4949         LDKPhantomRouteHints ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_ok(owner_conv);
4950         uint32_t ret_ref = 0;
4951         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4952         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4953         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4954         ret_ref = (uintptr_t)ret_var.inner;
4955         if (ret_var.is_owned) {
4956                 ret_ref |= 1;
4957         }
4958         return ret_ref;
4959 }
4960
4961 static inline struct LDKDecodeError CResult_PhantomRouteHintsDecodeErrorZ_get_err(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
4962 CHECK(!owner->result_ok);
4963         return DecodeError_clone(&*owner->contents.err);
4964 }
4965 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_get_err"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_get_err(uint32_t owner) {
4966         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
4967         LDKDecodeError ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_err(owner_conv);
4968         uint32_t ret_ref = 0;
4969         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4970         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4971         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4972         ret_ref = (uintptr_t)ret_var.inner;
4973         if (ret_var.is_owned) {
4974                 ret_ref |= 1;
4975         }
4976         return ret_ref;
4977 }
4978
4979 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
4980         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
4981         for (size_t i = 0; i < ret.datalen; i++) {
4982                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
4983         }
4984         return ret;
4985 }
4986 typedef struct LDKWatch_JCalls {
4987         atomic_size_t refcnt;
4988         uint32_t instance_ptr;
4989 } LDKWatch_JCalls;
4990 static void LDKWatch_JCalls_free(void* this_arg) {
4991         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4992         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4993                 FREE(j_calls);
4994         }
4995 }
4996 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
4997         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4998         LDKOutPoint funding_txo_var = funding_txo;
4999         uint32_t funding_txo_ref = 0;
5000         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5001         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5002         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
5003         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
5004         if (funding_txo_var.is_owned) {
5005                 funding_txo_ref |= 1;
5006         }
5007         LDKChannelMonitor monitor_var = monitor;
5008         uint32_t monitor_ref = 0;
5009         CHECK((((uintptr_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5010         CHECK((((uintptr_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5011         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
5012         monitor_ref = (uintptr_t)monitor_var.inner;
5013         if (monitor_var.is_owned) {
5014                 monitor_ref |= 1;
5015         }
5016         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 16, (uint32_t)funding_txo_ref, (uint32_t)monitor_ref);
5017         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5018         CHECK_ACCESS(ret_ptr);
5019         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
5020         FREE((void*)ret);
5021         return ret_conv;
5022 }
5023 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
5024         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5025         LDKOutPoint funding_txo_var = funding_txo;
5026         uint32_t funding_txo_ref = 0;
5027         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5028         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5029         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
5030         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
5031         if (funding_txo_var.is_owned) {
5032                 funding_txo_ref |= 1;
5033         }
5034         LDKChannelMonitorUpdate update_var = update;
5035         uint32_t update_ref = 0;
5036         CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5037         CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5038         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
5039         update_ref = (uintptr_t)update_var.inner;
5040         if (update_var.is_owned) {
5041                 update_ref |= 1;
5042         }
5043         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 17, (uint32_t)funding_txo_ref, (uint32_t)update_ref);
5044         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5045         CHECK_ACCESS(ret_ptr);
5046         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
5047         FREE((void*)ret);
5048         return ret_conv;
5049 }
5050 LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
5051         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
5052         uint32_tArray ret = (uint32_tArray)js_invoke_function_0(j_calls->instance_ptr, 18);
5053         LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ ret_constr;
5054         ret_constr.datalen = ret->arr_len;
5055         if (ret_constr.datalen > 0)
5056                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_OutPointCVec_MonitorEventZZ), "LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ Elements");
5057         else
5058                 ret_constr.data = NULL;
5059         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
5060         for (size_t m = 0; m < ret_constr.datalen; m++) {
5061                 uint32_t ret_conv_38 = ret_vals[m];
5062                 void* ret_conv_38_ptr = (void*)(((uintptr_t)ret_conv_38) & ~1);
5063                 CHECK_ACCESS(ret_conv_38_ptr);
5064                 LDKC2Tuple_OutPointCVec_MonitorEventZZ ret_conv_38_conv = *(LDKC2Tuple_OutPointCVec_MonitorEventZZ*)(ret_conv_38_ptr);
5065                 FREE((void*)ret_conv_38);
5066                 ret_constr.data[m] = ret_conv_38_conv;
5067         }
5068         return ret_constr;
5069 }
5070 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
5071         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
5072         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5073 }
5074 static inline LDKWatch LDKWatch_init (JSValue o) {
5075         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
5076         atomic_init(&calls->refcnt, 1);
5077         calls->instance_ptr = o;
5078
5079         LDKWatch ret = {
5080                 .this_arg = (void*) calls,
5081                 .watch_channel = watch_channel_LDKWatch_jcall,
5082                 .update_channel = update_channel_LDKWatch_jcall,
5083                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
5084                 .free = LDKWatch_JCalls_free,
5085         };
5086         return ret;
5087 }
5088 long  __attribute__((export_name("TS_LDKWatch_new"))) TS_LDKWatch_new(JSValue o) {
5089         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
5090         *res_ptr = LDKWatch_init(o);
5091         return (long)res_ptr;
5092 }
5093 uint32_t  __attribute__((export_name("TS_Watch_watch_channel"))) TS_Watch_watch_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t monitor) {
5094         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5095         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5096         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
5097         LDKOutPoint funding_txo_conv;
5098         funding_txo_conv.inner = (void*)(funding_txo & (~1));
5099         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
5100         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
5101         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
5102         LDKChannelMonitor monitor_conv;
5103         monitor_conv.inner = (void*)(monitor & (~1));
5104         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
5105         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
5106         monitor_conv = ChannelMonitor_clone(&monitor_conv);
5107         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5108         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
5109         return (uint32_t)ret_conv;
5110 }
5111
5112 uint32_t  __attribute__((export_name("TS_Watch_update_channel"))) TS_Watch_update_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t update) {
5113         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5114         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5115         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
5116         LDKOutPoint funding_txo_conv;
5117         funding_txo_conv.inner = (void*)(funding_txo & (~1));
5118         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
5119         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
5120         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
5121         LDKChannelMonitorUpdate update_conv;
5122         update_conv.inner = (void*)(update & (~1));
5123         update_conv.is_owned = (update & 1) || (update == 0);
5124         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
5125         update_conv = ChannelMonitorUpdate_clone(&update_conv);
5126         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
5127         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
5128         return (uint32_t)ret_conv;
5129 }
5130
5131 uint32_tArray  __attribute__((export_name("TS_Watch_release_pending_monitor_events"))) TS_Watch_release_pending_monitor_events(uint32_t this_arg) {
5132         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5133         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5134         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
5135         LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
5136         uint32_tArray ret_arr = NULL;
5137         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
5138         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
5139         for (size_t m = 0; m < ret_var.datalen; m++) {
5140                 LDKC2Tuple_OutPointCVec_MonitorEventZZ* ret_conv_38_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorEventZZ), "LDKC2Tuple_OutPointCVec_MonitorEventZZ");
5141                 *ret_conv_38_conv = ret_var.data[m];
5142                 ret_arr_ptr[m] = ((uint32_t)ret_conv_38_conv);
5143         }
5144         
5145         FREE(ret_var.data);
5146         return ret_arr;
5147 }
5148
5149 typedef struct LDKBroadcasterInterface_JCalls {
5150         atomic_size_t refcnt;
5151         uint32_t instance_ptr;
5152 } LDKBroadcasterInterface_JCalls;
5153 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
5154         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
5155         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5156                 FREE(j_calls);
5157         }
5158 }
5159 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
5160         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
5161         LDKTransaction tx_var = tx;
5162         int8_tArray tx_arr = init_int8_tArray(tx_var.datalen, __LINE__);
5163         memcpy(tx_arr->elems, tx_var.data, tx_var.datalen);
5164         Transaction_free(tx_var);
5165         js_invoke_function_1(j_calls->instance_ptr, 19, (uint32_t)tx_arr);
5166 }
5167 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
5168         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
5169         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5170 }
5171 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JSValue o) {
5172         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
5173         atomic_init(&calls->refcnt, 1);
5174         calls->instance_ptr = o;
5175
5176         LDKBroadcasterInterface ret = {
5177                 .this_arg = (void*) calls,
5178                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
5179                 .free = LDKBroadcasterInterface_JCalls_free,
5180         };
5181         return ret;
5182 }
5183 long  __attribute__((export_name("TS_LDKBroadcasterInterface_new"))) TS_LDKBroadcasterInterface_new(JSValue o) {
5184         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
5185         *res_ptr = LDKBroadcasterInterface_init(o);
5186         return (long)res_ptr;
5187 }
5188 void  __attribute__((export_name("TS_BroadcasterInterface_broadcast_transaction"))) TS_BroadcasterInterface_broadcast_transaction(uint32_t this_arg, int8_tArray tx) {
5189         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5190         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5191         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
5192         LDKTransaction tx_ref;
5193         tx_ref.datalen = tx->arr_len;
5194         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
5195         memcpy(tx_ref.data, tx->elems, tx_ref.datalen); FREE(tx);
5196         tx_ref.data_is_owned = true;
5197         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
5198 }
5199
5200 typedef struct LDKKeysInterface_JCalls {
5201         atomic_size_t refcnt;
5202         uint32_t instance_ptr;
5203 } LDKKeysInterface_JCalls;
5204 static void LDKKeysInterface_JCalls_free(void* this_arg) {
5205         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5206         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5207                 FREE(j_calls);
5208         }
5209 }
5210 LDKCResult_SecretKeyNoneZ get_node_secret_LDKKeysInterface_jcall(const void* this_arg, LDKRecipient recipient) {
5211         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5212         uint32_t recipient_conv = LDKRecipient_to_js(recipient);
5213         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 20, (uint32_t)recipient_conv);
5214         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5215         CHECK_ACCESS(ret_ptr);
5216         LDKCResult_SecretKeyNoneZ ret_conv = *(LDKCResult_SecretKeyNoneZ*)(ret_ptr);
5217         FREE((void*)ret);
5218         return ret_conv;
5219 }
5220 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
5221         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5222         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 21);
5223         LDKCVec_u8Z ret_ref;
5224         ret_ref.datalen = ret->arr_len;
5225         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
5226         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
5227         return ret_ref;
5228 }
5229 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
5230         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5231         uint32_t ret = js_invoke_function_0(j_calls->instance_ptr, 22);
5232         LDKShutdownScript ret_conv;
5233         ret_conv.inner = (void*)(ret & (~1));
5234         ret_conv.is_owned = (ret & 1) || (ret == 0);
5235         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
5236         return ret_conv;
5237 }
5238 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
5239         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5240         jboolean inbound_conv = inbound;
5241         int64_t channel_value_satoshis_conv = channel_value_satoshis;
5242         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 23, (uint32_t)inbound_conv, (uint32_t)channel_value_satoshis_conv);
5243         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5244         CHECK_ACCESS(ret_ptr);
5245         LDKSign ret_conv = *(LDKSign*)(ret_ptr);
5246         FREE((void*)ret);
5247         return ret_conv;
5248 }
5249 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
5250         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5251         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 24);
5252         LDKThirtyTwoBytes ret_ref;
5253         CHECK(ret->arr_len == 32);
5254         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
5255         return ret_ref;
5256 }
5257 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
5258         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5259         LDKu8slice reader_var = reader;
5260         int8_tArray reader_arr = init_int8_tArray(reader_var.datalen, __LINE__);
5261         memcpy(reader_arr->elems, reader_var.data, reader_var.datalen);
5262         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 25, (uint32_t)reader_arr);
5263         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5264         CHECK_ACCESS(ret_ptr);
5265         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
5266         FREE((void*)ret);
5267         return ret_conv;
5268 }
5269 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice hrp_bytes, LDKCVec_u5Z invoice_data, LDKRecipient receipient) {
5270         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5271         LDKu8slice hrp_bytes_var = hrp_bytes;
5272         int8_tArray hrp_bytes_arr = init_int8_tArray(hrp_bytes_var.datalen, __LINE__);
5273         memcpy(hrp_bytes_arr->elems, hrp_bytes_var.data, hrp_bytes_var.datalen);
5274         LDKCVec_u5Z invoice_data_var = invoice_data;
5275         ptrArray invoice_data_arr = NULL;
5276         invoice_data_arr = init_ptrArray(invoice_data_var.datalen, __LINE__);
5277         int8_t *invoice_data_arr_ptr = (int8_t*)(((uint8_t*)invoice_data_arr) + 4);
5278         for (size_t h = 0; h < invoice_data_var.datalen; h++) {
5279                 uint8_t invoice_data_conv_7_val = invoice_data_var.data[h]._0;
5280                 invoice_data_arr_ptr[h] = invoice_data_conv_7_val;
5281         }
5282         
5283         FREE(invoice_data_var.data);
5284         uint32_t receipient_conv = LDKRecipient_to_js(receipient);
5285         uint32_t ret = js_invoke_function_3(j_calls->instance_ptr, 26, (uint32_t)hrp_bytes_arr, (uint32_t)invoice_data_arr, (uint32_t)receipient_conv);
5286         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
5287         CHECK_ACCESS(ret_ptr);
5288         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
5289         FREE((void*)ret);
5290         return ret_conv;
5291 }
5292 LDKThirtyTwoBytes get_inbound_payment_key_material_LDKKeysInterface_jcall(const void* this_arg) {
5293         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
5294         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 27);
5295         LDKThirtyTwoBytes ret_ref;
5296         CHECK(ret->arr_len == 32);
5297         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
5298         return ret_ref;
5299 }
5300 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
5301         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
5302         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5303 }
5304 static inline LDKKeysInterface LDKKeysInterface_init (JSValue o) {
5305         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
5306         atomic_init(&calls->refcnt, 1);
5307         calls->instance_ptr = o;
5308
5309         LDKKeysInterface ret = {
5310                 .this_arg = (void*) calls,
5311                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
5312                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
5313                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
5314                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
5315                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
5316                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
5317                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
5318                 .get_inbound_payment_key_material = get_inbound_payment_key_material_LDKKeysInterface_jcall,
5319                 .free = LDKKeysInterface_JCalls_free,
5320         };
5321         return ret;
5322 }
5323 long  __attribute__((export_name("TS_LDKKeysInterface_new"))) TS_LDKKeysInterface_new(JSValue o) {
5324         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
5325         *res_ptr = LDKKeysInterface_init(o);
5326         return (long)res_ptr;
5327 }
5328 uint32_t  __attribute__((export_name("TS_KeysInterface_get_node_secret"))) TS_KeysInterface_get_node_secret(uint32_t this_arg, uint32_t recipient) {
5329         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5330         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5331         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5332         LDKRecipient recipient_conv = LDKRecipient_from_js(recipient);
5333         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
5334         *ret_conv = (this_arg_conv->get_node_secret)(this_arg_conv->this_arg, recipient_conv);
5335         return (uint32_t)ret_conv;
5336 }
5337
5338 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_destination_script"))) TS_KeysInterface_get_destination_script(uint32_t this_arg) {
5339         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5340         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5341         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5342         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
5343         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
5344         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
5345         CVec_u8Z_free(ret_var);
5346         return ret_arr;
5347 }
5348
5349 uint32_t  __attribute__((export_name("TS_KeysInterface_get_shutdown_scriptpubkey"))) TS_KeysInterface_get_shutdown_scriptpubkey(uint32_t this_arg) {
5350         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5351         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5352         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5353         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
5354         uint32_t ret_ref = 0;
5355         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5356         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5357         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5358         ret_ref = (uintptr_t)ret_var.inner;
5359         if (ret_var.is_owned) {
5360                 ret_ref |= 1;
5361         }
5362         return ret_ref;
5363 }
5364
5365 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) {
5366         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5367         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5368         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5369         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
5370         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
5371         return (uint32_t)ret_ret;
5372 }
5373
5374 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_secure_random_bytes"))) TS_KeysInterface_get_secure_random_bytes(uint32_t this_arg) {
5375         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5376         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5377         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5378         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5379         memcpy(ret_arr->elems, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data, 32);
5380         return ret_arr;
5381 }
5382
5383 uint32_t  __attribute__((export_name("TS_KeysInterface_read_chan_signer"))) TS_KeysInterface_read_chan_signer(uint32_t this_arg, int8_tArray reader) {
5384         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5385         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5386         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5387         LDKu8slice reader_ref;
5388         reader_ref.datalen = reader->arr_len;
5389         reader_ref.data = reader->elems /* XXX reader leaks */;
5390         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
5391         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
5392         return (uint32_t)ret_conv;
5393 }
5394
5395 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) {
5396         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5397         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5398         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5399         LDKu8slice hrp_bytes_ref;
5400         hrp_bytes_ref.datalen = hrp_bytes->arr_len;
5401         hrp_bytes_ref.data = hrp_bytes->elems /* XXX hrp_bytes leaks */;
5402         LDKCVec_u5Z invoice_data_constr;
5403         invoice_data_constr.datalen = invoice_data->arr_len;
5404         if (invoice_data_constr.datalen > 0)
5405                 invoice_data_constr.data = MALLOC(invoice_data_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
5406         else
5407                 invoice_data_constr.data = NULL;
5408         int8_t* invoice_data_vals = (void*) invoice_data->elems /* XXX invoice_data leaks */;
5409         for (size_t h = 0; h < invoice_data_constr.datalen; h++) {
5410                 int8_t invoice_data_conv_7 = invoice_data_vals[h];
5411                 
5412                 invoice_data_constr.data[h] = (LDKu5){ ._0 = invoice_data_conv_7 };
5413         }
5414         LDKRecipient receipient_conv = LDKRecipient_from_js(receipient);
5415         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
5416         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, hrp_bytes_ref, invoice_data_constr, receipient_conv);
5417         return (uint32_t)ret_conv;
5418 }
5419
5420 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_inbound_payment_key_material"))) TS_KeysInterface_get_inbound_payment_key_material(uint32_t this_arg) {
5421         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5422         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5423         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
5424         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5425         memcpy(ret_arr->elems, (this_arg_conv->get_inbound_payment_key_material)(this_arg_conv->this_arg).data, 32);
5426         return ret_arr;
5427 }
5428
5429 typedef struct LDKFeeEstimator_JCalls {
5430         atomic_size_t refcnt;
5431         uint32_t instance_ptr;
5432 } LDKFeeEstimator_JCalls;
5433 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
5434         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
5435         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5436                 FREE(j_calls);
5437         }
5438 }
5439 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
5440         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
5441         uint32_t confirmation_target_conv = LDKConfirmationTarget_to_js(confirmation_target);
5442         return js_invoke_function_1(j_calls->instance_ptr, 28, (uint32_t)confirmation_target_conv);
5443 }
5444 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
5445         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
5446         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5447 }
5448 static inline LDKFeeEstimator LDKFeeEstimator_init (JSValue o) {
5449         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
5450         atomic_init(&calls->refcnt, 1);
5451         calls->instance_ptr = o;
5452
5453         LDKFeeEstimator ret = {
5454                 .this_arg = (void*) calls,
5455                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
5456                 .free = LDKFeeEstimator_JCalls_free,
5457         };
5458         return ret;
5459 }
5460 long  __attribute__((export_name("TS_LDKFeeEstimator_new"))) TS_LDKFeeEstimator_new(JSValue o) {
5461         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
5462         *res_ptr = LDKFeeEstimator_init(o);
5463         return (long)res_ptr;
5464 }
5465 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) {
5466         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5467         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5468         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
5469         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_js(confirmation_target);
5470         int32_t ret_conv = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
5471         return ret_conv;
5472 }
5473
5474 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
5475         return ThirtyTwoBytes_clone(&owner->a);
5476 }
5477 int8_tArray  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_get_a"))) TS_C2Tuple_BlockHashChannelManagerZ_get_a(uint32_t owner) {
5478         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
5479         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5480         memcpy(ret_arr->elems, C2Tuple_BlockHashChannelManagerZ_get_a(owner_conv).data, 32);
5481         return ret_arr;
5482 }
5483
5484 static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
5485         return &owner->b;
5486 }
5487 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_get_b"))) TS_C2Tuple_BlockHashChannelManagerZ_get_b(uint32_t owner) {
5488         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
5489         LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(owner_conv);
5490         uint32_t ret_ref = 0;
5491         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5492         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5493         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5494         ret_ref = (uintptr_t)ret_var.inner & ~1;
5495         return ret_ref;
5496 }
5497
5498 static inline struct LDKC2Tuple_BlockHashChannelManagerZ *CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
5499 CHECK(owner->result_ok);
5500         return &*owner->contents.result;
5501 }
5502 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(uint32_t owner) {
5503         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
5504         uint32_t ret_ret = (uintptr_t)CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(owner_conv) | 1;
5505         return ret_ret;
5506 }
5507
5508 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
5509 CHECK(!owner->result_ok);
5510         return DecodeError_clone(&*owner->contents.err);
5511 }
5512 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(uint32_t owner) {
5513         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
5514         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(owner_conv);
5515         uint32_t ret_ref = 0;
5516         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5517         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5518         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5519         ret_ref = (uintptr_t)ret_var.inner;
5520         if (ret_var.is_owned) {
5521                 ret_ref |= 1;
5522         }
5523         return ret_ref;
5524 }
5525
5526 static inline struct LDKChannelConfig CResult_ChannelConfigDecodeErrorZ_get_ok(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
5527 CHECK(owner->result_ok);
5528         return ChannelConfig_clone(&*owner->contents.result);
5529 }
5530 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_get_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_get_ok(uint32_t owner) {
5531         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
5532         LDKChannelConfig ret_var = CResult_ChannelConfigDecodeErrorZ_get_ok(owner_conv);
5533         uint32_t ret_ref = 0;
5534         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5535         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5536         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5537         ret_ref = (uintptr_t)ret_var.inner;
5538         if (ret_var.is_owned) {
5539                 ret_ref |= 1;
5540         }
5541         return ret_ref;
5542 }
5543
5544 static inline struct LDKDecodeError CResult_ChannelConfigDecodeErrorZ_get_err(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
5545 CHECK(!owner->result_ok);
5546         return DecodeError_clone(&*owner->contents.err);
5547 }
5548 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_get_err"))) TS_CResult_ChannelConfigDecodeErrorZ_get_err(uint32_t owner) {
5549         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
5550         LDKDecodeError ret_var = CResult_ChannelConfigDecodeErrorZ_get_err(owner_conv);
5551         uint32_t ret_ref = 0;
5552         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5553         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5554         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5555         ret_ref = (uintptr_t)ret_var.inner;
5556         if (ret_var.is_owned) {
5557                 ret_ref |= 1;
5558         }
5559         return ret_ref;
5560 }
5561
5562 static inline struct LDKOutPoint CResult_OutPointDecodeErrorZ_get_ok(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
5563 CHECK(owner->result_ok);
5564         return OutPoint_clone(&*owner->contents.result);
5565 }
5566 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_get_ok"))) TS_CResult_OutPointDecodeErrorZ_get_ok(uint32_t owner) {
5567         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
5568         LDKOutPoint ret_var = CResult_OutPointDecodeErrorZ_get_ok(owner_conv);
5569         uint32_t ret_ref = 0;
5570         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5571         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5572         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5573         ret_ref = (uintptr_t)ret_var.inner;
5574         if (ret_var.is_owned) {
5575                 ret_ref |= 1;
5576         }
5577         return ret_ref;
5578 }
5579
5580 static inline struct LDKDecodeError CResult_OutPointDecodeErrorZ_get_err(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
5581 CHECK(!owner->result_ok);
5582         return DecodeError_clone(&*owner->contents.err);
5583 }
5584 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_get_err"))) TS_CResult_OutPointDecodeErrorZ_get_err(uint32_t owner) {
5585         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
5586         LDKDecodeError ret_var = CResult_OutPointDecodeErrorZ_get_err(owner_conv);
5587         uint32_t ret_ref = 0;
5588         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5589         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5590         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5591         ret_ref = (uintptr_t)ret_var.inner;
5592         if (ret_var.is_owned) {
5593                 ret_ref |= 1;
5594         }
5595         return ret_ref;
5596 }
5597
5598 typedef struct LDKType_JCalls {
5599         atomic_size_t refcnt;
5600         uint32_t instance_ptr;
5601 } LDKType_JCalls;
5602 static void LDKType_JCalls_free(void* this_arg) {
5603         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5604         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5605                 FREE(j_calls);
5606         }
5607 }
5608 uint16_t type_id_LDKType_jcall(const void* this_arg) {
5609         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5610         return js_invoke_function_0(j_calls->instance_ptr, 29);
5611 }
5612 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
5613         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5614         jstring ret = (jstring)js_invoke_function_0(j_calls->instance_ptr, 30);
5615         LDKStr ret_conv = str_ref_to_owned_c(ret);
5616         return ret_conv;
5617 }
5618 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
5619         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5620         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 31);
5621         LDKCVec_u8Z ret_ref;
5622         ret_ref.datalen = ret->arr_len;
5623         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
5624         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
5625         return ret_ref;
5626 }
5627 static void LDKType_JCalls_cloned(LDKType* new_obj) {
5628         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
5629         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5630 }
5631 static inline LDKType LDKType_init (JSValue o) {
5632         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
5633         atomic_init(&calls->refcnt, 1);
5634         calls->instance_ptr = o;
5635
5636         LDKType ret = {
5637                 .this_arg = (void*) calls,
5638                 .type_id = type_id_LDKType_jcall,
5639                 .debug_str = debug_str_LDKType_jcall,
5640                 .write = write_LDKType_jcall,
5641                 .cloned = LDKType_JCalls_cloned,
5642                 .free = LDKType_JCalls_free,
5643         };
5644         return ret;
5645 }
5646 long  __attribute__((export_name("TS_LDKType_new"))) TS_LDKType_new(JSValue o) {
5647         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
5648         *res_ptr = LDKType_init(o);
5649         return (long)res_ptr;
5650 }
5651 int16_t  __attribute__((export_name("TS_Type_type_id"))) TS_Type_type_id(uint32_t this_arg) {
5652         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5653         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5654         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5655         int16_t ret_conv = (this_arg_conv->type_id)(this_arg_conv->this_arg);
5656         return ret_conv;
5657 }
5658
5659 jstring  __attribute__((export_name("TS_Type_debug_str"))) TS_Type_debug_str(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         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5663         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
5664         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
5665         Str_free(ret_str);
5666         return ret_conv;
5667 }
5668
5669 int8_tArray  __attribute__((export_name("TS_Type_write"))) TS_Type_write(uint32_t this_arg) {
5670         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5671         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5672         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5673         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
5674         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
5675         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
5676         CVec_u8Z_free(ret_var);
5677         return ret_arr;
5678 }
5679
5680 uint32_t __attribute__((export_name("TS_LDKCOption_TypeZ_ty_from_ptr"))) TS_LDKCOption_TypeZ_ty_from_ptr(uint32_t ptr) {
5681         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
5682         switch(obj->tag) {
5683                 case LDKCOption_TypeZ_Some: return 0;
5684                 case LDKCOption_TypeZ_None: return 1;
5685                 default: abort();
5686         }
5687 }
5688 uint32_t __attribute__((export_name("TS_LDKCOption_TypeZ_Some_get_some"))) TS_LDKCOption_TypeZ_Some_get_some(uint32_t ptr) {
5689         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
5690         assert(obj->tag == LDKCOption_TypeZ_Some);
5691                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
5692                         *some_ret = Type_clone(&obj->some);
5693         return (uint32_t)some_ret;
5694 }
5695 static inline struct LDKCOption_TypeZ CResult_COption_TypeZDecodeErrorZ_get_ok(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
5696 CHECK(owner->result_ok);
5697         return COption_TypeZ_clone(&*owner->contents.result);
5698 }
5699 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_get_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_get_ok(uint32_t owner) {
5700         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
5701         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
5702         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_ok(owner_conv);
5703         uint32_t ret_ref = (uintptr_t)ret_copy;
5704         return ret_ref;
5705 }
5706
5707 static inline struct LDKDecodeError CResult_COption_TypeZDecodeErrorZ_get_err(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
5708 CHECK(!owner->result_ok);
5709         return DecodeError_clone(&*owner->contents.err);
5710 }
5711 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_get_err"))) TS_CResult_COption_TypeZDecodeErrorZ_get_err(uint32_t owner) {
5712         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
5713         LDKDecodeError ret_var = CResult_COption_TypeZDecodeErrorZ_get_err(owner_conv);
5714         uint32_t ret_ref = 0;
5715         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5716         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5717         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5718         ret_ref = (uintptr_t)ret_var.inner;
5719         if (ret_var.is_owned) {
5720                 ret_ref |= 1;
5721         }
5722         return ret_ref;
5723 }
5724
5725 uint32_t __attribute__((export_name("TS_LDKPaymentError_ty_from_ptr"))) TS_LDKPaymentError_ty_from_ptr(uint32_t ptr) {
5726         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
5727         switch(obj->tag) {
5728                 case LDKPaymentError_Invoice: return 0;
5729                 case LDKPaymentError_Routing: return 1;
5730                 case LDKPaymentError_Sending: return 2;
5731                 default: abort();
5732         }
5733 }
5734 jstring __attribute__((export_name("TS_LDKPaymentError_Invoice_get_invoice"))) TS_LDKPaymentError_Invoice_get_invoice(uint32_t ptr) {
5735         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
5736         assert(obj->tag == LDKPaymentError_Invoice);
5737                         LDKStr invoice_str = obj->invoice;
5738                         jstring invoice_conv = str_ref_to_ts(invoice_str.chars, invoice_str.len);
5739         return invoice_conv;
5740 }
5741 uint32_t __attribute__((export_name("TS_LDKPaymentError_Routing_get_routing"))) TS_LDKPaymentError_Routing_get_routing(uint32_t ptr) {
5742         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
5743         assert(obj->tag == LDKPaymentError_Routing);
5744                         LDKLightningError routing_var = obj->routing;
5745                         uint32_t routing_ref = 0;
5746                         CHECK((((uintptr_t)routing_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5747                         CHECK((((uintptr_t)&routing_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5748                         CHECK_INNER_FIELD_ACCESS_OR_NULL(routing_var);
5749                         routing_ref = (uintptr_t)routing_var.inner & ~1;
5750         return routing_ref;
5751 }
5752 uint32_t __attribute__((export_name("TS_LDKPaymentError_Sending_get_sending"))) TS_LDKPaymentError_Sending_get_sending(uint32_t ptr) {
5753         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
5754         assert(obj->tag == LDKPaymentError_Sending);
5755                         uint32_t sending_ref = ((uintptr_t)&obj->sending) | 1;
5756         return sending_ref;
5757 }
5758 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentErrorZ_get_ok(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
5759 CHECK(owner->result_ok);
5760         return ThirtyTwoBytes_clone(&*owner->contents.result);
5761 }
5762 int8_tArray  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_get_ok"))) TS_CResult_PaymentIdPaymentErrorZ_get_ok(uint32_t owner) {
5763         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
5764         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5765         memcpy(ret_arr->elems, CResult_PaymentIdPaymentErrorZ_get_ok(owner_conv).data, 32);
5766         return ret_arr;
5767 }
5768
5769 static inline struct LDKPaymentError CResult_PaymentIdPaymentErrorZ_get_err(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
5770 CHECK(!owner->result_ok);
5771         return PaymentError_clone(&*owner->contents.err);
5772 }
5773 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_get_err"))) TS_CResult_PaymentIdPaymentErrorZ_get_err(uint32_t owner) {
5774         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
5775         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
5776         *ret_copy = CResult_PaymentIdPaymentErrorZ_get_err(owner_conv);
5777         uint32_t ret_ref = (uintptr_t)ret_copy;
5778         return ret_ref;
5779 }
5780
5781 uint32_t __attribute__((export_name("TS_LDKParseError_ty_from_ptr"))) TS_LDKParseError_ty_from_ptr(uint32_t ptr) {
5782         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
5783         switch(obj->tag) {
5784                 case LDKParseError_Bech32Error: return 0;
5785                 case LDKParseError_ParseAmountError: return 1;
5786                 case LDKParseError_MalformedSignature: return 2;
5787                 case LDKParseError_BadPrefix: return 3;
5788                 case LDKParseError_UnknownCurrency: return 4;
5789                 case LDKParseError_UnknownSiPrefix: return 5;
5790                 case LDKParseError_MalformedHRP: return 6;
5791                 case LDKParseError_TooShortDataPart: return 7;
5792                 case LDKParseError_UnexpectedEndOfTaggedFields: return 8;
5793                 case LDKParseError_DescriptionDecodeError: return 9;
5794                 case LDKParseError_PaddingError: return 10;
5795                 case LDKParseError_IntegerOverflowError: return 11;
5796                 case LDKParseError_InvalidSegWitProgramLength: return 12;
5797                 case LDKParseError_InvalidPubKeyHashLength: return 13;
5798                 case LDKParseError_InvalidScriptHashLength: return 14;
5799                 case LDKParseError_InvalidRecoveryId: return 15;
5800                 case LDKParseError_InvalidSliceLength: return 16;
5801                 case LDKParseError_Skip: return 17;
5802                 default: abort();
5803         }
5804 }
5805 uint32_t __attribute__((export_name("TS_LDKParseError_Bech32Error_get_bech32_error"))) TS_LDKParseError_Bech32Error_get_bech32_error(uint32_t ptr) {
5806         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
5807         assert(obj->tag == LDKParseError_Bech32Error);
5808                         uint32_t bech32_error_ref = ((uintptr_t)&obj->bech32_error) | 1;
5809         return bech32_error_ref;
5810 }
5811 int32_t __attribute__((export_name("TS_LDKParseError_ParseAmountError_get_parse_amount_error"))) TS_LDKParseError_ParseAmountError_get_parse_amount_error(uint32_t ptr) {
5812         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
5813         assert(obj->tag == LDKParseError_ParseAmountError);
5814                         /*obj->parse_amount_error*/
5815         return 0;
5816 }
5817 uint32_t __attribute__((export_name("TS_LDKParseError_MalformedSignature_get_malformed_signature"))) TS_LDKParseError_MalformedSignature_get_malformed_signature(uint32_t ptr) {
5818         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
5819         assert(obj->tag == LDKParseError_MalformedSignature);
5820                         uint32_t malformed_signature_conv = LDKSecp256k1Error_to_js(obj->malformed_signature);
5821         return malformed_signature_conv;
5822 }
5823 int32_t __attribute__((export_name("TS_LDKParseError_DescriptionDecodeError_get_description_decode_error"))) TS_LDKParseError_DescriptionDecodeError_get_description_decode_error(uint32_t ptr) {
5824         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
5825         assert(obj->tag == LDKParseError_DescriptionDecodeError);
5826                         /*obj->description_decode_error*/
5827         return 0;
5828 }
5829 jstring __attribute__((export_name("TS_LDKParseError_InvalidSliceLength_get_invalid_slice_length"))) TS_LDKParseError_InvalidSliceLength_get_invalid_slice_length(uint32_t ptr) {
5830         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
5831         assert(obj->tag == LDKParseError_InvalidSliceLength);
5832                         LDKStr invalid_slice_length_str = obj->invalid_slice_length;
5833                         jstring invalid_slice_length_conv = str_ref_to_ts(invalid_slice_length_str.chars, invalid_slice_length_str.len);
5834         return invalid_slice_length_conv;
5835 }
5836 static inline enum LDKSiPrefix CResult_SiPrefixParseErrorZ_get_ok(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
5837 CHECK(owner->result_ok);
5838         return SiPrefix_clone(&*owner->contents.result);
5839 }
5840 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_get_ok"))) TS_CResult_SiPrefixParseErrorZ_get_ok(uint32_t owner) {
5841         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)(owner & ~1);
5842         uint32_t ret_conv = LDKSiPrefix_to_js(CResult_SiPrefixParseErrorZ_get_ok(owner_conv));
5843         return ret_conv;
5844 }
5845
5846 static inline struct LDKParseError CResult_SiPrefixParseErrorZ_get_err(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
5847 CHECK(!owner->result_ok);
5848         return ParseError_clone(&*owner->contents.err);
5849 }
5850 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_get_err"))) TS_CResult_SiPrefixParseErrorZ_get_err(uint32_t owner) {
5851         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)(owner & ~1);
5852         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
5853         *ret_copy = CResult_SiPrefixParseErrorZ_get_err(owner_conv);
5854         uint32_t ret_ref = (uintptr_t)ret_copy;
5855         return ret_ref;
5856 }
5857
5858 uint32_t __attribute__((export_name("TS_LDKParseOrSemanticError_ty_from_ptr"))) TS_LDKParseOrSemanticError_ty_from_ptr(uint32_t ptr) {
5859         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)(ptr & ~1);
5860         switch(obj->tag) {
5861                 case LDKParseOrSemanticError_ParseError: return 0;
5862                 case LDKParseOrSemanticError_SemanticError: return 1;
5863                 default: abort();
5864         }
5865 }
5866 uint32_t __attribute__((export_name("TS_LDKParseOrSemanticError_ParseError_get_parse_error"))) TS_LDKParseOrSemanticError_ParseError_get_parse_error(uint32_t ptr) {
5867         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)(ptr & ~1);
5868         assert(obj->tag == LDKParseOrSemanticError_ParseError);
5869                         uint32_t parse_error_ref = ((uintptr_t)&obj->parse_error) | 1;
5870         return parse_error_ref;
5871 }
5872 uint32_t __attribute__((export_name("TS_LDKParseOrSemanticError_SemanticError_get_semantic_error"))) TS_LDKParseOrSemanticError_SemanticError_get_semantic_error(uint32_t ptr) {
5873         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)(ptr & ~1);
5874         assert(obj->tag == LDKParseOrSemanticError_SemanticError);
5875                         uint32_t semantic_error_conv = LDKSemanticError_to_js(obj->semantic_error);
5876         return semantic_error_conv;
5877 }
5878 static inline struct LDKInvoice CResult_InvoiceParseOrSemanticErrorZ_get_ok(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
5879 CHECK(owner->result_ok);
5880         return Invoice_clone(&*owner->contents.result);
5881 }
5882 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_get_ok"))) TS_CResult_InvoiceParseOrSemanticErrorZ_get_ok(uint32_t owner) {
5883         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(owner & ~1);
5884         LDKInvoice ret_var = CResult_InvoiceParseOrSemanticErrorZ_get_ok(owner_conv);
5885         uint32_t ret_ref = 0;
5886         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5887         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5888         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5889         ret_ref = (uintptr_t)ret_var.inner;
5890         if (ret_var.is_owned) {
5891                 ret_ref |= 1;
5892         }
5893         return ret_ref;
5894 }
5895
5896 static inline struct LDKParseOrSemanticError CResult_InvoiceParseOrSemanticErrorZ_get_err(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
5897 CHECK(!owner->result_ok);
5898         return ParseOrSemanticError_clone(&*owner->contents.err);
5899 }
5900 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_get_err"))) TS_CResult_InvoiceParseOrSemanticErrorZ_get_err(uint32_t owner) {
5901         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(owner & ~1);
5902         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
5903         *ret_copy = CResult_InvoiceParseOrSemanticErrorZ_get_err(owner_conv);
5904         uint32_t ret_ref = (uintptr_t)ret_copy;
5905         return ret_ref;
5906 }
5907
5908 static inline struct LDKSignedRawInvoice CResult_SignedRawInvoiceParseErrorZ_get_ok(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
5909 CHECK(owner->result_ok);
5910         return SignedRawInvoice_clone(&*owner->contents.result);
5911 }
5912 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_get_ok"))) TS_CResult_SignedRawInvoiceParseErrorZ_get_ok(uint32_t owner) {
5913         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(owner & ~1);
5914         LDKSignedRawInvoice ret_var = CResult_SignedRawInvoiceParseErrorZ_get_ok(owner_conv);
5915         uint32_t ret_ref = 0;
5916         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5917         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5918         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5919         ret_ref = (uintptr_t)ret_var.inner;
5920         if (ret_var.is_owned) {
5921                 ret_ref |= 1;
5922         }
5923         return ret_ref;
5924 }
5925
5926 static inline struct LDKParseError CResult_SignedRawInvoiceParseErrorZ_get_err(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
5927 CHECK(!owner->result_ok);
5928         return ParseError_clone(&*owner->contents.err);
5929 }
5930 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_get_err"))) TS_CResult_SignedRawInvoiceParseErrorZ_get_err(uint32_t owner) {
5931         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(owner & ~1);
5932         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
5933         *ret_copy = CResult_SignedRawInvoiceParseErrorZ_get_err(owner_conv);
5934         uint32_t ret_ref = (uintptr_t)ret_copy;
5935         return ret_ref;
5936 }
5937
5938 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
5939         return RawInvoice_clone(&owner->a);
5940 }
5941 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(uint32_t owner) {
5942         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
5943         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(owner_conv);
5944         uint32_t ret_ref = 0;
5945         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5946         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5947         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5948         ret_ref = (uintptr_t)ret_var.inner;
5949         if (ret_var.is_owned) {
5950                 ret_ref |= 1;
5951         }
5952         return ret_ref;
5953 }
5954
5955 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
5956         return ThirtyTwoBytes_clone(&owner->b);
5957 }
5958 int8_tArray  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(uint32_t owner) {
5959         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
5960         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5961         memcpy(ret_arr->elems, C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(owner_conv).data, 32);
5962         return ret_arr;
5963 }
5964
5965 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
5966         return InvoiceSignature_clone(&owner->c);
5967 }
5968 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(uint32_t owner) {
5969         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
5970         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(owner_conv);
5971         uint32_t ret_ref = 0;
5972         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5973         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5974         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5975         ret_ref = (uintptr_t)ret_var.inner;
5976         if (ret_var.is_owned) {
5977                 ret_ref |= 1;
5978         }
5979         return ret_ref;
5980 }
5981
5982 static inline struct LDKPayeePubKey CResult_PayeePubKeyErrorZ_get_ok(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
5983 CHECK(owner->result_ok);
5984         return PayeePubKey_clone(&*owner->contents.result);
5985 }
5986 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_get_ok"))) TS_CResult_PayeePubKeyErrorZ_get_ok(uint32_t owner) {
5987         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
5988         LDKPayeePubKey ret_var = CResult_PayeePubKeyErrorZ_get_ok(owner_conv);
5989         uint32_t ret_ref = 0;
5990         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5991         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5992         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5993         ret_ref = (uintptr_t)ret_var.inner;
5994         if (ret_var.is_owned) {
5995                 ret_ref |= 1;
5996         }
5997         return ret_ref;
5998 }
5999
6000 static inline enum LDKSecp256k1Error CResult_PayeePubKeyErrorZ_get_err(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
6001 CHECK(!owner->result_ok);
6002         return *owner->contents.err;
6003 }
6004 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_get_err"))) TS_CResult_PayeePubKeyErrorZ_get_err(uint32_t owner) {
6005         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
6006         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_PayeePubKeyErrorZ_get_err(owner_conv));
6007         return ret_conv;
6008 }
6009
6010 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
6011         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
6012         for (size_t i = 0; i < ret.datalen; i++) {
6013                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
6014         }
6015         return ret;
6016 }
6017 static inline struct LDKPositiveTimestamp CResult_PositiveTimestampCreationErrorZ_get_ok(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
6018 CHECK(owner->result_ok);
6019         return PositiveTimestamp_clone(&*owner->contents.result);
6020 }
6021 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_get_ok"))) TS_CResult_PositiveTimestampCreationErrorZ_get_ok(uint32_t owner) {
6022         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
6023         LDKPositiveTimestamp ret_var = CResult_PositiveTimestampCreationErrorZ_get_ok(owner_conv);
6024         uint32_t ret_ref = 0;
6025         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6026         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6027         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6028         ret_ref = (uintptr_t)ret_var.inner;
6029         if (ret_var.is_owned) {
6030                 ret_ref |= 1;
6031         }
6032         return ret_ref;
6033 }
6034
6035 static inline enum LDKCreationError CResult_PositiveTimestampCreationErrorZ_get_err(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
6036 CHECK(!owner->result_ok);
6037         return CreationError_clone(&*owner->contents.err);
6038 }
6039 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_get_err"))) TS_CResult_PositiveTimestampCreationErrorZ_get_err(uint32_t owner) {
6040         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
6041         uint32_t ret_conv = LDKCreationError_to_js(CResult_PositiveTimestampCreationErrorZ_get_err(owner_conv));
6042         return ret_conv;
6043 }
6044
6045 static inline void CResult_NoneSemanticErrorZ_get_ok(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
6046 CHECK(owner->result_ok);
6047         return *owner->contents.result;
6048 }
6049 void  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_get_ok"))) TS_CResult_NoneSemanticErrorZ_get_ok(uint32_t owner) {
6050         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
6051         CResult_NoneSemanticErrorZ_get_ok(owner_conv);
6052 }
6053
6054 static inline enum LDKSemanticError CResult_NoneSemanticErrorZ_get_err(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
6055 CHECK(!owner->result_ok);
6056         return SemanticError_clone(&*owner->contents.err);
6057 }
6058 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_get_err"))) TS_CResult_NoneSemanticErrorZ_get_err(uint32_t owner) {
6059         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
6060         uint32_t ret_conv = LDKSemanticError_to_js(CResult_NoneSemanticErrorZ_get_err(owner_conv));
6061         return ret_conv;
6062 }
6063
6064 static inline struct LDKInvoice CResult_InvoiceSemanticErrorZ_get_ok(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
6065 CHECK(owner->result_ok);
6066         return Invoice_clone(&*owner->contents.result);
6067 }
6068 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_get_ok"))) TS_CResult_InvoiceSemanticErrorZ_get_ok(uint32_t owner) {
6069         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
6070         LDKInvoice ret_var = CResult_InvoiceSemanticErrorZ_get_ok(owner_conv);
6071         uint32_t ret_ref = 0;
6072         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6073         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6074         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6075         ret_ref = (uintptr_t)ret_var.inner;
6076         if (ret_var.is_owned) {
6077                 ret_ref |= 1;
6078         }
6079         return ret_ref;
6080 }
6081
6082 static inline enum LDKSemanticError CResult_InvoiceSemanticErrorZ_get_err(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
6083 CHECK(!owner->result_ok);
6084         return SemanticError_clone(&*owner->contents.err);
6085 }
6086 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_get_err"))) TS_CResult_InvoiceSemanticErrorZ_get_err(uint32_t owner) {
6087         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
6088         uint32_t ret_conv = LDKSemanticError_to_js(CResult_InvoiceSemanticErrorZ_get_err(owner_conv));
6089         return ret_conv;
6090 }
6091
6092 static inline struct LDKDescription CResult_DescriptionCreationErrorZ_get_ok(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
6093 CHECK(owner->result_ok);
6094         return Description_clone(&*owner->contents.result);
6095 }
6096 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_get_ok"))) TS_CResult_DescriptionCreationErrorZ_get_ok(uint32_t owner) {
6097         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
6098         LDKDescription ret_var = CResult_DescriptionCreationErrorZ_get_ok(owner_conv);
6099         uint32_t ret_ref = 0;
6100         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6101         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6102         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6103         ret_ref = (uintptr_t)ret_var.inner;
6104         if (ret_var.is_owned) {
6105                 ret_ref |= 1;
6106         }
6107         return ret_ref;
6108 }
6109
6110 static inline enum LDKCreationError CResult_DescriptionCreationErrorZ_get_err(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
6111 CHECK(!owner->result_ok);
6112         return CreationError_clone(&*owner->contents.err);
6113 }
6114 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_get_err"))) TS_CResult_DescriptionCreationErrorZ_get_err(uint32_t owner) {
6115         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
6116         uint32_t ret_conv = LDKCreationError_to_js(CResult_DescriptionCreationErrorZ_get_err(owner_conv));
6117         return ret_conv;
6118 }
6119
6120 static inline struct LDKPrivateRoute CResult_PrivateRouteCreationErrorZ_get_ok(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
6121 CHECK(owner->result_ok);
6122         return PrivateRoute_clone(&*owner->contents.result);
6123 }
6124 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_get_ok"))) TS_CResult_PrivateRouteCreationErrorZ_get_ok(uint32_t owner) {
6125         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
6126         LDKPrivateRoute ret_var = CResult_PrivateRouteCreationErrorZ_get_ok(owner_conv);
6127         uint32_t ret_ref = 0;
6128         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6129         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6130         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6131         ret_ref = (uintptr_t)ret_var.inner;
6132         if (ret_var.is_owned) {
6133                 ret_ref |= 1;
6134         }
6135         return ret_ref;
6136 }
6137
6138 static inline enum LDKCreationError CResult_PrivateRouteCreationErrorZ_get_err(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
6139 CHECK(!owner->result_ok);
6140         return CreationError_clone(&*owner->contents.err);
6141 }
6142 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_get_err"))) TS_CResult_PrivateRouteCreationErrorZ_get_err(uint32_t owner) {
6143         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
6144         uint32_t ret_conv = LDKCreationError_to_js(CResult_PrivateRouteCreationErrorZ_get_err(owner_conv));
6145         return ret_conv;
6146 }
6147
6148 static inline struct LDKStr CResult_StringErrorZ_get_ok(LDKCResult_StringErrorZ *NONNULL_PTR owner){
6149 CHECK(owner->result_ok);
6150         return *owner->contents.result;
6151 }
6152 jstring  __attribute__((export_name("TS_CResult_StringErrorZ_get_ok"))) TS_CResult_StringErrorZ_get_ok(uint32_t owner) {
6153         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
6154         LDKStr ret_str = CResult_StringErrorZ_get_ok(owner_conv);
6155         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
6156         return ret_conv;
6157 }
6158
6159 static inline enum LDKSecp256k1Error CResult_StringErrorZ_get_err(LDKCResult_StringErrorZ *NONNULL_PTR owner){
6160 CHECK(!owner->result_ok);
6161         return *owner->contents.err;
6162 }
6163 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_get_err"))) TS_CResult_StringErrorZ_get_err(uint32_t owner) {
6164         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
6165         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_StringErrorZ_get_err(owner_conv));
6166         return ret_conv;
6167 }
6168
6169 static inline struct LDKChannelMonitorUpdate CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
6170 CHECK(owner->result_ok);
6171         return ChannelMonitorUpdate_clone(&*owner->contents.result);
6172 }
6173 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(uint32_t owner) {
6174         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
6175         LDKChannelMonitorUpdate ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(owner_conv);
6176         uint32_t ret_ref = 0;
6177         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6178         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6179         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6180         ret_ref = (uintptr_t)ret_var.inner;
6181         if (ret_var.is_owned) {
6182                 ret_ref |= 1;
6183         }
6184         return ret_ref;
6185 }
6186
6187 static inline struct LDKDecodeError CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
6188 CHECK(!owner->result_ok);
6189         return DecodeError_clone(&*owner->contents.err);
6190 }
6191 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_err"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(uint32_t owner) {
6192         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
6193         LDKDecodeError ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(owner_conv);
6194         uint32_t ret_ref = 0;
6195         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6196         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6197         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6198         ret_ref = (uintptr_t)ret_var.inner;
6199         if (ret_var.is_owned) {
6200                 ret_ref |= 1;
6201         }
6202         return ret_ref;
6203 }
6204
6205 uint32_t __attribute__((export_name("TS_LDKCOption_MonitorEventZ_ty_from_ptr"))) TS_LDKCOption_MonitorEventZ_ty_from_ptr(uint32_t ptr) {
6206         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
6207         switch(obj->tag) {
6208                 case LDKCOption_MonitorEventZ_Some: return 0;
6209                 case LDKCOption_MonitorEventZ_None: return 1;
6210                 default: abort();
6211         }
6212 }
6213 uint32_t __attribute__((export_name("TS_LDKCOption_MonitorEventZ_Some_get_some"))) TS_LDKCOption_MonitorEventZ_Some_get_some(uint32_t ptr) {
6214         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
6215         assert(obj->tag == LDKCOption_MonitorEventZ_Some);
6216                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
6217         return some_ref;
6218 }
6219 static inline struct LDKCOption_MonitorEventZ CResult_COption_MonitorEventZDecodeErrorZ_get_ok(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
6220 CHECK(owner->result_ok);
6221         return COption_MonitorEventZ_clone(&*owner->contents.result);
6222 }
6223 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_get_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_get_ok(uint32_t owner) {
6224         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
6225         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
6226         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_ok(owner_conv);
6227         uint32_t ret_ref = (uintptr_t)ret_copy;
6228         return ret_ref;
6229 }
6230
6231 static inline struct LDKDecodeError CResult_COption_MonitorEventZDecodeErrorZ_get_err(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
6232 CHECK(!owner->result_ok);
6233         return DecodeError_clone(&*owner->contents.err);
6234 }
6235 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_get_err"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_get_err(uint32_t owner) {
6236         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
6237         LDKDecodeError ret_var = CResult_COption_MonitorEventZDecodeErrorZ_get_err(owner_conv);
6238         uint32_t ret_ref = 0;
6239         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6240         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6241         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6242         ret_ref = (uintptr_t)ret_var.inner;
6243         if (ret_var.is_owned) {
6244                 ret_ref |= 1;
6245         }
6246         return ret_ref;
6247 }
6248
6249 static inline struct LDKHTLCUpdate CResult_HTLCUpdateDecodeErrorZ_get_ok(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
6250 CHECK(owner->result_ok);
6251         return HTLCUpdate_clone(&*owner->contents.result);
6252 }
6253 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_get_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_get_ok(uint32_t owner) {
6254         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
6255         LDKHTLCUpdate ret_var = CResult_HTLCUpdateDecodeErrorZ_get_ok(owner_conv);
6256         uint32_t ret_ref = 0;
6257         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6258         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6259         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6260         ret_ref = (uintptr_t)ret_var.inner;
6261         if (ret_var.is_owned) {
6262                 ret_ref |= 1;
6263         }
6264         return ret_ref;
6265 }
6266
6267 static inline struct LDKDecodeError CResult_HTLCUpdateDecodeErrorZ_get_err(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
6268 CHECK(!owner->result_ok);
6269         return DecodeError_clone(&*owner->contents.err);
6270 }
6271 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_get_err"))) TS_CResult_HTLCUpdateDecodeErrorZ_get_err(uint32_t owner) {
6272         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
6273         LDKDecodeError ret_var = CResult_HTLCUpdateDecodeErrorZ_get_err(owner_conv);
6274         uint32_t ret_ref = 0;
6275         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6276         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6277         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6278         ret_ref = (uintptr_t)ret_var.inner;
6279         if (ret_var.is_owned) {
6280                 ret_ref |= 1;
6281         }
6282         return ret_ref;
6283 }
6284
6285 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
6286         return OutPoint_clone(&owner->a);
6287 }
6288 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_get_a"))) TS_C2Tuple_OutPointScriptZ_get_a(uint32_t owner) {
6289         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
6290         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(owner_conv);
6291         uint32_t ret_ref = 0;
6292         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6293         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6294         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6295         ret_ref = (uintptr_t)ret_var.inner;
6296         if (ret_var.is_owned) {
6297                 ret_ref |= 1;
6298         }
6299         return ret_ref;
6300 }
6301
6302 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
6303         return CVec_u8Z_clone(&owner->b);
6304 }
6305 int8_tArray  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_get_b"))) TS_C2Tuple_OutPointScriptZ_get_b(uint32_t owner) {
6306         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
6307         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(owner_conv);
6308         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
6309         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
6310         CVec_u8Z_free(ret_var);
6311         return ret_arr;
6312 }
6313
6314 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
6315         return owner->a;
6316 }
6317 int32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_get_a"))) TS_C2Tuple_u32ScriptZ_get_a(uint32_t owner) {
6318         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
6319         int32_t ret_conv = C2Tuple_u32ScriptZ_get_a(owner_conv);
6320         return ret_conv;
6321 }
6322
6323 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
6324         return CVec_u8Z_clone(&owner->b);
6325 }
6326 int8_tArray  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_get_b"))) TS_C2Tuple_u32ScriptZ_get_b(uint32_t owner) {
6327         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
6328         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(owner_conv);
6329         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
6330         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
6331         CVec_u8Z_free(ret_var);
6332         return ret_arr;
6333 }
6334
6335 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
6336         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
6337         for (size_t i = 0; i < ret.datalen; i++) {
6338                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
6339         }
6340         return ret;
6341 }
6342 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
6343         return ThirtyTwoBytes_clone(&owner->a);
6344 }
6345 int8_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(uint32_t owner) {
6346         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
6347         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6348         memcpy(ret_arr->elems, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(owner_conv).data, 32);
6349         return ret_arr;
6350 }
6351
6352 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
6353         return CVec_C2Tuple_u32ScriptZZ_clone(&owner->b);
6354 }
6355 uint32_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(uint32_t owner) {
6356         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
6357         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(owner_conv);
6358         uint32_tArray ret_arr = NULL;
6359         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
6360         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
6361         for (size_t v = 0; v < ret_var.datalen; v++) {
6362                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
6363                 *ret_conv_21_conv = ret_var.data[v];
6364                 ret_arr_ptr[v] = ((uint32_t)ret_conv_21_conv);
6365         }
6366         
6367         FREE(ret_var.data);
6368         return ret_arr;
6369 }
6370
6371 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
6372         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 };
6373         for (size_t i = 0; i < ret.datalen; i++) {
6374                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
6375         }
6376         return ret;
6377 }
6378 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
6379         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
6380         for (size_t i = 0; i < ret.datalen; i++) {
6381                 ret.data[i] = Event_clone(&orig->data[i]);
6382         }
6383         return ret;
6384 }
6385 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
6386         return owner->a;
6387 }
6388 int32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_get_a"))) TS_C2Tuple_u32TxOutZ_get_a(uint32_t owner) {
6389         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
6390         int32_t ret_conv = C2Tuple_u32TxOutZ_get_a(owner_conv);
6391         return ret_conv;
6392 }
6393
6394 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
6395         return TxOut_clone(&owner->b);
6396 }
6397 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_get_b"))) TS_C2Tuple_u32TxOutZ_get_b(uint32_t owner) {
6398         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
6399         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
6400         *ret_ref = C2Tuple_u32TxOutZ_get_b(owner_conv);
6401         return (uint32_t)ret_ref;
6402 }
6403
6404 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
6405         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
6406         for (size_t i = 0; i < ret.datalen; i++) {
6407                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
6408         }
6409         return ret;
6410 }
6411 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
6412         return ThirtyTwoBytes_clone(&owner->a);
6413 }
6414 int8_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(uint32_t owner) {
6415         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
6416         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6417         memcpy(ret_arr->elems, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(owner_conv).data, 32);
6418         return ret_arr;
6419 }
6420
6421 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
6422         return CVec_C2Tuple_u32TxOutZZ_clone(&owner->b);
6423 }
6424 uint32_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(uint32_t owner) {
6425         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
6426         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(owner_conv);
6427         uint32_tArray ret_arr = NULL;
6428         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
6429         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
6430         for (size_t u = 0; u < ret_var.datalen; u++) {
6431                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
6432                 *ret_conv_20_conv = ret_var.data[u];
6433                 ret_arr_ptr[u] = ((uint32_t)ret_conv_20_conv);
6434         }
6435         
6436         FREE(ret_var.data);
6437         return ret_arr;
6438 }
6439
6440 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
6441         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 };
6442         for (size_t i = 0; i < ret.datalen; i++) {
6443                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
6444         }
6445         return ret;
6446 }
6447 uint32_t __attribute__((export_name("TS_LDKBalance_ty_from_ptr"))) TS_LDKBalance_ty_from_ptr(uint32_t ptr) {
6448         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6449         switch(obj->tag) {
6450                 case LDKBalance_ClaimableOnChannelClose: return 0;
6451                 case LDKBalance_ClaimableAwaitingConfirmations: return 1;
6452                 case LDKBalance_ContentiousClaimable: return 2;
6453                 case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: return 3;
6454                 default: abort();
6455         }
6456 }
6457 int64_t __attribute__((export_name("TS_LDKBalance_ClaimableOnChannelClose_get_claimable_amount_satoshis"))) TS_LDKBalance_ClaimableOnChannelClose_get_claimable_amount_satoshis(uint32_t ptr) {
6458         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6459         assert(obj->tag == LDKBalance_ClaimableOnChannelClose);
6460                         int64_t claimable_amount_satoshis_conv = obj->claimable_on_channel_close.claimable_amount_satoshis;
6461         return claimable_amount_satoshis_conv;
6462 }
6463 int64_t __attribute__((export_name("TS_LDKBalance_ClaimableAwaitingConfirmations_get_claimable_amount_satoshis"))) TS_LDKBalance_ClaimableAwaitingConfirmations_get_claimable_amount_satoshis(uint32_t ptr) {
6464         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6465         assert(obj->tag == LDKBalance_ClaimableAwaitingConfirmations);
6466                         int64_t claimable_amount_satoshis_conv = obj->claimable_awaiting_confirmations.claimable_amount_satoshis;
6467         return claimable_amount_satoshis_conv;
6468 }
6469 int32_t __attribute__((export_name("TS_LDKBalance_ClaimableAwaitingConfirmations_get_confirmation_height"))) TS_LDKBalance_ClaimableAwaitingConfirmations_get_confirmation_height(uint32_t ptr) {
6470         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6471         assert(obj->tag == LDKBalance_ClaimableAwaitingConfirmations);
6472                         int32_t confirmation_height_conv = obj->claimable_awaiting_confirmations.confirmation_height;
6473         return confirmation_height_conv;
6474 }
6475 int64_t __attribute__((export_name("TS_LDKBalance_ContentiousClaimable_get_claimable_amount_satoshis"))) TS_LDKBalance_ContentiousClaimable_get_claimable_amount_satoshis(uint32_t ptr) {
6476         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6477         assert(obj->tag == LDKBalance_ContentiousClaimable);
6478                         int64_t claimable_amount_satoshis_conv = obj->contentious_claimable.claimable_amount_satoshis;
6479         return claimable_amount_satoshis_conv;
6480 }
6481 int32_t __attribute__((export_name("TS_LDKBalance_ContentiousClaimable_get_timeout_height"))) TS_LDKBalance_ContentiousClaimable_get_timeout_height(uint32_t ptr) {
6482         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6483         assert(obj->tag == LDKBalance_ContentiousClaimable);
6484                         int32_t timeout_height_conv = obj->contentious_claimable.timeout_height;
6485         return timeout_height_conv;
6486 }
6487 int64_t __attribute__((export_name("TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_amount_satoshis"))) TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_amount_satoshis(uint32_t ptr) {
6488         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6489         assert(obj->tag == LDKBalance_MaybeClaimableHTLCAwaitingTimeout);
6490                         int64_t claimable_amount_satoshis_conv = obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis;
6491         return claimable_amount_satoshis_conv;
6492 }
6493 int32_t __attribute__((export_name("TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_height"))) TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_height(uint32_t ptr) {
6494         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
6495         assert(obj->tag == LDKBalance_MaybeClaimableHTLCAwaitingTimeout);
6496                         int32_t claimable_height_conv = obj->maybe_claimable_htlc_awaiting_timeout.claimable_height;
6497         return claimable_height_conv;
6498 }
6499 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
6500         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
6501         for (size_t i = 0; i < ret.datalen; i++) {
6502                 ret.data[i] = Balance_clone(&orig->data[i]);
6503         }
6504         return ret;
6505 }
6506 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
6507         return ThirtyTwoBytes_clone(&owner->a);
6508 }
6509 int8_tArray  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_get_a"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_a(uint32_t owner) {
6510         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
6511         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
6512         memcpy(ret_arr->elems, C2Tuple_BlockHashChannelMonitorZ_get_a(owner_conv).data, 32);
6513         return ret_arr;
6514 }
6515
6516 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
6517         return ChannelMonitor_clone(&owner->b);
6518 }
6519 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_get_b"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_b(uint32_t owner) {
6520         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
6521         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(owner_conv);
6522         uint32_t ret_ref = 0;
6523         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6524         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6525         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6526         ret_ref = (uintptr_t)ret_var.inner;
6527         if (ret_var.is_owned) {
6528                 ret_ref |= 1;
6529         }
6530         return ret_ref;
6531 }
6532
6533 static inline struct LDKC2Tuple_BlockHashChannelMonitorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
6534 CHECK(owner->result_ok);
6535         return C2Tuple_BlockHashChannelMonitorZ_clone(&*owner->contents.result);
6536 }
6537 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(uint32_t owner) {
6538         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
6539         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
6540         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(owner_conv);
6541         return ((uint32_t)ret_conv);
6542 }
6543
6544 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
6545 CHECK(!owner->result_ok);
6546         return DecodeError_clone(&*owner->contents.err);
6547 }
6548 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(uint32_t owner) {
6549         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
6550         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(owner_conv);
6551         uint32_t ret_ref = 0;
6552         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6553         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6554         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6555         ret_ref = (uintptr_t)ret_var.inner;
6556         if (ret_var.is_owned) {
6557                 ret_ref |= 1;
6558         }
6559         return ret_ref;
6560 }
6561
6562 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
6563         return owner->a;
6564 }
6565 int8_tArray  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_get_a"))) TS_C2Tuple_PublicKeyTypeZ_get_a(uint32_t owner) {
6566         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
6567         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
6568         memcpy(ret_arr->elems, C2Tuple_PublicKeyTypeZ_get_a(owner_conv).compressed_form, 33);
6569         return ret_arr;
6570 }
6571
6572 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
6573         return Type_clone(&owner->b);
6574 }
6575 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_get_b"))) TS_C2Tuple_PublicKeyTypeZ_get_b(uint32_t owner) {
6576         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
6577         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
6578         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(owner_conv);
6579         return (uint32_t)ret_ret;
6580 }
6581
6582 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
6583         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
6584         for (size_t i = 0; i < ret.datalen; i++) {
6585                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
6586         }
6587         return ret;
6588 }
6589 uint32_t __attribute__((export_name("TS_LDKCOption_NetAddressZ_ty_from_ptr"))) TS_LDKCOption_NetAddressZ_ty_from_ptr(uint32_t ptr) {
6590         LDKCOption_NetAddressZ *obj = (LDKCOption_NetAddressZ*)(ptr & ~1);
6591         switch(obj->tag) {
6592                 case LDKCOption_NetAddressZ_Some: return 0;
6593                 case LDKCOption_NetAddressZ_None: return 1;
6594                 default: abort();
6595         }
6596 }
6597 uint32_t __attribute__((export_name("TS_LDKCOption_NetAddressZ_Some_get_some"))) TS_LDKCOption_NetAddressZ_Some_get_some(uint32_t ptr) {
6598         LDKCOption_NetAddressZ *obj = (LDKCOption_NetAddressZ*)(ptr & ~1);
6599         assert(obj->tag == LDKCOption_NetAddressZ_Some);
6600                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
6601         return some_ref;
6602 }
6603 static inline struct LDKCVec_u8Z CResult_CVec_u8ZPeerHandleErrorZ_get_ok(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
6604 CHECK(owner->result_ok);
6605         return CVec_u8Z_clone(&*owner->contents.result);
6606 }
6607 int8_tArray  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_get_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_get_ok(uint32_t owner) {
6608         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
6609         LDKCVec_u8Z ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_ok(owner_conv);
6610         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
6611         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
6612         CVec_u8Z_free(ret_var);
6613         return ret_arr;
6614 }
6615
6616 static inline struct LDKPeerHandleError CResult_CVec_u8ZPeerHandleErrorZ_get_err(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
6617 CHECK(!owner->result_ok);
6618         return PeerHandleError_clone(&*owner->contents.err);
6619 }
6620 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_get_err"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_get_err(uint32_t owner) {
6621         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
6622         LDKPeerHandleError ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_err(owner_conv);
6623         uint32_t ret_ref = 0;
6624         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6625         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6626         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6627         ret_ref = (uintptr_t)ret_var.inner;
6628         if (ret_var.is_owned) {
6629                 ret_ref |= 1;
6630         }
6631         return ret_ref;
6632 }
6633
6634 static inline void CResult_NonePeerHandleErrorZ_get_ok(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
6635 CHECK(owner->result_ok);
6636         return *owner->contents.result;
6637 }
6638 void  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_get_ok"))) TS_CResult_NonePeerHandleErrorZ_get_ok(uint32_t owner) {
6639         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
6640         CResult_NonePeerHandleErrorZ_get_ok(owner_conv);
6641 }
6642
6643 static inline struct LDKPeerHandleError CResult_NonePeerHandleErrorZ_get_err(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
6644 CHECK(!owner->result_ok);
6645         return PeerHandleError_clone(&*owner->contents.err);
6646 }
6647 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_get_err"))) TS_CResult_NonePeerHandleErrorZ_get_err(uint32_t owner) {
6648         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
6649         LDKPeerHandleError ret_var = CResult_NonePeerHandleErrorZ_get_err(owner_conv);
6650         uint32_t ret_ref = 0;
6651         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6652         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6653         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6654         ret_ref = (uintptr_t)ret_var.inner;
6655         if (ret_var.is_owned) {
6656                 ret_ref |= 1;
6657         }
6658         return ret_ref;
6659 }
6660
6661 static inline bool CResult_boolPeerHandleErrorZ_get_ok(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
6662 CHECK(owner->result_ok);
6663         return *owner->contents.result;
6664 }
6665 jboolean  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_get_ok"))) TS_CResult_boolPeerHandleErrorZ_get_ok(uint32_t owner) {
6666         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
6667         jboolean ret_conv = CResult_boolPeerHandleErrorZ_get_ok(owner_conv);
6668         return ret_conv;
6669 }
6670
6671 static inline struct LDKPeerHandleError CResult_boolPeerHandleErrorZ_get_err(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
6672 CHECK(!owner->result_ok);
6673         return PeerHandleError_clone(&*owner->contents.err);
6674 }
6675 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_get_err"))) TS_CResult_boolPeerHandleErrorZ_get_err(uint32_t owner) {
6676         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
6677         LDKPeerHandleError ret_var = CResult_boolPeerHandleErrorZ_get_err(owner_conv);
6678         uint32_t ret_ref = 0;
6679         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6680         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6681         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6682         ret_ref = (uintptr_t)ret_var.inner;
6683         if (ret_var.is_owned) {
6684                 ret_ref |= 1;
6685         }
6686         return ret_ref;
6687 }
6688
6689 static inline void CResult_NoneErrorZ_get_ok(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
6690 CHECK(owner->result_ok);
6691         return *owner->contents.result;
6692 }
6693 void  __attribute__((export_name("TS_CResult_NoneErrorZ_get_ok"))) TS_CResult_NoneErrorZ_get_ok(uint32_t owner) {
6694         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)(owner & ~1);
6695         CResult_NoneErrorZ_get_ok(owner_conv);
6696 }
6697
6698 static inline enum LDKIOError CResult_NoneErrorZ_get_err(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
6699 CHECK(!owner->result_ok);
6700         return *owner->contents.err;
6701 }
6702 uint32_t  __attribute__((export_name("TS_CResult_NoneErrorZ_get_err"))) TS_CResult_NoneErrorZ_get_err(uint32_t owner) {
6703         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)(owner & ~1);
6704         uint32_t ret_conv = LDKIOError_to_js(CResult_NoneErrorZ_get_err(owner_conv));
6705         return ret_conv;
6706 }
6707
6708 static inline struct LDKNetAddress CResult_NetAddressDecodeErrorZ_get_ok(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
6709 CHECK(owner->result_ok);
6710         return NetAddress_clone(&*owner->contents.result);
6711 }
6712 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_get_ok"))) TS_CResult_NetAddressDecodeErrorZ_get_ok(uint32_t owner) {
6713         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
6714         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
6715         *ret_copy = CResult_NetAddressDecodeErrorZ_get_ok(owner_conv);
6716         uint32_t ret_ref = (uintptr_t)ret_copy;
6717         return ret_ref;
6718 }
6719
6720 static inline struct LDKDecodeError CResult_NetAddressDecodeErrorZ_get_err(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
6721 CHECK(!owner->result_ok);
6722         return DecodeError_clone(&*owner->contents.err);
6723 }
6724 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_get_err"))) TS_CResult_NetAddressDecodeErrorZ_get_err(uint32_t owner) {
6725         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
6726         LDKDecodeError ret_var = CResult_NetAddressDecodeErrorZ_get_err(owner_conv);
6727         uint32_t ret_ref = 0;
6728         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6729         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6730         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6731         ret_ref = (uintptr_t)ret_var.inner;
6732         if (ret_var.is_owned) {
6733                 ret_ref |= 1;
6734         }
6735         return ret_ref;
6736 }
6737
6738 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
6739         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
6740         for (size_t i = 0; i < ret.datalen; i++) {
6741                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
6742         }
6743         return ret;
6744 }
6745 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
6746         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
6747         for (size_t i = 0; i < ret.datalen; i++) {
6748                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
6749         }
6750         return ret;
6751 }
6752 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
6753         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
6754         for (size_t i = 0; i < ret.datalen; i++) {
6755                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
6756         }
6757         return ret;
6758 }
6759 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
6760         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
6761         for (size_t i = 0; i < ret.datalen; i++) {
6762                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
6763         }
6764         return ret;
6765 }
6766 static inline struct LDKAcceptChannel CResult_AcceptChannelDecodeErrorZ_get_ok(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
6767 CHECK(owner->result_ok);
6768         return AcceptChannel_clone(&*owner->contents.result);
6769 }
6770 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_get_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_get_ok(uint32_t owner) {
6771         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
6772         LDKAcceptChannel ret_var = CResult_AcceptChannelDecodeErrorZ_get_ok(owner_conv);
6773         uint32_t ret_ref = 0;
6774         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6775         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6776         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6777         ret_ref = (uintptr_t)ret_var.inner;
6778         if (ret_var.is_owned) {
6779                 ret_ref |= 1;
6780         }
6781         return ret_ref;
6782 }
6783
6784 static inline struct LDKDecodeError CResult_AcceptChannelDecodeErrorZ_get_err(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
6785 CHECK(!owner->result_ok);
6786         return DecodeError_clone(&*owner->contents.err);
6787 }
6788 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_get_err"))) TS_CResult_AcceptChannelDecodeErrorZ_get_err(uint32_t owner) {
6789         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
6790         LDKDecodeError ret_var = CResult_AcceptChannelDecodeErrorZ_get_err(owner_conv);
6791         uint32_t ret_ref = 0;
6792         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6793         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6794         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6795         ret_ref = (uintptr_t)ret_var.inner;
6796         if (ret_var.is_owned) {
6797                 ret_ref |= 1;
6798         }
6799         return ret_ref;
6800 }
6801
6802 static inline struct LDKAnnouncementSignatures CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
6803 CHECK(owner->result_ok);
6804         return AnnouncementSignatures_clone(&*owner->contents.result);
6805 }
6806 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(uint32_t owner) {
6807         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
6808         LDKAnnouncementSignatures ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(owner_conv);
6809         uint32_t ret_ref = 0;
6810         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6811         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6812         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6813         ret_ref = (uintptr_t)ret_var.inner;
6814         if (ret_var.is_owned) {
6815                 ret_ref |= 1;
6816         }
6817         return ret_ref;
6818 }
6819
6820 static inline struct LDKDecodeError CResult_AnnouncementSignaturesDecodeErrorZ_get_err(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
6821 CHECK(!owner->result_ok);
6822         return DecodeError_clone(&*owner->contents.err);
6823 }
6824 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_err"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_err(uint32_t owner) {
6825         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
6826         LDKDecodeError ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_err(owner_conv);
6827         uint32_t ret_ref = 0;
6828         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6829         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6830         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6831         ret_ref = (uintptr_t)ret_var.inner;
6832         if (ret_var.is_owned) {
6833                 ret_ref |= 1;
6834         }
6835         return ret_ref;
6836 }
6837
6838 static inline struct LDKChannelReestablish CResult_ChannelReestablishDecodeErrorZ_get_ok(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
6839 CHECK(owner->result_ok);
6840         return ChannelReestablish_clone(&*owner->contents.result);
6841 }
6842 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_get_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_get_ok(uint32_t owner) {
6843         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
6844         LDKChannelReestablish ret_var = CResult_ChannelReestablishDecodeErrorZ_get_ok(owner_conv);
6845         uint32_t ret_ref = 0;
6846         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6847         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6848         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6849         ret_ref = (uintptr_t)ret_var.inner;
6850         if (ret_var.is_owned) {
6851                 ret_ref |= 1;
6852         }
6853         return ret_ref;
6854 }
6855
6856 static inline struct LDKDecodeError CResult_ChannelReestablishDecodeErrorZ_get_err(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
6857 CHECK(!owner->result_ok);
6858         return DecodeError_clone(&*owner->contents.err);
6859 }
6860 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_get_err"))) TS_CResult_ChannelReestablishDecodeErrorZ_get_err(uint32_t owner) {
6861         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
6862         LDKDecodeError ret_var = CResult_ChannelReestablishDecodeErrorZ_get_err(owner_conv);
6863         uint32_t ret_ref = 0;
6864         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6865         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6866         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6867         ret_ref = (uintptr_t)ret_var.inner;
6868         if (ret_var.is_owned) {
6869                 ret_ref |= 1;
6870         }
6871         return ret_ref;
6872 }
6873
6874 static inline struct LDKClosingSigned CResult_ClosingSignedDecodeErrorZ_get_ok(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
6875 CHECK(owner->result_ok);
6876         return ClosingSigned_clone(&*owner->contents.result);
6877 }
6878 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_get_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_get_ok(uint32_t owner) {
6879         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
6880         LDKClosingSigned ret_var = CResult_ClosingSignedDecodeErrorZ_get_ok(owner_conv);
6881         uint32_t ret_ref = 0;
6882         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6883         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6884         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6885         ret_ref = (uintptr_t)ret_var.inner;
6886         if (ret_var.is_owned) {
6887                 ret_ref |= 1;
6888         }
6889         return ret_ref;
6890 }
6891
6892 static inline struct LDKDecodeError CResult_ClosingSignedDecodeErrorZ_get_err(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
6893 CHECK(!owner->result_ok);
6894         return DecodeError_clone(&*owner->contents.err);
6895 }
6896 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_get_err"))) TS_CResult_ClosingSignedDecodeErrorZ_get_err(uint32_t owner) {
6897         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
6898         LDKDecodeError ret_var = CResult_ClosingSignedDecodeErrorZ_get_err(owner_conv);
6899         uint32_t ret_ref = 0;
6900         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6901         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6902         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6903         ret_ref = (uintptr_t)ret_var.inner;
6904         if (ret_var.is_owned) {
6905                 ret_ref |= 1;
6906         }
6907         return ret_ref;
6908 }
6909
6910 static inline struct LDKClosingSignedFeeRange CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
6911 CHECK(owner->result_ok);
6912         return ClosingSignedFeeRange_clone(&*owner->contents.result);
6913 }
6914 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(uint32_t owner) {
6915         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
6916         LDKClosingSignedFeeRange ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(owner_conv);
6917         uint32_t ret_ref = 0;
6918         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6919         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6920         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6921         ret_ref = (uintptr_t)ret_var.inner;
6922         if (ret_var.is_owned) {
6923                 ret_ref |= 1;
6924         }
6925         return ret_ref;
6926 }
6927
6928 static inline struct LDKDecodeError CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
6929 CHECK(!owner->result_ok);
6930         return DecodeError_clone(&*owner->contents.err);
6931 }
6932 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(uint32_t owner) {
6933         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
6934         LDKDecodeError ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(owner_conv);
6935         uint32_t ret_ref = 0;
6936         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6937         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6938         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6939         ret_ref = (uintptr_t)ret_var.inner;
6940         if (ret_var.is_owned) {
6941                 ret_ref |= 1;
6942         }
6943         return ret_ref;
6944 }
6945
6946 static inline struct LDKCommitmentSigned CResult_CommitmentSignedDecodeErrorZ_get_ok(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
6947 CHECK(owner->result_ok);
6948         return CommitmentSigned_clone(&*owner->contents.result);
6949 }
6950 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_get_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_get_ok(uint32_t owner) {
6951         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
6952         LDKCommitmentSigned ret_var = CResult_CommitmentSignedDecodeErrorZ_get_ok(owner_conv);
6953         uint32_t ret_ref = 0;
6954         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6955         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6956         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6957         ret_ref = (uintptr_t)ret_var.inner;
6958         if (ret_var.is_owned) {
6959                 ret_ref |= 1;
6960         }
6961         return ret_ref;
6962 }
6963
6964 static inline struct LDKDecodeError CResult_CommitmentSignedDecodeErrorZ_get_err(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
6965 CHECK(!owner->result_ok);
6966         return DecodeError_clone(&*owner->contents.err);
6967 }
6968 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_get_err"))) TS_CResult_CommitmentSignedDecodeErrorZ_get_err(uint32_t owner) {
6969         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
6970         LDKDecodeError ret_var = CResult_CommitmentSignedDecodeErrorZ_get_err(owner_conv);
6971         uint32_t ret_ref = 0;
6972         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6973         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6974         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6975         ret_ref = (uintptr_t)ret_var.inner;
6976         if (ret_var.is_owned) {
6977                 ret_ref |= 1;
6978         }
6979         return ret_ref;
6980 }
6981
6982 static inline struct LDKFundingCreated CResult_FundingCreatedDecodeErrorZ_get_ok(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
6983 CHECK(owner->result_ok);
6984         return FundingCreated_clone(&*owner->contents.result);
6985 }
6986 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_get_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_get_ok(uint32_t owner) {
6987         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
6988         LDKFundingCreated ret_var = CResult_FundingCreatedDecodeErrorZ_get_ok(owner_conv);
6989         uint32_t ret_ref = 0;
6990         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6991         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6992         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6993         ret_ref = (uintptr_t)ret_var.inner;
6994         if (ret_var.is_owned) {
6995                 ret_ref |= 1;
6996         }
6997         return ret_ref;
6998 }
6999
7000 static inline struct LDKDecodeError CResult_FundingCreatedDecodeErrorZ_get_err(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
7001 CHECK(!owner->result_ok);
7002         return DecodeError_clone(&*owner->contents.err);
7003 }
7004 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_get_err"))) TS_CResult_FundingCreatedDecodeErrorZ_get_err(uint32_t owner) {
7005         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
7006         LDKDecodeError ret_var = CResult_FundingCreatedDecodeErrorZ_get_err(owner_conv);
7007         uint32_t ret_ref = 0;
7008         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7009         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7010         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7011         ret_ref = (uintptr_t)ret_var.inner;
7012         if (ret_var.is_owned) {
7013                 ret_ref |= 1;
7014         }
7015         return ret_ref;
7016 }
7017
7018 static inline struct LDKFundingSigned CResult_FundingSignedDecodeErrorZ_get_ok(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
7019 CHECK(owner->result_ok);
7020         return FundingSigned_clone(&*owner->contents.result);
7021 }
7022 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_get_ok"))) TS_CResult_FundingSignedDecodeErrorZ_get_ok(uint32_t owner) {
7023         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
7024         LDKFundingSigned ret_var = CResult_FundingSignedDecodeErrorZ_get_ok(owner_conv);
7025         uint32_t ret_ref = 0;
7026         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7027         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7028         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7029         ret_ref = (uintptr_t)ret_var.inner;
7030         if (ret_var.is_owned) {
7031                 ret_ref |= 1;
7032         }
7033         return ret_ref;
7034 }
7035
7036 static inline struct LDKDecodeError CResult_FundingSignedDecodeErrorZ_get_err(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
7037 CHECK(!owner->result_ok);
7038         return DecodeError_clone(&*owner->contents.err);
7039 }
7040 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_get_err"))) TS_CResult_FundingSignedDecodeErrorZ_get_err(uint32_t owner) {
7041         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
7042         LDKDecodeError ret_var = CResult_FundingSignedDecodeErrorZ_get_err(owner_conv);
7043         uint32_t ret_ref = 0;
7044         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7045         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7046         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7047         ret_ref = (uintptr_t)ret_var.inner;
7048         if (ret_var.is_owned) {
7049                 ret_ref |= 1;
7050         }
7051         return ret_ref;
7052 }
7053
7054 static inline struct LDKChannelReady CResult_ChannelReadyDecodeErrorZ_get_ok(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
7055 CHECK(owner->result_ok);
7056         return ChannelReady_clone(&*owner->contents.result);
7057 }
7058 uint32_t  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_get_ok"))) TS_CResult_ChannelReadyDecodeErrorZ_get_ok(uint32_t owner) {
7059         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(owner & ~1);
7060         LDKChannelReady ret_var = CResult_ChannelReadyDecodeErrorZ_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_ChannelReadyDecodeErrorZ_get_err(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
7073 CHECK(!owner->result_ok);
7074         return DecodeError_clone(&*owner->contents.err);
7075 }
7076 uint32_t  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_get_err"))) TS_CResult_ChannelReadyDecodeErrorZ_get_err(uint32_t owner) {
7077         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(owner & ~1);
7078         LDKDecodeError ret_var = CResult_ChannelReadyDecodeErrorZ_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 LDKInit CResult_InitDecodeErrorZ_get_ok(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
7091 CHECK(owner->result_ok);
7092         return Init_clone(&*owner->contents.result);
7093 }
7094 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_get_ok"))) TS_CResult_InitDecodeErrorZ_get_ok(uint32_t owner) {
7095         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
7096         LDKInit ret_var = CResult_InitDecodeErrorZ_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_InitDecodeErrorZ_get_err(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
7109 CHECK(!owner->result_ok);
7110         return DecodeError_clone(&*owner->contents.err);
7111 }
7112 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_get_err"))) TS_CResult_InitDecodeErrorZ_get_err(uint32_t owner) {
7113         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
7114         LDKDecodeError ret_var = CResult_InitDecodeErrorZ_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 LDKOpenChannel CResult_OpenChannelDecodeErrorZ_get_ok(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
7127 CHECK(owner->result_ok);
7128         return OpenChannel_clone(&*owner->contents.result);
7129 }
7130 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_get_ok"))) TS_CResult_OpenChannelDecodeErrorZ_get_ok(uint32_t owner) {
7131         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
7132         LDKOpenChannel ret_var = CResult_OpenChannelDecodeErrorZ_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_OpenChannelDecodeErrorZ_get_err(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
7145 CHECK(!owner->result_ok);
7146         return DecodeError_clone(&*owner->contents.err);
7147 }
7148 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_get_err"))) TS_CResult_OpenChannelDecodeErrorZ_get_err(uint32_t owner) {
7149         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
7150         LDKDecodeError ret_var = CResult_OpenChannelDecodeErrorZ_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 LDKRevokeAndACK CResult_RevokeAndACKDecodeErrorZ_get_ok(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
7163 CHECK(owner->result_ok);
7164         return RevokeAndACK_clone(&*owner->contents.result);
7165 }
7166 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_get_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_get_ok(uint32_t owner) {
7167         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
7168         LDKRevokeAndACK ret_var = CResult_RevokeAndACKDecodeErrorZ_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_RevokeAndACKDecodeErrorZ_get_err(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
7181 CHECK(!owner->result_ok);
7182         return DecodeError_clone(&*owner->contents.err);
7183 }
7184 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_get_err"))) TS_CResult_RevokeAndACKDecodeErrorZ_get_err(uint32_t owner) {
7185         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
7186         LDKDecodeError ret_var = CResult_RevokeAndACKDecodeErrorZ_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 LDKShutdown CResult_ShutdownDecodeErrorZ_get_ok(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
7199 CHECK(owner->result_ok);
7200         return Shutdown_clone(&*owner->contents.result);
7201 }
7202 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_get_ok"))) TS_CResult_ShutdownDecodeErrorZ_get_ok(uint32_t owner) {
7203         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
7204         LDKShutdown ret_var = CResult_ShutdownDecodeErrorZ_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_ShutdownDecodeErrorZ_get_err(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
7217 CHECK(!owner->result_ok);
7218         return DecodeError_clone(&*owner->contents.err);
7219 }
7220 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_get_err"))) TS_CResult_ShutdownDecodeErrorZ_get_err(uint32_t owner) {
7221         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
7222         LDKDecodeError ret_var = CResult_ShutdownDecodeErrorZ_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 LDKUpdateFailHTLC CResult_UpdateFailHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
7235 CHECK(owner->result_ok);
7236         return UpdateFailHTLC_clone(&*owner->contents.result);
7237 }
7238 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7239         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
7240         LDKUpdateFailHTLC ret_var = CResult_UpdateFailHTLCDecodeErrorZ_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_UpdateFailHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
7253 CHECK(!owner->result_ok);
7254         return DecodeError_clone(&*owner->contents.err);
7255 }
7256 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_get_err(uint32_t owner) {
7257         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
7258         LDKDecodeError ret_var = CResult_UpdateFailHTLCDecodeErrorZ_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 LDKUpdateFailMalformedHTLC CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
7271 CHECK(owner->result_ok);
7272         return UpdateFailMalformedHTLC_clone(&*owner->contents.result);
7273 }
7274 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7275         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
7276         LDKUpdateFailMalformedHTLC ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_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_UpdateFailMalformedHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
7289 CHECK(!owner->result_ok);
7290         return DecodeError_clone(&*owner->contents.err);
7291 }
7292 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(uint32_t owner) {
7293         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
7294         LDKDecodeError ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_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 LDKUpdateFee CResult_UpdateFeeDecodeErrorZ_get_ok(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
7307 CHECK(owner->result_ok);
7308         return UpdateFee_clone(&*owner->contents.result);
7309 }
7310 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_get_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_get_ok(uint32_t owner) {
7311         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
7312         LDKUpdateFee ret_var = CResult_UpdateFeeDecodeErrorZ_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_UpdateFeeDecodeErrorZ_get_err(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
7325 CHECK(!owner->result_ok);
7326         return DecodeError_clone(&*owner->contents.err);
7327 }
7328 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_get_err"))) TS_CResult_UpdateFeeDecodeErrorZ_get_err(uint32_t owner) {
7329         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
7330         LDKDecodeError ret_var = CResult_UpdateFeeDecodeErrorZ_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 LDKUpdateFulfillHTLC CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
7343 CHECK(owner->result_ok);
7344         return UpdateFulfillHTLC_clone(&*owner->contents.result);
7345 }
7346 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7347         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
7348         LDKUpdateFulfillHTLC ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_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_UpdateFulfillHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
7361 CHECK(!owner->result_ok);
7362         return DecodeError_clone(&*owner->contents.err);
7363 }
7364 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(uint32_t owner) {
7365         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
7366         LDKDecodeError ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_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 LDKUpdateAddHTLC CResult_UpdateAddHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
7379 CHECK(owner->result_ok);
7380         return UpdateAddHTLC_clone(&*owner->contents.result);
7381 }
7382 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7383         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
7384         LDKUpdateAddHTLC ret_var = CResult_UpdateAddHTLCDecodeErrorZ_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_UpdateAddHTLCDecodeErrorZ_get_err(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
7397 CHECK(!owner->result_ok);
7398         return DecodeError_clone(&*owner->contents.err);
7399 }
7400 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_get_err(uint32_t owner) {
7401         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
7402         LDKDecodeError ret_var = CResult_UpdateAddHTLCDecodeErrorZ_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 LDKPing CResult_PingDecodeErrorZ_get_ok(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
7415 CHECK(owner->result_ok);
7416         return Ping_clone(&*owner->contents.result);
7417 }
7418 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_get_ok"))) TS_CResult_PingDecodeErrorZ_get_ok(uint32_t owner) {
7419         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
7420         LDKPing ret_var = CResult_PingDecodeErrorZ_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_PingDecodeErrorZ_get_err(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
7433 CHECK(!owner->result_ok);
7434         return DecodeError_clone(&*owner->contents.err);
7435 }
7436 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_get_err"))) TS_CResult_PingDecodeErrorZ_get_err(uint32_t owner) {
7437         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
7438         LDKDecodeError ret_var = CResult_PingDecodeErrorZ_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 LDKPong CResult_PongDecodeErrorZ_get_ok(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
7451 CHECK(owner->result_ok);
7452         return Pong_clone(&*owner->contents.result);
7453 }
7454 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_get_ok"))) TS_CResult_PongDecodeErrorZ_get_ok(uint32_t owner) {
7455         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
7456         LDKPong ret_var = CResult_PongDecodeErrorZ_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_PongDecodeErrorZ_get_err(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
7469 CHECK(!owner->result_ok);
7470         return DecodeError_clone(&*owner->contents.err);
7471 }
7472 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_get_err"))) TS_CResult_PongDecodeErrorZ_get_err(uint32_t owner) {
7473         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
7474         LDKDecodeError ret_var = CResult_PongDecodeErrorZ_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 LDKUnsignedChannelAnnouncement CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7487 CHECK(owner->result_ok);
7488         return UnsignedChannelAnnouncement_clone(&*owner->contents.result);
7489 }
7490 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7491         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7492         LDKUnsignedChannelAnnouncement ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_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_UnsignedChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7505 CHECK(!owner->result_ok);
7506         return DecodeError_clone(&*owner->contents.err);
7507 }
7508 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7509         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7510         LDKDecodeError ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_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 LDKChannelAnnouncement CResult_ChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7523 CHECK(owner->result_ok);
7524         return ChannelAnnouncement_clone(&*owner->contents.result);
7525 }
7526 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7527         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7528         LDKChannelAnnouncement ret_var = CResult_ChannelAnnouncementDecodeErrorZ_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_ChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7541 CHECK(!owner->result_ok);
7542         return DecodeError_clone(&*owner->contents.err);
7543 }
7544 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_get_err"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7545         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7546         LDKDecodeError ret_var = CResult_ChannelAnnouncementDecodeErrorZ_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 LDKUnsignedChannelUpdate CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7559 CHECK(owner->result_ok);
7560         return UnsignedChannelUpdate_clone(&*owner->contents.result);
7561 }
7562 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(uint32_t owner) {
7563         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
7564         LDKUnsignedChannelUpdate ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_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_UnsignedChannelUpdateDecodeErrorZ_get_err(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7577 CHECK(!owner->result_ok);
7578         return DecodeError_clone(&*owner->contents.err);
7579 }
7580 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_err"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(uint32_t owner) {
7581         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
7582         LDKDecodeError ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_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 LDKChannelUpdate CResult_ChannelUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7595 CHECK(owner->result_ok);
7596         return ChannelUpdate_clone(&*owner->contents.result);
7597 }
7598 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_get_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_get_ok(uint32_t owner) {
7599         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
7600         LDKChannelUpdate ret_var = CResult_ChannelUpdateDecodeErrorZ_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_ChannelUpdateDecodeErrorZ_get_err(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7613 CHECK(!owner->result_ok);
7614         return DecodeError_clone(&*owner->contents.err);
7615 }
7616 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_get_err"))) TS_CResult_ChannelUpdateDecodeErrorZ_get_err(uint32_t owner) {
7617         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
7618         LDKDecodeError ret_var = CResult_ChannelUpdateDecodeErrorZ_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 LDKErrorMessage CResult_ErrorMessageDecodeErrorZ_get_ok(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
7631 CHECK(owner->result_ok);
7632         return ErrorMessage_clone(&*owner->contents.result);
7633 }
7634 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_get_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_get_ok(uint32_t owner) {
7635         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
7636         LDKErrorMessage ret_var = CResult_ErrorMessageDecodeErrorZ_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_ErrorMessageDecodeErrorZ_get_err(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
7649 CHECK(!owner->result_ok);
7650         return DecodeError_clone(&*owner->contents.err);
7651 }
7652 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_get_err"))) TS_CResult_ErrorMessageDecodeErrorZ_get_err(uint32_t owner) {
7653         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
7654         LDKDecodeError ret_var = CResult_ErrorMessageDecodeErrorZ_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 LDKWarningMessage CResult_WarningMessageDecodeErrorZ_get_ok(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
7667 CHECK(owner->result_ok);
7668         return WarningMessage_clone(&*owner->contents.result);
7669 }
7670 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_get_ok"))) TS_CResult_WarningMessageDecodeErrorZ_get_ok(uint32_t owner) {
7671         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
7672         LDKWarningMessage ret_var = CResult_WarningMessageDecodeErrorZ_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_WarningMessageDecodeErrorZ_get_err(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
7685 CHECK(!owner->result_ok);
7686         return DecodeError_clone(&*owner->contents.err);
7687 }
7688 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_get_err"))) TS_CResult_WarningMessageDecodeErrorZ_get_err(uint32_t owner) {
7689         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
7690         LDKDecodeError ret_var = CResult_WarningMessageDecodeErrorZ_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 LDKUnsignedNodeAnnouncement CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7703 CHECK(owner->result_ok);
7704         return UnsignedNodeAnnouncement_clone(&*owner->contents.result);
7705 }
7706 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7707         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
7708         LDKUnsignedNodeAnnouncement ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_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_UnsignedNodeAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7721 CHECK(!owner->result_ok);
7722         return DecodeError_clone(&*owner->contents.err);
7723 }
7724 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7725         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
7726         LDKDecodeError ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_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 LDKNodeAnnouncement CResult_NodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7739 CHECK(owner->result_ok);
7740         return NodeAnnouncement_clone(&*owner->contents.result);
7741 }
7742 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7743         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
7744         LDKNodeAnnouncement ret_var = CResult_NodeAnnouncementDecodeErrorZ_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_NodeAnnouncementDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7757 CHECK(!owner->result_ok);
7758         return DecodeError_clone(&*owner->contents.err);
7759 }
7760 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_get_err"))) TS_CResult_NodeAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7761         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
7762         LDKDecodeError ret_var = CResult_NodeAnnouncementDecodeErrorZ_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 LDKQueryShortChannelIds CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
7775 CHECK(owner->result_ok);
7776         return QueryShortChannelIds_clone(&*owner->contents.result);
7777 }
7778 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(uint32_t owner) {
7779         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
7780         LDKQueryShortChannelIds ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_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_QueryShortChannelIdsDecodeErrorZ_get_err(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
7793 CHECK(!owner->result_ok);
7794         return DecodeError_clone(&*owner->contents.err);
7795 }
7796 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_err"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_err(uint32_t owner) {
7797         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
7798         LDKDecodeError ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_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 LDKReplyShortChannelIdsEnd CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
7811 CHECK(owner->result_ok);
7812         return ReplyShortChannelIdsEnd_clone(&*owner->contents.result);
7813 }
7814 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(uint32_t owner) {
7815         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
7816         LDKReplyShortChannelIdsEnd ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_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_ReplyShortChannelIdsEndDecodeErrorZ_get_err(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
7829 CHECK(!owner->result_ok);
7830         return DecodeError_clone(&*owner->contents.err);
7831 }
7832 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(uint32_t owner) {
7833         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
7834         LDKDecodeError ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_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 LDKQueryChannelRange CResult_QueryChannelRangeDecodeErrorZ_get_ok(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
7847 CHECK(owner->result_ok);
7848         return QueryChannelRange_clone(&*owner->contents.result);
7849 }
7850 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_get_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_get_ok(uint32_t owner) {
7851         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
7852         LDKQueryChannelRange ret_var = CResult_QueryChannelRangeDecodeErrorZ_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_QueryChannelRangeDecodeErrorZ_get_err(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
7865 CHECK(!owner->result_ok);
7866         return DecodeError_clone(&*owner->contents.err);
7867 }
7868 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_get_err"))) TS_CResult_QueryChannelRangeDecodeErrorZ_get_err(uint32_t owner) {
7869         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
7870         LDKDecodeError ret_var = CResult_QueryChannelRangeDecodeErrorZ_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 LDKReplyChannelRange CResult_ReplyChannelRangeDecodeErrorZ_get_ok(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
7883 CHECK(owner->result_ok);
7884         return ReplyChannelRange_clone(&*owner->contents.result);
7885 }
7886 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_get_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_get_ok(uint32_t owner) {
7887         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
7888         LDKReplyChannelRange ret_var = CResult_ReplyChannelRangeDecodeErrorZ_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_ReplyChannelRangeDecodeErrorZ_get_err(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
7901 CHECK(!owner->result_ok);
7902         return DecodeError_clone(&*owner->contents.err);
7903 }
7904 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_get_err"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_get_err(uint32_t owner) {
7905         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
7906         LDKDecodeError ret_var = CResult_ReplyChannelRangeDecodeErrorZ_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 LDKGossipTimestampFilter CResult_GossipTimestampFilterDecodeErrorZ_get_ok(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
7919 CHECK(owner->result_ok);
7920         return GossipTimestampFilter_clone(&*owner->contents.result);
7921 }
7922 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_get_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_get_ok(uint32_t owner) {
7923         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
7924         LDKGossipTimestampFilter ret_var = CResult_GossipTimestampFilterDecodeErrorZ_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_GossipTimestampFilterDecodeErrorZ_get_err(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
7937 CHECK(!owner->result_ok);
7938         return DecodeError_clone(&*owner->contents.err);
7939 }
7940 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_get_err"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_get_err(uint32_t owner) {
7941         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
7942         LDKDecodeError ret_var = CResult_GossipTimestampFilterDecodeErrorZ_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 uint32_t __attribute__((export_name("TS_LDKSignOrCreationError_ty_from_ptr"))) TS_LDKSignOrCreationError_ty_from_ptr(uint32_t ptr) {
7955         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
7956         switch(obj->tag) {
7957                 case LDKSignOrCreationError_SignError: return 0;
7958                 case LDKSignOrCreationError_CreationError: return 1;
7959                 default: abort();
7960         }
7961 }
7962 uint32_t __attribute__((export_name("TS_LDKSignOrCreationError_CreationError_get_creation_error"))) TS_LDKSignOrCreationError_CreationError_get_creation_error(uint32_t ptr) {
7963         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
7964         assert(obj->tag == LDKSignOrCreationError_CreationError);
7965                         uint32_t creation_error_conv = LDKCreationError_to_js(obj->creation_error);
7966         return creation_error_conv;
7967 }
7968 static inline struct LDKInvoice CResult_InvoiceSignOrCreationErrorZ_get_ok(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
7969 CHECK(owner->result_ok);
7970         return Invoice_clone(&*owner->contents.result);
7971 }
7972 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_get_ok"))) TS_CResult_InvoiceSignOrCreationErrorZ_get_ok(uint32_t owner) {
7973         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
7974         LDKInvoice ret_var = CResult_InvoiceSignOrCreationErrorZ_get_ok(owner_conv);
7975         uint32_t ret_ref = 0;
7976         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7977         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7978         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7979         ret_ref = (uintptr_t)ret_var.inner;
7980         if (ret_var.is_owned) {
7981                 ret_ref |= 1;
7982         }
7983         return ret_ref;
7984 }
7985
7986 static inline struct LDKSignOrCreationError CResult_InvoiceSignOrCreationErrorZ_get_err(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
7987 CHECK(!owner->result_ok);
7988         return SignOrCreationError_clone(&*owner->contents.err);
7989 }
7990 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_get_err"))) TS_CResult_InvoiceSignOrCreationErrorZ_get_err(uint32_t owner) {
7991         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
7992         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
7993         *ret_copy = CResult_InvoiceSignOrCreationErrorZ_get_err(owner_conv);
7994         uint32_t ret_ref = (uintptr_t)ret_copy;
7995         return ret_ref;
7996 }
7997
7998 typedef struct LDKFilter_JCalls {
7999         atomic_size_t refcnt;
8000         uint32_t instance_ptr;
8001 } LDKFilter_JCalls;
8002 static void LDKFilter_JCalls_free(void* this_arg) {
8003         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
8004         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8005                 FREE(j_calls);
8006         }
8007 }
8008 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
8009         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
8010         int8_tArray txid_arr = init_int8_tArray(32, __LINE__);
8011         memcpy(txid_arr->elems, *txid, 32);
8012         LDKu8slice script_pubkey_var = script_pubkey;
8013         int8_tArray script_pubkey_arr = init_int8_tArray(script_pubkey_var.datalen, __LINE__);
8014         memcpy(script_pubkey_arr->elems, script_pubkey_var.data, script_pubkey_var.datalen);
8015         js_invoke_function_2(j_calls->instance_ptr, 32, (uint32_t)txid_arr, (uint32_t)script_pubkey_arr);
8016 }
8017 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
8018         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
8019         LDKWatchedOutput output_var = output;
8020         uint32_t output_ref = 0;
8021         CHECK((((uintptr_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8022         CHECK((((uintptr_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8023         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
8024         output_ref = (uintptr_t)output_var.inner;
8025         if (output_var.is_owned) {
8026                 output_ref |= 1;
8027         }
8028         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 33, (uint32_t)output_ref);
8029         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8030         CHECK_ACCESS(ret_ptr);
8031         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(ret_ptr);
8032         FREE((void*)ret);
8033         return ret_conv;
8034 }
8035 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
8036         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
8037         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8038 }
8039 static inline LDKFilter LDKFilter_init (JSValue o) {
8040         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
8041         atomic_init(&calls->refcnt, 1);
8042         calls->instance_ptr = o;
8043
8044         LDKFilter ret = {
8045                 .this_arg = (void*) calls,
8046                 .register_tx = register_tx_LDKFilter_jcall,
8047                 .register_output = register_output_LDKFilter_jcall,
8048                 .free = LDKFilter_JCalls_free,
8049         };
8050         return ret;
8051 }
8052 long  __attribute__((export_name("TS_LDKFilter_new"))) TS_LDKFilter_new(JSValue o) {
8053         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
8054         *res_ptr = LDKFilter_init(o);
8055         return (long)res_ptr;
8056 }
8057 void  __attribute__((export_name("TS_Filter_register_tx"))) TS_Filter_register_tx(uint32_t this_arg, int8_tArray txid, int8_tArray script_pubkey) {
8058         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8059         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8060         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
8061         unsigned char txid_arr[32];
8062         CHECK(txid->arr_len == 32);
8063         memcpy(txid_arr, txid->elems, 32); FREE(txid);
8064         unsigned char (*txid_ref)[32] = &txid_arr;
8065         LDKu8slice script_pubkey_ref;
8066         script_pubkey_ref.datalen = script_pubkey->arr_len;
8067         script_pubkey_ref.data = script_pubkey->elems /* XXX script_pubkey leaks */;
8068         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
8069 }
8070
8071 uint32_t  __attribute__((export_name("TS_Filter_register_output"))) TS_Filter_register_output(uint32_t this_arg, uint32_t output) {
8072         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8073         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8074         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
8075         LDKWatchedOutput output_conv;
8076         output_conv.inner = (void*)(output & (~1));
8077         output_conv.is_owned = (output & 1) || (output == 0);
8078         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
8079         output_conv = WatchedOutput_clone(&output_conv);
8080         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
8081         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
8082         uint32_t ret_ref = (uintptr_t)ret_copy;
8083         return ret_ref;
8084 }
8085
8086 uint32_t __attribute__((export_name("TS_LDKCOption_FilterZ_ty_from_ptr"))) TS_LDKCOption_FilterZ_ty_from_ptr(uint32_t ptr) {
8087         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
8088         switch(obj->tag) {
8089                 case LDKCOption_FilterZ_Some: return 0;
8090                 case LDKCOption_FilterZ_None: return 1;
8091                 default: abort();
8092         }
8093 }
8094 uint32_t __attribute__((export_name("TS_LDKCOption_FilterZ_Some_get_some"))) TS_LDKCOption_FilterZ_Some_get_some(uint32_t ptr) {
8095         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
8096         assert(obj->tag == LDKCOption_FilterZ_Some);
8097                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
8098                         *some_ret = obj->some;
8099                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
8100                         if ((*some_ret).free == LDKFilter_JCalls_free) {
8101                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
8102                                 LDKFilter_JCalls_cloned(&(*some_ret));
8103                         }
8104         return (uint32_t)some_ret;
8105 }
8106 static inline struct LDKLockedChannelMonitor *CResult_LockedChannelMonitorNoneZ_get_ok(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
8107 CHECK(owner->result_ok);
8108         return &*owner->contents.result;
8109 }
8110 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_get_ok"))) TS_CResult_LockedChannelMonitorNoneZ_get_ok(uint32_t owner) {
8111         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
8112         LDKLockedChannelMonitor ret_var = *CResult_LockedChannelMonitorNoneZ_get_ok(owner_conv);
8113         uint32_t ret_ref = 0;
8114         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8115         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8116         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8117         ret_ref = (uintptr_t)ret_var.inner & ~1;
8118         return ret_ref;
8119 }
8120
8121 static inline void CResult_LockedChannelMonitorNoneZ_get_err(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
8122 CHECK(!owner->result_ok);
8123         return *owner->contents.err;
8124 }
8125 void  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_get_err"))) TS_CResult_LockedChannelMonitorNoneZ_get_err(uint32_t owner) {
8126         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
8127         CResult_LockedChannelMonitorNoneZ_get_err(owner_conv);
8128 }
8129
8130 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
8131         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
8132         for (size_t i = 0; i < ret.datalen; i++) {
8133                 ret.data[i] = OutPoint_clone(&orig->data[i]);
8134         }
8135         return ret;
8136 }
8137 typedef struct LDKMessageSendEventsProvider_JCalls {
8138         atomic_size_t refcnt;
8139         uint32_t instance_ptr;
8140 } LDKMessageSendEventsProvider_JCalls;
8141 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
8142         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
8143         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8144                 FREE(j_calls);
8145         }
8146 }
8147 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
8148         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
8149         uint32_tArray ret = (uint32_tArray)js_invoke_function_0(j_calls->instance_ptr, 34);
8150         LDKCVec_MessageSendEventZ ret_constr;
8151         ret_constr.datalen = ret->arr_len;
8152         if (ret_constr.datalen > 0)
8153                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
8154         else
8155                 ret_constr.data = NULL;
8156         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
8157         for (size_t s = 0; s < ret_constr.datalen; s++) {
8158                 uint32_t ret_conv_18 = ret_vals[s];
8159                 void* ret_conv_18_ptr = (void*)(((uintptr_t)ret_conv_18) & ~1);
8160                 CHECK_ACCESS(ret_conv_18_ptr);
8161                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
8162                 FREE((void*)ret_conv_18);
8163                 ret_constr.data[s] = ret_conv_18_conv;
8164         }
8165         return ret_constr;
8166 }
8167 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
8168         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
8169         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8170 }
8171 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JSValue o) {
8172         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
8173         atomic_init(&calls->refcnt, 1);
8174         calls->instance_ptr = o;
8175
8176         LDKMessageSendEventsProvider ret = {
8177                 .this_arg = (void*) calls,
8178                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
8179                 .free = LDKMessageSendEventsProvider_JCalls_free,
8180         };
8181         return ret;
8182 }
8183 long  __attribute__((export_name("TS_LDKMessageSendEventsProvider_new"))) TS_LDKMessageSendEventsProvider_new(JSValue o) {
8184         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
8185         *res_ptr = LDKMessageSendEventsProvider_init(o);
8186         return (long)res_ptr;
8187 }
8188 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) {
8189         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8190         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8191         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
8192         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
8193         uint32_tArray ret_arr = NULL;
8194         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
8195         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
8196         for (size_t s = 0; s < ret_var.datalen; s++) {
8197                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
8198                 *ret_conv_18_copy = ret_var.data[s];
8199                 uint32_t ret_conv_18_ref = (uintptr_t)ret_conv_18_copy;
8200                 ret_arr_ptr[s] = ret_conv_18_ref;
8201         }
8202         
8203         FREE(ret_var.data);
8204         return ret_arr;
8205 }
8206
8207 typedef struct LDKEventHandler_JCalls {
8208         atomic_size_t refcnt;
8209         uint32_t instance_ptr;
8210 } LDKEventHandler_JCalls;
8211 static void LDKEventHandler_JCalls_free(void* this_arg) {
8212         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
8213         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8214                 FREE(j_calls);
8215         }
8216 }
8217 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
8218         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
8219         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
8220         *ret_event = Event_clone(event);
8221         js_invoke_function_1(j_calls->instance_ptr, 35, (uint32_t)(uint32_t)ret_event);
8222 }
8223 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
8224         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
8225         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8226 }
8227 static inline LDKEventHandler LDKEventHandler_init (JSValue o) {
8228         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
8229         atomic_init(&calls->refcnt, 1);
8230         calls->instance_ptr = o;
8231
8232         LDKEventHandler ret = {
8233                 .this_arg = (void*) calls,
8234                 .handle_event = handle_event_LDKEventHandler_jcall,
8235                 .free = LDKEventHandler_JCalls_free,
8236         };
8237         return ret;
8238 }
8239 long  __attribute__((export_name("TS_LDKEventHandler_new"))) TS_LDKEventHandler_new(JSValue o) {
8240         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
8241         *res_ptr = LDKEventHandler_init(o);
8242         return (long)res_ptr;
8243 }
8244 void  __attribute__((export_name("TS_EventHandler_handle_event"))) TS_EventHandler_handle_event(uint32_t this_arg, uint32_t event) {
8245         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8246         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8247         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
8248         LDKEvent* event_conv = (LDKEvent*)event;
8249         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
8250 }
8251
8252 typedef struct LDKEventsProvider_JCalls {
8253         atomic_size_t refcnt;
8254         uint32_t instance_ptr;
8255 } LDKEventsProvider_JCalls;
8256 static void LDKEventsProvider_JCalls_free(void* this_arg) {
8257         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
8258         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8259                 FREE(j_calls);
8260         }
8261 }
8262 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
8263         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
8264         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
8265         *handler_ret = handler;
8266         js_invoke_function_1(j_calls->instance_ptr, 36, (uint32_t)(uint32_t)handler_ret);
8267 }
8268 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
8269         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
8270         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8271 }
8272 static inline LDKEventsProvider LDKEventsProvider_init (JSValue o) {
8273         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
8274         atomic_init(&calls->refcnt, 1);
8275         calls->instance_ptr = o;
8276
8277         LDKEventsProvider ret = {
8278                 .this_arg = (void*) calls,
8279                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
8280                 .free = LDKEventsProvider_JCalls_free,
8281         };
8282         return ret;
8283 }
8284 long  __attribute__((export_name("TS_LDKEventsProvider_new"))) TS_LDKEventsProvider_new(JSValue o) {
8285         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
8286         *res_ptr = LDKEventsProvider_init(o);
8287         return (long)res_ptr;
8288 }
8289 void  __attribute__((export_name("TS_EventsProvider_process_pending_events"))) TS_EventsProvider_process_pending_events(uint32_t this_arg, uint32_t handler) {
8290         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8291         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8292         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
8293         void* handler_ptr = (void*)(((uintptr_t)handler) & ~1);
8294         CHECK_ACCESS(handler_ptr);
8295         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
8296         if (handler_conv.free == LDKEventHandler_JCalls_free) {
8297                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
8298                 LDKEventHandler_JCalls_cloned(&handler_conv);
8299         }
8300         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
8301 }
8302
8303 typedef struct LDKScore_JCalls {
8304         atomic_size_t refcnt;
8305         uint32_t instance_ptr;
8306 } LDKScore_JCalls;
8307 static void LDKScore_JCalls_free(void* this_arg) {
8308         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8309         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8310                 FREE(j_calls);
8311         }
8312 }
8313 uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id, const LDKNodeId * source, const LDKNodeId * target, LDKChannelUsage usage) {
8314         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8315         int64_t short_channel_id_conv = short_channel_id;
8316         LDKNodeId source_var = *source;
8317         uint32_t source_ref = 0;
8318         source_var = NodeId_clone(&source_var);
8319         CHECK((((uintptr_t)source_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8320         CHECK((((uintptr_t)&source_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8321         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
8322         source_ref = (uintptr_t)source_var.inner;
8323         if (source_var.is_owned) {
8324                 source_ref |= 1;
8325         }
8326         LDKNodeId target_var = *target;
8327         uint32_t target_ref = 0;
8328         target_var = NodeId_clone(&target_var);
8329         CHECK((((uintptr_t)target_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8330         CHECK((((uintptr_t)&target_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8331         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
8332         target_ref = (uintptr_t)target_var.inner;
8333         if (target_var.is_owned) {
8334                 target_ref |= 1;
8335         }
8336         LDKChannelUsage usage_var = usage;
8337         uint32_t usage_ref = 0;
8338         CHECK((((uintptr_t)usage_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8339         CHECK((((uintptr_t)&usage_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8340         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_var);
8341         usage_ref = (uintptr_t)usage_var.inner;
8342         if (usage_var.is_owned) {
8343                 usage_ref |= 1;
8344         }
8345         return js_invoke_function_4(j_calls->instance_ptr, 37, (uint32_t)short_channel_id_conv, (uint32_t)source_ref, (uint32_t)target_ref, (uint32_t)usage_ref);
8346 }
8347 void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
8348         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8349         LDKCVec_RouteHopZ path_var = path;
8350         uint32_tArray path_arr = NULL;
8351         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
8352         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
8353         for (size_t k = 0; k < path_var.datalen; k++) {
8354                 LDKRouteHop path_conv_10_var = path_var.data[k];
8355                 uint32_t path_conv_10_ref = 0;
8356                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8357                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8358                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
8359                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
8360                 if (path_conv_10_var.is_owned) {
8361                         path_conv_10_ref |= 1;
8362                 }
8363                 path_arr_ptr[k] = path_conv_10_ref;
8364         }
8365         
8366         FREE(path_var.data);
8367         int64_t short_channel_id_conv = short_channel_id;
8368         js_invoke_function_2(j_calls->instance_ptr, 38, (uint32_t)path_arr, (uint32_t)short_channel_id_conv);
8369 }
8370 void payment_path_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
8371         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8372         LDKCVec_RouteHopZ path_var = path;
8373         uint32_tArray path_arr = NULL;
8374         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
8375         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
8376         for (size_t k = 0; k < path_var.datalen; k++) {
8377                 LDKRouteHop path_conv_10_var = path_var.data[k];
8378                 uint32_t path_conv_10_ref = 0;
8379                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8380                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8381                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
8382                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
8383                 if (path_conv_10_var.is_owned) {
8384                         path_conv_10_ref |= 1;
8385                 }
8386                 path_arr_ptr[k] = path_conv_10_ref;
8387         }
8388         
8389         FREE(path_var.data);
8390         js_invoke_function_1(j_calls->instance_ptr, 39, (uint32_t)path_arr);
8391 }
8392 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
8393         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
8394         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 40);
8395         LDKCVec_u8Z ret_ref;
8396         ret_ref.datalen = ret->arr_len;
8397         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
8398         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
8399         return ret_ref;
8400 }
8401 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
8402         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
8403         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8404 }
8405 static inline LDKScore LDKScore_init (JSValue o) {
8406         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
8407         atomic_init(&calls->refcnt, 1);
8408         calls->instance_ptr = o;
8409
8410         LDKScore ret = {
8411                 .this_arg = (void*) calls,
8412                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
8413                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
8414                 .payment_path_successful = payment_path_successful_LDKScore_jcall,
8415                 .write = write_LDKScore_jcall,
8416                 .free = LDKScore_JCalls_free,
8417         };
8418         return ret;
8419 }
8420 long  __attribute__((export_name("TS_LDKScore_new"))) TS_LDKScore_new(JSValue o) {
8421         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
8422         *res_ptr = LDKScore_init(o);
8423         return (long)res_ptr;
8424 }
8425 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) {
8426         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8427         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8428         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8429         LDKNodeId source_conv;
8430         source_conv.inner = (void*)(source & (~1));
8431         source_conv.is_owned = false;
8432         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
8433         LDKNodeId target_conv;
8434         target_conv.inner = (void*)(target & (~1));
8435         target_conv.is_owned = false;
8436         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
8437         LDKChannelUsage usage_conv;
8438         usage_conv.inner = (void*)(usage & (~1));
8439         usage_conv.is_owned = (usage & 1) || (usage == 0);
8440         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_conv);
8441         usage_conv = ChannelUsage_clone(&usage_conv);
8442         int64_t ret_conv = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, &source_conv, &target_conv, usage_conv);
8443         return ret_conv;
8444 }
8445
8446 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) {
8447         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8448         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8449         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8450         LDKCVec_RouteHopZ path_constr;
8451         path_constr.datalen = path->arr_len;
8452         if (path_constr.datalen > 0)
8453                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
8454         else
8455                 path_constr.data = NULL;
8456         uint32_t* path_vals = path->elems /* XXX path leaks */;
8457         for (size_t k = 0; k < path_constr.datalen; k++) {
8458                 uint32_t path_conv_10 = path_vals[k];
8459                 LDKRouteHop path_conv_10_conv;
8460                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
8461                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
8462                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
8463                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
8464                 path_constr.data[k] = path_conv_10_conv;
8465         }
8466         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
8467 }
8468
8469 void  __attribute__((export_name("TS_Score_payment_path_successful"))) TS_Score_payment_path_successful(uint32_t this_arg, uint32_tArray path) {
8470         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8471         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8472         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8473         LDKCVec_RouteHopZ path_constr;
8474         path_constr.datalen = path->arr_len;
8475         if (path_constr.datalen > 0)
8476                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
8477         else
8478                 path_constr.data = NULL;
8479         uint32_t* path_vals = path->elems /* XXX path leaks */;
8480         for (size_t k = 0; k < path_constr.datalen; k++) {
8481                 uint32_t path_conv_10 = path_vals[k];
8482                 LDKRouteHop path_conv_10_conv;
8483                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
8484                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
8485                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
8486                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
8487                 path_constr.data[k] = path_conv_10_conv;
8488         }
8489         (this_arg_conv->payment_path_successful)(this_arg_conv->this_arg, path_constr);
8490 }
8491
8492 int8_tArray  __attribute__((export_name("TS_Score_write"))) TS_Score_write(uint32_t this_arg) {
8493         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8494         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8495         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
8496         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
8497         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
8498         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
8499         CVec_u8Z_free(ret_var);
8500         return ret_arr;
8501 }
8502
8503 typedef struct LDKPersister_JCalls {
8504         atomic_size_t refcnt;
8505         uint32_t instance_ptr;
8506 } LDKPersister_JCalls;
8507 static void LDKPersister_JCalls_free(void* this_arg) {
8508         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
8509         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8510                 FREE(j_calls);
8511         }
8512 }
8513 LDKCResult_NoneErrorZ persist_manager_LDKPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
8514         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
8515         LDKChannelManager channel_manager_var = *channel_manager;
8516         uint32_t channel_manager_ref = 0;
8517         // WARNING: we may need a move here but no clone is available for LDKChannelManager
8518         CHECK((((uintptr_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8519         CHECK((((uintptr_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8520         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_var);
8521         channel_manager_ref = (uintptr_t)channel_manager_var.inner;
8522         if (channel_manager_var.is_owned) {
8523                 channel_manager_ref |= 1;
8524         }
8525         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 41, (uint32_t)channel_manager_ref);
8526         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8527         CHECK_ACCESS(ret_ptr);
8528         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
8529         FREE((void*)ret);
8530         return ret_conv;
8531 }
8532 LDKCResult_NoneErrorZ persist_graph_LDKPersister_jcall(const void* this_arg, const LDKNetworkGraph * network_graph) {
8533         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
8534         LDKNetworkGraph network_graph_var = *network_graph;
8535         uint32_t network_graph_ref = 0;
8536         // WARNING: we may need a move here but no clone is available for LDKNetworkGraph
8537         CHECK((((uintptr_t)network_graph_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8538         CHECK((((uintptr_t)&network_graph_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8539         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_var);
8540         network_graph_ref = (uintptr_t)network_graph_var.inner;
8541         if (network_graph_var.is_owned) {
8542                 network_graph_ref |= 1;
8543         }
8544         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 42, (uint32_t)network_graph_ref);
8545         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8546         CHECK_ACCESS(ret_ptr);
8547         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
8548         FREE((void*)ret);
8549         return ret_conv;
8550 }
8551 LDKCResult_NoneErrorZ persist_scorer_LDKPersister_jcall(const void* this_arg, const LDKMultiThreadedLockableScore * scorer) {
8552         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
8553         LDKMultiThreadedLockableScore scorer_var = *scorer;
8554         uint32_t scorer_ref = 0;
8555         // WARNING: we may need a move here but no clone is available for LDKMultiThreadedLockableScore
8556         CHECK((((uintptr_t)scorer_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8557         CHECK((((uintptr_t)&scorer_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8558         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_var);
8559         scorer_ref = (uintptr_t)scorer_var.inner;
8560         if (scorer_var.is_owned) {
8561                 scorer_ref |= 1;
8562         }
8563         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 43, (uint32_t)scorer_ref);
8564         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8565         CHECK_ACCESS(ret_ptr);
8566         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
8567         FREE((void*)ret);
8568         return ret_conv;
8569 }
8570 static void LDKPersister_JCalls_cloned(LDKPersister* new_obj) {
8571         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) new_obj->this_arg;
8572         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8573 }
8574 static inline LDKPersister LDKPersister_init (JSValue o) {
8575         LDKPersister_JCalls *calls = MALLOC(sizeof(LDKPersister_JCalls), "LDKPersister_JCalls");
8576         atomic_init(&calls->refcnt, 1);
8577         calls->instance_ptr = o;
8578
8579         LDKPersister ret = {
8580                 .this_arg = (void*) calls,
8581                 .persist_manager = persist_manager_LDKPersister_jcall,
8582                 .persist_graph = persist_graph_LDKPersister_jcall,
8583                 .persist_scorer = persist_scorer_LDKPersister_jcall,
8584                 .free = LDKPersister_JCalls_free,
8585         };
8586         return ret;
8587 }
8588 long  __attribute__((export_name("TS_LDKPersister_new"))) TS_LDKPersister_new(JSValue o) {
8589         LDKPersister *res_ptr = MALLOC(sizeof(LDKPersister), "LDKPersister");
8590         *res_ptr = LDKPersister_init(o);
8591         return (long)res_ptr;
8592 }
8593 uint32_t  __attribute__((export_name("TS_Persister_persist_manager"))) TS_Persister_persist_manager(uint32_t this_arg, uint32_t channel_manager) {
8594         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8595         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8596         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
8597         LDKChannelManager channel_manager_conv;
8598         channel_manager_conv.inner = (void*)(channel_manager & (~1));
8599         channel_manager_conv.is_owned = false;
8600         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
8601         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
8602         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
8603         return (uint32_t)ret_conv;
8604 }
8605
8606 uint32_t  __attribute__((export_name("TS_Persister_persist_graph"))) TS_Persister_persist_graph(uint32_t this_arg, uint32_t network_graph) {
8607         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8608         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8609         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
8610         LDKNetworkGraph network_graph_conv;
8611         network_graph_conv.inner = (void*)(network_graph & (~1));
8612         network_graph_conv.is_owned = false;
8613         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
8614         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
8615         *ret_conv = (this_arg_conv->persist_graph)(this_arg_conv->this_arg, &network_graph_conv);
8616         return (uint32_t)ret_conv;
8617 }
8618
8619 uint32_t  __attribute__((export_name("TS_Persister_persist_scorer"))) TS_Persister_persist_scorer(uint32_t this_arg, uint32_t scorer) {
8620         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8621         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8622         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
8623         LDKMultiThreadedLockableScore scorer_conv;
8624         scorer_conv.inner = (void*)(scorer & (~1));
8625         scorer_conv.is_owned = false;
8626         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
8627         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
8628         *ret_conv = (this_arg_conv->persist_scorer)(this_arg_conv->this_arg, &scorer_conv);
8629         return (uint32_t)ret_conv;
8630 }
8631
8632 typedef struct LDKListen_JCalls {
8633         atomic_size_t refcnt;
8634         uint32_t instance_ptr;
8635 } LDKListen_JCalls;
8636 static void LDKListen_JCalls_free(void* this_arg) {
8637         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
8638         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8639                 FREE(j_calls);
8640         }
8641 }
8642 void filtered_block_connected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
8643         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
8644         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
8645         memcpy(header_arr->elems, *header, 80);
8646         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
8647         uint32_tArray txdata_arr = NULL;
8648         txdata_arr = init_uint32_tArray(txdata_var.datalen, __LINE__);
8649         uint32_t *txdata_arr_ptr = (uint32_t*)(((uint8_t*)txdata_arr) + 4);
8650         for (size_t c = 0; c < txdata_var.datalen; c++) {
8651                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
8652                 *txdata_conv_28_conv = txdata_var.data[c];
8653                 txdata_arr_ptr[c] = ((uint32_t)txdata_conv_28_conv);
8654         }
8655         
8656         FREE(txdata_var.data);
8657         int32_t height_conv = height;
8658         js_invoke_function_3(j_calls->instance_ptr, 44, (uint32_t)header_arr, (uint32_t)txdata_arr, (uint32_t)height_conv);
8659 }
8660 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
8661         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
8662         LDKu8slice block_var = block;
8663         int8_tArray block_arr = init_int8_tArray(block_var.datalen, __LINE__);
8664         memcpy(block_arr->elems, block_var.data, block_var.datalen);
8665         int32_t height_conv = height;
8666         js_invoke_function_2(j_calls->instance_ptr, 45, (uint32_t)block_arr, (uint32_t)height_conv);
8667 }
8668 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
8669         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
8670         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
8671         memcpy(header_arr->elems, *header, 80);
8672         int32_t height_conv = height;
8673         js_invoke_function_2(j_calls->instance_ptr, 46, (uint32_t)header_arr, (uint32_t)height_conv);
8674 }
8675 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
8676         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
8677         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8678 }
8679 static inline LDKListen LDKListen_init (JSValue o) {
8680         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
8681         atomic_init(&calls->refcnt, 1);
8682         calls->instance_ptr = o;
8683
8684         LDKListen ret = {
8685                 .this_arg = (void*) calls,
8686                 .filtered_block_connected = filtered_block_connected_LDKListen_jcall,
8687                 .block_connected = block_connected_LDKListen_jcall,
8688                 .block_disconnected = block_disconnected_LDKListen_jcall,
8689                 .free = LDKListen_JCalls_free,
8690         };
8691         return ret;
8692 }
8693 long  __attribute__((export_name("TS_LDKListen_new"))) TS_LDKListen_new(JSValue o) {
8694         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
8695         *res_ptr = LDKListen_init(o);
8696         return (long)res_ptr;
8697 }
8698 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) {
8699         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8700         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8701         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
8702         unsigned char header_arr[80];
8703         CHECK(header->arr_len == 80);
8704         memcpy(header_arr, header->elems, 80); FREE(header);
8705         unsigned char (*header_ref)[80] = &header_arr;
8706         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
8707         txdata_constr.datalen = txdata->arr_len;
8708         if (txdata_constr.datalen > 0)
8709                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
8710         else
8711                 txdata_constr.data = NULL;
8712         uint32_t* txdata_vals = txdata->elems /* XXX txdata leaks */;
8713         for (size_t c = 0; c < txdata_constr.datalen; c++) {
8714                 uint32_t txdata_conv_28 = txdata_vals[c];
8715                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
8716                 CHECK_ACCESS(txdata_conv_28_ptr);
8717                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
8718                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
8719                 txdata_constr.data[c] = txdata_conv_28_conv;
8720         }
8721         (this_arg_conv->filtered_block_connected)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
8722 }
8723
8724 void  __attribute__((export_name("TS_Listen_block_connected"))) TS_Listen_block_connected(uint32_t this_arg, int8_tArray block, int32_t height) {
8725         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8726         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8727         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
8728         LDKu8slice block_ref;
8729         block_ref.datalen = block->arr_len;
8730         block_ref.data = block->elems /* XXX block leaks */;
8731         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
8732 }
8733
8734 void  __attribute__((export_name("TS_Listen_block_disconnected"))) TS_Listen_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t height) {
8735         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8736         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8737         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
8738         unsigned char header_arr[80];
8739         CHECK(header->arr_len == 80);
8740         memcpy(header_arr, header->elems, 80); FREE(header);
8741         unsigned char (*header_ref)[80] = &header_arr;
8742         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
8743 }
8744
8745 typedef struct LDKConfirm_JCalls {
8746         atomic_size_t refcnt;
8747         uint32_t instance_ptr;
8748 } LDKConfirm_JCalls;
8749 static void LDKConfirm_JCalls_free(void* this_arg) {
8750         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8751         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8752                 FREE(j_calls);
8753         }
8754 }
8755 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
8756         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8757         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
8758         memcpy(header_arr->elems, *header, 80);
8759         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
8760         uint32_tArray txdata_arr = NULL;
8761         txdata_arr = init_uint32_tArray(txdata_var.datalen, __LINE__);
8762         uint32_t *txdata_arr_ptr = (uint32_t*)(((uint8_t*)txdata_arr) + 4);
8763         for (size_t c = 0; c < txdata_var.datalen; c++) {
8764                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
8765                 *txdata_conv_28_conv = txdata_var.data[c];
8766                 txdata_arr_ptr[c] = ((uint32_t)txdata_conv_28_conv);
8767         }
8768         
8769         FREE(txdata_var.data);
8770         int32_t height_conv = height;
8771         js_invoke_function_3(j_calls->instance_ptr, 47, (uint32_t)header_arr, (uint32_t)txdata_arr, (uint32_t)height_conv);
8772 }
8773 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
8774         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8775         int8_tArray txid_arr = init_int8_tArray(32, __LINE__);
8776         memcpy(txid_arr->elems, *txid, 32);
8777         js_invoke_function_1(j_calls->instance_ptr, 48, (uint32_t)txid_arr);
8778 }
8779 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
8780         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8781         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
8782         memcpy(header_arr->elems, *header, 80);
8783         int32_t height_conv = height;
8784         js_invoke_function_2(j_calls->instance_ptr, 49, (uint32_t)header_arr, (uint32_t)height_conv);
8785 }
8786 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
8787         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8788         ptrArray ret = (ptrArray)js_invoke_function_0(j_calls->instance_ptr, 50);
8789         LDKCVec_TxidZ ret_constr;
8790         ret_constr.datalen = ret->arr_len;
8791         if (ret_constr.datalen > 0)
8792                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
8793         else
8794                 ret_constr.data = NULL;
8795         int8_tArray* ret_vals = (void*) ret->elems /* XXX ret leaks */;
8796         for (size_t m = 0; m < ret_constr.datalen; m++) {
8797                 int8_tArray ret_conv_12 = ret_vals[m];
8798                 LDKThirtyTwoBytes ret_conv_12_ref;
8799                 CHECK(ret_conv_12->arr_len == 32);
8800                 memcpy(ret_conv_12_ref.data, ret_conv_12->elems, 32); FREE(ret_conv_12);
8801                 ret_constr.data[m] = ret_conv_12_ref;
8802         }
8803         return ret_constr;
8804 }
8805 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
8806         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
8807         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8808 }
8809 static inline LDKConfirm LDKConfirm_init (JSValue o) {
8810         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
8811         atomic_init(&calls->refcnt, 1);
8812         calls->instance_ptr = o;
8813
8814         LDKConfirm ret = {
8815                 .this_arg = (void*) calls,
8816                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
8817                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
8818                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
8819                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
8820                 .free = LDKConfirm_JCalls_free,
8821         };
8822         return ret;
8823 }
8824 long  __attribute__((export_name("TS_LDKConfirm_new"))) TS_LDKConfirm_new(JSValue o) {
8825         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
8826         *res_ptr = LDKConfirm_init(o);
8827         return (long)res_ptr;
8828 }
8829 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) {
8830         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8831         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8832         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8833         unsigned char header_arr[80];
8834         CHECK(header->arr_len == 80);
8835         memcpy(header_arr, header->elems, 80); FREE(header);
8836         unsigned char (*header_ref)[80] = &header_arr;
8837         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
8838         txdata_constr.datalen = txdata->arr_len;
8839         if (txdata_constr.datalen > 0)
8840                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
8841         else
8842                 txdata_constr.data = NULL;
8843         uint32_t* txdata_vals = txdata->elems /* XXX txdata leaks */;
8844         for (size_t c = 0; c < txdata_constr.datalen; c++) {
8845                 uint32_t txdata_conv_28 = txdata_vals[c];
8846                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
8847                 CHECK_ACCESS(txdata_conv_28_ptr);
8848                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
8849                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
8850                 txdata_constr.data[c] = txdata_conv_28_conv;
8851         }
8852         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
8853 }
8854
8855 void  __attribute__((export_name("TS_Confirm_transaction_unconfirmed"))) TS_Confirm_transaction_unconfirmed(uint32_t this_arg, int8_tArray txid) {
8856         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8857         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8858         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8859         unsigned char txid_arr[32];
8860         CHECK(txid->arr_len == 32);
8861         memcpy(txid_arr, txid->elems, 32); FREE(txid);
8862         unsigned char (*txid_ref)[32] = &txid_arr;
8863         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
8864 }
8865
8866 void  __attribute__((export_name("TS_Confirm_best_block_updated"))) TS_Confirm_best_block_updated(uint32_t this_arg, int8_tArray header, int32_t height) {
8867         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8868         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8869         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8870         unsigned char header_arr[80];
8871         CHECK(header->arr_len == 80);
8872         memcpy(header_arr, header->elems, 80); FREE(header);
8873         unsigned char (*header_ref)[80] = &header_arr;
8874         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
8875 }
8876
8877 ptrArray  __attribute__((export_name("TS_Confirm_get_relevant_txids"))) TS_Confirm_get_relevant_txids(uint32_t this_arg) {
8878         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8879         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8880         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8881         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
8882         ptrArray ret_arr = NULL;
8883         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
8884         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
8885         for (size_t m = 0; m < ret_var.datalen; m++) {
8886                 int8_tArray ret_conv_12_arr = init_int8_tArray(32, __LINE__);
8887                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].data, 32);
8888                 ret_arr_ptr[m] = ret_conv_12_arr;
8889         }
8890         
8891         FREE(ret_var.data);
8892         return ret_arr;
8893 }
8894
8895 typedef struct LDKPersist_JCalls {
8896         atomic_size_t refcnt;
8897         uint32_t instance_ptr;
8898 } LDKPersist_JCalls;
8899 static void LDKPersist_JCalls_free(void* this_arg) {
8900         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
8901         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8902                 FREE(j_calls);
8903         }
8904 }
8905 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
8906         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
8907         LDKOutPoint channel_id_var = channel_id;
8908         uint32_t channel_id_ref = 0;
8909         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8910         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8911         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
8912         channel_id_ref = (uintptr_t)channel_id_var.inner;
8913         if (channel_id_var.is_owned) {
8914                 channel_id_ref |= 1;
8915         }
8916         LDKChannelMonitor data_var = *data;
8917         uint32_t data_ref = 0;
8918         data_var = ChannelMonitor_clone(&data_var);
8919         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8920         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8921         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
8922         data_ref = (uintptr_t)data_var.inner;
8923         if (data_var.is_owned) {
8924                 data_ref |= 1;
8925         }
8926         LDKMonitorUpdateId update_id_var = update_id;
8927         uint32_t update_id_ref = 0;
8928         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8929         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8930         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
8931         update_id_ref = (uintptr_t)update_id_var.inner;
8932         if (update_id_var.is_owned) {
8933                 update_id_ref |= 1;
8934         }
8935         uint32_t ret = js_invoke_function_3(j_calls->instance_ptr, 51, (uint32_t)channel_id_ref, (uint32_t)data_ref, (uint32_t)update_id_ref);
8936         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8937         CHECK_ACCESS(ret_ptr);
8938         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
8939         FREE((void*)ret);
8940         return ret_conv;
8941 }
8942 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
8943         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
8944         LDKOutPoint channel_id_var = channel_id;
8945         uint32_t channel_id_ref = 0;
8946         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8947         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8948         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
8949         channel_id_ref = (uintptr_t)channel_id_var.inner;
8950         if (channel_id_var.is_owned) {
8951                 channel_id_ref |= 1;
8952         }
8953         LDKChannelMonitorUpdate update_var = *update;
8954         uint32_t update_ref = 0;
8955         if ((uintptr_t)update_var.inner > 4096) {
8956                 update_var = ChannelMonitorUpdate_clone(&update_var);
8957                 CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8958                 CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8959         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
8960                 update_ref = (uintptr_t)update_var.inner;
8961                 if (update_var.is_owned) {
8962                         update_ref |= 1;
8963                 }
8964         }
8965         LDKChannelMonitor data_var = *data;
8966         uint32_t data_ref = 0;
8967         data_var = ChannelMonitor_clone(&data_var);
8968         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8969         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8970         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
8971         data_ref = (uintptr_t)data_var.inner;
8972         if (data_var.is_owned) {
8973                 data_ref |= 1;
8974         }
8975         LDKMonitorUpdateId update_id_var = update_id;
8976         uint32_t update_id_ref = 0;
8977         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8978         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8979         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
8980         update_id_ref = (uintptr_t)update_id_var.inner;
8981         if (update_id_var.is_owned) {
8982                 update_id_ref |= 1;
8983         }
8984         uint32_t ret = js_invoke_function_4(j_calls->instance_ptr, 52, (uint32_t)channel_id_ref, (uint32_t)update_ref, (uint32_t)data_ref, (uint32_t)update_id_ref);
8985         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8986         CHECK_ACCESS(ret_ptr);
8987         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
8988         FREE((void*)ret);
8989         return ret_conv;
8990 }
8991 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
8992         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
8993         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8994 }
8995 static inline LDKPersist LDKPersist_init (JSValue o) {
8996         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
8997         atomic_init(&calls->refcnt, 1);
8998         calls->instance_ptr = o;
8999
9000         LDKPersist ret = {
9001                 .this_arg = (void*) calls,
9002                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
9003                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
9004                 .free = LDKPersist_JCalls_free,
9005         };
9006         return ret;
9007 }
9008 long  __attribute__((export_name("TS_LDKPersist_new"))) TS_LDKPersist_new(JSValue o) {
9009         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
9010         *res_ptr = LDKPersist_init(o);
9011         return (long)res_ptr;
9012 }
9013 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) {
9014         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9015         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9016         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
9017         LDKOutPoint channel_id_conv;
9018         channel_id_conv.inner = (void*)(channel_id & (~1));
9019         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
9020         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
9021         channel_id_conv = OutPoint_clone(&channel_id_conv);
9022         LDKChannelMonitor data_conv;
9023         data_conv.inner = (void*)(data & (~1));
9024         data_conv.is_owned = false;
9025         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
9026         LDKMonitorUpdateId update_id_conv;
9027         update_id_conv.inner = (void*)(update_id & (~1));
9028         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
9029         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
9030         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
9031         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9032         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv);
9033         return (uint32_t)ret_conv;
9034 }
9035
9036 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) {
9037         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9038         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9039         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
9040         LDKOutPoint channel_id_conv;
9041         channel_id_conv.inner = (void*)(channel_id & (~1));
9042         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
9043         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
9044         channel_id_conv = OutPoint_clone(&channel_id_conv);
9045         LDKChannelMonitorUpdate update_conv;
9046         update_conv.inner = (void*)(update & (~1));
9047         update_conv.is_owned = false;
9048         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
9049         LDKChannelMonitor data_conv;
9050         data_conv.inner = (void*)(data & (~1));
9051         data_conv.is_owned = false;
9052         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
9053         LDKMonitorUpdateId update_id_conv;
9054         update_id_conv.inner = (void*)(update_id & (~1));
9055         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
9056         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
9057         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
9058         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
9059         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv);
9060         return (uint32_t)ret_conv;
9061 }
9062
9063 typedef struct LDKChannelMessageHandler_JCalls {
9064         atomic_size_t refcnt;
9065         uint32_t instance_ptr;
9066         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
9067 } LDKChannelMessageHandler_JCalls;
9068 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
9069         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9070         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9071                 FREE(j_calls);
9072         }
9073 }
9074 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
9075         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9076         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9077         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9078         LDKInitFeatures their_features_var = their_features;
9079         uint32_t their_features_ref = 0;
9080         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9081         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9082         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
9083         their_features_ref = (uintptr_t)their_features_var.inner;
9084         if (their_features_var.is_owned) {
9085                 their_features_ref |= 1;
9086         }
9087         LDKOpenChannel msg_var = *msg;
9088         uint32_t msg_ref = 0;
9089         msg_var = OpenChannel_clone(&msg_var);
9090         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9091         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9092         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9093         msg_ref = (uintptr_t)msg_var.inner;
9094         if (msg_var.is_owned) {
9095                 msg_ref |= 1;
9096         }
9097         js_invoke_function_3(j_calls->instance_ptr, 53, (uint32_t)their_node_id_arr, (uint32_t)their_features_ref, (uint32_t)msg_ref);
9098 }
9099 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
9100         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9101         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9102         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9103         LDKInitFeatures their_features_var = their_features;
9104         uint32_t their_features_ref = 0;
9105         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9106         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9107         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
9108         their_features_ref = (uintptr_t)their_features_var.inner;
9109         if (their_features_var.is_owned) {
9110                 their_features_ref |= 1;
9111         }
9112         LDKAcceptChannel msg_var = *msg;
9113         uint32_t msg_ref = 0;
9114         msg_var = AcceptChannel_clone(&msg_var);
9115         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9116         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9117         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9118         msg_ref = (uintptr_t)msg_var.inner;
9119         if (msg_var.is_owned) {
9120                 msg_ref |= 1;
9121         }
9122         js_invoke_function_3(j_calls->instance_ptr, 54, (uint32_t)their_node_id_arr, (uint32_t)their_features_ref, (uint32_t)msg_ref);
9123 }
9124 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
9125         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9126         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9127         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9128         LDKFundingCreated msg_var = *msg;
9129         uint32_t msg_ref = 0;
9130         msg_var = FundingCreated_clone(&msg_var);
9131         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9132         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9133         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9134         msg_ref = (uintptr_t)msg_var.inner;
9135         if (msg_var.is_owned) {
9136                 msg_ref |= 1;
9137         }
9138         js_invoke_function_2(j_calls->instance_ptr, 55, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9139 }
9140 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
9141         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9142         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9143         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9144         LDKFundingSigned msg_var = *msg;
9145         uint32_t msg_ref = 0;
9146         msg_var = FundingSigned_clone(&msg_var);
9147         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9148         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9149         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9150         msg_ref = (uintptr_t)msg_var.inner;
9151         if (msg_var.is_owned) {
9152                 msg_ref |= 1;
9153         }
9154         js_invoke_function_2(j_calls->instance_ptr, 56, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9155 }
9156 void handle_channel_ready_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReady * msg) {
9157         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9158         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9159         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9160         LDKChannelReady msg_var = *msg;
9161         uint32_t msg_ref = 0;
9162         msg_var = ChannelReady_clone(&msg_var);
9163         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9164         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9165         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9166         msg_ref = (uintptr_t)msg_var.inner;
9167         if (msg_var.is_owned) {
9168                 msg_ref |= 1;
9169         }
9170         js_invoke_function_2(j_calls->instance_ptr, 57, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9171 }
9172 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
9173         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9174         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9175         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9176         LDKInitFeatures their_features_var = *their_features;
9177         uint32_t their_features_ref = 0;
9178         their_features_var = InitFeatures_clone(&their_features_var);
9179         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9180         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9181         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
9182         their_features_ref = (uintptr_t)their_features_var.inner;
9183         if (their_features_var.is_owned) {
9184                 their_features_ref |= 1;
9185         }
9186         LDKShutdown msg_var = *msg;
9187         uint32_t msg_ref = 0;
9188         msg_var = Shutdown_clone(&msg_var);
9189         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9190         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9191         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9192         msg_ref = (uintptr_t)msg_var.inner;
9193         if (msg_var.is_owned) {
9194                 msg_ref |= 1;
9195         }
9196         js_invoke_function_3(j_calls->instance_ptr, 58, (uint32_t)their_node_id_arr, (uint32_t)their_features_ref, (uint32_t)msg_ref);
9197 }
9198 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
9199         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9200         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9201         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9202         LDKClosingSigned msg_var = *msg;
9203         uint32_t msg_ref = 0;
9204         msg_var = ClosingSigned_clone(&msg_var);
9205         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9206         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9207         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9208         msg_ref = (uintptr_t)msg_var.inner;
9209         if (msg_var.is_owned) {
9210                 msg_ref |= 1;
9211         }
9212         js_invoke_function_2(j_calls->instance_ptr, 59, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9213 }
9214 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
9215         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9216         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9217         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9218         LDKUpdateAddHTLC msg_var = *msg;
9219         uint32_t msg_ref = 0;
9220         msg_var = UpdateAddHTLC_clone(&msg_var);
9221         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9222         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9223         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9224         msg_ref = (uintptr_t)msg_var.inner;
9225         if (msg_var.is_owned) {
9226                 msg_ref |= 1;
9227         }
9228         js_invoke_function_2(j_calls->instance_ptr, 60, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9229 }
9230 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
9231         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9232         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9233         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9234         LDKUpdateFulfillHTLC msg_var = *msg;
9235         uint32_t msg_ref = 0;
9236         msg_var = UpdateFulfillHTLC_clone(&msg_var);
9237         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9238         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9239         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9240         msg_ref = (uintptr_t)msg_var.inner;
9241         if (msg_var.is_owned) {
9242                 msg_ref |= 1;
9243         }
9244         js_invoke_function_2(j_calls->instance_ptr, 61, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9245 }
9246 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
9247         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9248         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9249         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9250         LDKUpdateFailHTLC msg_var = *msg;
9251         uint32_t msg_ref = 0;
9252         msg_var = UpdateFailHTLC_clone(&msg_var);
9253         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9254         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9255         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9256         msg_ref = (uintptr_t)msg_var.inner;
9257         if (msg_var.is_owned) {
9258                 msg_ref |= 1;
9259         }
9260         js_invoke_function_2(j_calls->instance_ptr, 62, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9261 }
9262 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
9263         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9264         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9265         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9266         LDKUpdateFailMalformedHTLC msg_var = *msg;
9267         uint32_t msg_ref = 0;
9268         msg_var = UpdateFailMalformedHTLC_clone(&msg_var);
9269         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9270         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9271         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9272         msg_ref = (uintptr_t)msg_var.inner;
9273         if (msg_var.is_owned) {
9274                 msg_ref |= 1;
9275         }
9276         js_invoke_function_2(j_calls->instance_ptr, 63, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9277 }
9278 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
9279         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9280         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9281         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9282         LDKCommitmentSigned msg_var = *msg;
9283         uint32_t msg_ref = 0;
9284         msg_var = CommitmentSigned_clone(&msg_var);
9285         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9286         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9287         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9288         msg_ref = (uintptr_t)msg_var.inner;
9289         if (msg_var.is_owned) {
9290                 msg_ref |= 1;
9291         }
9292         js_invoke_function_2(j_calls->instance_ptr, 64, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9293 }
9294 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
9295         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9296         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9297         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9298         LDKRevokeAndACK msg_var = *msg;
9299         uint32_t msg_ref = 0;
9300         msg_var = RevokeAndACK_clone(&msg_var);
9301         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9302         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9303         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9304         msg_ref = (uintptr_t)msg_var.inner;
9305         if (msg_var.is_owned) {
9306                 msg_ref |= 1;
9307         }
9308         js_invoke_function_2(j_calls->instance_ptr, 65, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9309 }
9310 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
9311         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9312         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9313         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9314         LDKUpdateFee msg_var = *msg;
9315         uint32_t msg_ref = 0;
9316         msg_var = UpdateFee_clone(&msg_var);
9317         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9318         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9319         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9320         msg_ref = (uintptr_t)msg_var.inner;
9321         if (msg_var.is_owned) {
9322                 msg_ref |= 1;
9323         }
9324         js_invoke_function_2(j_calls->instance_ptr, 66, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9325 }
9326 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
9327         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9328         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9329         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9330         LDKAnnouncementSignatures msg_var = *msg;
9331         uint32_t msg_ref = 0;
9332         msg_var = AnnouncementSignatures_clone(&msg_var);
9333         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9334         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9335         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9336         msg_ref = (uintptr_t)msg_var.inner;
9337         if (msg_var.is_owned) {
9338                 msg_ref |= 1;
9339         }
9340         js_invoke_function_2(j_calls->instance_ptr, 67, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9341 }
9342 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
9343         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9344         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9345         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9346         jboolean no_connection_possible_conv = no_connection_possible;
9347         js_invoke_function_2(j_calls->instance_ptr, 68, (uint32_t)their_node_id_arr, (uint32_t)no_connection_possible_conv);
9348 }
9349 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
9350         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9351         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9352         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9353         LDKInit msg_var = *msg;
9354         uint32_t msg_ref = 0;
9355         msg_var = Init_clone(&msg_var);
9356         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9357         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9358         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9359         msg_ref = (uintptr_t)msg_var.inner;
9360         if (msg_var.is_owned) {
9361                 msg_ref |= 1;
9362         }
9363         js_invoke_function_2(j_calls->instance_ptr, 69, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9364 }
9365 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
9366         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9367         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9368         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9369         LDKChannelReestablish msg_var = *msg;
9370         uint32_t msg_ref = 0;
9371         msg_var = ChannelReestablish_clone(&msg_var);
9372         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9373         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9374         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9375         msg_ref = (uintptr_t)msg_var.inner;
9376         if (msg_var.is_owned) {
9377                 msg_ref |= 1;
9378         }
9379         js_invoke_function_2(j_calls->instance_ptr, 70, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9380 }
9381 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
9382         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9383         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9384         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9385         LDKChannelUpdate msg_var = *msg;
9386         uint32_t msg_ref = 0;
9387         msg_var = ChannelUpdate_clone(&msg_var);
9388         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9389         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9390         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9391         msg_ref = (uintptr_t)msg_var.inner;
9392         if (msg_var.is_owned) {
9393                 msg_ref |= 1;
9394         }
9395         js_invoke_function_2(j_calls->instance_ptr, 71, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9396 }
9397 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
9398         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
9399         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9400         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9401         LDKErrorMessage msg_var = *msg;
9402         uint32_t msg_ref = 0;
9403         msg_var = ErrorMessage_clone(&msg_var);
9404         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9405         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9406         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9407         msg_ref = (uintptr_t)msg_var.inner;
9408         if (msg_var.is_owned) {
9409                 msg_ref |= 1;
9410         }
9411         js_invoke_function_2(j_calls->instance_ptr, 72, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9412 }
9413 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
9414         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
9415         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9416         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
9417 }
9418 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JSValue o, JSValue MessageSendEventsProvider) {
9419         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
9420         atomic_init(&calls->refcnt, 1);
9421         calls->instance_ptr = o;
9422
9423         LDKChannelMessageHandler ret = {
9424                 .this_arg = (void*) calls,
9425                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
9426                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
9427                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
9428                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
9429                 .handle_channel_ready = handle_channel_ready_LDKChannelMessageHandler_jcall,
9430                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
9431                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
9432                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
9433                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
9434                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
9435                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
9436                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
9437                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
9438                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
9439                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
9440                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
9441                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
9442                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
9443                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
9444                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
9445                 .free = LDKChannelMessageHandler_JCalls_free,
9446                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
9447         };
9448         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
9449         return ret;
9450 }
9451 long  __attribute__((export_name("TS_LDKChannelMessageHandler_new"))) TS_LDKChannelMessageHandler_new(JSValue o, JSValue MessageSendEventsProvider) {
9452         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
9453         *res_ptr = LDKChannelMessageHandler_init(o, MessageSendEventsProvider);
9454         return (long)res_ptr;
9455 }
9456 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) {
9457         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9458         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9459         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9460         LDKPublicKey their_node_id_ref;
9461         CHECK(their_node_id->arr_len == 33);
9462         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9463         LDKInitFeatures their_features_conv;
9464         their_features_conv.inner = (void*)(their_features & (~1));
9465         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
9466         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
9467         their_features_conv = InitFeatures_clone(&their_features_conv);
9468         LDKOpenChannel msg_conv;
9469         msg_conv.inner = (void*)(msg & (~1));
9470         msg_conv.is_owned = false;
9471         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9472         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
9473 }
9474
9475 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) {
9476         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9477         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9478         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9479         LDKPublicKey their_node_id_ref;
9480         CHECK(their_node_id->arr_len == 33);
9481         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9482         LDKInitFeatures their_features_conv;
9483         their_features_conv.inner = (void*)(their_features & (~1));
9484         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
9485         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
9486         their_features_conv = InitFeatures_clone(&their_features_conv);
9487         LDKAcceptChannel msg_conv;
9488         msg_conv.inner = (void*)(msg & (~1));
9489         msg_conv.is_owned = false;
9490         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9491         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
9492 }
9493
9494 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) {
9495         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9496         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9497         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9498         LDKPublicKey their_node_id_ref;
9499         CHECK(their_node_id->arr_len == 33);
9500         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9501         LDKFundingCreated msg_conv;
9502         msg_conv.inner = (void*)(msg & (~1));
9503         msg_conv.is_owned = false;
9504         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9505         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9506 }
9507
9508 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) {
9509         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9510         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9511         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9512         LDKPublicKey their_node_id_ref;
9513         CHECK(their_node_id->arr_len == 33);
9514         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9515         LDKFundingSigned msg_conv;
9516         msg_conv.inner = (void*)(msg & (~1));
9517         msg_conv.is_owned = false;
9518         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9519         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9520 }
9521
9522 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) {
9523         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9524         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9525         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9526         LDKPublicKey their_node_id_ref;
9527         CHECK(their_node_id->arr_len == 33);
9528         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9529         LDKChannelReady msg_conv;
9530         msg_conv.inner = (void*)(msg & (~1));
9531         msg_conv.is_owned = false;
9532         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9533         (this_arg_conv->handle_channel_ready)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9534 }
9535
9536 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) {
9537         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9538         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9539         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9540         LDKPublicKey their_node_id_ref;
9541         CHECK(their_node_id->arr_len == 33);
9542         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9543         LDKInitFeatures their_features_conv;
9544         their_features_conv.inner = (void*)(their_features & (~1));
9545         their_features_conv.is_owned = false;
9546         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
9547         LDKShutdown msg_conv;
9548         msg_conv.inner = (void*)(msg & (~1));
9549         msg_conv.is_owned = false;
9550         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9551         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
9552 }
9553
9554 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) {
9555         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9556         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9557         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9558         LDKPublicKey their_node_id_ref;
9559         CHECK(their_node_id->arr_len == 33);
9560         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9561         LDKClosingSigned msg_conv;
9562         msg_conv.inner = (void*)(msg & (~1));
9563         msg_conv.is_owned = false;
9564         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9565         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9566 }
9567
9568 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) {
9569         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9570         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9571         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9572         LDKPublicKey their_node_id_ref;
9573         CHECK(their_node_id->arr_len == 33);
9574         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9575         LDKUpdateAddHTLC msg_conv;
9576         msg_conv.inner = (void*)(msg & (~1));
9577         msg_conv.is_owned = false;
9578         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9579         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9580 }
9581
9582 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) {
9583         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9584         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9585         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9586         LDKPublicKey their_node_id_ref;
9587         CHECK(their_node_id->arr_len == 33);
9588         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9589         LDKUpdateFulfillHTLC msg_conv;
9590         msg_conv.inner = (void*)(msg & (~1));
9591         msg_conv.is_owned = false;
9592         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9593         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9594 }
9595
9596 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) {
9597         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9598         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9599         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9600         LDKPublicKey their_node_id_ref;
9601         CHECK(their_node_id->arr_len == 33);
9602         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9603         LDKUpdateFailHTLC msg_conv;
9604         msg_conv.inner = (void*)(msg & (~1));
9605         msg_conv.is_owned = false;
9606         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9607         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9608 }
9609
9610 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) {
9611         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9612         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9613         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9614         LDKPublicKey their_node_id_ref;
9615         CHECK(their_node_id->arr_len == 33);
9616         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9617         LDKUpdateFailMalformedHTLC msg_conv;
9618         msg_conv.inner = (void*)(msg & (~1));
9619         msg_conv.is_owned = false;
9620         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9621         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9622 }
9623
9624 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) {
9625         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9626         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9627         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9628         LDKPublicKey their_node_id_ref;
9629         CHECK(their_node_id->arr_len == 33);
9630         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9631         LDKCommitmentSigned msg_conv;
9632         msg_conv.inner = (void*)(msg & (~1));
9633         msg_conv.is_owned = false;
9634         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9635         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9636 }
9637
9638 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) {
9639         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9640         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9641         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9642         LDKPublicKey their_node_id_ref;
9643         CHECK(their_node_id->arr_len == 33);
9644         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9645         LDKRevokeAndACK msg_conv;
9646         msg_conv.inner = (void*)(msg & (~1));
9647         msg_conv.is_owned = false;
9648         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9649         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9650 }
9651
9652 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) {
9653         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9654         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9655         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9656         LDKPublicKey their_node_id_ref;
9657         CHECK(their_node_id->arr_len == 33);
9658         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9659         LDKUpdateFee msg_conv;
9660         msg_conv.inner = (void*)(msg & (~1));
9661         msg_conv.is_owned = false;
9662         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9663         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9664 }
9665
9666 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) {
9667         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9668         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9669         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9670         LDKPublicKey their_node_id_ref;
9671         CHECK(their_node_id->arr_len == 33);
9672         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9673         LDKAnnouncementSignatures msg_conv;
9674         msg_conv.inner = (void*)(msg & (~1));
9675         msg_conv.is_owned = false;
9676         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9677         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9678 }
9679
9680 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) {
9681         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9682         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9683         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9684         LDKPublicKey their_node_id_ref;
9685         CHECK(their_node_id->arr_len == 33);
9686         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9687         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
9688 }
9689
9690 void  __attribute__((export_name("TS_ChannelMessageHandler_peer_connected"))) TS_ChannelMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
9691         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9692         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9693         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9694         LDKPublicKey their_node_id_ref;
9695         CHECK(their_node_id->arr_len == 33);
9696         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9697         LDKInit msg_conv;
9698         msg_conv.inner = (void*)(msg & (~1));
9699         msg_conv.is_owned = false;
9700         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9701         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9702 }
9703
9704 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) {
9705         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9706         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9707         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9708         LDKPublicKey their_node_id_ref;
9709         CHECK(their_node_id->arr_len == 33);
9710         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9711         LDKChannelReestablish msg_conv;
9712         msg_conv.inner = (void*)(msg & (~1));
9713         msg_conv.is_owned = false;
9714         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9715         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9716 }
9717
9718 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) {
9719         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9720         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9721         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9722         LDKPublicKey their_node_id_ref;
9723         CHECK(their_node_id->arr_len == 33);
9724         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9725         LDKChannelUpdate msg_conv;
9726         msg_conv.inner = (void*)(msg & (~1));
9727         msg_conv.is_owned = false;
9728         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9729         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9730 }
9731
9732 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_error"))) TS_ChannelMessageHandler_handle_error(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
9733         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9734         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9735         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9736         LDKPublicKey their_node_id_ref;
9737         CHECK(their_node_id->arr_len == 33);
9738         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9739         LDKErrorMessage msg_conv;
9740         msg_conv.inner = (void*)(msg & (~1));
9741         msg_conv.is_owned = false;
9742         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9743         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9744 }
9745
9746 typedef struct LDKRoutingMessageHandler_JCalls {
9747         atomic_size_t refcnt;
9748         uint32_t instance_ptr;
9749         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
9750 } LDKRoutingMessageHandler_JCalls;
9751 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
9752         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9753         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9754                 FREE(j_calls);
9755         }
9756 }
9757 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
9758         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9759         LDKNodeAnnouncement msg_var = *msg;
9760         uint32_t msg_ref = 0;
9761         msg_var = NodeAnnouncement_clone(&msg_var);
9762         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9763         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9764         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9765         msg_ref = (uintptr_t)msg_var.inner;
9766         if (msg_var.is_owned) {
9767                 msg_ref |= 1;
9768         }
9769         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 73, (uint32_t)msg_ref);
9770         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9771         CHECK_ACCESS(ret_ptr);
9772         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9773         FREE((void*)ret);
9774         return ret_conv;
9775 }
9776 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
9777         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9778         LDKChannelAnnouncement msg_var = *msg;
9779         uint32_t msg_ref = 0;
9780         msg_var = ChannelAnnouncement_clone(&msg_var);
9781         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9782         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9783         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9784         msg_ref = (uintptr_t)msg_var.inner;
9785         if (msg_var.is_owned) {
9786                 msg_ref |= 1;
9787         }
9788         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 74, (uint32_t)msg_ref);
9789         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9790         CHECK_ACCESS(ret_ptr);
9791         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9792         FREE((void*)ret);
9793         return ret_conv;
9794 }
9795 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
9796         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9797         LDKChannelUpdate msg_var = *msg;
9798         uint32_t msg_ref = 0;
9799         msg_var = ChannelUpdate_clone(&msg_var);
9800         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9801         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9802         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9803         msg_ref = (uintptr_t)msg_var.inner;
9804         if (msg_var.is_owned) {
9805                 msg_ref |= 1;
9806         }
9807         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 75, (uint32_t)msg_ref);
9808         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9809         CHECK_ACCESS(ret_ptr);
9810         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9811         FREE((void*)ret);
9812         return ret_conv;
9813 }
9814 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
9815         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9816         int64_t starting_point_conv = starting_point;
9817         int8_t batch_amount_conv = batch_amount;
9818         uint32_tArray ret = (uint32_tArray)js_invoke_function_2(j_calls->instance_ptr, 76, (uint32_t)starting_point_conv, (uint32_t)batch_amount_conv);
9819         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
9820         ret_constr.datalen = ret->arr_len;
9821         if (ret_constr.datalen > 0)
9822                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
9823         else
9824                 ret_constr.data = NULL;
9825         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
9826         for (size_t h = 0; h < ret_constr.datalen; h++) {
9827                 uint32_t ret_conv_59 = ret_vals[h];
9828                 void* ret_conv_59_ptr = (void*)(((uintptr_t)ret_conv_59) & ~1);
9829                 CHECK_ACCESS(ret_conv_59_ptr);
9830                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ret_conv_59_ptr);
9831                 FREE((void*)ret_conv_59);
9832                 ret_constr.data[h] = ret_conv_59_conv;
9833         }
9834         return ret_constr;
9835 }
9836 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
9837         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9838         int8_tArray starting_point_arr = init_int8_tArray(33, __LINE__);
9839         memcpy(starting_point_arr->elems, starting_point.compressed_form, 33);
9840         int8_t batch_amount_conv = batch_amount;
9841         uint32_tArray ret = (uint32_tArray)js_invoke_function_2(j_calls->instance_ptr, 77, (uint32_t)starting_point_arr, (uint32_t)batch_amount_conv);
9842         LDKCVec_NodeAnnouncementZ ret_constr;
9843         ret_constr.datalen = ret->arr_len;
9844         if (ret_constr.datalen > 0)
9845                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
9846         else
9847                 ret_constr.data = NULL;
9848         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
9849         for (size_t s = 0; s < ret_constr.datalen; s++) {
9850                 uint32_t ret_conv_18 = ret_vals[s];
9851                 LDKNodeAnnouncement ret_conv_18_conv;
9852                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
9853                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
9854                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_conv);
9855                 ret_constr.data[s] = ret_conv_18_conv;
9856         }
9857         return ret_constr;
9858 }
9859 void peer_connected_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
9860         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9861         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9862         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9863         LDKInit init_var = *init;
9864         uint32_t init_ref = 0;
9865         init_var = Init_clone(&init_var);
9866         CHECK((((uintptr_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9867         CHECK((((uintptr_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9868         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
9869         init_ref = (uintptr_t)init_var.inner;
9870         if (init_var.is_owned) {
9871                 init_ref |= 1;
9872         }
9873         js_invoke_function_2(j_calls->instance_ptr, 78, (uint32_t)their_node_id_arr, (uint32_t)init_ref);
9874 }
9875 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
9876         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9877         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9878         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9879         LDKReplyChannelRange msg_var = msg;
9880         uint32_t msg_ref = 0;
9881         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9882         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9883         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9884         msg_ref = (uintptr_t)msg_var.inner;
9885         if (msg_var.is_owned) {
9886                 msg_ref |= 1;
9887         }
9888         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 79, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9889         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9890         CHECK_ACCESS(ret_ptr);
9891         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9892         FREE((void*)ret);
9893         return ret_conv;
9894 }
9895 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
9896         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9897         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9898         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9899         LDKReplyShortChannelIdsEnd msg_var = msg;
9900         uint32_t msg_ref = 0;
9901         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9902         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9903         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9904         msg_ref = (uintptr_t)msg_var.inner;
9905         if (msg_var.is_owned) {
9906                 msg_ref |= 1;
9907         }
9908         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 80, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9909         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9910         CHECK_ACCESS(ret_ptr);
9911         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9912         FREE((void*)ret);
9913         return ret_conv;
9914 }
9915 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
9916         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9917         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9918         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9919         LDKQueryChannelRange msg_var = msg;
9920         uint32_t msg_ref = 0;
9921         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9922         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9923         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9924         msg_ref = (uintptr_t)msg_var.inner;
9925         if (msg_var.is_owned) {
9926                 msg_ref |= 1;
9927         }
9928         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 81, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9929         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9930         CHECK_ACCESS(ret_ptr);
9931         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9932         FREE((void*)ret);
9933         return ret_conv;
9934 }
9935 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
9936         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9937         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9938         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9939         LDKQueryShortChannelIds msg_var = msg;
9940         uint32_t msg_ref = 0;
9941         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9942         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9943         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9944         msg_ref = (uintptr_t)msg_var.inner;
9945         if (msg_var.is_owned) {
9946                 msg_ref |= 1;
9947         }
9948         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 82, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9949         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9950         CHECK_ACCESS(ret_ptr);
9951         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9952         FREE((void*)ret);
9953         return ret_conv;
9954 }
9955 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
9956         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
9957         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9958         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
9959 }
9960 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JSValue o, JSValue MessageSendEventsProvider) {
9961         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
9962         atomic_init(&calls->refcnt, 1);
9963         calls->instance_ptr = o;
9964
9965         LDKRoutingMessageHandler ret = {
9966                 .this_arg = (void*) calls,
9967                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
9968                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
9969                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
9970                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
9971                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
9972                 .peer_connected = peer_connected_LDKRoutingMessageHandler_jcall,
9973                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
9974                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
9975                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
9976                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
9977                 .free = LDKRoutingMessageHandler_JCalls_free,
9978                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
9979         };
9980         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
9981         return ret;
9982 }
9983 long  __attribute__((export_name("TS_LDKRoutingMessageHandler_new"))) TS_LDKRoutingMessageHandler_new(JSValue o, JSValue MessageSendEventsProvider) {
9984         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
9985         *res_ptr = LDKRoutingMessageHandler_init(o, MessageSendEventsProvider);
9986         return (long)res_ptr;
9987 }
9988 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_node_announcement"))) TS_RoutingMessageHandler_handle_node_announcement(uint32_t this_arg, uint32_t msg) {
9989         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9990         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9991         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9992         LDKNodeAnnouncement msg_conv;
9993         msg_conv.inner = (void*)(msg & (~1));
9994         msg_conv.is_owned = false;
9995         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9996         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9997         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
9998         return (uint32_t)ret_conv;
9999 }
10000
10001 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_channel_announcement"))) TS_RoutingMessageHandler_handle_channel_announcement(uint32_t this_arg, 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         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10005         LDKChannelAnnouncement msg_conv;
10006         msg_conv.inner = (void*)(msg & (~1));
10007         msg_conv.is_owned = false;
10008         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10009         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
10010         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
10011         return (uint32_t)ret_conv;
10012 }
10013
10014 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_channel_update"))) TS_RoutingMessageHandler_handle_channel_update(uint32_t this_arg, uint32_t msg) {
10015         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10016         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10017         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10018         LDKChannelUpdate msg_conv;
10019         msg_conv.inner = (void*)(msg & (~1));
10020         msg_conv.is_owned = false;
10021         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10022         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
10023         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
10024         return (uint32_t)ret_conv;
10025 }
10026
10027 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) {
10028         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10029         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10030         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10031         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
10032         uint32_tArray ret_arr = NULL;
10033         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
10034         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
10035         for (size_t h = 0; h < ret_var.datalen; h++) {
10036                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
10037                 *ret_conv_59_conv = ret_var.data[h];
10038                 ret_arr_ptr[h] = ((uint32_t)ret_conv_59_conv);
10039         }
10040         
10041         FREE(ret_var.data);
10042         return ret_arr;
10043 }
10044
10045 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) {
10046         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10047         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10048         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10049         LDKPublicKey starting_point_ref;
10050         CHECK(starting_point->arr_len == 33);
10051         memcpy(starting_point_ref.compressed_form, starting_point->elems, 33); FREE(starting_point);
10052         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
10053         uint32_tArray ret_arr = NULL;
10054         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
10055         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
10056         for (size_t s = 0; s < ret_var.datalen; s++) {
10057                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
10058                 uint32_t ret_conv_18_ref = 0;
10059                 CHECK((((uintptr_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10060                 CHECK((((uintptr_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10061                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_var);
10062                 ret_conv_18_ref = (uintptr_t)ret_conv_18_var.inner;
10063                 if (ret_conv_18_var.is_owned) {
10064                         ret_conv_18_ref |= 1;
10065                 }
10066                 ret_arr_ptr[s] = ret_conv_18_ref;
10067         }
10068         
10069         FREE(ret_var.data);
10070         return ret_arr;
10071 }
10072
10073 void  __attribute__((export_name("TS_RoutingMessageHandler_peer_connected"))) TS_RoutingMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t init) {
10074         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10075         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10076         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10077         LDKPublicKey their_node_id_ref;
10078         CHECK(their_node_id->arr_len == 33);
10079         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10080         LDKInit init_conv;
10081         init_conv.inner = (void*)(init & (~1));
10082         init_conv.is_owned = false;
10083         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
10084         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
10085 }
10086
10087 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) {
10088         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10089         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10090         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10091         LDKPublicKey their_node_id_ref;
10092         CHECK(their_node_id->arr_len == 33);
10093         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10094         LDKReplyChannelRange msg_conv;
10095         msg_conv.inner = (void*)(msg & (~1));
10096         msg_conv.is_owned = (msg & 1) || (msg == 0);
10097         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10098         msg_conv = ReplyChannelRange_clone(&msg_conv);
10099         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10100         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
10101         return (uint32_t)ret_conv;
10102 }
10103
10104 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) {
10105         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10106         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10107         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10108         LDKPublicKey their_node_id_ref;
10109         CHECK(their_node_id->arr_len == 33);
10110         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10111         LDKReplyShortChannelIdsEnd msg_conv;
10112         msg_conv.inner = (void*)(msg & (~1));
10113         msg_conv.is_owned = (msg & 1) || (msg == 0);
10114         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10115         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
10116         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10117         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
10118         return (uint32_t)ret_conv;
10119 }
10120
10121 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) {
10122         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10123         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10124         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10125         LDKPublicKey their_node_id_ref;
10126         CHECK(their_node_id->arr_len == 33);
10127         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10128         LDKQueryChannelRange msg_conv;
10129         msg_conv.inner = (void*)(msg & (~1));
10130         msg_conv.is_owned = (msg & 1) || (msg == 0);
10131         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10132         msg_conv = QueryChannelRange_clone(&msg_conv);
10133         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10134         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
10135         return (uint32_t)ret_conv;
10136 }
10137
10138 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) {
10139         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10140         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10141         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
10142         LDKPublicKey their_node_id_ref;
10143         CHECK(their_node_id->arr_len == 33);
10144         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
10145         LDKQueryShortChannelIds msg_conv;
10146         msg_conv.inner = (void*)(msg & (~1));
10147         msg_conv.is_owned = (msg & 1) || (msg == 0);
10148         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
10149         msg_conv = QueryShortChannelIds_clone(&msg_conv);
10150         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10151         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
10152         return (uint32_t)ret_conv;
10153 }
10154
10155 typedef struct LDKCustomMessageReader_JCalls {
10156         atomic_size_t refcnt;
10157         uint32_t instance_ptr;
10158 } LDKCustomMessageReader_JCalls;
10159 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
10160         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
10161         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10162                 FREE(j_calls);
10163         }
10164 }
10165 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
10166         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
10167         int16_t message_type_conv = message_type;
10168         LDKu8slice buffer_var = buffer;
10169         int8_tArray buffer_arr = init_int8_tArray(buffer_var.datalen, __LINE__);
10170         memcpy(buffer_arr->elems, buffer_var.data, buffer_var.datalen);
10171         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 83, (uint32_t)message_type_conv, (uint32_t)buffer_arr);
10172         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10173         CHECK_ACCESS(ret_ptr);
10174         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
10175         FREE((void*)ret);
10176         return ret_conv;
10177 }
10178 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
10179         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
10180         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10181 }
10182 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JSValue o) {
10183         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
10184         atomic_init(&calls->refcnt, 1);
10185         calls->instance_ptr = o;
10186
10187         LDKCustomMessageReader ret = {
10188                 .this_arg = (void*) calls,
10189                 .read = read_LDKCustomMessageReader_jcall,
10190                 .free = LDKCustomMessageReader_JCalls_free,
10191         };
10192         return ret;
10193 }
10194 long  __attribute__((export_name("TS_LDKCustomMessageReader_new"))) TS_LDKCustomMessageReader_new(JSValue o) {
10195         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
10196         *res_ptr = LDKCustomMessageReader_init(o);
10197         return (long)res_ptr;
10198 }
10199 uint32_t  __attribute__((export_name("TS_CustomMessageReader_read"))) TS_CustomMessageReader_read(uint32_t this_arg, int16_t message_type, int8_tArray buffer) {
10200         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10201         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10202         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
10203         LDKu8slice buffer_ref;
10204         buffer_ref.datalen = buffer->arr_len;
10205         buffer_ref.data = buffer->elems /* XXX buffer leaks */;
10206         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
10207         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
10208         return (uint32_t)ret_conv;
10209 }
10210
10211 typedef struct LDKCustomMessageHandler_JCalls {
10212         atomic_size_t refcnt;
10213         uint32_t instance_ptr;
10214         LDKCustomMessageReader_JCalls* CustomMessageReader;
10215 } LDKCustomMessageHandler_JCalls;
10216 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
10217         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
10218         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10219                 FREE(j_calls);
10220         }
10221 }
10222 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
10223         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
10224         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
10225         *msg_ret = msg;
10226         int8_tArray sender_node_id_arr = init_int8_tArray(33, __LINE__);
10227         memcpy(sender_node_id_arr->elems, sender_node_id.compressed_form, 33);
10228         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 84, (uint32_t)(uint32_t)msg_ret, (uint32_t)sender_node_id_arr);
10229         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10230         CHECK_ACCESS(ret_ptr);
10231         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
10232         FREE((void*)ret);
10233         return ret_conv;
10234 }
10235 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
10236         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
10237         uint32_tArray ret = (uint32_tArray)js_invoke_function_0(j_calls->instance_ptr, 85);
10238         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
10239         ret_constr.datalen = ret->arr_len;
10240         if (ret_constr.datalen > 0)
10241                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
10242         else
10243                 ret_constr.data = NULL;
10244         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
10245         for (size_t z = 0; z < ret_constr.datalen; z++) {
10246                 uint32_t ret_conv_25 = ret_vals[z];
10247                 void* ret_conv_25_ptr = (void*)(((uintptr_t)ret_conv_25) & ~1);
10248                 CHECK_ACCESS(ret_conv_25_ptr);
10249                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
10250                 FREE((void*)ret_conv_25);
10251                 ret_constr.data[z] = ret_conv_25_conv;
10252         }
10253         return ret_constr;
10254 }
10255 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
10256         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
10257         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10258         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
10259 }
10260 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JSValue o, JSValue CustomMessageReader) {
10261         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
10262         atomic_init(&calls->refcnt, 1);
10263         calls->instance_ptr = o;
10264
10265         LDKCustomMessageHandler ret = {
10266                 .this_arg = (void*) calls,
10267                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
10268                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
10269                 .free = LDKCustomMessageHandler_JCalls_free,
10270                 .CustomMessageReader = LDKCustomMessageReader_init(CustomMessageReader),
10271         };
10272         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
10273         return ret;
10274 }
10275 long  __attribute__((export_name("TS_LDKCustomMessageHandler_new"))) TS_LDKCustomMessageHandler_new(JSValue o, JSValue CustomMessageReader) {
10276         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
10277         *res_ptr = LDKCustomMessageHandler_init(o, CustomMessageReader);
10278         return (long)res_ptr;
10279 }
10280 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) {
10281         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10282         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10283         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
10284         void* msg_ptr = (void*)(((uintptr_t)msg) & ~1);
10285         CHECK_ACCESS(msg_ptr);
10286         LDKType msg_conv = *(LDKType*)(msg_ptr);
10287         if (msg_conv.free == LDKType_JCalls_free) {
10288                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10289                 LDKType_JCalls_cloned(&msg_conv);
10290         }
10291         LDKPublicKey sender_node_id_ref;
10292         CHECK(sender_node_id->arr_len == 33);
10293         memcpy(sender_node_id_ref.compressed_form, sender_node_id->elems, 33); FREE(sender_node_id);
10294         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10295         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
10296         return (uint32_t)ret_conv;
10297 }
10298
10299 uint32_tArray  __attribute__((export_name("TS_CustomMessageHandler_get_and_clear_pending_msg"))) TS_CustomMessageHandler_get_and_clear_pending_msg(uint32_t this_arg) {
10300         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10301         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10302         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
10303         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
10304         uint32_tArray ret_arr = NULL;
10305         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
10306         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
10307         for (size_t z = 0; z < ret_var.datalen; z++) {
10308                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
10309                 *ret_conv_25_conv = ret_var.data[z];
10310                 ret_arr_ptr[z] = ((uint32_t)ret_conv_25_conv);
10311         }
10312         
10313         FREE(ret_var.data);
10314         return ret_arr;
10315 }
10316
10317 typedef struct LDKSocketDescriptor_JCalls {
10318         atomic_size_t refcnt;
10319         uint32_t instance_ptr;
10320 } LDKSocketDescriptor_JCalls;
10321 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
10322         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10323         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10324                 FREE(j_calls);
10325         }
10326 }
10327 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
10328         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10329         LDKu8slice data_var = data;
10330         int8_tArray data_arr = init_int8_tArray(data_var.datalen, __LINE__);
10331         memcpy(data_arr->elems, data_var.data, data_var.datalen);
10332         jboolean resume_read_conv = resume_read;
10333         return js_invoke_function_2(j_calls->instance_ptr, 86, (uint32_t)data_arr, (uint32_t)resume_read_conv);
10334 }
10335 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
10336         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10337         js_invoke_function_0(j_calls->instance_ptr, 87);
10338 }
10339 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
10340         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10341         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
10342         *other_arg_clone = SocketDescriptor_clone(other_arg);
10343         return js_invoke_function_1(j_calls->instance_ptr, 88, (uint32_t)(uint32_t)other_arg_clone);
10344 }
10345 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
10346         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10347         return js_invoke_function_0(j_calls->instance_ptr, 89);
10348 }
10349 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
10350         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
10351         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10352 }
10353 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JSValue o) {
10354         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
10355         atomic_init(&calls->refcnt, 1);
10356         calls->instance_ptr = o;
10357
10358         LDKSocketDescriptor ret = {
10359                 .this_arg = (void*) calls,
10360                 .send_data = send_data_LDKSocketDescriptor_jcall,
10361                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
10362                 .eq = eq_LDKSocketDescriptor_jcall,
10363                 .hash = hash_LDKSocketDescriptor_jcall,
10364                 .cloned = LDKSocketDescriptor_JCalls_cloned,
10365                 .free = LDKSocketDescriptor_JCalls_free,
10366         };
10367         return ret;
10368 }
10369 long  __attribute__((export_name("TS_LDKSocketDescriptor_new"))) TS_LDKSocketDescriptor_new(JSValue o) {
10370         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
10371         *res_ptr = LDKSocketDescriptor_init(o);
10372         return (long)res_ptr;
10373 }
10374 uint32_t  __attribute__((export_name("TS_SocketDescriptor_send_data"))) TS_SocketDescriptor_send_data(uint32_t this_arg, int8_tArray data, jboolean resume_read) {
10375         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10376         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10377         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
10378         LDKu8slice data_ref;
10379         data_ref.datalen = data->arr_len;
10380         data_ref.data = data->elems /* XXX data leaks */;
10381         uint32_t ret_conv = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
10382         return ret_conv;
10383 }
10384
10385 void  __attribute__((export_name("TS_SocketDescriptor_disconnect_socket"))) TS_SocketDescriptor_disconnect_socket(uint32_t this_arg) {
10386         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10387         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10388         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
10389         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
10390 }
10391
10392 int64_t  __attribute__((export_name("TS_SocketDescriptor_hash"))) TS_SocketDescriptor_hash(uint32_t this_arg) {
10393         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10394         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10395         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
10396         int64_t ret_conv = (this_arg_conv->hash)(this_arg_conv->this_arg);
10397         return ret_conv;
10398 }
10399
10400 uint32_t __attribute__((export_name("TS_LDKEffectiveCapacity_ty_from_ptr"))) TS_LDKEffectiveCapacity_ty_from_ptr(uint32_t ptr) {
10401         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
10402         switch(obj->tag) {
10403                 case LDKEffectiveCapacity_ExactLiquidity: return 0;
10404                 case LDKEffectiveCapacity_MaximumHTLC: return 1;
10405                 case LDKEffectiveCapacity_Total: return 2;
10406                 case LDKEffectiveCapacity_Infinite: return 3;
10407                 case LDKEffectiveCapacity_Unknown: return 4;
10408                 default: abort();
10409         }
10410 }
10411 int64_t __attribute__((export_name("TS_LDKEffectiveCapacity_ExactLiquidity_get_liquidity_msat"))) TS_LDKEffectiveCapacity_ExactLiquidity_get_liquidity_msat(uint32_t ptr) {
10412         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
10413         assert(obj->tag == LDKEffectiveCapacity_ExactLiquidity);
10414                         int64_t liquidity_msat_conv = obj->exact_liquidity.liquidity_msat;
10415         return liquidity_msat_conv;
10416 }
10417 int64_t __attribute__((export_name("TS_LDKEffectiveCapacity_MaximumHTLC_get_amount_msat"))) TS_LDKEffectiveCapacity_MaximumHTLC_get_amount_msat(uint32_t ptr) {
10418         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
10419         assert(obj->tag == LDKEffectiveCapacity_MaximumHTLC);
10420                         int64_t amount_msat_conv = obj->maximum_htlc.amount_msat;
10421         return amount_msat_conv;
10422 }
10423 int64_t __attribute__((export_name("TS_LDKEffectiveCapacity_Total_get_capacity_msat"))) TS_LDKEffectiveCapacity_Total_get_capacity_msat(uint32_t ptr) {
10424         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
10425         assert(obj->tag == LDKEffectiveCapacity_Total);
10426                         int64_t capacity_msat_conv = obj->total.capacity_msat;
10427         return capacity_msat_conv;
10428 }
10429 typedef struct LDKLockableScore_JCalls {
10430         atomic_size_t refcnt;
10431         uint32_t instance_ptr;
10432 } LDKLockableScore_JCalls;
10433 static void LDKLockableScore_JCalls_free(void* this_arg) {
10434         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
10435         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10436                 FREE(j_calls);
10437         }
10438 }
10439 LDKScore lock_LDKLockableScore_jcall(const void* this_arg) {
10440         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
10441         uint32_t ret = js_invoke_function_0(j_calls->instance_ptr, 90);
10442         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10443         CHECK_ACCESS(ret_ptr);
10444         LDKScore ret_conv = *(LDKScore*)(ret_ptr);
10445         if (ret_conv.free == LDKScore_JCalls_free) {
10446                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10447                 LDKScore_JCalls_cloned(&ret_conv);
10448         }// WARNING: we may need a move here but no clone is available for LDKScore
10449         
10450         return ret_conv;
10451 }
10452 static void LDKLockableScore_JCalls_cloned(LDKLockableScore* new_obj) {
10453         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) new_obj->this_arg;
10454         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10455 }
10456 static inline LDKLockableScore LDKLockableScore_init (JSValue o) {
10457         LDKLockableScore_JCalls *calls = MALLOC(sizeof(LDKLockableScore_JCalls), "LDKLockableScore_JCalls");
10458         atomic_init(&calls->refcnt, 1);
10459         calls->instance_ptr = o;
10460
10461         LDKLockableScore ret = {
10462                 .this_arg = (void*) calls,
10463                 .lock = lock_LDKLockableScore_jcall,
10464                 .free = LDKLockableScore_JCalls_free,
10465         };
10466         return ret;
10467 }
10468 long  __attribute__((export_name("TS_LDKLockableScore_new"))) TS_LDKLockableScore_new(JSValue o) {
10469         LDKLockableScore *res_ptr = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
10470         *res_ptr = LDKLockableScore_init(o);
10471         return (long)res_ptr;
10472 }
10473 uint32_t  __attribute__((export_name("TS_LockableScore_lock"))) TS_LockableScore_lock(uint32_t this_arg) {
10474         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10475         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10476         LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
10477         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
10478         *ret_ret = (this_arg_conv->lock)(this_arg_conv->this_arg);
10479         return (uint32_t)ret_ret;
10480 }
10481
10482 uint32_t __attribute__((export_name("TS_LDKFallback_ty_from_ptr"))) TS_LDKFallback_ty_from_ptr(uint32_t ptr) {
10483         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10484         switch(obj->tag) {
10485                 case LDKFallback_SegWitProgram: return 0;
10486                 case LDKFallback_PubKeyHash: return 1;
10487                 case LDKFallback_ScriptHash: return 2;
10488                 default: abort();
10489         }
10490 }
10491 int8_t __attribute__((export_name("TS_LDKFallback_SegWitProgram_get_version"))) TS_LDKFallback_SegWitProgram_get_version(uint32_t ptr) {
10492         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10493         assert(obj->tag == LDKFallback_SegWitProgram);
10494                         uint8_t version_val = obj->seg_wit_program.version._0;
10495         return version_val;
10496 }
10497 int8_tArray __attribute__((export_name("TS_LDKFallback_SegWitProgram_get_program"))) TS_LDKFallback_SegWitProgram_get_program(uint32_t ptr) {
10498         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10499         assert(obj->tag == LDKFallback_SegWitProgram);
10500                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
10501                         int8_tArray program_arr = init_int8_tArray(program_var.datalen, __LINE__);
10502                         memcpy(program_arr->elems, program_var.data, program_var.datalen);
10503         return program_arr;
10504 }
10505 int8_tArray __attribute__((export_name("TS_LDKFallback_PubKeyHash_get_pub_key_hash"))) TS_LDKFallback_PubKeyHash_get_pub_key_hash(uint32_t ptr) {
10506         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10507         assert(obj->tag == LDKFallback_PubKeyHash);
10508                         int8_tArray pub_key_hash_arr = init_int8_tArray(20, __LINE__);
10509                         memcpy(pub_key_hash_arr->elems, obj->pub_key_hash.data, 20);
10510         return pub_key_hash_arr;
10511 }
10512 int8_tArray __attribute__((export_name("TS_LDKFallback_ScriptHash_get_script_hash"))) TS_LDKFallback_ScriptHash_get_script_hash(uint32_t ptr) {
10513         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10514         assert(obj->tag == LDKFallback_ScriptHash);
10515                         int8_tArray script_hash_arr = init_int8_tArray(20, __LINE__);
10516                         memcpy(script_hash_arr->elems, obj->script_hash.data, 20);
10517         return script_hash_arr;
10518 }
10519 typedef struct LDKPayer_JCalls {
10520         atomic_size_t refcnt;
10521         uint32_t instance_ptr;
10522 } LDKPayer_JCalls;
10523 static void LDKPayer_JCalls_free(void* this_arg) {
10524         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10525         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10526                 FREE(j_calls);
10527         }
10528 }
10529 LDKPublicKey node_id_LDKPayer_jcall(const void* this_arg) {
10530         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10531         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 91);
10532         LDKPublicKey ret_ref;
10533         CHECK(ret->arr_len == 33);
10534         memcpy(ret_ref.compressed_form, ret->elems, 33); FREE(ret);
10535         return ret_ref;
10536 }
10537 LDKCVec_ChannelDetailsZ first_hops_LDKPayer_jcall(const void* this_arg) {
10538         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10539         uint32_tArray ret = (uint32_tArray)js_invoke_function_0(j_calls->instance_ptr, 92);
10540         LDKCVec_ChannelDetailsZ ret_constr;
10541         ret_constr.datalen = ret->arr_len;
10542         if (ret_constr.datalen > 0)
10543                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
10544         else
10545                 ret_constr.data = NULL;
10546         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
10547         for (size_t q = 0; q < ret_constr.datalen; q++) {
10548                 uint32_t ret_conv_16 = ret_vals[q];
10549                 LDKChannelDetails ret_conv_16_conv;
10550                 ret_conv_16_conv.inner = (void*)(ret_conv_16 & (~1));
10551                 ret_conv_16_conv.is_owned = (ret_conv_16 & 1) || (ret_conv_16 == 0);
10552                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_conv);
10553                 ret_constr.data[q] = ret_conv_16_conv;
10554         }
10555         return ret_constr;
10556 }
10557 LDKCResult_PaymentIdPaymentSendFailureZ send_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret) {
10558         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10559         LDKRoute route_var = *route;
10560         uint32_t route_ref = 0;
10561         route_var = Route_clone(&route_var);
10562         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10563         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10564         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
10565         route_ref = (uintptr_t)route_var.inner;
10566         if (route_var.is_owned) {
10567                 route_ref |= 1;
10568         }
10569         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
10570         memcpy(payment_hash_arr->elems, payment_hash.data, 32);
10571         int8_tArray payment_secret_arr = init_int8_tArray(32, __LINE__);
10572         memcpy(payment_secret_arr->elems, payment_secret.data, 32);
10573         uint32_t ret = js_invoke_function_3(j_calls->instance_ptr, 93, (uint32_t)route_ref, (uint32_t)payment_hash_arr, (uint32_t)payment_secret_arr);
10574         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10575         CHECK_ACCESS(ret_ptr);
10576         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
10577         FREE((void*)ret);
10578         return ret_conv;
10579 }
10580 LDKCResult_PaymentIdPaymentSendFailureZ send_spontaneous_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_preimage) {
10581         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10582         LDKRoute route_var = *route;
10583         uint32_t route_ref = 0;
10584         route_var = Route_clone(&route_var);
10585         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10586         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10587         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
10588         route_ref = (uintptr_t)route_var.inner;
10589         if (route_var.is_owned) {
10590                 route_ref |= 1;
10591         }
10592         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
10593         memcpy(payment_preimage_arr->elems, payment_preimage.data, 32);
10594         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 94, (uint32_t)route_ref, (uint32_t)payment_preimage_arr);
10595         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10596         CHECK_ACCESS(ret_ptr);
10597         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
10598         FREE((void*)ret);
10599         return ret_conv;
10600 }
10601 LDKCResult_NonePaymentSendFailureZ retry_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_id) {
10602         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10603         LDKRoute route_var = *route;
10604         uint32_t route_ref = 0;
10605         route_var = Route_clone(&route_var);
10606         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10607         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10608         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
10609         route_ref = (uintptr_t)route_var.inner;
10610         if (route_var.is_owned) {
10611                 route_ref |= 1;
10612         }
10613         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
10614         memcpy(payment_id_arr->elems, payment_id.data, 32);
10615         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 95, (uint32_t)route_ref, (uint32_t)payment_id_arr);
10616         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10617         CHECK_ACCESS(ret_ptr);
10618         LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
10619         FREE((void*)ret);
10620         return ret_conv;
10621 }
10622 void abandon_payment_LDKPayer_jcall(const void* this_arg, LDKThirtyTwoBytes payment_id) {
10623         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10624         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
10625         memcpy(payment_id_arr->elems, payment_id.data, 32);
10626         js_invoke_function_1(j_calls->instance_ptr, 96, (uint32_t)payment_id_arr);
10627 }
10628 static void LDKPayer_JCalls_cloned(LDKPayer* new_obj) {
10629         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) new_obj->this_arg;
10630         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10631 }
10632 static inline LDKPayer LDKPayer_init (JSValue o) {
10633         LDKPayer_JCalls *calls = MALLOC(sizeof(LDKPayer_JCalls), "LDKPayer_JCalls");
10634         atomic_init(&calls->refcnt, 1);
10635         calls->instance_ptr = o;
10636
10637         LDKPayer ret = {
10638                 .this_arg = (void*) calls,
10639                 .node_id = node_id_LDKPayer_jcall,
10640                 .first_hops = first_hops_LDKPayer_jcall,
10641                 .send_payment = send_payment_LDKPayer_jcall,
10642                 .send_spontaneous_payment = send_spontaneous_payment_LDKPayer_jcall,
10643                 .retry_payment = retry_payment_LDKPayer_jcall,
10644                 .abandon_payment = abandon_payment_LDKPayer_jcall,
10645                 .free = LDKPayer_JCalls_free,
10646         };
10647         return ret;
10648 }
10649 long  __attribute__((export_name("TS_LDKPayer_new"))) TS_LDKPayer_new(JSValue o) {
10650         LDKPayer *res_ptr = MALLOC(sizeof(LDKPayer), "LDKPayer");
10651         *res_ptr = LDKPayer_init(o);
10652         return (long)res_ptr;
10653 }
10654 int8_tArray  __attribute__((export_name("TS_Payer_node_id"))) TS_Payer_node_id(uint32_t this_arg) {
10655         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10656         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10657         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10658         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
10659         memcpy(ret_arr->elems, (this_arg_conv->node_id)(this_arg_conv->this_arg).compressed_form, 33);
10660         return ret_arr;
10661 }
10662
10663 uint32_tArray  __attribute__((export_name("TS_Payer_first_hops"))) TS_Payer_first_hops(uint32_t this_arg) {
10664         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10665         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10666         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10667         LDKCVec_ChannelDetailsZ ret_var = (this_arg_conv->first_hops)(this_arg_conv->this_arg);
10668         uint32_tArray ret_arr = NULL;
10669         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
10670         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
10671         for (size_t q = 0; q < ret_var.datalen; q++) {
10672                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
10673                 uint32_t ret_conv_16_ref = 0;
10674                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10675                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10676                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
10677                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
10678                 if (ret_conv_16_var.is_owned) {
10679                         ret_conv_16_ref |= 1;
10680                 }
10681                 ret_arr_ptr[q] = ret_conv_16_ref;
10682         }
10683         
10684         FREE(ret_var.data);
10685         return ret_arr;
10686 }
10687
10688 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) {
10689         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10690         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10691         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10692         LDKRoute route_conv;
10693         route_conv.inner = (void*)(route & (~1));
10694         route_conv.is_owned = false;
10695         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
10696         LDKThirtyTwoBytes payment_hash_ref;
10697         CHECK(payment_hash->arr_len == 32);
10698         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
10699         LDKThirtyTwoBytes payment_secret_ref;
10700         CHECK(payment_secret->arr_len == 32);
10701         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
10702         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
10703         *ret_conv = (this_arg_conv->send_payment)(this_arg_conv->this_arg, &route_conv, payment_hash_ref, payment_secret_ref);
10704         return (uint32_t)ret_conv;
10705 }
10706
10707 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) {
10708         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10709         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10710         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10711         LDKRoute route_conv;
10712         route_conv.inner = (void*)(route & (~1));
10713         route_conv.is_owned = false;
10714         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
10715         LDKThirtyTwoBytes payment_preimage_ref;
10716         CHECK(payment_preimage->arr_len == 32);
10717         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
10718         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
10719         *ret_conv = (this_arg_conv->send_spontaneous_payment)(this_arg_conv->this_arg, &route_conv, payment_preimage_ref);
10720         return (uint32_t)ret_conv;
10721 }
10722
10723 uint32_t  __attribute__((export_name("TS_Payer_retry_payment"))) TS_Payer_retry_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_id) {
10724         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10725         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10726         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10727         LDKRoute route_conv;
10728         route_conv.inner = (void*)(route & (~1));
10729         route_conv.is_owned = false;
10730         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
10731         LDKThirtyTwoBytes payment_id_ref;
10732         CHECK(payment_id->arr_len == 32);
10733         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
10734         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10735         *ret_conv = (this_arg_conv->retry_payment)(this_arg_conv->this_arg, &route_conv, payment_id_ref);
10736         return (uint32_t)ret_conv;
10737 }
10738
10739 void  __attribute__((export_name("TS_Payer_abandon_payment"))) TS_Payer_abandon_payment(uint32_t this_arg, int8_tArray payment_id) {
10740         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10741         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10742         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10743         LDKThirtyTwoBytes payment_id_ref;
10744         CHECK(payment_id->arr_len == 32);
10745         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
10746         (this_arg_conv->abandon_payment)(this_arg_conv->this_arg, payment_id_ref);
10747 }
10748
10749 typedef struct LDKRouter_JCalls {
10750         atomic_size_t refcnt;
10751         uint32_t instance_ptr;
10752 } LDKRouter_JCalls;
10753 static void LDKRouter_JCalls_free(void* this_arg) {
10754         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
10755         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10756                 FREE(j_calls);
10757         }
10758 }
10759 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) {
10760         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
10761         int8_tArray payer_arr = init_int8_tArray(33, __LINE__);
10762         memcpy(payer_arr->elems, payer.compressed_form, 33);
10763         LDKRouteParameters route_params_var = *route_params;
10764         uint32_t route_params_ref = 0;
10765         route_params_var = RouteParameters_clone(&route_params_var);
10766         CHECK((((uintptr_t)route_params_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10767         CHECK((((uintptr_t)&route_params_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10768         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
10769         route_params_ref = (uintptr_t)route_params_var.inner;
10770         if (route_params_var.is_owned) {
10771                 route_params_ref |= 1;
10772         }
10773         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
10774         memcpy(payment_hash_arr->elems, *payment_hash, 32);
10775         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
10776         uint32_tArray first_hops_arr = NULL;
10777         if (first_hops != NULL) {
10778                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
10779                 first_hops_arr = init_uint32_tArray(first_hops_var.datalen, __LINE__);
10780                 uint32_t *first_hops_arr_ptr = (uint32_t*)(((uint8_t*)first_hops_arr) + 4);
10781                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
10782                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
10783                         uint32_t first_hops_conv_16_ref = 0;
10784                         CHECK((((uintptr_t)first_hops_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10785                         CHECK((((uintptr_t)&first_hops_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10786                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
10787                         first_hops_conv_16_ref = (uintptr_t)first_hops_conv_16_var.inner;
10788                         if (first_hops_conv_16_var.is_owned) {
10789                                 first_hops_conv_16_ref |= 1;
10790                         }
10791                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
10792                 }
10793         
10794         }
10795         // WARNING: This object doesn't live past this scope, needs clone!
10796         uint32_t ret_scorer = ((uintptr_t)scorer) | 1;
10797         uint32_t ret = js_invoke_function_5(j_calls->instance_ptr, 97, (uint32_t)payer_arr, (uint32_t)route_params_ref, (uint32_t)payment_hash_arr, (uint32_t)first_hops_arr, (uint32_t)ret_scorer);
10798         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10799         CHECK_ACCESS(ret_ptr);
10800         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
10801         FREE((void*)ret);
10802         return ret_conv;
10803 }
10804 static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
10805         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
10806         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10807 }
10808 static inline LDKRouter LDKRouter_init (JSValue o) {
10809         LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
10810         atomic_init(&calls->refcnt, 1);
10811         calls->instance_ptr = o;
10812
10813         LDKRouter ret = {
10814                 .this_arg = (void*) calls,
10815                 .find_route = find_route_LDKRouter_jcall,
10816                 .free = LDKRouter_JCalls_free,
10817         };
10818         return ret;
10819 }
10820 long  __attribute__((export_name("TS_LDKRouter_new"))) TS_LDKRouter_new(JSValue o) {
10821         LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
10822         *res_ptr = LDKRouter_init(o);
10823         return (long)res_ptr;
10824 }
10825 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) {
10826         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10827         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10828         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
10829         LDKPublicKey payer_ref;
10830         CHECK(payer->arr_len == 33);
10831         memcpy(payer_ref.compressed_form, payer->elems, 33); FREE(payer);
10832         LDKRouteParameters route_params_conv;
10833         route_params_conv.inner = (void*)(route_params & (~1));
10834         route_params_conv.is_owned = false;
10835         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
10836         unsigned char payment_hash_arr[32];
10837         CHECK(payment_hash->arr_len == 32);
10838         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
10839         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
10840         LDKCVec_ChannelDetailsZ first_hops_constr;
10841         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
10842         if (first_hops != 0) {
10843                 first_hops_constr.datalen = first_hops->arr_len;
10844                 if (first_hops_constr.datalen > 0)
10845                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
10846                 else
10847                         first_hops_constr.data = NULL;
10848                 uint32_t* first_hops_vals = first_hops->elems /* XXX first_hops leaks */;
10849                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
10850                         uint32_t first_hops_conv_16 = first_hops_vals[q];
10851                         LDKChannelDetails first_hops_conv_16_conv;
10852                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
10853                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
10854                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
10855                         first_hops_constr.data[q] = first_hops_conv_16_conv;
10856                 }
10857                 first_hops_ptr = &first_hops_constr;
10858         }
10859         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
10860         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
10861         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
10862         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
10863         *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);
10864         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
10865         return (uint32_t)ret_conv;
10866 }
10867
10868 uint32_t __attribute__((export_name("TS_LDKRetry_ty_from_ptr"))) TS_LDKRetry_ty_from_ptr(uint32_t ptr) {
10869         LDKRetry *obj = (LDKRetry*)(ptr & ~1);
10870         switch(obj->tag) {
10871                 case LDKRetry_Attempts: return 0;
10872                 default: abort();
10873         }
10874 }
10875 uint32_t __attribute__((export_name("TS_LDKRetry_Attempts_get_attempts"))) TS_LDKRetry_Attempts_get_attempts(uint32_t ptr) {
10876         LDKRetry *obj = (LDKRetry*)(ptr & ~1);
10877         assert(obj->tag == LDKRetry_Attempts);
10878                         uint32_t attempts_conv = obj->attempts;
10879         return attempts_conv;
10880 }
10881 jstring  __attribute__((export_name("TS__ldk_get_compiled_version"))) TS__ldk_get_compiled_version() {
10882         LDKStr ret_str = _ldk_get_compiled_version();
10883         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
10884         Str_free(ret_str);
10885         return ret_conv;
10886 }
10887
10888 jstring  __attribute__((export_name("TS__ldk_c_bindings_get_compiled_version"))) TS__ldk_c_bindings_get_compiled_version() {
10889         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
10890         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
10891         Str_free(ret_str);
10892         return ret_conv;
10893 }
10894
10895 static inline uintptr_t Bech32Error_clone_ptr(LDKBech32Error *NONNULL_PTR arg) {
10896         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
10897         *ret_copy = Bech32Error_clone(arg);
10898 uint32_t ret_ref = (uintptr_t)ret_copy;
10899         return ret_ref;
10900 }
10901 uint32_t  __attribute__((export_name("TS_Bech32Error_clone_ptr"))) TS_Bech32Error_clone_ptr(uint32_t arg) {
10902         LDKBech32Error* arg_conv = (LDKBech32Error*)arg;
10903         uint32_t ret_conv = Bech32Error_clone_ptr(arg_conv);
10904         return ret_conv;
10905 }
10906
10907 uint32_t  __attribute__((export_name("TS_Bech32Error_clone"))) TS_Bech32Error_clone(uint32_t orig) {
10908         LDKBech32Error* orig_conv = (LDKBech32Error*)orig;
10909         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
10910         *ret_copy = Bech32Error_clone(orig_conv);
10911         uint32_t ret_ref = (uintptr_t)ret_copy;
10912         return ret_ref;
10913 }
10914
10915 void  __attribute__((export_name("TS_Bech32Error_free"))) TS_Bech32Error_free(uint32_t o) {
10916         if ((o & 1) != 0) return;
10917         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
10918         CHECK_ACCESS(o_ptr);
10919         LDKBech32Error o_conv = *(LDKBech32Error*)(o_ptr);
10920         FREE((void*)o);
10921         Bech32Error_free(o_conv);
10922 }
10923
10924 void  __attribute__((export_name("TS_Transaction_free"))) TS_Transaction_free(int8_tArray _res) {
10925         LDKTransaction _res_ref;
10926         _res_ref.datalen = _res->arr_len;
10927         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
10928         memcpy(_res_ref.data, _res->elems, _res_ref.datalen); FREE(_res);
10929         _res_ref.data_is_owned = true;
10930         Transaction_free(_res_ref);
10931 }
10932
10933 uint32_t  __attribute__((export_name("TS_TxOut_new"))) TS_TxOut_new(int8_tArray script_pubkey, int64_t value) {
10934         LDKCVec_u8Z script_pubkey_ref;
10935         script_pubkey_ref.datalen = script_pubkey->arr_len;
10936         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
10937         memcpy(script_pubkey_ref.data, script_pubkey->elems, script_pubkey_ref.datalen); FREE(script_pubkey);
10938         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
10939         *ret_ref = TxOut_new(script_pubkey_ref, value);
10940         return (uint32_t)ret_ref;
10941 }
10942
10943 void  __attribute__((export_name("TS_TxOut_free"))) TS_TxOut_free(uint32_t _res) {
10944         if ((_res & 1) != 0) return;
10945         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10946         CHECK_ACCESS(_res_ptr);
10947         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
10948         FREE((void*)_res);
10949         TxOut_free(_res_conv);
10950 }
10951
10952 static inline uintptr_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
10953         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
10954         *ret_ref = TxOut_clone(arg);
10955         return (uint32_t)ret_ref;
10956 }
10957 uint32_t  __attribute__((export_name("TS_TxOut_clone_ptr"))) TS_TxOut_clone_ptr(uint32_t arg) {
10958         LDKTxOut* arg_conv = (LDKTxOut*)(arg & ~1);
10959         uint32_t ret_conv = TxOut_clone_ptr(arg_conv);
10960         return ret_conv;
10961 }
10962
10963 uint32_t  __attribute__((export_name("TS_TxOut_clone"))) TS_TxOut_clone(uint32_t orig) {
10964         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
10965         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
10966         *ret_ref = TxOut_clone(orig_conv);
10967         return (uint32_t)ret_ref;
10968 }
10969
10970 void  __attribute__((export_name("TS_Str_free"))) TS_Str_free(jstring _res) {
10971         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
10972         Str_free(dummy);
10973 }
10974
10975 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_ok"))) TS_CResult_NoneNoneZ_ok() {
10976         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10977         *ret_conv = CResult_NoneNoneZ_ok();
10978         return (uint32_t)ret_conv;
10979 }
10980
10981 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_err"))) TS_CResult_NoneNoneZ_err() {
10982         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10983         *ret_conv = CResult_NoneNoneZ_err();
10984         return (uint32_t)ret_conv;
10985 }
10986
10987 jboolean  __attribute__((export_name("TS_CResult_NoneNoneZ_is_ok"))) TS_CResult_NoneNoneZ_is_ok(uint32_t o) {
10988         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)(o & ~1);
10989         jboolean ret_conv = CResult_NoneNoneZ_is_ok(o_conv);
10990         return ret_conv;
10991 }
10992
10993 void  __attribute__((export_name("TS_CResult_NoneNoneZ_free"))) TS_CResult_NoneNoneZ_free(uint32_t _res) {
10994         if ((_res & 1) != 0) return;
10995         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10996         CHECK_ACCESS(_res_ptr);
10997         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
10998         FREE((void*)_res);
10999         CResult_NoneNoneZ_free(_res_conv);
11000 }
11001
11002 static inline uintptr_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
11003         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
11004         *ret_conv = CResult_NoneNoneZ_clone(arg);
11005         return (uint32_t)ret_conv;
11006 }
11007 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_clone_ptr"))) TS_CResult_NoneNoneZ_clone_ptr(uint32_t arg) {
11008         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)(arg & ~1);
11009         uint32_t ret_conv = CResult_NoneNoneZ_clone_ptr(arg_conv);
11010         return ret_conv;
11011 }
11012
11013 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_clone"))) TS_CResult_NoneNoneZ_clone(uint32_t orig) {
11014         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1);
11015         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
11016         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
11017         return (uint32_t)ret_conv;
11018 }
11019
11020 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(uint32_t o) {
11021         LDKCounterpartyCommitmentSecrets o_conv;
11022         o_conv.inner = (void*)(o & (~1));
11023         o_conv.is_owned = (o & 1) || (o == 0);
11024         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11025         o_conv = CounterpartyCommitmentSecrets_clone(&o_conv);
11026         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
11027         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(o_conv);
11028         return (uint32_t)ret_conv;
11029 }
11030
11031 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(uint32_t e) {
11032         LDKDecodeError e_conv;
11033         e_conv.inner = (void*)(e & (~1));
11034         e_conv.is_owned = (e & 1) || (e == 0);
11035         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11036         e_conv = DecodeError_clone(&e_conv);
11037         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
11038         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e_conv);
11039         return (uint32_t)ret_conv;
11040 }
11041
11042 jboolean  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(uint32_t o) {
11043         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* o_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(o & ~1);
11044         jboolean ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(o_conv);
11045         return ret_conv;
11046 }
11047
11048 void  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(uint32_t _res) {
11049         if ((_res & 1) != 0) return;
11050         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11051         CHECK_ACCESS(_res_ptr);
11052         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(_res_ptr);
11053         FREE((void*)_res);
11054         CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(_res_conv);
11055 }
11056
11057 static inline uintptr_t CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR arg) {
11058         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
11059         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(arg);
11060         return (uint32_t)ret_conv;
11061 }
11062 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(uint32_t arg) {
11063         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(arg & ~1);
11064         uint32_t ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(arg_conv);
11065         return ret_conv;
11066 }
11067
11068 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(uint32_t orig) {
11069         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(orig & ~1);
11070         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
11071         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(orig_conv);
11072         return (uint32_t)ret_conv;
11073 }
11074
11075 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_ok"))) TS_CResult_SecretKeyErrorZ_ok(int8_tArray o) {
11076         LDKSecretKey o_ref;
11077         CHECK(o->arr_len == 32);
11078         memcpy(o_ref.bytes, o->elems, 32); FREE(o);
11079         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
11080         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
11081         return (uint32_t)ret_conv;
11082 }
11083
11084 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_err"))) TS_CResult_SecretKeyErrorZ_err(uint32_t e) {
11085         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
11086         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
11087         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
11088         return (uint32_t)ret_conv;
11089 }
11090
11091 jboolean  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_is_ok"))) TS_CResult_SecretKeyErrorZ_is_ok(uint32_t o) {
11092         LDKCResult_SecretKeyErrorZ* o_conv = (LDKCResult_SecretKeyErrorZ*)(o & ~1);
11093         jboolean ret_conv = CResult_SecretKeyErrorZ_is_ok(o_conv);
11094         return ret_conv;
11095 }
11096
11097 void  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_free"))) TS_CResult_SecretKeyErrorZ_free(uint32_t _res) {
11098         if ((_res & 1) != 0) return;
11099         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11100         CHECK_ACCESS(_res_ptr);
11101         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
11102         FREE((void*)_res);
11103         CResult_SecretKeyErrorZ_free(_res_conv);
11104 }
11105
11106 static inline uintptr_t CResult_SecretKeyErrorZ_clone_ptr(LDKCResult_SecretKeyErrorZ *NONNULL_PTR arg) {
11107         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
11108         *ret_conv = CResult_SecretKeyErrorZ_clone(arg);
11109         return (uint32_t)ret_conv;
11110 }
11111 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_clone_ptr"))) TS_CResult_SecretKeyErrorZ_clone_ptr(uint32_t arg) {
11112         LDKCResult_SecretKeyErrorZ* arg_conv = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
11113         uint32_t ret_conv = CResult_SecretKeyErrorZ_clone_ptr(arg_conv);
11114         return ret_conv;
11115 }
11116
11117 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_clone"))) TS_CResult_SecretKeyErrorZ_clone(uint32_t orig) {
11118         LDKCResult_SecretKeyErrorZ* orig_conv = (LDKCResult_SecretKeyErrorZ*)(orig & ~1);
11119         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
11120         *ret_conv = CResult_SecretKeyErrorZ_clone(orig_conv);
11121         return (uint32_t)ret_conv;
11122 }
11123
11124 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_ok"))) TS_CResult_PublicKeyErrorZ_ok(int8_tArray o) {
11125         LDKPublicKey o_ref;
11126         CHECK(o->arr_len == 33);
11127         memcpy(o_ref.compressed_form, o->elems, 33); FREE(o);
11128         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
11129         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
11130         return (uint32_t)ret_conv;
11131 }
11132
11133 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_err"))) TS_CResult_PublicKeyErrorZ_err(uint32_t e) {
11134         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
11135         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
11136         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
11137         return (uint32_t)ret_conv;
11138 }
11139
11140 jboolean  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_is_ok"))) TS_CResult_PublicKeyErrorZ_is_ok(uint32_t o) {
11141         LDKCResult_PublicKeyErrorZ* o_conv = (LDKCResult_PublicKeyErrorZ*)(o & ~1);
11142         jboolean ret_conv = CResult_PublicKeyErrorZ_is_ok(o_conv);
11143         return ret_conv;
11144 }
11145
11146 void  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_free"))) TS_CResult_PublicKeyErrorZ_free(uint32_t _res) {
11147         if ((_res & 1) != 0) return;
11148         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11149         CHECK_ACCESS(_res_ptr);
11150         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
11151         FREE((void*)_res);
11152         CResult_PublicKeyErrorZ_free(_res_conv);
11153 }
11154
11155 static inline uintptr_t CResult_PublicKeyErrorZ_clone_ptr(LDKCResult_PublicKeyErrorZ *NONNULL_PTR arg) {
11156         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
11157         *ret_conv = CResult_PublicKeyErrorZ_clone(arg);
11158         return (uint32_t)ret_conv;
11159 }
11160 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_clone_ptr"))) TS_CResult_PublicKeyErrorZ_clone_ptr(uint32_t arg) {
11161         LDKCResult_PublicKeyErrorZ* arg_conv = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
11162         uint32_t ret_conv = CResult_PublicKeyErrorZ_clone_ptr(arg_conv);
11163         return ret_conv;
11164 }
11165
11166 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_clone"))) TS_CResult_PublicKeyErrorZ_clone(uint32_t orig) {
11167         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
11168         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
11169         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
11170         return (uint32_t)ret_conv;
11171 }
11172
11173 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_ok(uint32_t o) {
11174         LDKTxCreationKeys o_conv;
11175         o_conv.inner = (void*)(o & (~1));
11176         o_conv.is_owned = (o & 1) || (o == 0);
11177         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11178         o_conv = TxCreationKeys_clone(&o_conv);
11179         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
11180         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
11181         return (uint32_t)ret_conv;
11182 }
11183
11184 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_err"))) TS_CResult_TxCreationKeysDecodeErrorZ_err(uint32_t e) {
11185         LDKDecodeError e_conv;
11186         e_conv.inner = (void*)(e & (~1));
11187         e_conv.is_owned = (e & 1) || (e == 0);
11188         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11189         e_conv = DecodeError_clone(&e_conv);
11190         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
11191         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
11192         return (uint32_t)ret_conv;
11193 }
11194
11195 jboolean  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_is_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_is_ok(uint32_t o) {
11196         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(o & ~1);
11197         jboolean ret_conv = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
11198         return ret_conv;
11199 }
11200
11201 void  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_free"))) TS_CResult_TxCreationKeysDecodeErrorZ_free(uint32_t _res) {
11202         if ((_res & 1) != 0) return;
11203         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11204         CHECK_ACCESS(_res_ptr);
11205         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
11206         FREE((void*)_res);
11207         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
11208 }
11209
11210 static inline uintptr_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
11211         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
11212         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
11213         return (uint32_t)ret_conv;
11214 }
11215 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_clone_ptr"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone_ptr(uint32_t arg) {
11216         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
11217         uint32_t ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
11218         return ret_conv;
11219 }
11220
11221 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_clone"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone(uint32_t orig) {
11222         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
11223         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
11224         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
11225         return (uint32_t)ret_conv;
11226 }
11227
11228 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_ok(uint32_t o) {
11229         LDKChannelPublicKeys o_conv;
11230         o_conv.inner = (void*)(o & (~1));
11231         o_conv.is_owned = (o & 1) || (o == 0);
11232         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11233         o_conv = ChannelPublicKeys_clone(&o_conv);
11234         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
11235         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
11236         return (uint32_t)ret_conv;
11237 }
11238
11239 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_err"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_err(uint32_t e) {
11240         LDKDecodeError e_conv;
11241         e_conv.inner = (void*)(e & (~1));
11242         e_conv.is_owned = (e & 1) || (e == 0);
11243         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11244         e_conv = DecodeError_clone(&e_conv);
11245         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
11246         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
11247         return (uint32_t)ret_conv;
11248 }
11249
11250 jboolean  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_is_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_is_ok(uint32_t o) {
11251         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(o & ~1);
11252         jboolean ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
11253         return ret_conv;
11254 }
11255
11256 void  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_free"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_free(uint32_t _res) {
11257         if ((_res & 1) != 0) return;
11258         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11259         CHECK_ACCESS(_res_ptr);
11260         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
11261         FREE((void*)_res);
11262         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
11263 }
11264
11265 static inline uintptr_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
11266         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
11267         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
11268         return (uint32_t)ret_conv;
11269 }
11270 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(uint32_t arg) {
11271         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
11272         uint32_t ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
11273         return ret_conv;
11274 }
11275
11276 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_clone"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone(uint32_t orig) {
11277         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
11278         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
11279         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
11280         return (uint32_t)ret_conv;
11281 }
11282
11283 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_ok"))) TS_CResult_TxCreationKeysErrorZ_ok(uint32_t o) {
11284         LDKTxCreationKeys o_conv;
11285         o_conv.inner = (void*)(o & (~1));
11286         o_conv.is_owned = (o & 1) || (o == 0);
11287         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11288         o_conv = TxCreationKeys_clone(&o_conv);
11289         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11290         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
11291         return (uint32_t)ret_conv;
11292 }
11293
11294 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_err"))) TS_CResult_TxCreationKeysErrorZ_err(uint32_t e) {
11295         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
11296         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11297         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
11298         return (uint32_t)ret_conv;
11299 }
11300
11301 jboolean  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_is_ok"))) TS_CResult_TxCreationKeysErrorZ_is_ok(uint32_t o) {
11302         LDKCResult_TxCreationKeysErrorZ* o_conv = (LDKCResult_TxCreationKeysErrorZ*)(o & ~1);
11303         jboolean ret_conv = CResult_TxCreationKeysErrorZ_is_ok(o_conv);
11304         return ret_conv;
11305 }
11306
11307 void  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_free"))) TS_CResult_TxCreationKeysErrorZ_free(uint32_t _res) {
11308         if ((_res & 1) != 0) return;
11309         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11310         CHECK_ACCESS(_res_ptr);
11311         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
11312         FREE((void*)_res);
11313         CResult_TxCreationKeysErrorZ_free(_res_conv);
11314 }
11315
11316 static inline uintptr_t CResult_TxCreationKeysErrorZ_clone_ptr(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR arg) {
11317         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11318         *ret_conv = CResult_TxCreationKeysErrorZ_clone(arg);
11319         return (uint32_t)ret_conv;
11320 }
11321 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_clone_ptr"))) TS_CResult_TxCreationKeysErrorZ_clone_ptr(uint32_t arg) {
11322         LDKCResult_TxCreationKeysErrorZ* arg_conv = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
11323         uint32_t ret_conv = CResult_TxCreationKeysErrorZ_clone_ptr(arg_conv);
11324         return ret_conv;
11325 }
11326
11327 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_clone"))) TS_CResult_TxCreationKeysErrorZ_clone(uint32_t orig) {
11328         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
11329         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11330         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
11331         return (uint32_t)ret_conv;
11332 }
11333
11334 uint32_t  __attribute__((export_name("TS_COption_u32Z_some"))) TS_COption_u32Z_some(int32_t o) {
11335         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11336         *ret_copy = COption_u32Z_some(o);
11337         uint32_t ret_ref = (uintptr_t)ret_copy;
11338         return ret_ref;
11339 }
11340
11341 uint32_t  __attribute__((export_name("TS_COption_u32Z_none"))) TS_COption_u32Z_none() {
11342         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11343         *ret_copy = COption_u32Z_none();
11344         uint32_t ret_ref = (uintptr_t)ret_copy;
11345         return ret_ref;
11346 }
11347
11348 void  __attribute__((export_name("TS_COption_u32Z_free"))) TS_COption_u32Z_free(uint32_t _res) {
11349         if ((_res & 1) != 0) return;
11350         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11351         CHECK_ACCESS(_res_ptr);
11352         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
11353         FREE((void*)_res);
11354         COption_u32Z_free(_res_conv);
11355 }
11356
11357 static inline uintptr_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
11358         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11359         *ret_copy = COption_u32Z_clone(arg);
11360 uint32_t ret_ref = (uintptr_t)ret_copy;
11361         return ret_ref;
11362 }
11363 uint32_t  __attribute__((export_name("TS_COption_u32Z_clone_ptr"))) TS_COption_u32Z_clone_ptr(uint32_t arg) {
11364         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)arg;
11365         uint32_t ret_conv = COption_u32Z_clone_ptr(arg_conv);
11366         return ret_conv;
11367 }
11368
11369 uint32_t  __attribute__((export_name("TS_COption_u32Z_clone"))) TS_COption_u32Z_clone(uint32_t orig) {
11370         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
11371         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11372         *ret_copy = COption_u32Z_clone(orig_conv);
11373         uint32_t ret_ref = (uintptr_t)ret_copy;
11374         return ret_ref;
11375 }
11376
11377 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(uint32_t o) {
11378         LDKHTLCOutputInCommitment o_conv;
11379         o_conv.inner = (void*)(o & (~1));
11380         o_conv.is_owned = (o & 1) || (o == 0);
11381         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11382         o_conv = HTLCOutputInCommitment_clone(&o_conv);
11383         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11384         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
11385         return (uint32_t)ret_conv;
11386 }
11387
11388 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err(uint32_t e) {
11389         LDKDecodeError e_conv;
11390         e_conv.inner = (void*)(e & (~1));
11391         e_conv.is_owned = (e & 1) || (e == 0);
11392         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11393         e_conv = DecodeError_clone(&e_conv);
11394         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11395         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
11396         return (uint32_t)ret_conv;
11397 }
11398
11399 jboolean  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(uint32_t o) {
11400         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(o & ~1);
11401         jboolean ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
11402         return ret_conv;
11403 }
11404
11405 void  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free(uint32_t _res) {
11406         if ((_res & 1) != 0) return;
11407         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11408         CHECK_ACCESS(_res_ptr);
11409         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
11410         FREE((void*)_res);
11411         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
11412 }
11413
11414 static inline uintptr_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
11415         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11416         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
11417         return (uint32_t)ret_conv;
11418 }
11419 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(uint32_t arg) {
11420         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
11421         uint32_t ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
11422         return ret_conv;
11423 }
11424
11425 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(uint32_t orig) {
11426         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
11427         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11428         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
11429         return (uint32_t)ret_conv;
11430 }
11431
11432 uint32_t  __attribute__((export_name("TS_COption_NoneZ_some"))) TS_COption_NoneZ_some() {
11433         uint32_t ret_conv = LDKCOption_NoneZ_to_js(COption_NoneZ_some());
11434         return ret_conv;
11435 }
11436
11437 uint32_t  __attribute__((export_name("TS_COption_NoneZ_none"))) TS_COption_NoneZ_none() {
11438         uint32_t ret_conv = LDKCOption_NoneZ_to_js(COption_NoneZ_none());
11439         return ret_conv;
11440 }
11441
11442 void  __attribute__((export_name("TS_COption_NoneZ_free"))) TS_COption_NoneZ_free(uint32_t _res) {
11443         LDKCOption_NoneZ _res_conv = LDKCOption_NoneZ_from_js(_res);
11444         COption_NoneZ_free(_res_conv);
11445 }
11446
11447 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
11448         LDKCounterpartyChannelTransactionParameters o_conv;
11449         o_conv.inner = (void*)(o & (~1));
11450         o_conv.is_owned = (o & 1) || (o == 0);
11451         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11452         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
11453         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11454         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
11455         return (uint32_t)ret_conv;
11456 }
11457
11458 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
11459         LDKDecodeError e_conv;
11460         e_conv.inner = (void*)(e & (~1));
11461         e_conv.is_owned = (e & 1) || (e == 0);
11462         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11463         e_conv = DecodeError_clone(&e_conv);
11464         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11465         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
11466         return (uint32_t)ret_conv;
11467 }
11468
11469 jboolean  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(uint32_t o) {
11470         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(o & ~1);
11471         jboolean ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
11472         return ret_conv;
11473 }
11474
11475 void  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
11476         if ((_res & 1) != 0) return;
11477         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11478         CHECK_ACCESS(_res_ptr);
11479         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
11480         FREE((void*)_res);
11481         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
11482 }
11483
11484 static inline uintptr_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
11485         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11486         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
11487         return (uint32_t)ret_conv;
11488 }
11489 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
11490         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
11491         uint32_t ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
11492         return ret_conv;
11493 }
11494
11495 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
11496         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
11497         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11498         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
11499         return (uint32_t)ret_conv;
11500 }
11501
11502 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
11503         LDKChannelTransactionParameters o_conv;
11504         o_conv.inner = (void*)(o & (~1));
11505         o_conv.is_owned = (o & 1) || (o == 0);
11506         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11507         o_conv = ChannelTransactionParameters_clone(&o_conv);
11508         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11509         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
11510         return (uint32_t)ret_conv;
11511 }
11512
11513 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_err"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
11514         LDKDecodeError e_conv;
11515         e_conv.inner = (void*)(e & (~1));
11516         e_conv.is_owned = (e & 1) || (e == 0);
11517         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11518         e_conv = DecodeError_clone(&e_conv);
11519         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11520         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
11521         return (uint32_t)ret_conv;
11522 }
11523
11524 jboolean  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_is_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(uint32_t o) {
11525         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(o & ~1);
11526         jboolean ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
11527         return ret_conv;
11528 }
11529
11530 void  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_free"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
11531         if ((_res & 1) != 0) return;
11532         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11533         CHECK_ACCESS(_res_ptr);
11534         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
11535         FREE((void*)_res);
11536         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
11537 }
11538
11539 static inline uintptr_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
11540         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11541         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
11542         return (uint32_t)ret_conv;
11543 }
11544 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
11545         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
11546         uint32_t ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
11547         return ret_conv;
11548 }
11549
11550 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
11551         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
11552         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11553         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
11554         return (uint32_t)ret_conv;
11555 }
11556
11557 void  __attribute__((export_name("TS_CVec_SignatureZ_free"))) TS_CVec_SignatureZ_free(ptrArray _res) {
11558         LDKCVec_SignatureZ _res_constr;
11559         _res_constr.datalen = _res->arr_len;
11560         if (_res_constr.datalen > 0)
11561                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
11562         else
11563                 _res_constr.data = NULL;
11564         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
11565         for (size_t m = 0; m < _res_constr.datalen; m++) {
11566                 int8_tArray _res_conv_12 = _res_vals[m];
11567                 LDKSignature _res_conv_12_ref;
11568                 CHECK(_res_conv_12->arr_len == 64);
11569                 memcpy(_res_conv_12_ref.compact_form, _res_conv_12->elems, 64); FREE(_res_conv_12);
11570                 _res_constr.data[m] = _res_conv_12_ref;
11571         }
11572         CVec_SignatureZ_free(_res_constr);
11573 }
11574
11575 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
11576         LDKHolderCommitmentTransaction o_conv;
11577         o_conv.inner = (void*)(o & (~1));
11578         o_conv.is_owned = (o & 1) || (o == 0);
11579         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11580         o_conv = HolderCommitmentTransaction_clone(&o_conv);
11581         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11582         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
11583         return (uint32_t)ret_conv;
11584 }
11585
11586 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
11587         LDKDecodeError e_conv;
11588         e_conv.inner = (void*)(e & (~1));
11589         e_conv.is_owned = (e & 1) || (e == 0);
11590         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11591         e_conv = DecodeError_clone(&e_conv);
11592         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11593         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
11594         return (uint32_t)ret_conv;
11595 }
11596
11597 jboolean  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
11598         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(o & ~1);
11599         jboolean ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
11600         return ret_conv;
11601 }
11602
11603 void  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
11604         if ((_res & 1) != 0) return;
11605         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11606         CHECK_ACCESS(_res_ptr);
11607         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
11608         FREE((void*)_res);
11609         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
11610 }
11611
11612 static inline uintptr_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
11613         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11614         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
11615         return (uint32_t)ret_conv;
11616 }
11617 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
11618         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
11619         uint32_t ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
11620         return ret_conv;
11621 }
11622
11623 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
11624         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
11625         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11626         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
11627         return (uint32_t)ret_conv;
11628 }
11629
11630 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
11631         LDKBuiltCommitmentTransaction o_conv;
11632         o_conv.inner = (void*)(o & (~1));
11633         o_conv.is_owned = (o & 1) || (o == 0);
11634         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11635         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
11636         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11637         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
11638         return (uint32_t)ret_conv;
11639 }
11640
11641 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
11642         LDKDecodeError e_conv;
11643         e_conv.inner = (void*)(e & (~1));
11644         e_conv.is_owned = (e & 1) || (e == 0);
11645         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11646         e_conv = DecodeError_clone(&e_conv);
11647         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11648         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
11649         return (uint32_t)ret_conv;
11650 }
11651
11652 jboolean  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
11653         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(o & ~1);
11654         jboolean ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
11655         return ret_conv;
11656 }
11657
11658 void  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
11659         if ((_res & 1) != 0) return;
11660         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11661         CHECK_ACCESS(_res_ptr);
11662         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
11663         FREE((void*)_res);
11664         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
11665 }
11666
11667 static inline uintptr_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
11668         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11669         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
11670         return (uint32_t)ret_conv;
11671 }
11672 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
11673         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
11674         uint32_t ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
11675         return ret_conv;
11676 }
11677
11678 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
11679         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
11680         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11681         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
11682         return (uint32_t)ret_conv;
11683 }
11684
11685 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_ok(uint32_t o) {
11686         LDKTrustedClosingTransaction o_conv;
11687         o_conv.inner = (void*)(o & (~1));
11688         o_conv.is_owned = (o & 1) || (o == 0);
11689         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11690         // WARNING: we need a move here but no clone is available for LDKTrustedClosingTransaction
11691         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
11692         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
11693         return (uint32_t)ret_conv;
11694 }
11695
11696 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_err"))) TS_CResult_TrustedClosingTransactionNoneZ_err() {
11697         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
11698         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
11699         return (uint32_t)ret_conv;
11700 }
11701
11702 jboolean  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_is_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_is_ok(uint32_t o) {
11703         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(o & ~1);
11704         jboolean ret_conv = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
11705         return ret_conv;
11706 }
11707
11708 void  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_free"))) TS_CResult_TrustedClosingTransactionNoneZ_free(uint32_t _res) {
11709         if ((_res & 1) != 0) return;
11710         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11711         CHECK_ACCESS(_res_ptr);
11712         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
11713         FREE((void*)_res);
11714         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
11715 }
11716
11717 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
11718         LDKCommitmentTransaction o_conv;
11719         o_conv.inner = (void*)(o & (~1));
11720         o_conv.is_owned = (o & 1) || (o == 0);
11721         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11722         o_conv = CommitmentTransaction_clone(&o_conv);
11723         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11724         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
11725         return (uint32_t)ret_conv;
11726 }
11727
11728 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_err"))) TS_CResult_CommitmentTransactionDecodeErrorZ_err(uint32_t e) {
11729         LDKDecodeError e_conv;
11730         e_conv.inner = (void*)(e & (~1));
11731         e_conv.is_owned = (e & 1) || (e == 0);
11732         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11733         e_conv = DecodeError_clone(&e_conv);
11734         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11735         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
11736         return (uint32_t)ret_conv;
11737 }
11738
11739 jboolean  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
11740         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(o & ~1);
11741         jboolean ret_conv = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
11742         return ret_conv;
11743 }
11744
11745 void  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_free"))) TS_CResult_CommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
11746         if ((_res & 1) != 0) return;
11747         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11748         CHECK_ACCESS(_res_ptr);
11749         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
11750         FREE((void*)_res);
11751         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
11752 }
11753
11754 static inline uintptr_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
11755         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11756         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
11757         return (uint32_t)ret_conv;
11758 }
11759 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
11760         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
11761         uint32_t ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
11762         return ret_conv;
11763 }
11764
11765 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
11766         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
11767         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11768         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
11769         return (uint32_t)ret_conv;
11770 }
11771
11772 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_ok(uint32_t o) {
11773         LDKTrustedCommitmentTransaction o_conv;
11774         o_conv.inner = (void*)(o & (~1));
11775         o_conv.is_owned = (o & 1) || (o == 0);
11776         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11777         // WARNING: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
11778         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
11779         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
11780         return (uint32_t)ret_conv;
11781 }
11782
11783 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_err"))) TS_CResult_TrustedCommitmentTransactionNoneZ_err() {
11784         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
11785         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
11786         return (uint32_t)ret_conv;
11787 }
11788
11789 jboolean  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_is_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_is_ok(uint32_t o) {
11790         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(o & ~1);
11791         jboolean ret_conv = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
11792         return ret_conv;
11793 }
11794
11795 void  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_free"))) TS_CResult_TrustedCommitmentTransactionNoneZ_free(uint32_t _res) {
11796         if ((_res & 1) != 0) return;
11797         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11798         CHECK_ACCESS(_res_ptr);
11799         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
11800         FREE((void*)_res);
11801         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
11802 }
11803
11804 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_ok"))) TS_CResult_CVec_SignatureZNoneZ_ok(ptrArray o) {
11805         LDKCVec_SignatureZ o_constr;
11806         o_constr.datalen = o->arr_len;
11807         if (o_constr.datalen > 0)
11808                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
11809         else
11810                 o_constr.data = NULL;
11811         int8_tArray* o_vals = (void*) o->elems /* XXX o leaks */;
11812         for (size_t m = 0; m < o_constr.datalen; m++) {
11813                 int8_tArray o_conv_12 = o_vals[m];
11814                 LDKSignature o_conv_12_ref;
11815                 CHECK(o_conv_12->arr_len == 64);
11816                 memcpy(o_conv_12_ref.compact_form, o_conv_12->elems, 64); FREE(o_conv_12);
11817                 o_constr.data[m] = o_conv_12_ref;
11818         }
11819         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11820         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
11821         return (uint32_t)ret_conv;
11822 }
11823
11824 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_err"))) TS_CResult_CVec_SignatureZNoneZ_err() {
11825         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11826         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
11827         return (uint32_t)ret_conv;
11828 }
11829
11830 jboolean  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_is_ok"))) TS_CResult_CVec_SignatureZNoneZ_is_ok(uint32_t o) {
11831         LDKCResult_CVec_SignatureZNoneZ* o_conv = (LDKCResult_CVec_SignatureZNoneZ*)(o & ~1);
11832         jboolean ret_conv = CResult_CVec_SignatureZNoneZ_is_ok(o_conv);
11833         return ret_conv;
11834 }
11835
11836 void  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_free"))) TS_CResult_CVec_SignatureZNoneZ_free(uint32_t _res) {
11837         if ((_res & 1) != 0) return;
11838         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11839         CHECK_ACCESS(_res_ptr);
11840         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
11841         FREE((void*)_res);
11842         CResult_CVec_SignatureZNoneZ_free(_res_conv);
11843 }
11844
11845 static inline uintptr_t CResult_CVec_SignatureZNoneZ_clone_ptr(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR arg) {
11846         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11847         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(arg);
11848         return (uint32_t)ret_conv;
11849 }
11850 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_clone_ptr"))) TS_CResult_CVec_SignatureZNoneZ_clone_ptr(uint32_t arg) {
11851         LDKCResult_CVec_SignatureZNoneZ* arg_conv = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
11852         uint32_t ret_conv = CResult_CVec_SignatureZNoneZ_clone_ptr(arg_conv);
11853         return ret_conv;
11854 }
11855
11856 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_clone"))) TS_CResult_CVec_SignatureZNoneZ_clone(uint32_t orig) {
11857         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
11858         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11859         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
11860         return (uint32_t)ret_conv;
11861 }
11862
11863 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_ok(uint32_t o) {
11864         LDKShutdownScript o_conv;
11865         o_conv.inner = (void*)(o & (~1));
11866         o_conv.is_owned = (o & 1) || (o == 0);
11867         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11868         o_conv = ShutdownScript_clone(&o_conv);
11869         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11870         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
11871         return (uint32_t)ret_conv;
11872 }
11873
11874 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_err"))) TS_CResult_ShutdownScriptDecodeErrorZ_err(uint32_t e) {
11875         LDKDecodeError e_conv;
11876         e_conv.inner = (void*)(e & (~1));
11877         e_conv.is_owned = (e & 1) || (e == 0);
11878         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11879         e_conv = DecodeError_clone(&e_conv);
11880         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11881         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
11882         return (uint32_t)ret_conv;
11883 }
11884
11885 jboolean  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_is_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_is_ok(uint32_t o) {
11886         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(o & ~1);
11887         jboolean ret_conv = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
11888         return ret_conv;
11889 }
11890
11891 void  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_free"))) TS_CResult_ShutdownScriptDecodeErrorZ_free(uint32_t _res) {
11892         if ((_res & 1) != 0) return;
11893         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11894         CHECK_ACCESS(_res_ptr);
11895         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
11896         FREE((void*)_res);
11897         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
11898 }
11899
11900 static inline uintptr_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
11901         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11902         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
11903         return (uint32_t)ret_conv;
11904 }
11905 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_clone_ptr"))) TS_CResult_ShutdownScriptDecodeErrorZ_clone_ptr(uint32_t arg) {
11906         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
11907         uint32_t ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
11908         return ret_conv;
11909 }
11910
11911 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_clone"))) TS_CResult_ShutdownScriptDecodeErrorZ_clone(uint32_t orig) {
11912         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1);
11913         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11914         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
11915         return (uint32_t)ret_conv;
11916 }
11917
11918 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_ok(uint32_t o) {
11919         LDKShutdownScript o_conv;
11920         o_conv.inner = (void*)(o & (~1));
11921         o_conv.is_owned = (o & 1) || (o == 0);
11922         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11923         o_conv = ShutdownScript_clone(&o_conv);
11924         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
11925         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
11926         return (uint32_t)ret_conv;
11927 }
11928
11929 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_err"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_err(uint32_t e) {
11930         LDKInvalidShutdownScript e_conv;
11931         e_conv.inner = (void*)(e & (~1));
11932         e_conv.is_owned = (e & 1) || (e == 0);
11933         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11934         e_conv = InvalidShutdownScript_clone(&e_conv);
11935         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
11936         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
11937         return (uint32_t)ret_conv;
11938 }
11939
11940 jboolean  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(uint32_t o) {
11941         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(o & ~1);
11942         jboolean ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
11943         return ret_conv;
11944 }
11945
11946 void  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_free"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_free(uint32_t _res) {
11947         if ((_res & 1) != 0) return;
11948         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11949         CHECK_ACCESS(_res_ptr);
11950         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
11951         FREE((void*)_res);
11952         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
11953 }
11954
11955 static inline uintptr_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
11956         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
11957         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
11958         return (uint32_t)ret_conv;
11959 }
11960 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(uint32_t arg) {
11961         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
11962         uint32_t ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
11963         return ret_conv;
11964 }
11965
11966 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone(uint32_t orig) {
11967         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(orig & ~1);
11968         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
11969         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
11970         return (uint32_t)ret_conv;
11971 }
11972
11973 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_ok"))) TS_CResult_RouteHopDecodeErrorZ_ok(uint32_t o) {
11974         LDKRouteHop o_conv;
11975         o_conv.inner = (void*)(o & (~1));
11976         o_conv.is_owned = (o & 1) || (o == 0);
11977         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11978         o_conv = RouteHop_clone(&o_conv);
11979         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
11980         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
11981         return (uint32_t)ret_conv;
11982 }
11983
11984 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_err"))) TS_CResult_RouteHopDecodeErrorZ_err(uint32_t e) {
11985         LDKDecodeError e_conv;
11986         e_conv.inner = (void*)(e & (~1));
11987         e_conv.is_owned = (e & 1) || (e == 0);
11988         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11989         e_conv = DecodeError_clone(&e_conv);
11990         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
11991         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
11992         return (uint32_t)ret_conv;
11993 }
11994
11995 jboolean  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_is_ok"))) TS_CResult_RouteHopDecodeErrorZ_is_ok(uint32_t o) {
11996         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)(o & ~1);
11997         jboolean ret_conv = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
11998         return ret_conv;
11999 }
12000
12001 void  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_free"))) TS_CResult_RouteHopDecodeErrorZ_free(uint32_t _res) {
12002         if ((_res & 1) != 0) return;
12003         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12004         CHECK_ACCESS(_res_ptr);
12005         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
12006         FREE((void*)_res);
12007         CResult_RouteHopDecodeErrorZ_free(_res_conv);
12008 }
12009
12010 static inline uintptr_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
12011         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
12012         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
12013         return (uint32_t)ret_conv;
12014 }
12015 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHopDecodeErrorZ_clone_ptr(uint32_t arg) {
12016         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
12017         uint32_t ret_conv = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
12018         return ret_conv;
12019 }
12020
12021 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_clone"))) TS_CResult_RouteHopDecodeErrorZ_clone(uint32_t orig) {
12022         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
12023         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
12024         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
12025         return (uint32_t)ret_conv;
12026 }
12027
12028 void  __attribute__((export_name("TS_CVec_RouteHopZ_free"))) TS_CVec_RouteHopZ_free(uint32_tArray _res) {
12029         LDKCVec_RouteHopZ _res_constr;
12030         _res_constr.datalen = _res->arr_len;
12031         if (_res_constr.datalen > 0)
12032                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
12033         else
12034                 _res_constr.data = NULL;
12035         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12036         for (size_t k = 0; k < _res_constr.datalen; k++) {
12037                 uint32_t _res_conv_10 = _res_vals[k];
12038                 LDKRouteHop _res_conv_10_conv;
12039                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
12040                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
12041                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
12042                 _res_constr.data[k] = _res_conv_10_conv;
12043         }
12044         CVec_RouteHopZ_free(_res_constr);
12045 }
12046
12047 void  __attribute__((export_name("TS_CVec_CVec_RouteHopZZ_free"))) TS_CVec_CVec_RouteHopZZ_free(ptrArray _res) {
12048         LDKCVec_CVec_RouteHopZZ _res_constr;
12049         _res_constr.datalen = _res->arr_len;
12050         if (_res_constr.datalen > 0)
12051                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
12052         else
12053                 _res_constr.data = NULL;
12054         uint32_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
12055         for (size_t m = 0; m < _res_constr.datalen; m++) {
12056                 uint32_tArray _res_conv_12 = _res_vals[m];
12057                 LDKCVec_RouteHopZ _res_conv_12_constr;
12058                 _res_conv_12_constr.datalen = _res_conv_12->arr_len;
12059                 if (_res_conv_12_constr.datalen > 0)
12060                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
12061                 else
12062                         _res_conv_12_constr.data = NULL;
12063                 uint32_t* _res_conv_12_vals = _res_conv_12->elems /* XXX _res_conv_12 leaks */;
12064                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
12065                         uint32_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
12066                         LDKRouteHop _res_conv_12_conv_10_conv;
12067                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
12068                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
12069                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv_10_conv);
12070                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
12071                 }
12072                 _res_constr.data[m] = _res_conv_12_constr;
12073         }
12074         CVec_CVec_RouteHopZZ_free(_res_constr);
12075 }
12076
12077 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_ok"))) TS_CResult_RouteDecodeErrorZ_ok(uint32_t o) {
12078         LDKRoute o_conv;
12079         o_conv.inner = (void*)(o & (~1));
12080         o_conv.is_owned = (o & 1) || (o == 0);
12081         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12082         o_conv = Route_clone(&o_conv);
12083         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
12084         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
12085         return (uint32_t)ret_conv;
12086 }
12087
12088 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_err"))) TS_CResult_RouteDecodeErrorZ_err(uint32_t e) {
12089         LDKDecodeError e_conv;
12090         e_conv.inner = (void*)(e & (~1));
12091         e_conv.is_owned = (e & 1) || (e == 0);
12092         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12093         e_conv = DecodeError_clone(&e_conv);
12094         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
12095         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
12096         return (uint32_t)ret_conv;
12097 }
12098
12099 jboolean  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_is_ok"))) TS_CResult_RouteDecodeErrorZ_is_ok(uint32_t o) {
12100         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)(o & ~1);
12101         jboolean ret_conv = CResult_RouteDecodeErrorZ_is_ok(o_conv);
12102         return ret_conv;
12103 }
12104
12105 void  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_free"))) TS_CResult_RouteDecodeErrorZ_free(uint32_t _res) {
12106         if ((_res & 1) != 0) return;
12107         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12108         CHECK_ACCESS(_res_ptr);
12109         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
12110         FREE((void*)_res);
12111         CResult_RouteDecodeErrorZ_free(_res_conv);
12112 }
12113
12114 static inline uintptr_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
12115         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
12116         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
12117         return (uint32_t)ret_conv;
12118 }
12119 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_clone_ptr"))) TS_CResult_RouteDecodeErrorZ_clone_ptr(uint32_t arg) {
12120         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
12121         uint32_t ret_conv = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
12122         return ret_conv;
12123 }
12124
12125 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_clone"))) TS_CResult_RouteDecodeErrorZ_clone(uint32_t orig) {
12126         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
12127         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
12128         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
12129         return (uint32_t)ret_conv;
12130 }
12131
12132 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_ok"))) TS_CResult_RouteParametersDecodeErrorZ_ok(uint32_t o) {
12133         LDKRouteParameters o_conv;
12134         o_conv.inner = (void*)(o & (~1));
12135         o_conv.is_owned = (o & 1) || (o == 0);
12136         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12137         o_conv = RouteParameters_clone(&o_conv);
12138         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
12139         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
12140         return (uint32_t)ret_conv;
12141 }
12142
12143 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_err"))) TS_CResult_RouteParametersDecodeErrorZ_err(uint32_t e) {
12144         LDKDecodeError e_conv;
12145         e_conv.inner = (void*)(e & (~1));
12146         e_conv.is_owned = (e & 1) || (e == 0);
12147         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12148         e_conv = DecodeError_clone(&e_conv);
12149         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
12150         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
12151         return (uint32_t)ret_conv;
12152 }
12153
12154 jboolean  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_is_ok"))) TS_CResult_RouteParametersDecodeErrorZ_is_ok(uint32_t o) {
12155         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(o & ~1);
12156         jboolean ret_conv = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
12157         return ret_conv;
12158 }
12159
12160 void  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_free"))) TS_CResult_RouteParametersDecodeErrorZ_free(uint32_t _res) {
12161         if ((_res & 1) != 0) return;
12162         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12163         CHECK_ACCESS(_res_ptr);
12164         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
12165         FREE((void*)_res);
12166         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
12167 }
12168
12169 static inline uintptr_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
12170         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
12171         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
12172         return (uint32_t)ret_conv;
12173 }
12174 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_clone_ptr"))) TS_CResult_RouteParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
12175         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
12176         uint32_t ret_conv = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
12177         return ret_conv;
12178 }
12179
12180 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_clone"))) TS_CResult_RouteParametersDecodeErrorZ_clone(uint32_t orig) {
12181         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(orig & ~1);
12182         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
12183         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
12184         return (uint32_t)ret_conv;
12185 }
12186
12187 void  __attribute__((export_name("TS_CVec_RouteHintZ_free"))) TS_CVec_RouteHintZ_free(uint32_tArray _res) {
12188         LDKCVec_RouteHintZ _res_constr;
12189         _res_constr.datalen = _res->arr_len;
12190         if (_res_constr.datalen > 0)
12191                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
12192         else
12193                 _res_constr.data = NULL;
12194         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12195         for (size_t l = 0; l < _res_constr.datalen; l++) {
12196                 uint32_t _res_conv_11 = _res_vals[l];
12197                 LDKRouteHint _res_conv_11_conv;
12198                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
12199                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
12200                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
12201                 _res_constr.data[l] = _res_conv_11_conv;
12202         }
12203         CVec_RouteHintZ_free(_res_constr);
12204 }
12205
12206 uint32_t  __attribute__((export_name("TS_COption_u64Z_some"))) TS_COption_u64Z_some(int64_t o) {
12207         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12208         *ret_copy = COption_u64Z_some(o);
12209         uint32_t ret_ref = (uintptr_t)ret_copy;
12210         return ret_ref;
12211 }
12212
12213 uint32_t  __attribute__((export_name("TS_COption_u64Z_none"))) TS_COption_u64Z_none() {
12214         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12215         *ret_copy = COption_u64Z_none();
12216         uint32_t ret_ref = (uintptr_t)ret_copy;
12217         return ret_ref;
12218 }
12219
12220 void  __attribute__((export_name("TS_COption_u64Z_free"))) TS_COption_u64Z_free(uint32_t _res) {
12221         if ((_res & 1) != 0) return;
12222         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12223         CHECK_ACCESS(_res_ptr);
12224         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
12225         FREE((void*)_res);
12226         COption_u64Z_free(_res_conv);
12227 }
12228
12229 static inline uintptr_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
12230         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12231         *ret_copy = COption_u64Z_clone(arg);
12232 uint32_t ret_ref = (uintptr_t)ret_copy;
12233         return ret_ref;
12234 }
12235 uint32_t  __attribute__((export_name("TS_COption_u64Z_clone_ptr"))) TS_COption_u64Z_clone_ptr(uint32_t arg) {
12236         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)arg;
12237         uint32_t ret_conv = COption_u64Z_clone_ptr(arg_conv);
12238         return ret_conv;
12239 }
12240
12241 uint32_t  __attribute__((export_name("TS_COption_u64Z_clone"))) TS_COption_u64Z_clone(uint32_t orig) {
12242         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
12243         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12244         *ret_copy = COption_u64Z_clone(orig_conv);
12245         uint32_t ret_ref = (uintptr_t)ret_copy;
12246         return ret_ref;
12247 }
12248
12249 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_ok"))) TS_CResult_PaymentParametersDecodeErrorZ_ok(uint32_t o) {
12250         LDKPaymentParameters o_conv;
12251         o_conv.inner = (void*)(o & (~1));
12252         o_conv.is_owned = (o & 1) || (o == 0);
12253         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12254         o_conv = PaymentParameters_clone(&o_conv);
12255         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
12256         *ret_conv = CResult_PaymentParametersDecodeErrorZ_ok(o_conv);
12257         return (uint32_t)ret_conv;
12258 }
12259
12260 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_err"))) TS_CResult_PaymentParametersDecodeErrorZ_err(uint32_t e) {
12261         LDKDecodeError e_conv;
12262         e_conv.inner = (void*)(e & (~1));
12263         e_conv.is_owned = (e & 1) || (e == 0);
12264         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12265         e_conv = DecodeError_clone(&e_conv);
12266         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
12267         *ret_conv = CResult_PaymentParametersDecodeErrorZ_err(e_conv);
12268         return (uint32_t)ret_conv;
12269 }
12270
12271 jboolean  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_is_ok"))) TS_CResult_PaymentParametersDecodeErrorZ_is_ok(uint32_t o) {
12272         LDKCResult_PaymentParametersDecodeErrorZ* o_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(o & ~1);
12273         jboolean ret_conv = CResult_PaymentParametersDecodeErrorZ_is_ok(o_conv);
12274         return ret_conv;
12275 }
12276
12277 void  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_free"))) TS_CResult_PaymentParametersDecodeErrorZ_free(uint32_t _res) {
12278         if ((_res & 1) != 0) return;
12279         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12280         CHECK_ACCESS(_res_ptr);
12281         LDKCResult_PaymentParametersDecodeErrorZ _res_conv = *(LDKCResult_PaymentParametersDecodeErrorZ*)(_res_ptr);
12282         FREE((void*)_res);
12283         CResult_PaymentParametersDecodeErrorZ_free(_res_conv);
12284 }
12285
12286 static inline uintptr_t CResult_PaymentParametersDecodeErrorZ_clone_ptr(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR arg) {
12287         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
12288         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(arg);
12289         return (uint32_t)ret_conv;
12290 }
12291 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_clone_ptr"))) TS_CResult_PaymentParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
12292         LDKCResult_PaymentParametersDecodeErrorZ* arg_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(arg & ~1);
12293         uint32_t ret_conv = CResult_PaymentParametersDecodeErrorZ_clone_ptr(arg_conv);
12294         return ret_conv;
12295 }
12296
12297 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_clone"))) TS_CResult_PaymentParametersDecodeErrorZ_clone(uint32_t orig) {
12298         LDKCResult_PaymentParametersDecodeErrorZ* orig_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(orig & ~1);
12299         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
12300         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(orig_conv);
12301         return (uint32_t)ret_conv;
12302 }
12303
12304 void  __attribute__((export_name("TS_CVec_RouteHintHopZ_free"))) TS_CVec_RouteHintHopZ_free(uint32_tArray _res) {
12305         LDKCVec_RouteHintHopZ _res_constr;
12306         _res_constr.datalen = _res->arr_len;
12307         if (_res_constr.datalen > 0)
12308                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
12309         else
12310                 _res_constr.data = NULL;
12311         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12312         for (size_t o = 0; o < _res_constr.datalen; o++) {
12313                 uint32_t _res_conv_14 = _res_vals[o];
12314                 LDKRouteHintHop _res_conv_14_conv;
12315                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
12316                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
12317                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
12318                 _res_constr.data[o] = _res_conv_14_conv;
12319         }
12320         CVec_RouteHintHopZ_free(_res_constr);
12321 }
12322
12323 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_ok"))) TS_CResult_RouteHintDecodeErrorZ_ok(uint32_t o) {
12324         LDKRouteHint o_conv;
12325         o_conv.inner = (void*)(o & (~1));
12326         o_conv.is_owned = (o & 1) || (o == 0);
12327         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12328         o_conv = RouteHint_clone(&o_conv);
12329         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12330         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
12331         return (uint32_t)ret_conv;
12332 }
12333
12334 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_err"))) TS_CResult_RouteHintDecodeErrorZ_err(uint32_t e) {
12335         LDKDecodeError e_conv;
12336         e_conv.inner = (void*)(e & (~1));
12337         e_conv.is_owned = (e & 1) || (e == 0);
12338         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12339         e_conv = DecodeError_clone(&e_conv);
12340         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12341         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
12342         return (uint32_t)ret_conv;
12343 }
12344
12345 jboolean  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_is_ok"))) TS_CResult_RouteHintDecodeErrorZ_is_ok(uint32_t o) {
12346         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)(o & ~1);
12347         jboolean ret_conv = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
12348         return ret_conv;
12349 }
12350
12351 void  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_free"))) TS_CResult_RouteHintDecodeErrorZ_free(uint32_t _res) {
12352         if ((_res & 1) != 0) return;
12353         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12354         CHECK_ACCESS(_res_ptr);
12355         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
12356         FREE((void*)_res);
12357         CResult_RouteHintDecodeErrorZ_free(_res_conv);
12358 }
12359
12360 static inline uintptr_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
12361         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12362         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
12363         return (uint32_t)ret_conv;
12364 }
12365 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHintDecodeErrorZ_clone_ptr(uint32_t arg) {
12366         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
12367         uint32_t ret_conv = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
12368         return ret_conv;
12369 }
12370
12371 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_clone"))) TS_CResult_RouteHintDecodeErrorZ_clone(uint32_t orig) {
12372         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)(orig & ~1);
12373         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12374         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
12375         return (uint32_t)ret_conv;
12376 }
12377
12378 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_ok(uint32_t o) {
12379         LDKRouteHintHop o_conv;
12380         o_conv.inner = (void*)(o & (~1));
12381         o_conv.is_owned = (o & 1) || (o == 0);
12382         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12383         o_conv = RouteHintHop_clone(&o_conv);
12384         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12385         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
12386         return (uint32_t)ret_conv;
12387 }
12388
12389 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_err"))) TS_CResult_RouteHintHopDecodeErrorZ_err(uint32_t e) {
12390         LDKDecodeError e_conv;
12391         e_conv.inner = (void*)(e & (~1));
12392         e_conv.is_owned = (e & 1) || (e == 0);
12393         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12394         e_conv = DecodeError_clone(&e_conv);
12395         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12396         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
12397         return (uint32_t)ret_conv;
12398 }
12399
12400 jboolean  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_is_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_is_ok(uint32_t o) {
12401         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(o & ~1);
12402         jboolean ret_conv = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
12403         return ret_conv;
12404 }
12405
12406 void  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_free"))) TS_CResult_RouteHintHopDecodeErrorZ_free(uint32_t _res) {
12407         if ((_res & 1) != 0) return;
12408         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12409         CHECK_ACCESS(_res_ptr);
12410         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
12411         FREE((void*)_res);
12412         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
12413 }
12414
12415 static inline uintptr_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
12416         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12417         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
12418         return (uint32_t)ret_conv;
12419 }
12420 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHintHopDecodeErrorZ_clone_ptr(uint32_t arg) {
12421         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
12422         uint32_t ret_conv = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
12423         return ret_conv;
12424 }
12425
12426 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_clone"))) TS_CResult_RouteHintHopDecodeErrorZ_clone(uint32_t orig) {
12427         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(orig & ~1);
12428         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12429         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
12430         return (uint32_t)ret_conv;
12431 }
12432
12433 void  __attribute__((export_name("TS_CVec_ChannelDetailsZ_free"))) TS_CVec_ChannelDetailsZ_free(uint32_tArray _res) {
12434         LDKCVec_ChannelDetailsZ _res_constr;
12435         _res_constr.datalen = _res->arr_len;
12436         if (_res_constr.datalen > 0)
12437                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
12438         else
12439                 _res_constr.data = NULL;
12440         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12441         for (size_t q = 0; q < _res_constr.datalen; q++) {
12442                 uint32_t _res_conv_16 = _res_vals[q];
12443                 LDKChannelDetails _res_conv_16_conv;
12444                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
12445                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
12446                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
12447                 _res_constr.data[q] = _res_conv_16_conv;
12448         }
12449         CVec_ChannelDetailsZ_free(_res_constr);
12450 }
12451
12452 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_ok"))) TS_CResult_RouteLightningErrorZ_ok(uint32_t o) {
12453         LDKRoute o_conv;
12454         o_conv.inner = (void*)(o & (~1));
12455         o_conv.is_owned = (o & 1) || (o == 0);
12456         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12457         o_conv = Route_clone(&o_conv);
12458         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12459         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
12460         return (uint32_t)ret_conv;
12461 }
12462
12463 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_err"))) TS_CResult_RouteLightningErrorZ_err(uint32_t e) {
12464         LDKLightningError e_conv;
12465         e_conv.inner = (void*)(e & (~1));
12466         e_conv.is_owned = (e & 1) || (e == 0);
12467         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12468         e_conv = LightningError_clone(&e_conv);
12469         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12470         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
12471         return (uint32_t)ret_conv;
12472 }
12473
12474 jboolean  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_is_ok"))) TS_CResult_RouteLightningErrorZ_is_ok(uint32_t o) {
12475         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)(o & ~1);
12476         jboolean ret_conv = CResult_RouteLightningErrorZ_is_ok(o_conv);
12477         return ret_conv;
12478 }
12479
12480 void  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_free"))) TS_CResult_RouteLightningErrorZ_free(uint32_t _res) {
12481         if ((_res & 1) != 0) return;
12482         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12483         CHECK_ACCESS(_res_ptr);
12484         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
12485         FREE((void*)_res);
12486         CResult_RouteLightningErrorZ_free(_res_conv);
12487 }
12488
12489 static inline uintptr_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
12490         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12491         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
12492         return (uint32_t)ret_conv;
12493 }
12494 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_clone_ptr"))) TS_CResult_RouteLightningErrorZ_clone_ptr(uint32_t arg) {
12495         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
12496         uint32_t ret_conv = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
12497         return ret_conv;
12498 }
12499
12500 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_clone"))) TS_CResult_RouteLightningErrorZ_clone(uint32_t orig) {
12501         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
12502         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12503         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
12504         return (uint32_t)ret_conv;
12505 }
12506
12507 void  __attribute__((export_name("TS_CVec_PublicKeyZ_free"))) TS_CVec_PublicKeyZ_free(ptrArray _res) {
12508         LDKCVec_PublicKeyZ _res_constr;
12509         _res_constr.datalen = _res->arr_len;
12510         if (_res_constr.datalen > 0)
12511                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
12512         else
12513                 _res_constr.data = NULL;
12514         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
12515         for (size_t m = 0; m < _res_constr.datalen; m++) {
12516                 int8_tArray _res_conv_12 = _res_vals[m];
12517                 LDKPublicKey _res_conv_12_ref;
12518                 CHECK(_res_conv_12->arr_len == 33);
12519                 memcpy(_res_conv_12_ref.compressed_form, _res_conv_12->elems, 33); FREE(_res_conv_12);
12520                 _res_constr.data[m] = _res_conv_12_ref;
12521         }
12522         CVec_PublicKeyZ_free(_res_constr);
12523 }
12524
12525 uint32_t  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_ok"))) TS_CResult_PaymentPurposeDecodeErrorZ_ok(uint32_t o) {
12526         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12527         CHECK_ACCESS(o_ptr);
12528         LDKPaymentPurpose o_conv = *(LDKPaymentPurpose*)(o_ptr);
12529         o_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)o) & ~1));
12530         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
12531         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_ok(o_conv);
12532         return (uint32_t)ret_conv;
12533 }
12534
12535 uint32_t  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_err"))) TS_CResult_PaymentPurposeDecodeErrorZ_err(uint32_t e) {
12536         LDKDecodeError e_conv;
12537         e_conv.inner = (void*)(e & (~1));
12538         e_conv.is_owned = (e & 1) || (e == 0);
12539         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12540         e_conv = DecodeError_clone(&e_conv);
12541         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
12542         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_err(e_conv);
12543         return (uint32_t)ret_conv;
12544 }
12545
12546 jboolean  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_is_ok"))) TS_CResult_PaymentPurposeDecodeErrorZ_is_ok(uint32_t o) {
12547         LDKCResult_PaymentPurposeDecodeErrorZ* o_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(o & ~1);
12548         jboolean ret_conv = CResult_PaymentPurposeDecodeErrorZ_is_ok(o_conv);
12549         return ret_conv;
12550 }
12551
12552 void  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_free"))) TS_CResult_PaymentPurposeDecodeErrorZ_free(uint32_t _res) {
12553         if ((_res & 1) != 0) return;
12554         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12555         CHECK_ACCESS(_res_ptr);
12556         LDKCResult_PaymentPurposeDecodeErrorZ _res_conv = *(LDKCResult_PaymentPurposeDecodeErrorZ*)(_res_ptr);
12557         FREE((void*)_res);
12558         CResult_PaymentPurposeDecodeErrorZ_free(_res_conv);
12559 }
12560
12561 static inline uintptr_t CResult_PaymentPurposeDecodeErrorZ_clone_ptr(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR arg) {
12562         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
12563         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(arg);
12564         return (uint32_t)ret_conv;
12565 }
12566 uint32_t  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_clone_ptr"))) TS_CResult_PaymentPurposeDecodeErrorZ_clone_ptr(uint32_t arg) {
12567         LDKCResult_PaymentPurposeDecodeErrorZ* arg_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(arg & ~1);
12568         uint32_t ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone_ptr(arg_conv);
12569         return ret_conv;
12570 }
12571
12572 uint32_t  __attribute__((export_name("TS_CResult_PaymentPurposeDecodeErrorZ_clone"))) TS_CResult_PaymentPurposeDecodeErrorZ_clone(uint32_t orig) {
12573         LDKCResult_PaymentPurposeDecodeErrorZ* orig_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)(orig & ~1);
12574         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
12575         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(orig_conv);
12576         return (uint32_t)ret_conv;
12577 }
12578
12579 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_some"))) TS_COption_ClosureReasonZ_some(uint32_t o) {
12580         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12581         CHECK_ACCESS(o_ptr);
12582         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
12583         o_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)o) & ~1));
12584         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12585         *ret_copy = COption_ClosureReasonZ_some(o_conv);
12586         uint32_t ret_ref = (uintptr_t)ret_copy;
12587         return ret_ref;
12588 }
12589
12590 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_none"))) TS_COption_ClosureReasonZ_none() {
12591         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12592         *ret_copy = COption_ClosureReasonZ_none();
12593         uint32_t ret_ref = (uintptr_t)ret_copy;
12594         return ret_ref;
12595 }
12596
12597 void  __attribute__((export_name("TS_COption_ClosureReasonZ_free"))) TS_COption_ClosureReasonZ_free(uint32_t _res) {
12598         if ((_res & 1) != 0) return;
12599         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12600         CHECK_ACCESS(_res_ptr);
12601         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
12602         FREE((void*)_res);
12603         COption_ClosureReasonZ_free(_res_conv);
12604 }
12605
12606 static inline uintptr_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
12607         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12608         *ret_copy = COption_ClosureReasonZ_clone(arg);
12609 uint32_t ret_ref = (uintptr_t)ret_copy;
12610         return ret_ref;
12611 }
12612 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_clone_ptr"))) TS_COption_ClosureReasonZ_clone_ptr(uint32_t arg) {
12613         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)arg;
12614         uint32_t ret_conv = COption_ClosureReasonZ_clone_ptr(arg_conv);
12615         return ret_conv;
12616 }
12617
12618 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_clone"))) TS_COption_ClosureReasonZ_clone(uint32_t orig) {
12619         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)orig;
12620         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12621         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
12622         uint32_t ret_ref = (uintptr_t)ret_copy;
12623         return ret_ref;
12624 }
12625
12626 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_ok(uint32_t o) {
12627         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12628         CHECK_ACCESS(o_ptr);
12629         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
12630         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)(((uintptr_t)o) & ~1));
12631         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12632         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
12633         return (uint32_t)ret_conv;
12634 }
12635
12636 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_err"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_err(uint32_t e) {
12637         LDKDecodeError e_conv;
12638         e_conv.inner = (void*)(e & (~1));
12639         e_conv.is_owned = (e & 1) || (e == 0);
12640         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12641         e_conv = DecodeError_clone(&e_conv);
12642         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12643         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
12644         return (uint32_t)ret_conv;
12645 }
12646
12647 jboolean  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_is_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(uint32_t o) {
12648         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(o & ~1);
12649         jboolean ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
12650         return ret_conv;
12651 }
12652
12653 void  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_free"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_free(uint32_t _res) {
12654         if ((_res & 1) != 0) return;
12655         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12656         CHECK_ACCESS(_res_ptr);
12657         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
12658         FREE((void*)_res);
12659         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
12660 }
12661
12662 static inline uintptr_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
12663         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12664         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
12665         return (uint32_t)ret_conv;
12666 }
12667 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(uint32_t arg) {
12668         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(arg & ~1);
12669         uint32_t ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
12670         return ret_conv;
12671 }
12672
12673 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone(uint32_t orig) {
12674         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(orig & ~1);
12675         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12676         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
12677         return (uint32_t)ret_conv;
12678 }
12679
12680 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_some"))) TS_COption_NetworkUpdateZ_some(uint32_t o) {
12681         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12682         CHECK_ACCESS(o_ptr);
12683         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
12684         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uintptr_t)o) & ~1));
12685         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12686         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
12687         uint32_t ret_ref = (uintptr_t)ret_copy;
12688         return ret_ref;
12689 }
12690
12691 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_none"))) TS_COption_NetworkUpdateZ_none() {
12692         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12693         *ret_copy = COption_NetworkUpdateZ_none();
12694         uint32_t ret_ref = (uintptr_t)ret_copy;
12695         return ret_ref;
12696 }
12697
12698 void  __attribute__((export_name("TS_COption_NetworkUpdateZ_free"))) TS_COption_NetworkUpdateZ_free(uint32_t _res) {
12699         if ((_res & 1) != 0) return;
12700         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12701         CHECK_ACCESS(_res_ptr);
12702         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
12703         FREE((void*)_res);
12704         COption_NetworkUpdateZ_free(_res_conv);
12705 }
12706
12707 static inline uintptr_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
12708         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12709         *ret_copy = COption_NetworkUpdateZ_clone(arg);
12710 uint32_t ret_ref = (uintptr_t)ret_copy;
12711         return ret_ref;
12712 }
12713 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_clone_ptr"))) TS_COption_NetworkUpdateZ_clone_ptr(uint32_t arg) {
12714         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)arg;
12715         uint32_t ret_conv = COption_NetworkUpdateZ_clone_ptr(arg_conv);
12716         return ret_conv;
12717 }
12718
12719 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_clone"))) TS_COption_NetworkUpdateZ_clone(uint32_t orig) {
12720         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig;
12721         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12722         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
12723         uint32_t ret_ref = (uintptr_t)ret_copy;
12724         return ret_ref;
12725 }
12726
12727 void  __attribute__((export_name("TS_CVec_SpendableOutputDescriptorZ_free"))) TS_CVec_SpendableOutputDescriptorZ_free(uint32_tArray _res) {
12728         LDKCVec_SpendableOutputDescriptorZ _res_constr;
12729         _res_constr.datalen = _res->arr_len;
12730         if (_res_constr.datalen > 0)
12731                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
12732         else
12733                 _res_constr.data = NULL;
12734         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12735         for (size_t b = 0; b < _res_constr.datalen; b++) {
12736                 uint32_t _res_conv_27 = _res_vals[b];
12737                 void* _res_conv_27_ptr = (void*)(((uintptr_t)_res_conv_27) & ~1);
12738                 CHECK_ACCESS(_res_conv_27_ptr);
12739                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
12740                 FREE((void*)_res_conv_27);
12741                 _res_constr.data[b] = _res_conv_27_conv;
12742         }
12743         CVec_SpendableOutputDescriptorZ_free(_res_constr);
12744 }
12745
12746 uint32_t  __attribute__((export_name("TS_COption_EventZ_some"))) TS_COption_EventZ_some(uint32_t o) {
12747         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12748         CHECK_ACCESS(o_ptr);
12749         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
12750         o_conv = Event_clone((LDKEvent*)(((uintptr_t)o) & ~1));
12751         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12752         *ret_copy = COption_EventZ_some(o_conv);
12753         uint32_t ret_ref = (uintptr_t)ret_copy;
12754         return ret_ref;
12755 }
12756
12757 uint32_t  __attribute__((export_name("TS_COption_EventZ_none"))) TS_COption_EventZ_none() {
12758         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12759         *ret_copy = COption_EventZ_none();
12760         uint32_t ret_ref = (uintptr_t)ret_copy;
12761         return ret_ref;
12762 }
12763
12764 void  __attribute__((export_name("TS_COption_EventZ_free"))) TS_COption_EventZ_free(uint32_t _res) {
12765         if ((_res & 1) != 0) return;
12766         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12767         CHECK_ACCESS(_res_ptr);
12768         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
12769         FREE((void*)_res);
12770         COption_EventZ_free(_res_conv);
12771 }
12772
12773 static inline uintptr_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
12774         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12775         *ret_copy = COption_EventZ_clone(arg);
12776 uint32_t ret_ref = (uintptr_t)ret_copy;
12777         return ret_ref;
12778 }
12779 uint32_t  __attribute__((export_name("TS_COption_EventZ_clone_ptr"))) TS_COption_EventZ_clone_ptr(uint32_t arg) {
12780         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)arg;
12781         uint32_t ret_conv = COption_EventZ_clone_ptr(arg_conv);
12782         return ret_conv;
12783 }
12784
12785 uint32_t  __attribute__((export_name("TS_COption_EventZ_clone"))) TS_COption_EventZ_clone(uint32_t orig) {
12786         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)orig;
12787         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12788         *ret_copy = COption_EventZ_clone(orig_conv);
12789         uint32_t ret_ref = (uintptr_t)ret_copy;
12790         return ret_ref;
12791 }
12792
12793 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_ok"))) TS_CResult_COption_EventZDecodeErrorZ_ok(uint32_t o) {
12794         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12795         CHECK_ACCESS(o_ptr);
12796         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
12797         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)(((uintptr_t)o) & ~1));
12798         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12799         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
12800         return (uint32_t)ret_conv;
12801 }
12802
12803 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_err"))) TS_CResult_COption_EventZDecodeErrorZ_err(uint32_t e) {
12804         LDKDecodeError e_conv;
12805         e_conv.inner = (void*)(e & (~1));
12806         e_conv.is_owned = (e & 1) || (e == 0);
12807         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12808         e_conv = DecodeError_clone(&e_conv);
12809         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12810         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
12811         return (uint32_t)ret_conv;
12812 }
12813
12814 jboolean  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_is_ok"))) TS_CResult_COption_EventZDecodeErrorZ_is_ok(uint32_t o) {
12815         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(o & ~1);
12816         jboolean ret_conv = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
12817         return ret_conv;
12818 }
12819
12820 void  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_free"))) TS_CResult_COption_EventZDecodeErrorZ_free(uint32_t _res) {
12821         if ((_res & 1) != 0) return;
12822         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12823         CHECK_ACCESS(_res_ptr);
12824         LDKCResult_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
12825         FREE((void*)_res);
12826         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
12827 }
12828
12829 static inline uintptr_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
12830         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12831         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
12832         return (uint32_t)ret_conv;
12833 }
12834 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_EventZDecodeErrorZ_clone_ptr(uint32_t arg) {
12835         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(arg & ~1);
12836         uint32_t ret_conv = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
12837         return ret_conv;
12838 }
12839
12840 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_clone"))) TS_CResult_COption_EventZDecodeErrorZ_clone(uint32_t orig) {
12841         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(orig & ~1);
12842         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12843         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
12844         return (uint32_t)ret_conv;
12845 }
12846
12847 void  __attribute__((export_name("TS_CVec_MessageSendEventZ_free"))) TS_CVec_MessageSendEventZ_free(uint32_tArray _res) {
12848         LDKCVec_MessageSendEventZ _res_constr;
12849         _res_constr.datalen = _res->arr_len;
12850         if (_res_constr.datalen > 0)
12851                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
12852         else
12853                 _res_constr.data = NULL;
12854         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12855         for (size_t s = 0; s < _res_constr.datalen; s++) {
12856                 uint32_t _res_conv_18 = _res_vals[s];
12857                 void* _res_conv_18_ptr = (void*)(((uintptr_t)_res_conv_18) & ~1);
12858                 CHECK_ACCESS(_res_conv_18_ptr);
12859                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
12860                 FREE((void*)_res_conv_18);
12861                 _res_constr.data[s] = _res_conv_18_conv;
12862         }
12863         CVec_MessageSendEventZ_free(_res_constr);
12864 }
12865
12866 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_ok"))) TS_CResult_TxOutAccessErrorZ_ok(uint32_t o) {
12867         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12868         CHECK_ACCESS(o_ptr);
12869         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
12870         o_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)o) & ~1));
12871         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
12872         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
12873         return (uint32_t)ret_conv;
12874 }
12875
12876 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_err"))) TS_CResult_TxOutAccessErrorZ_err(uint32_t e) {
12877         LDKAccessError e_conv = LDKAccessError_from_js(e);
12878         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
12879         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
12880         return (uint32_t)ret_conv;
12881 }
12882
12883 jboolean  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_is_ok"))) TS_CResult_TxOutAccessErrorZ_is_ok(uint32_t o) {
12884         LDKCResult_TxOutAccessErrorZ* o_conv = (LDKCResult_TxOutAccessErrorZ*)(o & ~1);
12885         jboolean ret_conv = CResult_TxOutAccessErrorZ_is_ok(o_conv);
12886         return ret_conv;
12887 }
12888
12889 void  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_free"))) TS_CResult_TxOutAccessErrorZ_free(uint32_t _res) {
12890         if ((_res & 1) != 0) return;
12891         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12892         CHECK_ACCESS(_res_ptr);
12893         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
12894         FREE((void*)_res);
12895         CResult_TxOutAccessErrorZ_free(_res_conv);
12896 }
12897
12898 static inline uintptr_t CResult_TxOutAccessErrorZ_clone_ptr(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR arg) {
12899         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
12900         *ret_conv = CResult_TxOutAccessErrorZ_clone(arg);
12901         return (uint32_t)ret_conv;
12902 }
12903 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_clone_ptr"))) TS_CResult_TxOutAccessErrorZ_clone_ptr(uint32_t arg) {
12904         LDKCResult_TxOutAccessErrorZ* arg_conv = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
12905         uint32_t ret_conv = CResult_TxOutAccessErrorZ_clone_ptr(arg_conv);
12906         return ret_conv;
12907 }
12908
12909 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_clone"))) TS_CResult_TxOutAccessErrorZ_clone(uint32_t orig) {
12910         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
12911         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
12912         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
12913         return (uint32_t)ret_conv;
12914 }
12915
12916 static inline uintptr_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
12917         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
12918         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
12919         return ((uint32_t)ret_conv);
12920 }
12921 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_clone_ptr"))) TS_C2Tuple_usizeTransactionZ_clone_ptr(uint32_t arg) {
12922         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)(arg & ~1);
12923         uint32_t ret_conv = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
12924         return ret_conv;
12925 }
12926
12927 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_clone"))) TS_C2Tuple_usizeTransactionZ_clone(uint32_t orig) {
12928         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
12929         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
12930         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
12931         return ((uint32_t)ret_conv);
12932 }
12933
12934 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_new"))) TS_C2Tuple_usizeTransactionZ_new(uint32_t a, int8_tArray b) {
12935         LDKTransaction b_ref;
12936         b_ref.datalen = b->arr_len;
12937         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
12938         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
12939         b_ref.data_is_owned = true;
12940         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
12941         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
12942         return ((uint32_t)ret_conv);
12943 }
12944
12945 void  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_free"))) TS_C2Tuple_usizeTransactionZ_free(uint32_t _res) {
12946         if ((_res & 1) != 0) return;
12947         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12948         CHECK_ACCESS(_res_ptr);
12949         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
12950         FREE((void*)_res);
12951         C2Tuple_usizeTransactionZ_free(_res_conv);
12952 }
12953
12954 void  __attribute__((export_name("TS_CVec_C2Tuple_usizeTransactionZZ_free"))) TS_CVec_C2Tuple_usizeTransactionZZ_free(uint32_tArray _res) {
12955         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
12956         _res_constr.datalen = _res->arr_len;
12957         if (_res_constr.datalen > 0)
12958                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
12959         else
12960                 _res_constr.data = NULL;
12961         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12962         for (size_t c = 0; c < _res_constr.datalen; c++) {
12963                 uint32_t _res_conv_28 = _res_vals[c];
12964                 void* _res_conv_28_ptr = (void*)(((uintptr_t)_res_conv_28) & ~1);
12965                 CHECK_ACCESS(_res_conv_28_ptr);
12966                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
12967                 FREE((void*)_res_conv_28);
12968                 _res_constr.data[c] = _res_conv_28_conv;
12969         }
12970         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
12971 }
12972
12973 void  __attribute__((export_name("TS_CVec_TxidZ_free"))) TS_CVec_TxidZ_free(ptrArray _res) {
12974         LDKCVec_TxidZ _res_constr;
12975         _res_constr.datalen = _res->arr_len;
12976         if (_res_constr.datalen > 0)
12977                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
12978         else
12979                 _res_constr.data = NULL;
12980         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
12981         for (size_t m = 0; m < _res_constr.datalen; m++) {
12982                 int8_tArray _res_conv_12 = _res_vals[m];
12983                 LDKThirtyTwoBytes _res_conv_12_ref;
12984                 CHECK(_res_conv_12->arr_len == 32);
12985                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, 32); FREE(_res_conv_12);
12986                 _res_constr.data[m] = _res_conv_12_ref;
12987         }
12988         CVec_TxidZ_free(_res_constr);
12989 }
12990
12991 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_ok() {
12992         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
12993         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
12994         return (uint32_t)ret_conv;
12995 }
12996
12997 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_err"))) TS_CResult_NoneChannelMonitorUpdateErrZ_err(uint32_t e) {
12998         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_js(e);
12999         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
13000         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
13001         return (uint32_t)ret_conv;
13002 }
13003
13004 jboolean  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_is_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_is_ok(uint32_t o) {
13005         LDKCResult_NoneChannelMonitorUpdateErrZ* o_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(o & ~1);
13006         jboolean ret_conv = CResult_NoneChannelMonitorUpdateErrZ_is_ok(o_conv);
13007         return ret_conv;
13008 }
13009
13010 void  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_free"))) TS_CResult_NoneChannelMonitorUpdateErrZ_free(uint32_t _res) {
13011         if ((_res & 1) != 0) return;
13012         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13013         CHECK_ACCESS(_res_ptr);
13014         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(_res_ptr);
13015         FREE((void*)_res);
13016         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
13017 }
13018
13019 static inline uintptr_t CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR arg) {
13020         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
13021         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(arg);
13022         return (uint32_t)ret_conv;
13023 }
13024 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_clone_ptr"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(uint32_t arg) {
13025         LDKCResult_NoneChannelMonitorUpdateErrZ* arg_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
13026         uint32_t ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(arg_conv);
13027         return ret_conv;
13028 }
13029
13030 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_clone"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone(uint32_t orig) {
13031         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
13032         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
13033         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
13034         return (uint32_t)ret_conv;
13035 }
13036
13037 void  __attribute__((export_name("TS_CVec_MonitorEventZ_free"))) TS_CVec_MonitorEventZ_free(uint32_tArray _res) {
13038         LDKCVec_MonitorEventZ _res_constr;
13039         _res_constr.datalen = _res->arr_len;
13040         if (_res_constr.datalen > 0)
13041                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
13042         else
13043                 _res_constr.data = NULL;
13044         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
13045         for (size_t o = 0; o < _res_constr.datalen; o++) {
13046                 uint32_t _res_conv_14 = _res_vals[o];
13047                 void* _res_conv_14_ptr = (void*)(((uintptr_t)_res_conv_14) & ~1);
13048                 CHECK_ACCESS(_res_conv_14_ptr);
13049                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
13050                 FREE((void*)_res_conv_14);
13051                 _res_constr.data[o] = _res_conv_14_conv;
13052         }
13053         CVec_MonitorEventZ_free(_res_constr);
13054 }
13055
13056 static inline uintptr_t C2Tuple_OutPointCVec_MonitorEventZZ_clone_ptr(LDKC2Tuple_OutPointCVec_MonitorEventZZ *NONNULL_PTR arg) {
13057         LDKC2Tuple_OutPointCVec_MonitorEventZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorEventZZ), "LDKC2Tuple_OutPointCVec_MonitorEventZZ");
13058         *ret_conv = C2Tuple_OutPointCVec_MonitorEventZZ_clone(arg);
13059         return ((uint32_t)ret_conv);
13060 }
13061 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointCVec_MonitorEventZZ_clone_ptr"))) TS_C2Tuple_OutPointCVec_MonitorEventZZ_clone_ptr(uint32_t arg) {
13062         LDKC2Tuple_OutPointCVec_MonitorEventZZ* arg_conv = (LDKC2Tuple_OutPointCVec_MonitorEventZZ*)(arg & ~1);
13063         uint32_t ret_conv = C2Tuple_OutPointCVec_MonitorEventZZ_clone_ptr(arg_conv);
13064         return ret_conv;
13065 }
13066
13067 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointCVec_MonitorEventZZ_clone"))) TS_C2Tuple_OutPointCVec_MonitorEventZZ_clone(uint32_t orig) {
13068         LDKC2Tuple_OutPointCVec_MonitorEventZZ* orig_conv = (LDKC2Tuple_OutPointCVec_MonitorEventZZ*)(orig & ~1);
13069         LDKC2Tuple_OutPointCVec_MonitorEventZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorEventZZ), "LDKC2Tuple_OutPointCVec_MonitorEventZZ");
13070         *ret_conv = C2Tuple_OutPointCVec_MonitorEventZZ_clone(orig_conv);
13071         return ((uint32_t)ret_conv);
13072 }
13073
13074 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointCVec_MonitorEventZZ_new"))) TS_C2Tuple_OutPointCVec_MonitorEventZZ_new(uint32_t a, uint32_tArray b) {
13075         LDKOutPoint a_conv;
13076         a_conv.inner = (void*)(a & (~1));
13077         a_conv.is_owned = (a & 1) || (a == 0);
13078         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
13079         a_conv = OutPoint_clone(&a_conv);
13080         LDKCVec_MonitorEventZ b_constr;
13081         b_constr.datalen = b->arr_len;
13082         if (b_constr.datalen > 0)
13083                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
13084         else
13085                 b_constr.data = NULL;
13086         uint32_t* b_vals = b->elems /* XXX b leaks */;
13087         for (size_t o = 0; o < b_constr.datalen; o++) {
13088                 uint32_t b_conv_14 = b_vals[o];
13089                 void* b_conv_14_ptr = (void*)(((uintptr_t)b_conv_14) & ~1);
13090                 CHECK_ACCESS(b_conv_14_ptr);
13091                 LDKMonitorEvent b_conv_14_conv = *(LDKMonitorEvent*)(b_conv_14_ptr);
13092                 b_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uintptr_t)b_conv_14) & ~1));
13093                 b_constr.data[o] = b_conv_14_conv;
13094         }
13095         LDKC2Tuple_OutPointCVec_MonitorEventZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorEventZZ), "LDKC2Tuple_OutPointCVec_MonitorEventZZ");
13096         *ret_conv = C2Tuple_OutPointCVec_MonitorEventZZ_new(a_conv, b_constr);
13097         return ((uint32_t)ret_conv);
13098 }
13099
13100 void  __attribute__((export_name("TS_C2Tuple_OutPointCVec_MonitorEventZZ_free"))) TS_C2Tuple_OutPointCVec_MonitorEventZZ_free(uint32_t _res) {
13101         if ((_res & 1) != 0) return;
13102         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13103         CHECK_ACCESS(_res_ptr);
13104         LDKC2Tuple_OutPointCVec_MonitorEventZZ _res_conv = *(LDKC2Tuple_OutPointCVec_MonitorEventZZ*)(_res_ptr);
13105         FREE((void*)_res);
13106         C2Tuple_OutPointCVec_MonitorEventZZ_free(_res_conv);
13107 }
13108
13109 void  __attribute__((export_name("TS_CVec_C2Tuple_OutPointCVec_MonitorEventZZZ_free"))) TS_CVec_C2Tuple_OutPointCVec_MonitorEventZZZ_free(uint32_tArray _res) {
13110         LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ _res_constr;
13111         _res_constr.datalen = _res->arr_len;
13112         if (_res_constr.datalen > 0)
13113                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_OutPointCVec_MonitorEventZZ), "LDKCVec_C2Tuple_OutPointCVec_MonitorEventZZZ Elements");
13114         else
13115                 _res_constr.data = NULL;
13116         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
13117         for (size_t m = 0; m < _res_constr.datalen; m++) {
13118                 uint32_t _res_conv_38 = _res_vals[m];
13119                 void* _res_conv_38_ptr = (void*)(((uintptr_t)_res_conv_38) & ~1);
13120                 CHECK_ACCESS(_res_conv_38_ptr);
13121                 LDKC2Tuple_OutPointCVec_MonitorEventZZ _res_conv_38_conv = *(LDKC2Tuple_OutPointCVec_MonitorEventZZ*)(_res_conv_38_ptr);
13122                 FREE((void*)_res_conv_38);
13123                 _res_constr.data[m] = _res_conv_38_conv;
13124         }
13125         CVec_C2Tuple_OutPointCVec_MonitorEventZZZ_free(_res_constr);
13126 }
13127
13128 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_some"))) TS_COption_C2Tuple_usizeTransactionZZ_some(uint32_t o) {
13129         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13130         CHECK_ACCESS(o_ptr);
13131         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(o_ptr);
13132         o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)o) & ~1));
13133         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
13134         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
13135         uint32_t ret_ref = (uintptr_t)ret_copy;
13136         return ret_ref;
13137 }
13138
13139 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_none"))) TS_COption_C2Tuple_usizeTransactionZZ_none() {
13140         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
13141         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
13142         uint32_t ret_ref = (uintptr_t)ret_copy;
13143         return ret_ref;
13144 }
13145
13146 void  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_free"))) TS_COption_C2Tuple_usizeTransactionZZ_free(uint32_t _res) {
13147         if ((_res & 1) != 0) return;
13148         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13149         CHECK_ACCESS(_res_ptr);
13150         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(_res_ptr);
13151         FREE((void*)_res);
13152         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
13153 }
13154
13155 static inline uintptr_t COption_C2Tuple_usizeTransactionZZ_clone_ptr(LDKCOption_C2Tuple_usizeTransactionZZ *NONNULL_PTR arg) {
13156         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
13157         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(arg);
13158 uint32_t ret_ref = (uintptr_t)ret_copy;
13159         return ret_ref;
13160 }
13161 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_clone_ptr"))) TS_COption_C2Tuple_usizeTransactionZZ_clone_ptr(uint32_t arg) {
13162         LDKCOption_C2Tuple_usizeTransactionZZ* arg_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)arg;
13163         uint32_t ret_conv = COption_C2Tuple_usizeTransactionZZ_clone_ptr(arg_conv);
13164         return ret_conv;
13165 }
13166
13167 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_clone"))) TS_COption_C2Tuple_usizeTransactionZZ_clone(uint32_t orig) {
13168         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
13169         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
13170         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
13171         uint32_t ret_ref = (uintptr_t)ret_copy;
13172         return ret_ref;
13173 }
13174
13175 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_ok"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_ok(uint32_t o) {
13176         LDKFixedPenaltyScorer o_conv;
13177         o_conv.inner = (void*)(o & (~1));
13178         o_conv.is_owned = (o & 1) || (o == 0);
13179         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13180         o_conv = FixedPenaltyScorer_clone(&o_conv);
13181         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
13182         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_ok(o_conv);
13183         return (uint32_t)ret_conv;
13184 }
13185
13186 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_err"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_err(uint32_t e) {
13187         LDKDecodeError e_conv;
13188         e_conv.inner = (void*)(e & (~1));
13189         e_conv.is_owned = (e & 1) || (e == 0);
13190         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13191         e_conv = DecodeError_clone(&e_conv);
13192         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
13193         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_err(e_conv);
13194         return (uint32_t)ret_conv;
13195 }
13196
13197 jboolean  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_is_ok"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(uint32_t o) {
13198         LDKCResult_FixedPenaltyScorerDecodeErrorZ* o_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(o & ~1);
13199         jboolean ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(o_conv);
13200         return ret_conv;
13201 }
13202
13203 void  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_free"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_free(uint32_t _res) {
13204         if ((_res & 1) != 0) return;
13205         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13206         CHECK_ACCESS(_res_ptr);
13207         LDKCResult_FixedPenaltyScorerDecodeErrorZ _res_conv = *(LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(_res_ptr);
13208         FREE((void*)_res);
13209         CResult_FixedPenaltyScorerDecodeErrorZ_free(_res_conv);
13210 }
13211
13212 static inline uintptr_t CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR arg) {
13213         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
13214         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(arg);
13215         return (uint32_t)ret_conv;
13216 }
13217 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(uint32_t arg) {
13218         LDKCResult_FixedPenaltyScorerDecodeErrorZ* arg_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(arg & ~1);
13219         uint32_t ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(arg_conv);
13220         return ret_conv;
13221 }
13222
13223 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone(uint32_t orig) {
13224         LDKCResult_FixedPenaltyScorerDecodeErrorZ* orig_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(orig & ~1);
13225         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
13226         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig_conv);
13227         return (uint32_t)ret_conv;
13228 }
13229
13230 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_ok"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_ok(uint32_t o) {
13231         LDKProbabilisticScorer o_conv;
13232         o_conv.inner = (void*)(o & (~1));
13233         o_conv.is_owned = (o & 1) || (o == 0);
13234         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13235         // WARNING: we need a move here but no clone is available for LDKProbabilisticScorer
13236         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
13237         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_ok(o_conv);
13238         return (uint32_t)ret_conv;
13239 }
13240
13241 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_err"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_err(uint32_t e) {
13242         LDKDecodeError e_conv;
13243         e_conv.inner = (void*)(e & (~1));
13244         e_conv.is_owned = (e & 1) || (e == 0);
13245         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13246         e_conv = DecodeError_clone(&e_conv);
13247         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
13248         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_err(e_conv);
13249         return (uint32_t)ret_conv;
13250 }
13251
13252 jboolean  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_is_ok"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_is_ok(uint32_t o) {
13253         LDKCResult_ProbabilisticScorerDecodeErrorZ* o_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(o & ~1);
13254         jboolean ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_is_ok(o_conv);
13255         return ret_conv;
13256 }
13257
13258 void  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_free"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_free(uint32_t _res) {
13259         if ((_res & 1) != 0) return;
13260         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13261         CHECK_ACCESS(_res_ptr);
13262         LDKCResult_ProbabilisticScorerDecodeErrorZ _res_conv = *(LDKCResult_ProbabilisticScorerDecodeErrorZ*)(_res_ptr);
13263         FREE((void*)_res);
13264         CResult_ProbabilisticScorerDecodeErrorZ_free(_res_conv);
13265 }
13266
13267 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_ok(uint32_t o) {
13268         LDKInitFeatures o_conv;
13269         o_conv.inner = (void*)(o & (~1));
13270         o_conv.is_owned = (o & 1) || (o == 0);
13271         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13272         o_conv = InitFeatures_clone(&o_conv);
13273         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
13274         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
13275         return (uint32_t)ret_conv;
13276 }
13277
13278 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_err"))) TS_CResult_InitFeaturesDecodeErrorZ_err(uint32_t e) {
13279         LDKDecodeError e_conv;
13280         e_conv.inner = (void*)(e & (~1));
13281         e_conv.is_owned = (e & 1) || (e == 0);
13282         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13283         e_conv = DecodeError_clone(&e_conv);
13284         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
13285         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
13286         return (uint32_t)ret_conv;
13287 }
13288
13289 jboolean  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_is_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_is_ok(uint32_t o) {
13290         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(o & ~1);
13291         jboolean ret_conv = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
13292         return ret_conv;
13293 }
13294
13295 void  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_free"))) TS_CResult_InitFeaturesDecodeErrorZ_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         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
13300         FREE((void*)_res);
13301         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
13302 }
13303
13304 static inline uintptr_t CResult_InitFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR arg) {
13305         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
13306         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(arg);
13307         return (uint32_t)ret_conv;
13308 }
13309 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_clone_ptr"))) TS_CResult_InitFeaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
13310         LDKCResult_InitFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
13311         uint32_t ret_conv = CResult_InitFeaturesDecodeErrorZ_clone_ptr(arg_conv);
13312         return ret_conv;
13313 }
13314
13315 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_clone"))) TS_CResult_InitFeaturesDecodeErrorZ_clone(uint32_t orig) {
13316         LDKCResult_InitFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(orig & ~1);
13317         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
13318         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(orig_conv);
13319         return (uint32_t)ret_conv;
13320 }
13321
13322 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_ok(uint32_t o) {
13323         LDKChannelFeatures o_conv;
13324         o_conv.inner = (void*)(o & (~1));
13325         o_conv.is_owned = (o & 1) || (o == 0);
13326         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13327         o_conv = ChannelFeatures_clone(&o_conv);
13328         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
13329         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
13330         return (uint32_t)ret_conv;
13331 }
13332
13333 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_err"))) TS_CResult_ChannelFeaturesDecodeErrorZ_err(uint32_t e) {
13334         LDKDecodeError e_conv;
13335         e_conv.inner = (void*)(e & (~1));
13336         e_conv.is_owned = (e & 1) || (e == 0);
13337         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13338         e_conv = DecodeError_clone(&e_conv);
13339         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
13340         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
13341         return (uint32_t)ret_conv;
13342 }
13343
13344 jboolean  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_is_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_is_ok(uint32_t o) {
13345         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(o & ~1);
13346         jboolean ret_conv = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
13347         return ret_conv;
13348 }
13349
13350 void  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_free"))) TS_CResult_ChannelFeaturesDecodeErrorZ_free(uint32_t _res) {
13351         if ((_res & 1) != 0) return;
13352         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13353         CHECK_ACCESS(_res_ptr);
13354         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
13355         FREE((void*)_res);
13356         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
13357 }
13358
13359 static inline uintptr_t CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR arg) {
13360         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
13361         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(arg);
13362         return (uint32_t)ret_conv;
13363 }
13364 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
13365         LDKCResult_ChannelFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
13366         uint32_t ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(arg_conv);
13367         return ret_conv;
13368 }
13369
13370 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_clone"))) TS_CResult_ChannelFeaturesDecodeErrorZ_clone(uint32_t orig) {
13371         LDKCResult_ChannelFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(orig & ~1);
13372         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
13373         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(orig_conv);
13374         return (uint32_t)ret_conv;
13375 }
13376
13377 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_ok(uint32_t o) {
13378         LDKNodeFeatures o_conv;
13379         o_conv.inner = (void*)(o & (~1));
13380         o_conv.is_owned = (o & 1) || (o == 0);
13381         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13382         o_conv = NodeFeatures_clone(&o_conv);
13383         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
13384         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
13385         return (uint32_t)ret_conv;
13386 }
13387
13388 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_err"))) TS_CResult_NodeFeaturesDecodeErrorZ_err(uint32_t e) {
13389         LDKDecodeError e_conv;
13390         e_conv.inner = (void*)(e & (~1));
13391         e_conv.is_owned = (e & 1) || (e == 0);
13392         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13393         e_conv = DecodeError_clone(&e_conv);
13394         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
13395         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
13396         return (uint32_t)ret_conv;
13397 }
13398
13399 jboolean  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_is_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_is_ok(uint32_t o) {
13400         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(o & ~1);
13401         jboolean ret_conv = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
13402         return ret_conv;
13403 }
13404
13405 void  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_free"))) TS_CResult_NodeFeaturesDecodeErrorZ_free(uint32_t _res) {
13406         if ((_res & 1) != 0) return;
13407         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13408         CHECK_ACCESS(_res_ptr);
13409         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
13410         FREE((void*)_res);
13411         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
13412 }
13413
13414 static inline uintptr_t CResult_NodeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
13415         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
13416         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(arg);
13417         return (uint32_t)ret_conv;
13418 }
13419 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_clone_ptr"))) TS_CResult_NodeFeaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
13420         LDKCResult_NodeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
13421         uint32_t ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
13422         return ret_conv;
13423 }
13424
13425 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_clone"))) TS_CResult_NodeFeaturesDecodeErrorZ_clone(uint32_t orig) {
13426         LDKCResult_NodeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(orig & ~1);
13427         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
13428         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(orig_conv);
13429         return (uint32_t)ret_conv;
13430 }
13431
13432 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_ok(uint32_t o) {
13433         LDKInvoiceFeatures o_conv;
13434         o_conv.inner = (void*)(o & (~1));
13435         o_conv.is_owned = (o & 1) || (o == 0);
13436         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13437         o_conv = InvoiceFeatures_clone(&o_conv);
13438         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
13439         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
13440         return (uint32_t)ret_conv;
13441 }
13442
13443 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_err"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_err(uint32_t e) {
13444         LDKDecodeError e_conv;
13445         e_conv.inner = (void*)(e & (~1));
13446         e_conv.is_owned = (e & 1) || (e == 0);
13447         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13448         e_conv = DecodeError_clone(&e_conv);
13449         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
13450         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
13451         return (uint32_t)ret_conv;
13452 }
13453
13454 jboolean  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_is_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_is_ok(uint32_t o) {
13455         LDKCResult_InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(o & ~1);
13456         jboolean ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
13457         return ret_conv;
13458 }
13459
13460 void  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_free"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_free(uint32_t _res) {
13461         if ((_res & 1) != 0) return;
13462         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13463         CHECK_ACCESS(_res_ptr);
13464         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
13465         FREE((void*)_res);
13466         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
13467 }
13468
13469 static inline uintptr_t CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR arg) {
13470         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
13471         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone(arg);
13472         return (uint32_t)ret_conv;
13473 }
13474 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
13475         LDKCResult_InvoiceFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
13476         uint32_t ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(arg_conv);
13477         return ret_conv;
13478 }
13479
13480 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_clone"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_clone(uint32_t orig) {
13481         LDKCResult_InvoiceFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(orig & ~1);
13482         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
13483         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone(orig_conv);
13484         return (uint32_t)ret_conv;
13485 }
13486
13487 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_ok(uint32_t o) {
13488         LDKChannelTypeFeatures o_conv;
13489         o_conv.inner = (void*)(o & (~1));
13490         o_conv.is_owned = (o & 1) || (o == 0);
13491         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13492         o_conv = ChannelTypeFeatures_clone(&o_conv);
13493         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
13494         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o_conv);
13495         return (uint32_t)ret_conv;
13496 }
13497
13498 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_err"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_err(uint32_t e) {
13499         LDKDecodeError e_conv;
13500         e_conv.inner = (void*)(e & (~1));
13501         e_conv.is_owned = (e & 1) || (e == 0);
13502         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13503         e_conv = DecodeError_clone(&e_conv);
13504         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
13505         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_err(e_conv);
13506         return (uint32_t)ret_conv;
13507 }
13508
13509 jboolean  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(uint32_t o) {
13510         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(o & ~1);
13511         jboolean ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o_conv);
13512         return ret_conv;
13513 }
13514
13515 void  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_free"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_free(uint32_t _res) {
13516         if ((_res & 1) != 0) return;
13517         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13518         CHECK_ACCESS(_res_ptr);
13519         LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(_res_ptr);
13520         FREE((void*)_res);
13521         CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res_conv);
13522 }
13523
13524 static inline uintptr_t CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
13525         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
13526         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(arg);
13527         return (uint32_t)ret_conv;
13528 }
13529 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
13530         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(arg & ~1);
13531         uint32_t ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
13532         return ret_conv;
13533 }
13534
13535 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_clone"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_clone(uint32_t orig) {
13536         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(orig & ~1);
13537         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
13538         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(orig_conv);
13539         return (uint32_t)ret_conv;
13540 }
13541
13542 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_ok"))) TS_CResult_NodeIdDecodeErrorZ_ok(uint32_t o) {
13543         LDKNodeId o_conv;
13544         o_conv.inner = (void*)(o & (~1));
13545         o_conv.is_owned = (o & 1) || (o == 0);
13546         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13547         o_conv = NodeId_clone(&o_conv);
13548         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
13549         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
13550         return (uint32_t)ret_conv;
13551 }
13552
13553 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_err"))) TS_CResult_NodeIdDecodeErrorZ_err(uint32_t e) {
13554         LDKDecodeError e_conv;
13555         e_conv.inner = (void*)(e & (~1));
13556         e_conv.is_owned = (e & 1) || (e == 0);
13557         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13558         e_conv = DecodeError_clone(&e_conv);
13559         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
13560         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
13561         return (uint32_t)ret_conv;
13562 }
13563
13564 jboolean  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_is_ok"))) TS_CResult_NodeIdDecodeErrorZ_is_ok(uint32_t o) {
13565         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)(o & ~1);
13566         jboolean ret_conv = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
13567         return ret_conv;
13568 }
13569
13570 void  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_free"))) TS_CResult_NodeIdDecodeErrorZ_free(uint32_t _res) {
13571         if ((_res & 1) != 0) return;
13572         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13573         CHECK_ACCESS(_res_ptr);
13574         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
13575         FREE((void*)_res);
13576         CResult_NodeIdDecodeErrorZ_free(_res_conv);
13577 }
13578
13579 static inline uintptr_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
13580         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
13581         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
13582         return (uint32_t)ret_conv;
13583 }
13584 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_clone_ptr"))) TS_CResult_NodeIdDecodeErrorZ_clone_ptr(uint32_t arg) {
13585         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
13586         uint32_t ret_conv = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
13587         return ret_conv;
13588 }
13589
13590 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_clone"))) TS_CResult_NodeIdDecodeErrorZ_clone(uint32_t orig) {
13591         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)(orig & ~1);
13592         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
13593         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
13594         return (uint32_t)ret_conv;
13595 }
13596
13597 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_ok(uint32_t o) {
13598         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13599         CHECK_ACCESS(o_ptr);
13600         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
13601         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)o) & ~1));
13602         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
13603         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
13604         return (uint32_t)ret_conv;
13605 }
13606
13607 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_err"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_err(uint32_t e) {
13608         LDKDecodeError e_conv;
13609         e_conv.inner = (void*)(e & (~1));
13610         e_conv.is_owned = (e & 1) || (e == 0);
13611         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13612         e_conv = DecodeError_clone(&e_conv);
13613         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
13614         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
13615         return (uint32_t)ret_conv;
13616 }
13617
13618 jboolean  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(uint32_t o) {
13619         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(o & ~1);
13620         jboolean ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
13621         return ret_conv;
13622 }
13623
13624 void  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_free"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_free(uint32_t _res) {
13625         if ((_res & 1) != 0) return;
13626         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13627         CHECK_ACCESS(_res_ptr);
13628         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
13629         FREE((void*)_res);
13630         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
13631 }
13632
13633 static inline uintptr_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
13634         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
13635         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
13636         return (uint32_t)ret_conv;
13637 }
13638 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(uint32_t arg) {
13639         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(arg & ~1);
13640         uint32_t ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
13641         return ret_conv;
13642 }
13643
13644 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone(uint32_t orig) {
13645         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(orig & ~1);
13646         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
13647         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
13648         return (uint32_t)ret_conv;
13649 }
13650
13651 uint32_t  __attribute__((export_name("TS_COption_AccessZ_some"))) TS_COption_AccessZ_some(uint32_t o) {
13652         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13653         CHECK_ACCESS(o_ptr);
13654         LDKAccess o_conv = *(LDKAccess*)(o_ptr);
13655         if (o_conv.free == LDKAccess_JCalls_free) {
13656                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13657                 LDKAccess_JCalls_cloned(&o_conv);
13658         }
13659         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
13660         *ret_copy = COption_AccessZ_some(o_conv);
13661         uint32_t ret_ref = (uintptr_t)ret_copy;
13662         return ret_ref;
13663 }
13664
13665 uint32_t  __attribute__((export_name("TS_COption_AccessZ_none"))) TS_COption_AccessZ_none() {
13666         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
13667         *ret_copy = COption_AccessZ_none();
13668         uint32_t ret_ref = (uintptr_t)ret_copy;
13669         return ret_ref;
13670 }
13671
13672 void  __attribute__((export_name("TS_COption_AccessZ_free"))) TS_COption_AccessZ_free(uint32_t _res) {
13673         if ((_res & 1) != 0) return;
13674         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13675         CHECK_ACCESS(_res_ptr);
13676         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
13677         FREE((void*)_res);
13678         COption_AccessZ_free(_res_conv);
13679 }
13680
13681 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_ok"))) TS_CResult_boolLightningErrorZ_ok(jboolean o) {
13682         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13683         *ret_conv = CResult_boolLightningErrorZ_ok(o);
13684         return (uint32_t)ret_conv;
13685 }
13686
13687 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_err"))) TS_CResult_boolLightningErrorZ_err(uint32_t e) {
13688         LDKLightningError e_conv;
13689         e_conv.inner = (void*)(e & (~1));
13690         e_conv.is_owned = (e & 1) || (e == 0);
13691         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13692         e_conv = LightningError_clone(&e_conv);
13693         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13694         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
13695         return (uint32_t)ret_conv;
13696 }
13697
13698 jboolean  __attribute__((export_name("TS_CResult_boolLightningErrorZ_is_ok"))) TS_CResult_boolLightningErrorZ_is_ok(uint32_t o) {
13699         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)(o & ~1);
13700         jboolean ret_conv = CResult_boolLightningErrorZ_is_ok(o_conv);
13701         return ret_conv;
13702 }
13703
13704 void  __attribute__((export_name("TS_CResult_boolLightningErrorZ_free"))) TS_CResult_boolLightningErrorZ_free(uint32_t _res) {
13705         if ((_res & 1) != 0) return;
13706         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13707         CHECK_ACCESS(_res_ptr);
13708         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
13709         FREE((void*)_res);
13710         CResult_boolLightningErrorZ_free(_res_conv);
13711 }
13712
13713 static inline uintptr_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
13714         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13715         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
13716         return (uint32_t)ret_conv;
13717 }
13718 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_clone_ptr"))) TS_CResult_boolLightningErrorZ_clone_ptr(uint32_t arg) {
13719         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
13720         uint32_t ret_conv = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
13721         return ret_conv;
13722 }
13723
13724 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_clone"))) TS_CResult_boolLightningErrorZ_clone(uint32_t orig) {
13725         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
13726         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13727         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
13728         return (uint32_t)ret_conv;
13729 }
13730
13731 static inline uintptr_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
13732         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
13733         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
13734         return ((uint32_t)ret_conv);
13735 }
13736 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(uint32_t arg) {
13737         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(arg & ~1);
13738         uint32_t ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
13739         return ret_conv;
13740 }
13741
13742 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(uint32_t orig) {
13743         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
13744         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
13745         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
13746         return ((uint32_t)ret_conv);
13747 }
13748
13749 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
13750         LDKChannelAnnouncement a_conv;
13751         a_conv.inner = (void*)(a & (~1));
13752         a_conv.is_owned = (a & 1) || (a == 0);
13753         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
13754         a_conv = ChannelAnnouncement_clone(&a_conv);
13755         LDKChannelUpdate b_conv;
13756         b_conv.inner = (void*)(b & (~1));
13757         b_conv.is_owned = (b & 1) || (b == 0);
13758         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
13759         b_conv = ChannelUpdate_clone(&b_conv);
13760         LDKChannelUpdate c_conv;
13761         c_conv.inner = (void*)(c & (~1));
13762         c_conv.is_owned = (c & 1) || (c == 0);
13763         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
13764         c_conv = ChannelUpdate_clone(&c_conv);
13765         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
13766         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
13767         return ((uint32_t)ret_conv);
13768 }
13769
13770 void  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(uint32_t _res) {
13771         if ((_res & 1) != 0) return;
13772         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13773         CHECK_ACCESS(_res_ptr);
13774         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
13775         FREE((void*)_res);
13776         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
13777 }
13778
13779 void  __attribute__((export_name("TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free"))) TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(uint32_tArray _res) {
13780         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
13781         _res_constr.datalen = _res->arr_len;
13782         if (_res_constr.datalen > 0)
13783                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
13784         else
13785                 _res_constr.data = NULL;
13786         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
13787         for (size_t h = 0; h < _res_constr.datalen; h++) {
13788                 uint32_t _res_conv_59 = _res_vals[h];
13789                 void* _res_conv_59_ptr = (void*)(((uintptr_t)_res_conv_59) & ~1);
13790                 CHECK_ACCESS(_res_conv_59_ptr);
13791                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_conv_59_ptr);
13792                 FREE((void*)_res_conv_59);
13793                 _res_constr.data[h] = _res_conv_59_conv;
13794         }
13795         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
13796 }
13797
13798 void  __attribute__((export_name("TS_CVec_NodeAnnouncementZ_free"))) TS_CVec_NodeAnnouncementZ_free(uint32_tArray _res) {
13799         LDKCVec_NodeAnnouncementZ _res_constr;
13800         _res_constr.datalen = _res->arr_len;
13801         if (_res_constr.datalen > 0)
13802                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
13803         else
13804                 _res_constr.data = NULL;
13805         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
13806         for (size_t s = 0; s < _res_constr.datalen; s++) {
13807                 uint32_t _res_conv_18 = _res_vals[s];
13808                 LDKNodeAnnouncement _res_conv_18_conv;
13809                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
13810                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
13811                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_18_conv);
13812                 _res_constr.data[s] = _res_conv_18_conv;
13813         }
13814         CVec_NodeAnnouncementZ_free(_res_constr);
13815 }
13816
13817 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_ok"))) TS_CResult_NoneLightningErrorZ_ok() {
13818         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13819         *ret_conv = CResult_NoneLightningErrorZ_ok();
13820         return (uint32_t)ret_conv;
13821 }
13822
13823 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_err"))) TS_CResult_NoneLightningErrorZ_err(uint32_t e) {
13824         LDKLightningError e_conv;
13825         e_conv.inner = (void*)(e & (~1));
13826         e_conv.is_owned = (e & 1) || (e == 0);
13827         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13828         e_conv = LightningError_clone(&e_conv);
13829         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13830         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
13831         return (uint32_t)ret_conv;
13832 }
13833
13834 jboolean  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_is_ok"))) TS_CResult_NoneLightningErrorZ_is_ok(uint32_t o) {
13835         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)(o & ~1);
13836         jboolean ret_conv = CResult_NoneLightningErrorZ_is_ok(o_conv);
13837         return ret_conv;
13838 }
13839
13840 void  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_free"))) TS_CResult_NoneLightningErrorZ_free(uint32_t _res) {
13841         if ((_res & 1) != 0) return;
13842         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13843         CHECK_ACCESS(_res_ptr);
13844         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
13845         FREE((void*)_res);
13846         CResult_NoneLightningErrorZ_free(_res_conv);
13847 }
13848
13849 static inline uintptr_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
13850         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13851         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
13852         return (uint32_t)ret_conv;
13853 }
13854 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_clone_ptr"))) TS_CResult_NoneLightningErrorZ_clone_ptr(uint32_t arg) {
13855         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
13856         uint32_t ret_conv = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
13857         return ret_conv;
13858 }
13859
13860 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_clone"))) TS_CResult_NoneLightningErrorZ_clone(uint32_t orig) {
13861         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
13862         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13863         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
13864         return (uint32_t)ret_conv;
13865 }
13866
13867 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_ok"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_ok(uint32_t o) {
13868         LDKChannelUpdateInfo o_conv;
13869         o_conv.inner = (void*)(o & (~1));
13870         o_conv.is_owned = (o & 1) || (o == 0);
13871         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13872         o_conv = ChannelUpdateInfo_clone(&o_conv);
13873         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
13874         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_ok(o_conv);
13875         return (uint32_t)ret_conv;
13876 }
13877
13878 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_err"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_err(uint32_t e) {
13879         LDKDecodeError e_conv;
13880         e_conv.inner = (void*)(e & (~1));
13881         e_conv.is_owned = (e & 1) || (e == 0);
13882         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13883         e_conv = DecodeError_clone(&e_conv);
13884         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
13885         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_err(e_conv);
13886         return (uint32_t)ret_conv;
13887 }
13888
13889 jboolean  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_is_ok"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(uint32_t o) {
13890         LDKCResult_ChannelUpdateInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(o & ~1);
13891         jboolean ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(o_conv);
13892         return ret_conv;
13893 }
13894
13895 void  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_free"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_free(uint32_t _res) {
13896         if ((_res & 1) != 0) return;
13897         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13898         CHECK_ACCESS(_res_ptr);
13899         LDKCResult_ChannelUpdateInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(_res_ptr);
13900         FREE((void*)_res);
13901         CResult_ChannelUpdateInfoDecodeErrorZ_free(_res_conv);
13902 }
13903
13904 static inline uintptr_t CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR arg) {
13905         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
13906         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(arg);
13907         return (uint32_t)ret_conv;
13908 }
13909 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
13910         LDKCResult_ChannelUpdateInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(arg & ~1);
13911         uint32_t ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(arg_conv);
13912         return ret_conv;
13913 }
13914
13915 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone(uint32_t orig) {
13916         LDKCResult_ChannelUpdateInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(orig & ~1);
13917         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
13918         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(orig_conv);
13919         return (uint32_t)ret_conv;
13920 }
13921
13922 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_ok(uint32_t o) {
13923         LDKChannelInfo o_conv;
13924         o_conv.inner = (void*)(o & (~1));
13925         o_conv.is_owned = (o & 1) || (o == 0);
13926         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13927         o_conv = ChannelInfo_clone(&o_conv);
13928         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
13929         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
13930         return (uint32_t)ret_conv;
13931 }
13932
13933 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_err"))) TS_CResult_ChannelInfoDecodeErrorZ_err(uint32_t e) {
13934         LDKDecodeError e_conv;
13935         e_conv.inner = (void*)(e & (~1));
13936         e_conv.is_owned = (e & 1) || (e == 0);
13937         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13938         e_conv = DecodeError_clone(&e_conv);
13939         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
13940         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
13941         return (uint32_t)ret_conv;
13942 }
13943
13944 jboolean  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_is_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_is_ok(uint32_t o) {
13945         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(o & ~1);
13946         jboolean ret_conv = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
13947         return ret_conv;
13948 }
13949
13950 void  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_free"))) TS_CResult_ChannelInfoDecodeErrorZ_free(uint32_t _res) {
13951         if ((_res & 1) != 0) return;
13952         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13953         CHECK_ACCESS(_res_ptr);
13954         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
13955         FREE((void*)_res);
13956         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
13957 }
13958
13959 static inline uintptr_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
13960         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
13961         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
13962         return (uint32_t)ret_conv;
13963 }
13964 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
13965         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
13966         uint32_t ret_conv = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
13967         return ret_conv;
13968 }
13969
13970 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_clone"))) TS_CResult_ChannelInfoDecodeErrorZ_clone(uint32_t orig) {
13971         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
13972         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
13973         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
13974         return (uint32_t)ret_conv;
13975 }
13976
13977 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_ok(uint32_t o) {
13978         LDKRoutingFees o_conv;
13979         o_conv.inner = (void*)(o & (~1));
13980         o_conv.is_owned = (o & 1) || (o == 0);
13981         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13982         o_conv = RoutingFees_clone(&o_conv);
13983         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
13984         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
13985         return (uint32_t)ret_conv;
13986 }
13987
13988 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_err"))) TS_CResult_RoutingFeesDecodeErrorZ_err(uint32_t e) {
13989         LDKDecodeError e_conv;
13990         e_conv.inner = (void*)(e & (~1));
13991         e_conv.is_owned = (e & 1) || (e == 0);
13992         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13993         e_conv = DecodeError_clone(&e_conv);
13994         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
13995         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
13996         return (uint32_t)ret_conv;
13997 }
13998
13999 jboolean  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_is_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_is_ok(uint32_t o) {
14000         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(o & ~1);
14001         jboolean ret_conv = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
14002         return ret_conv;
14003 }
14004
14005 void  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_free"))) TS_CResult_RoutingFeesDecodeErrorZ_free(uint32_t _res) {
14006         if ((_res & 1) != 0) return;
14007         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14008         CHECK_ACCESS(_res_ptr);
14009         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
14010         FREE((void*)_res);
14011         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
14012 }
14013
14014 static inline uintptr_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
14015         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
14016         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
14017         return (uint32_t)ret_conv;
14018 }
14019 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_clone_ptr"))) TS_CResult_RoutingFeesDecodeErrorZ_clone_ptr(uint32_t arg) {
14020         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
14021         uint32_t ret_conv = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
14022         return ret_conv;
14023 }
14024
14025 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_clone"))) TS_CResult_RoutingFeesDecodeErrorZ_clone(uint32_t orig) {
14026         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
14027         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
14028         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
14029         return (uint32_t)ret_conv;
14030 }
14031
14032 void  __attribute__((export_name("TS_CVec_NetAddressZ_free"))) TS_CVec_NetAddressZ_free(uint32_tArray _res) {
14033         LDKCVec_NetAddressZ _res_constr;
14034         _res_constr.datalen = _res->arr_len;
14035         if (_res_constr.datalen > 0)
14036                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
14037         else
14038                 _res_constr.data = NULL;
14039         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
14040         for (size_t m = 0; m < _res_constr.datalen; m++) {
14041                 uint32_t _res_conv_12 = _res_vals[m];
14042                 void* _res_conv_12_ptr = (void*)(((uintptr_t)_res_conv_12) & ~1);
14043                 CHECK_ACCESS(_res_conv_12_ptr);
14044                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
14045                 FREE((void*)_res_conv_12);
14046                 _res_constr.data[m] = _res_conv_12_conv;
14047         }
14048         CVec_NetAddressZ_free(_res_constr);
14049 }
14050
14051 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok(uint32_t o) {
14052         LDKNodeAnnouncementInfo o_conv;
14053         o_conv.inner = (void*)(o & (~1));
14054         o_conv.is_owned = (o & 1) || (o == 0);
14055         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14056         o_conv = NodeAnnouncementInfo_clone(&o_conv);
14057         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
14058         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
14059         return (uint32_t)ret_conv;
14060 }
14061
14062 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err(uint32_t e) {
14063         LDKDecodeError e_conv;
14064         e_conv.inner = (void*)(e & (~1));
14065         e_conv.is_owned = (e & 1) || (e == 0);
14066         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14067         e_conv = DecodeError_clone(&e_conv);
14068         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
14069         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
14070         return (uint32_t)ret_conv;
14071 }
14072
14073 jboolean  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(uint32_t o) {
14074         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(o & ~1);
14075         jboolean ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
14076         return ret_conv;
14077 }
14078
14079 void  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free(uint32_t _res) {
14080         if ((_res & 1) != 0) return;
14081         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14082         CHECK_ACCESS(_res_ptr);
14083         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
14084         FREE((void*)_res);
14085         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
14086 }
14087
14088 static inline uintptr_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
14089         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
14090         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
14091         return (uint32_t)ret_conv;
14092 }
14093 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
14094         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
14095         uint32_t ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
14096         return ret_conv;
14097 }
14098
14099 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone(uint32_t orig) {
14100         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
14101         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
14102         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
14103         return (uint32_t)ret_conv;
14104 }
14105
14106 void  __attribute__((export_name("TS_CVec_u64Z_free"))) TS_CVec_u64Z_free(int64_tArray _res) {
14107         LDKCVec_u64Z _res_constr;
14108         _res_constr.datalen = _res->arr_len;
14109         if (_res_constr.datalen > 0)
14110                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
14111         else
14112                 _res_constr.data = NULL;
14113         int64_t* _res_vals = _res->elems /* XXX _res leaks */;
14114         for (size_t i = 0; i < _res_constr.datalen; i++) {
14115                 int64_t _res_conv_8 = _res_vals[i];
14116                 _res_constr.data[i] = _res_conv_8;
14117         }
14118         CVec_u64Z_free(_res_constr);
14119 }
14120
14121 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_ok"))) TS_CResult_NodeInfoDecodeErrorZ_ok(uint32_t o) {
14122         LDKNodeInfo o_conv;
14123         o_conv.inner = (void*)(o & (~1));
14124         o_conv.is_owned = (o & 1) || (o == 0);
14125         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14126         o_conv = NodeInfo_clone(&o_conv);
14127         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
14128         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
14129         return (uint32_t)ret_conv;
14130 }
14131
14132 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_err"))) TS_CResult_NodeInfoDecodeErrorZ_err(uint32_t e) {
14133         LDKDecodeError e_conv;
14134         e_conv.inner = (void*)(e & (~1));
14135         e_conv.is_owned = (e & 1) || (e == 0);
14136         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14137         e_conv = DecodeError_clone(&e_conv);
14138         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
14139         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
14140         return (uint32_t)ret_conv;
14141 }
14142
14143 jboolean  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_is_ok"))) TS_CResult_NodeInfoDecodeErrorZ_is_ok(uint32_t o) {
14144         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(o & ~1);
14145         jboolean ret_conv = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
14146         return ret_conv;
14147 }
14148
14149 void  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_free"))) TS_CResult_NodeInfoDecodeErrorZ_free(uint32_t _res) {
14150         if ((_res & 1) != 0) return;
14151         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14152         CHECK_ACCESS(_res_ptr);
14153         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
14154         FREE((void*)_res);
14155         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
14156 }
14157
14158 static inline uintptr_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
14159         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
14160         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
14161         return (uint32_t)ret_conv;
14162 }
14163 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_clone_ptr"))) TS_CResult_NodeInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
14164         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
14165         uint32_t ret_conv = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
14166         return ret_conv;
14167 }
14168
14169 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_clone"))) TS_CResult_NodeInfoDecodeErrorZ_clone(uint32_t orig) {
14170         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
14171         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
14172         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
14173         return (uint32_t)ret_conv;
14174 }
14175
14176 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_ok(uint32_t o) {
14177         LDKNetworkGraph o_conv;
14178         o_conv.inner = (void*)(o & (~1));
14179         o_conv.is_owned = (o & 1) || (o == 0);
14180         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14181         // WARNING: we need a move here but no clone is available for LDKNetworkGraph
14182         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
14183         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
14184         return (uint32_t)ret_conv;
14185 }
14186
14187 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_err"))) TS_CResult_NetworkGraphDecodeErrorZ_err(uint32_t e) {
14188         LDKDecodeError e_conv;
14189         e_conv.inner = (void*)(e & (~1));
14190         e_conv.is_owned = (e & 1) || (e == 0);
14191         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14192         e_conv = DecodeError_clone(&e_conv);
14193         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
14194         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
14195         return (uint32_t)ret_conv;
14196 }
14197
14198 jboolean  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_is_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_is_ok(uint32_t o) {
14199         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(o & ~1);
14200         jboolean ret_conv = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
14201         return ret_conv;
14202 }
14203
14204 void  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_free"))) TS_CResult_NetworkGraphDecodeErrorZ_free(uint32_t _res) {
14205         if ((_res & 1) != 0) return;
14206         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14207         CHECK_ACCESS(_res_ptr);
14208         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
14209         FREE((void*)_res);
14210         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
14211 }
14212
14213 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_some"))) TS_COption_CVec_NetAddressZZ_some(uint32_tArray o) {
14214         LDKCVec_NetAddressZ o_constr;
14215         o_constr.datalen = o->arr_len;
14216         if (o_constr.datalen > 0)
14217                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
14218         else
14219                 o_constr.data = NULL;
14220         uint32_t* o_vals = o->elems /* XXX o leaks */;
14221         for (size_t m = 0; m < o_constr.datalen; m++) {
14222                 uint32_t o_conv_12 = o_vals[m];
14223                 void* o_conv_12_ptr = (void*)(((uintptr_t)o_conv_12) & ~1);
14224                 CHECK_ACCESS(o_conv_12_ptr);
14225                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
14226                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o_conv_12) & ~1));
14227                 o_constr.data[m] = o_conv_12_conv;
14228         }
14229         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
14230         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
14231         uint32_t ret_ref = (uintptr_t)ret_copy;
14232         return ret_ref;
14233 }
14234
14235 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_none"))) TS_COption_CVec_NetAddressZZ_none() {
14236         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
14237         *ret_copy = COption_CVec_NetAddressZZ_none();
14238         uint32_t ret_ref = (uintptr_t)ret_copy;
14239         return ret_ref;
14240 }
14241
14242 void  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_free"))) TS_COption_CVec_NetAddressZZ_free(uint32_t _res) {
14243         if ((_res & 1) != 0) return;
14244         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14245         CHECK_ACCESS(_res_ptr);
14246         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
14247         FREE((void*)_res);
14248         COption_CVec_NetAddressZZ_free(_res_conv);
14249 }
14250
14251 static inline uintptr_t COption_CVec_NetAddressZZ_clone_ptr(LDKCOption_CVec_NetAddressZZ *NONNULL_PTR arg) {
14252         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
14253         *ret_copy = COption_CVec_NetAddressZZ_clone(arg);
14254 uint32_t ret_ref = (uintptr_t)ret_copy;
14255         return ret_ref;
14256 }
14257 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_clone_ptr"))) TS_COption_CVec_NetAddressZZ_clone_ptr(uint32_t arg) {
14258         LDKCOption_CVec_NetAddressZZ* arg_conv = (LDKCOption_CVec_NetAddressZZ*)arg;
14259         uint32_t ret_conv = COption_CVec_NetAddressZZ_clone_ptr(arg_conv);
14260         return ret_conv;
14261 }
14262
14263 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_clone"))) TS_COption_CVec_NetAddressZZ_clone(uint32_t orig) {
14264         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)orig;
14265         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
14266         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
14267         uint32_t ret_ref = (uintptr_t)ret_copy;
14268         return ret_ref;
14269 }
14270
14271 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
14272         LDKDelayedPaymentOutputDescriptor o_conv;
14273         o_conv.inner = (void*)(o & (~1));
14274         o_conv.is_owned = (o & 1) || (o == 0);
14275         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14276         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
14277         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
14278         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
14279         return (uint32_t)ret_conv;
14280 }
14281
14282 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
14283         LDKDecodeError e_conv;
14284         e_conv.inner = (void*)(e & (~1));
14285         e_conv.is_owned = (e & 1) || (e == 0);
14286         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14287         e_conv = DecodeError_clone(&e_conv);
14288         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
14289         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
14290         return (uint32_t)ret_conv;
14291 }
14292
14293 jboolean  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
14294         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
14295         jboolean ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
14296         return ret_conv;
14297 }
14298
14299 void  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
14300         if ((_res & 1) != 0) return;
14301         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14302         CHECK_ACCESS(_res_ptr);
14303         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
14304         FREE((void*)_res);
14305         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
14306 }
14307
14308 static inline uintptr_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
14309         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
14310         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
14311         return (uint32_t)ret_conv;
14312 }
14313 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
14314         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
14315         uint32_t ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
14316         return ret_conv;
14317 }
14318
14319 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
14320         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
14321         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
14322         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
14323         return (uint32_t)ret_conv;
14324 }
14325
14326 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
14327         LDKStaticPaymentOutputDescriptor o_conv;
14328         o_conv.inner = (void*)(o & (~1));
14329         o_conv.is_owned = (o & 1) || (o == 0);
14330         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14331         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
14332         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
14333         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
14334         return (uint32_t)ret_conv;
14335 }
14336
14337 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
14338         LDKDecodeError e_conv;
14339         e_conv.inner = (void*)(e & (~1));
14340         e_conv.is_owned = (e & 1) || (e == 0);
14341         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14342         e_conv = DecodeError_clone(&e_conv);
14343         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
14344         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
14345         return (uint32_t)ret_conv;
14346 }
14347
14348 jboolean  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
14349         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
14350         jboolean ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
14351         return ret_conv;
14352 }
14353
14354 void  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
14355         if ((_res & 1) != 0) return;
14356         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14357         CHECK_ACCESS(_res_ptr);
14358         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
14359         FREE((void*)_res);
14360         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
14361 }
14362
14363 static inline uintptr_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
14364         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
14365         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
14366         return (uint32_t)ret_conv;
14367 }
14368 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
14369         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
14370         uint32_t ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
14371         return ret_conv;
14372 }
14373
14374 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
14375         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
14376         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
14377         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
14378         return (uint32_t)ret_conv;
14379 }
14380
14381 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
14382         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14383         CHECK_ACCESS(o_ptr);
14384         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
14385         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)o) & ~1));
14386         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
14387         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
14388         return (uint32_t)ret_conv;
14389 }
14390
14391 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err(uint32_t e) {
14392         LDKDecodeError e_conv;
14393         e_conv.inner = (void*)(e & (~1));
14394         e_conv.is_owned = (e & 1) || (e == 0);
14395         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14396         e_conv = DecodeError_clone(&e_conv);
14397         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
14398         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
14399         return (uint32_t)ret_conv;
14400 }
14401
14402 jboolean  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
14403         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(o & ~1);
14404         jboolean ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
14405         return ret_conv;
14406 }
14407
14408 void  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
14409         if ((_res & 1) != 0) return;
14410         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14411         CHECK_ACCESS(_res_ptr);
14412         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
14413         FREE((void*)_res);
14414         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
14415 }
14416
14417 static inline uintptr_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
14418         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
14419         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
14420         return (uint32_t)ret_conv;
14421 }
14422 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
14423         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
14424         uint32_t ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
14425         return ret_conv;
14426 }
14427
14428 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
14429         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
14430         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
14431         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
14432         return (uint32_t)ret_conv;
14433 }
14434
14435 void  __attribute__((export_name("TS_CVec_PaymentPreimageZ_free"))) TS_CVec_PaymentPreimageZ_free(ptrArray _res) {
14436         LDKCVec_PaymentPreimageZ _res_constr;
14437         _res_constr.datalen = _res->arr_len;
14438         if (_res_constr.datalen > 0)
14439                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
14440         else
14441                 _res_constr.data = NULL;
14442         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
14443         for (size_t m = 0; m < _res_constr.datalen; m++) {
14444                 int8_tArray _res_conv_12 = _res_vals[m];
14445                 LDKThirtyTwoBytes _res_conv_12_ref;
14446                 CHECK(_res_conv_12->arr_len == 32);
14447                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, 32); FREE(_res_conv_12);
14448                 _res_constr.data[m] = _res_conv_12_ref;
14449         }
14450         CVec_PaymentPreimageZ_free(_res_constr);
14451 }
14452
14453 static inline uintptr_t C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR arg) {
14454         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
14455         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(arg);
14456         return ((uint32_t)ret_conv);
14457 }
14458 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_clone_ptr"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(uint32_t arg) {
14459         LDKC2Tuple_SignatureCVec_SignatureZZ* arg_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(arg & ~1);
14460         uint32_t ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(arg_conv);
14461         return ret_conv;
14462 }
14463
14464 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_clone"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone(uint32_t orig) {
14465         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
14466         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
14467         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
14468         return ((uint32_t)ret_conv);
14469 }
14470
14471 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_new"))) TS_C2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
14472         LDKSignature a_ref;
14473         CHECK(a->arr_len == 64);
14474         memcpy(a_ref.compact_form, a->elems, 64); FREE(a);
14475         LDKCVec_SignatureZ b_constr;
14476         b_constr.datalen = b->arr_len;
14477         if (b_constr.datalen > 0)
14478                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
14479         else
14480                 b_constr.data = NULL;
14481         int8_tArray* b_vals = (void*) b->elems /* XXX b leaks */;
14482         for (size_t m = 0; m < b_constr.datalen; m++) {
14483                 int8_tArray b_conv_12 = b_vals[m];
14484                 LDKSignature b_conv_12_ref;
14485                 CHECK(b_conv_12->arr_len == 64);
14486                 memcpy(b_conv_12_ref.compact_form, b_conv_12->elems, 64); FREE(b_conv_12);
14487                 b_constr.data[m] = b_conv_12_ref;
14488         }
14489         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
14490         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
14491         return ((uint32_t)ret_conv);
14492 }
14493
14494 void  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_free"))) TS_C2Tuple_SignatureCVec_SignatureZZ_free(uint32_t _res) {
14495         if ((_res & 1) != 0) return;
14496         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14497         CHECK_ACCESS(_res_ptr);
14498         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
14499         FREE((void*)_res);
14500         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
14501 }
14502
14503 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(uint32_t o) {
14504         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14505         CHECK_ACCESS(o_ptr);
14506         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
14507         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uintptr_t)o) & ~1));
14508         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
14509         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
14510         return (uint32_t)ret_conv;
14511 }
14512
14513 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() {
14514         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
14515         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
14516         return (uint32_t)ret_conv;
14517 }
14518
14519 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(uint32_t o) {
14520         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(o & ~1);
14521         jboolean ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o_conv);
14522         return ret_conv;
14523 }
14524
14525 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(uint32_t _res) {
14526         if ((_res & 1) != 0) return;
14527         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14528         CHECK_ACCESS(_res_ptr);
14529         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
14530         FREE((void*)_res);
14531         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
14532 }
14533
14534 static inline uintptr_t CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR arg) {
14535         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
14536         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(arg);
14537         return (uint32_t)ret_conv;
14538 }
14539 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(uint32_t arg) {
14540         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
14541         uint32_t ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(arg_conv);
14542         return ret_conv;
14543 }
14544
14545 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(uint32_t orig) {
14546         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
14547         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
14548         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
14549         return (uint32_t)ret_conv;
14550 }
14551
14552 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_ok"))) TS_CResult_SignatureNoneZ_ok(int8_tArray o) {
14553         LDKSignature o_ref;
14554         CHECK(o->arr_len == 64);
14555         memcpy(o_ref.compact_form, o->elems, 64); FREE(o);
14556         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
14557         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
14558         return (uint32_t)ret_conv;
14559 }
14560
14561 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_err"))) TS_CResult_SignatureNoneZ_err() {
14562         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
14563         *ret_conv = CResult_SignatureNoneZ_err();
14564         return (uint32_t)ret_conv;
14565 }
14566
14567 jboolean  __attribute__((export_name("TS_CResult_SignatureNoneZ_is_ok"))) TS_CResult_SignatureNoneZ_is_ok(uint32_t o) {
14568         LDKCResult_SignatureNoneZ* o_conv = (LDKCResult_SignatureNoneZ*)(o & ~1);
14569         jboolean ret_conv = CResult_SignatureNoneZ_is_ok(o_conv);
14570         return ret_conv;
14571 }
14572
14573 void  __attribute__((export_name("TS_CResult_SignatureNoneZ_free"))) TS_CResult_SignatureNoneZ_free(uint32_t _res) {
14574         if ((_res & 1) != 0) return;
14575         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14576         CHECK_ACCESS(_res_ptr);
14577         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
14578         FREE((void*)_res);
14579         CResult_SignatureNoneZ_free(_res_conv);
14580 }
14581
14582 static inline uintptr_t CResult_SignatureNoneZ_clone_ptr(LDKCResult_SignatureNoneZ *NONNULL_PTR arg) {
14583         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
14584         *ret_conv = CResult_SignatureNoneZ_clone(arg);
14585         return (uint32_t)ret_conv;
14586 }
14587 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_clone_ptr"))) TS_CResult_SignatureNoneZ_clone_ptr(uint32_t arg) {
14588         LDKCResult_SignatureNoneZ* arg_conv = (LDKCResult_SignatureNoneZ*)(arg & ~1);
14589         uint32_t ret_conv = CResult_SignatureNoneZ_clone_ptr(arg_conv);
14590         return ret_conv;
14591 }
14592
14593 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_clone"))) TS_CResult_SignatureNoneZ_clone(uint32_t orig) {
14594         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
14595         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
14596         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
14597         return (uint32_t)ret_conv;
14598 }
14599
14600 static inline uintptr_t C2Tuple_SignatureSignatureZ_clone_ptr(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR arg) {
14601         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
14602         *ret_conv = C2Tuple_SignatureSignatureZ_clone(arg);
14603         return ((uint32_t)ret_conv);
14604 }
14605 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_clone_ptr"))) TS_C2Tuple_SignatureSignatureZ_clone_ptr(uint32_t arg) {
14606         LDKC2Tuple_SignatureSignatureZ* arg_conv = (LDKC2Tuple_SignatureSignatureZ*)(arg & ~1);
14607         uint32_t ret_conv = C2Tuple_SignatureSignatureZ_clone_ptr(arg_conv);
14608         return ret_conv;
14609 }
14610
14611 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_clone"))) TS_C2Tuple_SignatureSignatureZ_clone(uint32_t orig) {
14612         LDKC2Tuple_SignatureSignatureZ* orig_conv = (LDKC2Tuple_SignatureSignatureZ*)(orig & ~1);
14613         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
14614         *ret_conv = C2Tuple_SignatureSignatureZ_clone(orig_conv);
14615         return ((uint32_t)ret_conv);
14616 }
14617
14618 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_new"))) TS_C2Tuple_SignatureSignatureZ_new(int8_tArray a, int8_tArray b) {
14619         LDKSignature a_ref;
14620         CHECK(a->arr_len == 64);
14621         memcpy(a_ref.compact_form, a->elems, 64); FREE(a);
14622         LDKSignature b_ref;
14623         CHECK(b->arr_len == 64);
14624         memcpy(b_ref.compact_form, b->elems, 64); FREE(b);
14625         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
14626         *ret_conv = C2Tuple_SignatureSignatureZ_new(a_ref, b_ref);
14627         return ((uint32_t)ret_conv);
14628 }
14629
14630 void  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_free"))) TS_C2Tuple_SignatureSignatureZ_free(uint32_t _res) {
14631         if ((_res & 1) != 0) return;
14632         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14633         CHECK_ACCESS(_res_ptr);
14634         LDKC2Tuple_SignatureSignatureZ _res_conv = *(LDKC2Tuple_SignatureSignatureZ*)(_res_ptr);
14635         FREE((void*)_res);
14636         C2Tuple_SignatureSignatureZ_free(_res_conv);
14637 }
14638
14639 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_ok"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_ok(uint32_t o) {
14640         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14641         CHECK_ACCESS(o_ptr);
14642         LDKC2Tuple_SignatureSignatureZ o_conv = *(LDKC2Tuple_SignatureSignatureZ*)(o_ptr);
14643         o_conv = C2Tuple_SignatureSignatureZ_clone((LDKC2Tuple_SignatureSignatureZ*)(((uintptr_t)o) & ~1));
14644         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
14645         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_ok(o_conv);
14646         return (uint32_t)ret_conv;
14647 }
14648
14649 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_err"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_err() {
14650         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
14651         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_err();
14652         return (uint32_t)ret_conv;
14653 }
14654
14655 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(uint32_t o) {
14656         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(o & ~1);
14657         jboolean ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(o_conv);
14658         return ret_conv;
14659 }
14660
14661 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_free"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_free(uint32_t _res) {
14662         if ((_res & 1) != 0) return;
14663         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14664         CHECK_ACCESS(_res_ptr);
14665         LDKCResult_C2Tuple_SignatureSignatureZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(_res_ptr);
14666         FREE((void*)_res);
14667         CResult_C2Tuple_SignatureSignatureZNoneZ_free(_res_conv);
14668 }
14669
14670 static inline uintptr_t CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR arg) {
14671         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
14672         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(arg);
14673         return (uint32_t)ret_conv;
14674 }
14675 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(uint32_t arg) {
14676         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(arg & ~1);
14677         uint32_t ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(arg_conv);
14678         return ret_conv;
14679 }
14680
14681 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone(uint32_t orig) {
14682         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(orig & ~1);
14683         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
14684         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(orig_conv);
14685         return (uint32_t)ret_conv;
14686 }
14687
14688 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_ok"))) TS_CResult_SecretKeyNoneZ_ok(int8_tArray o) {
14689         LDKSecretKey o_ref;
14690         CHECK(o->arr_len == 32);
14691         memcpy(o_ref.bytes, o->elems, 32); FREE(o);
14692         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
14693         *ret_conv = CResult_SecretKeyNoneZ_ok(o_ref);
14694         return (uint32_t)ret_conv;
14695 }
14696
14697 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_err"))) TS_CResult_SecretKeyNoneZ_err() {
14698         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
14699         *ret_conv = CResult_SecretKeyNoneZ_err();
14700         return (uint32_t)ret_conv;
14701 }
14702
14703 jboolean  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_is_ok"))) TS_CResult_SecretKeyNoneZ_is_ok(uint32_t o) {
14704         LDKCResult_SecretKeyNoneZ* o_conv = (LDKCResult_SecretKeyNoneZ*)(o & ~1);
14705         jboolean ret_conv = CResult_SecretKeyNoneZ_is_ok(o_conv);
14706         return ret_conv;
14707 }
14708
14709 void  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_free"))) TS_CResult_SecretKeyNoneZ_free(uint32_t _res) {
14710         if ((_res & 1) != 0) return;
14711         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14712         CHECK_ACCESS(_res_ptr);
14713         LDKCResult_SecretKeyNoneZ _res_conv = *(LDKCResult_SecretKeyNoneZ*)(_res_ptr);
14714         FREE((void*)_res);
14715         CResult_SecretKeyNoneZ_free(_res_conv);
14716 }
14717
14718 static inline uintptr_t CResult_SecretKeyNoneZ_clone_ptr(LDKCResult_SecretKeyNoneZ *NONNULL_PTR arg) {
14719         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
14720         *ret_conv = CResult_SecretKeyNoneZ_clone(arg);
14721         return (uint32_t)ret_conv;
14722 }
14723 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_clone_ptr"))) TS_CResult_SecretKeyNoneZ_clone_ptr(uint32_t arg) {
14724         LDKCResult_SecretKeyNoneZ* arg_conv = (LDKCResult_SecretKeyNoneZ*)(arg & ~1);
14725         uint32_t ret_conv = CResult_SecretKeyNoneZ_clone_ptr(arg_conv);
14726         return ret_conv;
14727 }
14728
14729 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_clone"))) TS_CResult_SecretKeyNoneZ_clone(uint32_t orig) {
14730         LDKCResult_SecretKeyNoneZ* orig_conv = (LDKCResult_SecretKeyNoneZ*)(orig & ~1);
14731         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
14732         *ret_conv = CResult_SecretKeyNoneZ_clone(orig_conv);
14733         return (uint32_t)ret_conv;
14734 }
14735
14736 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_ok"))) TS_CResult_SignDecodeErrorZ_ok(uint32_t o) {
14737         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14738         CHECK_ACCESS(o_ptr);
14739         LDKSign o_conv = *(LDKSign*)(o_ptr);
14740         if (o_conv.free == LDKSign_JCalls_free) {
14741                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14742                 LDKSign_JCalls_cloned(&o_conv);
14743         }
14744         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
14745         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
14746         return (uint32_t)ret_conv;
14747 }
14748
14749 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_err"))) TS_CResult_SignDecodeErrorZ_err(uint32_t e) {
14750         LDKDecodeError e_conv;
14751         e_conv.inner = (void*)(e & (~1));
14752         e_conv.is_owned = (e & 1) || (e == 0);
14753         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14754         e_conv = DecodeError_clone(&e_conv);
14755         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
14756         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
14757         return (uint32_t)ret_conv;
14758 }
14759
14760 jboolean  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_is_ok"))) TS_CResult_SignDecodeErrorZ_is_ok(uint32_t o) {
14761         LDKCResult_SignDecodeErrorZ* o_conv = (LDKCResult_SignDecodeErrorZ*)(o & ~1);
14762         jboolean ret_conv = CResult_SignDecodeErrorZ_is_ok(o_conv);
14763         return ret_conv;
14764 }
14765
14766 void  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_free"))) TS_CResult_SignDecodeErrorZ_free(uint32_t _res) {
14767         if ((_res & 1) != 0) return;
14768         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14769         CHECK_ACCESS(_res_ptr);
14770         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
14771         FREE((void*)_res);
14772         CResult_SignDecodeErrorZ_free(_res_conv);
14773 }
14774
14775 static inline uintptr_t CResult_SignDecodeErrorZ_clone_ptr(LDKCResult_SignDecodeErrorZ *NONNULL_PTR arg) {
14776         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
14777         *ret_conv = CResult_SignDecodeErrorZ_clone(arg);
14778         return (uint32_t)ret_conv;
14779 }
14780 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_clone_ptr"))) TS_CResult_SignDecodeErrorZ_clone_ptr(uint32_t arg) {
14781         LDKCResult_SignDecodeErrorZ* arg_conv = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
14782         uint32_t ret_conv = CResult_SignDecodeErrorZ_clone_ptr(arg_conv);
14783         return ret_conv;
14784 }
14785
14786 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_clone"))) TS_CResult_SignDecodeErrorZ_clone(uint32_t orig) {
14787         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
14788         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
14789         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
14790         return (uint32_t)ret_conv;
14791 }
14792
14793 void  __attribute__((export_name("TS_CVec_u5Z_free"))) TS_CVec_u5Z_free(ptrArray _res) {
14794         LDKCVec_u5Z _res_constr;
14795         _res_constr.datalen = _res->arr_len;
14796         if (_res_constr.datalen > 0)
14797                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
14798         else
14799                 _res_constr.data = NULL;
14800         int8_t* _res_vals = (void*) _res->elems /* XXX _res leaks */;
14801         for (size_t h = 0; h < _res_constr.datalen; h++) {
14802                 int8_t _res_conv_7 = _res_vals[h];
14803                 
14804                 _res_constr.data[h] = (LDKu5){ ._0 = _res_conv_7 };
14805         }
14806         CVec_u5Z_free(_res_constr);
14807 }
14808
14809 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_ok"))) TS_CResult_RecoverableSignatureNoneZ_ok(int8_tArray o) {
14810         LDKRecoverableSignature o_ref;
14811         CHECK(o->arr_len == 68);
14812         memcpy(o_ref.serialized_form, o->elems, 68); FREE(o);
14813         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
14814         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(o_ref);
14815         return (uint32_t)ret_conv;
14816 }
14817
14818 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_err"))) TS_CResult_RecoverableSignatureNoneZ_err() {
14819         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
14820         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
14821         return (uint32_t)ret_conv;
14822 }
14823
14824 jboolean  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_is_ok"))) TS_CResult_RecoverableSignatureNoneZ_is_ok(uint32_t o) {
14825         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)(o & ~1);
14826         jboolean ret_conv = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
14827         return ret_conv;
14828 }
14829
14830 void  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_free"))) TS_CResult_RecoverableSignatureNoneZ_free(uint32_t _res) {
14831         if ((_res & 1) != 0) return;
14832         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14833         CHECK_ACCESS(_res_ptr);
14834         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
14835         FREE((void*)_res);
14836         CResult_RecoverableSignatureNoneZ_free(_res_conv);
14837 }
14838
14839 static inline uintptr_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
14840         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
14841         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
14842         return (uint32_t)ret_conv;
14843 }
14844 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_clone_ptr"))) TS_CResult_RecoverableSignatureNoneZ_clone_ptr(uint32_t arg) {
14845         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
14846         uint32_t ret_conv = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
14847         return ret_conv;
14848 }
14849
14850 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_clone"))) TS_CResult_RecoverableSignatureNoneZ_clone(uint32_t orig) {
14851         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
14852         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
14853         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
14854         return (uint32_t)ret_conv;
14855 }
14856
14857 void  __attribute__((export_name("TS_CVec_u8Z_free"))) TS_CVec_u8Z_free(int8_tArray _res) {
14858         LDKCVec_u8Z _res_ref;
14859         _res_ref.datalen = _res->arr_len;
14860         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
14861         memcpy(_res_ref.data, _res->elems, _res_ref.datalen); FREE(_res);
14862         CVec_u8Z_free(_res_ref);
14863 }
14864
14865 void  __attribute__((export_name("TS_CVec_CVec_u8ZZ_free"))) TS_CVec_CVec_u8ZZ_free(ptrArray _res) {
14866         LDKCVec_CVec_u8ZZ _res_constr;
14867         _res_constr.datalen = _res->arr_len;
14868         if (_res_constr.datalen > 0)
14869                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
14870         else
14871                 _res_constr.data = NULL;
14872         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
14873         for (size_t m = 0; m < _res_constr.datalen; m++) {
14874                 int8_tArray _res_conv_12 = _res_vals[m];
14875                 LDKCVec_u8Z _res_conv_12_ref;
14876                 _res_conv_12_ref.datalen = _res_conv_12->arr_len;
14877                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
14878                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, _res_conv_12_ref.datalen); FREE(_res_conv_12);
14879                 _res_constr.data[m] = _res_conv_12_ref;
14880         }
14881         CVec_CVec_u8ZZ_free(_res_constr);
14882 }
14883
14884 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_ok(ptrArray o) {
14885         LDKCVec_CVec_u8ZZ o_constr;
14886         o_constr.datalen = o->arr_len;
14887         if (o_constr.datalen > 0)
14888                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
14889         else
14890                 o_constr.data = NULL;
14891         int8_tArray* o_vals = (void*) o->elems /* XXX o leaks */;
14892         for (size_t m = 0; m < o_constr.datalen; m++) {
14893                 int8_tArray o_conv_12 = o_vals[m];
14894                 LDKCVec_u8Z o_conv_12_ref;
14895                 o_conv_12_ref.datalen = o_conv_12->arr_len;
14896                 o_conv_12_ref.data = MALLOC(o_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
14897                 memcpy(o_conv_12_ref.data, o_conv_12->elems, o_conv_12_ref.datalen); FREE(o_conv_12);
14898                 o_constr.data[m] = o_conv_12_ref;
14899         }
14900         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
14901         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
14902         return (uint32_t)ret_conv;
14903 }
14904
14905 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_err"))) TS_CResult_CVec_CVec_u8ZZNoneZ_err() {
14906         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
14907         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
14908         return (uint32_t)ret_conv;
14909 }
14910
14911 jboolean  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_is_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_is_ok(uint32_t o) {
14912         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(o & ~1);
14913         jboolean ret_conv = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
14914         return ret_conv;
14915 }
14916
14917 void  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_free"))) TS_CResult_CVec_CVec_u8ZZNoneZ_free(uint32_t _res) {
14918         if ((_res & 1) != 0) return;
14919         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14920         CHECK_ACCESS(_res_ptr);
14921         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
14922         FREE((void*)_res);
14923         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
14924 }
14925
14926 static inline uintptr_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
14927         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
14928         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
14929         return (uint32_t)ret_conv;
14930 }
14931 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_clone_ptr"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(uint32_t arg) {
14932         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
14933         uint32_t ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
14934         return ret_conv;
14935 }
14936
14937 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_clone"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone(uint32_t orig) {
14938         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
14939         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
14940         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
14941         return (uint32_t)ret_conv;
14942 }
14943
14944 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_ok(uint32_t o) {
14945         LDKInMemorySigner o_conv;
14946         o_conv.inner = (void*)(o & (~1));
14947         o_conv.is_owned = (o & 1) || (o == 0);
14948         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14949         o_conv = InMemorySigner_clone(&o_conv);
14950         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
14951         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
14952         return (uint32_t)ret_conv;
14953 }
14954
14955 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_err"))) TS_CResult_InMemorySignerDecodeErrorZ_err(uint32_t e) {
14956         LDKDecodeError e_conv;
14957         e_conv.inner = (void*)(e & (~1));
14958         e_conv.is_owned = (e & 1) || (e == 0);
14959         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14960         e_conv = DecodeError_clone(&e_conv);
14961         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
14962         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
14963         return (uint32_t)ret_conv;
14964 }
14965
14966 jboolean  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_is_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_is_ok(uint32_t o) {
14967         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(o & ~1);
14968         jboolean ret_conv = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
14969         return ret_conv;
14970 }
14971
14972 void  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_free"))) TS_CResult_InMemorySignerDecodeErrorZ_free(uint32_t _res) {
14973         if ((_res & 1) != 0) return;
14974         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14975         CHECK_ACCESS(_res_ptr);
14976         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
14977         FREE((void*)_res);
14978         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
14979 }
14980
14981 static inline uintptr_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
14982         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
14983         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
14984         return (uint32_t)ret_conv;
14985 }
14986 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_clone_ptr"))) TS_CResult_InMemorySignerDecodeErrorZ_clone_ptr(uint32_t arg) {
14987         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
14988         uint32_t ret_conv = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
14989         return ret_conv;
14990 }
14991
14992 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_clone"))) TS_CResult_InMemorySignerDecodeErrorZ_clone(uint32_t orig) {
14993         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
14994         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
14995         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
14996         return (uint32_t)ret_conv;
14997 }
14998
14999 void  __attribute__((export_name("TS_CVec_TxOutZ_free"))) TS_CVec_TxOutZ_free(uint32_tArray _res) {
15000         LDKCVec_TxOutZ _res_constr;
15001         _res_constr.datalen = _res->arr_len;
15002         if (_res_constr.datalen > 0)
15003                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
15004         else
15005                 _res_constr.data = NULL;
15006         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
15007         for (size_t h = 0; h < _res_constr.datalen; h++) {
15008                 uint32_t _res_conv_7 = _res_vals[h];
15009                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
15010                 CHECK_ACCESS(_res_conv_7_ptr);
15011                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
15012                 FREE((void*)_res_conv_7);
15013                 _res_constr.data[h] = _res_conv_7_conv;
15014         }
15015         CVec_TxOutZ_free(_res_constr);
15016 }
15017
15018 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_ok"))) TS_CResult_TransactionNoneZ_ok(int8_tArray o) {
15019         LDKTransaction o_ref;
15020         o_ref.datalen = o->arr_len;
15021         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
15022         memcpy(o_ref.data, o->elems, o_ref.datalen); FREE(o);
15023         o_ref.data_is_owned = true;
15024         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15025         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
15026         return (uint32_t)ret_conv;
15027 }
15028
15029 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_err"))) TS_CResult_TransactionNoneZ_err() {
15030         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15031         *ret_conv = CResult_TransactionNoneZ_err();
15032         return (uint32_t)ret_conv;
15033 }
15034
15035 jboolean  __attribute__((export_name("TS_CResult_TransactionNoneZ_is_ok"))) TS_CResult_TransactionNoneZ_is_ok(uint32_t o) {
15036         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)(o & ~1);
15037         jboolean ret_conv = CResult_TransactionNoneZ_is_ok(o_conv);
15038         return ret_conv;
15039 }
15040
15041 void  __attribute__((export_name("TS_CResult_TransactionNoneZ_free"))) TS_CResult_TransactionNoneZ_free(uint32_t _res) {
15042         if ((_res & 1) != 0) return;
15043         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15044         CHECK_ACCESS(_res_ptr);
15045         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
15046         FREE((void*)_res);
15047         CResult_TransactionNoneZ_free(_res_conv);
15048 }
15049
15050 static inline uintptr_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
15051         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15052         *ret_conv = CResult_TransactionNoneZ_clone(arg);
15053         return (uint32_t)ret_conv;
15054 }
15055 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_clone_ptr"))) TS_CResult_TransactionNoneZ_clone_ptr(uint32_t arg) {
15056         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)(arg & ~1);
15057         uint32_t ret_conv = CResult_TransactionNoneZ_clone_ptr(arg_conv);
15058         return ret_conv;
15059 }
15060
15061 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_clone"))) TS_CResult_TransactionNoneZ_clone(uint32_t orig) {
15062         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
15063         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
15064         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
15065         return (uint32_t)ret_conv;
15066 }
15067
15068 uint32_t  __attribute__((export_name("TS_COption_u16Z_some"))) TS_COption_u16Z_some(int16_t o) {
15069         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
15070         *ret_copy = COption_u16Z_some(o);
15071         uint32_t ret_ref = (uintptr_t)ret_copy;
15072         return ret_ref;
15073 }
15074
15075 uint32_t  __attribute__((export_name("TS_COption_u16Z_none"))) TS_COption_u16Z_none() {
15076         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
15077         *ret_copy = COption_u16Z_none();
15078         uint32_t ret_ref = (uintptr_t)ret_copy;
15079         return ret_ref;
15080 }
15081
15082 void  __attribute__((export_name("TS_COption_u16Z_free"))) TS_COption_u16Z_free(uint32_t _res) {
15083         if ((_res & 1) != 0) return;
15084         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15085         CHECK_ACCESS(_res_ptr);
15086         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
15087         FREE((void*)_res);
15088         COption_u16Z_free(_res_conv);
15089 }
15090
15091 static inline uintptr_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
15092         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
15093         *ret_copy = COption_u16Z_clone(arg);
15094 uint32_t ret_ref = (uintptr_t)ret_copy;
15095         return ret_ref;
15096 }
15097 uint32_t  __attribute__((export_name("TS_COption_u16Z_clone_ptr"))) TS_COption_u16Z_clone_ptr(uint32_t arg) {
15098         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)arg;
15099         uint32_t ret_conv = COption_u16Z_clone_ptr(arg_conv);
15100         return ret_conv;
15101 }
15102
15103 uint32_t  __attribute__((export_name("TS_COption_u16Z_clone"))) TS_COption_u16Z_clone(uint32_t orig) {
15104         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
15105         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
15106         *ret_copy = COption_u16Z_clone(orig_conv);
15107         uint32_t ret_ref = (uintptr_t)ret_copy;
15108         return ret_ref;
15109 }
15110
15111 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_ok"))) TS_CResult_NoneAPIErrorZ_ok() {
15112         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15113         *ret_conv = CResult_NoneAPIErrorZ_ok();
15114         return (uint32_t)ret_conv;
15115 }
15116
15117 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_err"))) TS_CResult_NoneAPIErrorZ_err(uint32_t e) {
15118         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15119         CHECK_ACCESS(e_ptr);
15120         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
15121         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
15122         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15123         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
15124         return (uint32_t)ret_conv;
15125 }
15126
15127 jboolean  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_is_ok"))) TS_CResult_NoneAPIErrorZ_is_ok(uint32_t o) {
15128         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)(o & ~1);
15129         jboolean ret_conv = CResult_NoneAPIErrorZ_is_ok(o_conv);
15130         return ret_conv;
15131 }
15132
15133 void  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_free"))) TS_CResult_NoneAPIErrorZ_free(uint32_t _res) {
15134         if ((_res & 1) != 0) return;
15135         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15136         CHECK_ACCESS(_res_ptr);
15137         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
15138         FREE((void*)_res);
15139         CResult_NoneAPIErrorZ_free(_res_conv);
15140 }
15141
15142 static inline uintptr_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
15143         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15144         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
15145         return (uint32_t)ret_conv;
15146 }
15147 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_clone_ptr"))) TS_CResult_NoneAPIErrorZ_clone_ptr(uint32_t arg) {
15148         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
15149         uint32_t ret_conv = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
15150         return ret_conv;
15151 }
15152
15153 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_clone"))) TS_CResult_NoneAPIErrorZ_clone(uint32_t orig) {
15154         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
15155         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
15156         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
15157         return (uint32_t)ret_conv;
15158 }
15159
15160 void  __attribute__((export_name("TS_CVec_CResult_NoneAPIErrorZZ_free"))) TS_CVec_CResult_NoneAPIErrorZZ_free(uint32_tArray _res) {
15161         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
15162         _res_constr.datalen = _res->arr_len;
15163         if (_res_constr.datalen > 0)
15164                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
15165         else
15166                 _res_constr.data = NULL;
15167         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
15168         for (size_t w = 0; w < _res_constr.datalen; w++) {
15169                 uint32_t _res_conv_22 = _res_vals[w];
15170                 void* _res_conv_22_ptr = (void*)(((uintptr_t)_res_conv_22) & ~1);
15171                 CHECK_ACCESS(_res_conv_22_ptr);
15172                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
15173                 FREE((void*)_res_conv_22);
15174                 _res_constr.data[w] = _res_conv_22_conv;
15175         }
15176         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
15177 }
15178
15179 void  __attribute__((export_name("TS_CVec_APIErrorZ_free"))) TS_CVec_APIErrorZ_free(uint32_tArray _res) {
15180         LDKCVec_APIErrorZ _res_constr;
15181         _res_constr.datalen = _res->arr_len;
15182         if (_res_constr.datalen > 0)
15183                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
15184         else
15185                 _res_constr.data = NULL;
15186         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
15187         for (size_t k = 0; k < _res_constr.datalen; k++) {
15188                 uint32_t _res_conv_10 = _res_vals[k];
15189                 void* _res_conv_10_ptr = (void*)(((uintptr_t)_res_conv_10) & ~1);
15190                 CHECK_ACCESS(_res_conv_10_ptr);
15191                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
15192                 FREE((void*)_res_conv_10);
15193                 _res_constr.data[k] = _res_conv_10_conv;
15194         }
15195         CVec_APIErrorZ_free(_res_constr);
15196 }
15197
15198 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_ok"))) TS_CResult__u832APIErrorZ_ok(int8_tArray o) {
15199         LDKThirtyTwoBytes o_ref;
15200         CHECK(o->arr_len == 32);
15201         memcpy(o_ref.data, o->elems, 32); FREE(o);
15202         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
15203         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
15204         return (uint32_t)ret_conv;
15205 }
15206
15207 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_err"))) TS_CResult__u832APIErrorZ_err(uint32_t e) {
15208         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15209         CHECK_ACCESS(e_ptr);
15210         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
15211         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
15212         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
15213         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
15214         return (uint32_t)ret_conv;
15215 }
15216
15217 jboolean  __attribute__((export_name("TS_CResult__u832APIErrorZ_is_ok"))) TS_CResult__u832APIErrorZ_is_ok(uint32_t o) {
15218         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)(o & ~1);
15219         jboolean ret_conv = CResult__u832APIErrorZ_is_ok(o_conv);
15220         return ret_conv;
15221 }
15222
15223 void  __attribute__((export_name("TS_CResult__u832APIErrorZ_free"))) TS_CResult__u832APIErrorZ_free(uint32_t _res) {
15224         if ((_res & 1) != 0) return;
15225         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15226         CHECK_ACCESS(_res_ptr);
15227         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
15228         FREE((void*)_res);
15229         CResult__u832APIErrorZ_free(_res_conv);
15230 }
15231
15232 static inline uintptr_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
15233         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
15234         *ret_conv = CResult__u832APIErrorZ_clone(arg);
15235         return (uint32_t)ret_conv;
15236 }
15237 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_clone_ptr"))) TS_CResult__u832APIErrorZ_clone_ptr(uint32_t arg) {
15238         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)(arg & ~1);
15239         uint32_t ret_conv = CResult__u832APIErrorZ_clone_ptr(arg_conv);
15240         return ret_conv;
15241 }
15242
15243 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_clone"))) TS_CResult__u832APIErrorZ_clone(uint32_t orig) {
15244         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)(orig & ~1);
15245         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
15246         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
15247         return (uint32_t)ret_conv;
15248 }
15249
15250 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_ok(int8_tArray o) {
15251         LDKThirtyTwoBytes o_ref;
15252         CHECK(o->arr_len == 32);
15253         memcpy(o_ref.data, o->elems, 32); FREE(o);
15254         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
15255         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_ref);
15256         return (uint32_t)ret_conv;
15257 }
15258
15259 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_err"))) TS_CResult_PaymentIdPaymentSendFailureZ_err(uint32_t e) {
15260         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15261         CHECK_ACCESS(e_ptr);
15262         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
15263         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
15264         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
15265         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
15266         return (uint32_t)ret_conv;
15267 }
15268
15269 jboolean  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_is_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_is_ok(uint32_t o) {
15270         LDKCResult_PaymentIdPaymentSendFailureZ* o_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(o & ~1);
15271         jboolean ret_conv = CResult_PaymentIdPaymentSendFailureZ_is_ok(o_conv);
15272         return ret_conv;
15273 }
15274
15275 void  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_free"))) TS_CResult_PaymentIdPaymentSendFailureZ_free(uint32_t _res) {
15276         if ((_res & 1) != 0) return;
15277         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15278         CHECK_ACCESS(_res_ptr);
15279         LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
15280         FREE((void*)_res);
15281         CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
15282 }
15283
15284 static inline uintptr_t CResult_PaymentIdPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR arg) {
15285         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
15286         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(arg);
15287         return (uint32_t)ret_conv;
15288 }
15289 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_clone_ptr"))) TS_CResult_PaymentIdPaymentSendFailureZ_clone_ptr(uint32_t arg) {
15290         LDKCResult_PaymentIdPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
15291         uint32_t ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone_ptr(arg_conv);
15292         return ret_conv;
15293 }
15294
15295 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_clone"))) TS_CResult_PaymentIdPaymentSendFailureZ_clone(uint32_t orig) {
15296         LDKCResult_PaymentIdPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(orig & ~1);
15297         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
15298         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(orig_conv);
15299         return (uint32_t)ret_conv;
15300 }
15301
15302 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_ok"))) TS_CResult_NonePaymentSendFailureZ_ok() {
15303         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
15304         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
15305         return (uint32_t)ret_conv;
15306 }
15307
15308 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_err"))) TS_CResult_NonePaymentSendFailureZ_err(uint32_t e) {
15309         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15310         CHECK_ACCESS(e_ptr);
15311         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
15312         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
15313         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
15314         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
15315         return (uint32_t)ret_conv;
15316 }
15317
15318 jboolean  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_is_ok"))) TS_CResult_NonePaymentSendFailureZ_is_ok(uint32_t o) {
15319         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)(o & ~1);
15320         jboolean ret_conv = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
15321         return ret_conv;
15322 }
15323
15324 void  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_free"))) TS_CResult_NonePaymentSendFailureZ_free(uint32_t _res) {
15325         if ((_res & 1) != 0) return;
15326         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15327         CHECK_ACCESS(_res_ptr);
15328         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
15329         FREE((void*)_res);
15330         CResult_NonePaymentSendFailureZ_free(_res_conv);
15331 }
15332
15333 static inline uintptr_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
15334         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
15335         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
15336         return (uint32_t)ret_conv;
15337 }
15338 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_clone_ptr"))) TS_CResult_NonePaymentSendFailureZ_clone_ptr(uint32_t arg) {
15339         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
15340         uint32_t ret_conv = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
15341         return ret_conv;
15342 }
15343
15344 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_clone"))) TS_CResult_NonePaymentSendFailureZ_clone(uint32_t orig) {
15345         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
15346         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
15347         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
15348         return (uint32_t)ret_conv;
15349 }
15350
15351 static inline uintptr_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
15352         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
15353         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
15354         return ((uint32_t)ret_conv);
15355 }
15356 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_clone_ptr"))) TS_C2Tuple_PaymentHashPaymentIdZ_clone_ptr(uint32_t arg) {
15357         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(arg & ~1);
15358         uint32_t ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
15359         return ret_conv;
15360 }
15361
15362 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_clone"))) TS_C2Tuple_PaymentHashPaymentIdZ_clone(uint32_t orig) {
15363         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(orig & ~1);
15364         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
15365         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
15366         return ((uint32_t)ret_conv);
15367 }
15368
15369 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_new"))) TS_C2Tuple_PaymentHashPaymentIdZ_new(int8_tArray a, int8_tArray b) {
15370         LDKThirtyTwoBytes a_ref;
15371         CHECK(a->arr_len == 32);
15372         memcpy(a_ref.data, a->elems, 32); FREE(a);
15373         LDKThirtyTwoBytes b_ref;
15374         CHECK(b->arr_len == 32);
15375         memcpy(b_ref.data, b->elems, 32); FREE(b);
15376         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
15377         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
15378         return ((uint32_t)ret_conv);
15379 }
15380
15381 void  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_free"))) TS_C2Tuple_PaymentHashPaymentIdZ_free(uint32_t _res) {
15382         if ((_res & 1) != 0) return;
15383         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15384         CHECK_ACCESS(_res_ptr);
15385         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
15386         FREE((void*)_res);
15387         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
15388 }
15389
15390 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(uint32_t o) {
15391         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15392         CHECK_ACCESS(o_ptr);
15393         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
15394         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)(((uintptr_t)o) & ~1));
15395         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
15396         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
15397         return (uint32_t)ret_conv;
15398 }
15399
15400 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(uint32_t e) {
15401         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15402         CHECK_ACCESS(e_ptr);
15403         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
15404         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
15405         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
15406         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
15407         return (uint32_t)ret_conv;
15408 }
15409
15410 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(uint32_t o) {
15411         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(o & ~1);
15412         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
15413         return ret_conv;
15414 }
15415
15416 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(uint32_t _res) {
15417         if ((_res & 1) != 0) return;
15418         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15419         CHECK_ACCESS(_res_ptr);
15420         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
15421         FREE((void*)_res);
15422         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
15423 }
15424
15425 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
15426         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
15427         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
15428         return (uint32_t)ret_conv;
15429 }
15430 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(uint32_t arg) {
15431         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
15432         uint32_t ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
15433         return ret_conv;
15434 }
15435
15436 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(uint32_t orig) {
15437         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(orig & ~1);
15438         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
15439         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
15440         return (uint32_t)ret_conv;
15441 }
15442
15443 static inline uintptr_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
15444         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
15445         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
15446         return ((uint32_t)ret_conv);
15447 }
15448 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_clone_ptr"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(uint32_t arg) {
15449         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(arg & ~1);
15450         uint32_t ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
15451         return ret_conv;
15452 }
15453
15454 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_clone"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone(uint32_t orig) {
15455         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
15456         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
15457         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
15458         return ((uint32_t)ret_conv);
15459 }
15460
15461 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_new"))) TS_C2Tuple_PaymentHashPaymentSecretZ_new(int8_tArray a, int8_tArray b) {
15462         LDKThirtyTwoBytes a_ref;
15463         CHECK(a->arr_len == 32);
15464         memcpy(a_ref.data, a->elems, 32); FREE(a);
15465         LDKThirtyTwoBytes b_ref;
15466         CHECK(b->arr_len == 32);
15467         memcpy(b_ref.data, b->elems, 32); FREE(b);
15468         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
15469         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
15470         return ((uint32_t)ret_conv);
15471 }
15472
15473 void  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_free"))) TS_C2Tuple_PaymentHashPaymentSecretZ_free(uint32_t _res) {
15474         if ((_res & 1) != 0) return;
15475         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15476         CHECK_ACCESS(_res_ptr);
15477         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
15478         FREE((void*)_res);
15479         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
15480 }
15481
15482 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(uint32_t o) {
15483         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15484         CHECK_ACCESS(o_ptr);
15485         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
15486         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
15487         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
15488         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o_conv);
15489         return (uint32_t)ret_conv;
15490 }
15491
15492 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err() {
15493         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
15494         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err();
15495         return (uint32_t)ret_conv;
15496 }
15497
15498 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(uint32_t o) {
15499         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(o & ~1);
15500         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o_conv);
15501         return ret_conv;
15502 }
15503
15504 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(uint32_t _res) {
15505         if ((_res & 1) != 0) return;
15506         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15507         CHECK_ACCESS(_res_ptr);
15508         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(_res_ptr);
15509         FREE((void*)_res);
15510         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res_conv);
15511 }
15512
15513 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR arg) {
15514         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
15515         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(arg);
15516         return (uint32_t)ret_conv;
15517 }
15518 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(uint32_t arg) {
15519         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(arg & ~1);
15520         uint32_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(arg_conv);
15521         return ret_conv;
15522 }
15523
15524 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(uint32_t orig) {
15525         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(orig & ~1);
15526         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
15527         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig_conv);
15528         return (uint32_t)ret_conv;
15529 }
15530
15531 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(uint32_t o) {
15532         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15533         CHECK_ACCESS(o_ptr);
15534         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
15535         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
15536         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
15537         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(o_conv);
15538         return (uint32_t)ret_conv;
15539 }
15540
15541 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(uint32_t e) {
15542         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15543         CHECK_ACCESS(e_ptr);
15544         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
15545         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
15546         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
15547         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e_conv);
15548         return (uint32_t)ret_conv;
15549 }
15550
15551 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(uint32_t o) {
15552         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(o & ~1);
15553         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(o_conv);
15554         return ret_conv;
15555 }
15556
15557 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(uint32_t _res) {
15558         if ((_res & 1) != 0) return;
15559         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15560         CHECK_ACCESS(_res_ptr);
15561         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(_res_ptr);
15562         FREE((void*)_res);
15563         CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(_res_conv);
15564 }
15565
15566 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR arg) {
15567         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
15568         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(arg);
15569         return (uint32_t)ret_conv;
15570 }
15571 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(uint32_t arg) {
15572         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(arg & ~1);
15573         uint32_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(arg_conv);
15574         return ret_conv;
15575 }
15576
15577 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(uint32_t orig) {
15578         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(orig & ~1);
15579         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
15580         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(orig_conv);
15581         return (uint32_t)ret_conv;
15582 }
15583
15584 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_ok"))) TS_CResult_PaymentSecretNoneZ_ok(int8_tArray o) {
15585         LDKThirtyTwoBytes o_ref;
15586         CHECK(o->arr_len == 32);
15587         memcpy(o_ref.data, o->elems, 32); FREE(o);
15588         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
15589         *ret_conv = CResult_PaymentSecretNoneZ_ok(o_ref);
15590         return (uint32_t)ret_conv;
15591 }
15592
15593 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_err"))) TS_CResult_PaymentSecretNoneZ_err() {
15594         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
15595         *ret_conv = CResult_PaymentSecretNoneZ_err();
15596         return (uint32_t)ret_conv;
15597 }
15598
15599 jboolean  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_is_ok"))) TS_CResult_PaymentSecretNoneZ_is_ok(uint32_t o) {
15600         LDKCResult_PaymentSecretNoneZ* o_conv = (LDKCResult_PaymentSecretNoneZ*)(o & ~1);
15601         jboolean ret_conv = CResult_PaymentSecretNoneZ_is_ok(o_conv);
15602         return ret_conv;
15603 }
15604
15605 void  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_free"))) TS_CResult_PaymentSecretNoneZ_free(uint32_t _res) {
15606         if ((_res & 1) != 0) return;
15607         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15608         CHECK_ACCESS(_res_ptr);
15609         LDKCResult_PaymentSecretNoneZ _res_conv = *(LDKCResult_PaymentSecretNoneZ*)(_res_ptr);
15610         FREE((void*)_res);
15611         CResult_PaymentSecretNoneZ_free(_res_conv);
15612 }
15613
15614 static inline uintptr_t CResult_PaymentSecretNoneZ_clone_ptr(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR arg) {
15615         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
15616         *ret_conv = CResult_PaymentSecretNoneZ_clone(arg);
15617         return (uint32_t)ret_conv;
15618 }
15619 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_clone_ptr"))) TS_CResult_PaymentSecretNoneZ_clone_ptr(uint32_t arg) {
15620         LDKCResult_PaymentSecretNoneZ* arg_conv = (LDKCResult_PaymentSecretNoneZ*)(arg & ~1);
15621         uint32_t ret_conv = CResult_PaymentSecretNoneZ_clone_ptr(arg_conv);
15622         return ret_conv;
15623 }
15624
15625 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_clone"))) TS_CResult_PaymentSecretNoneZ_clone(uint32_t orig) {
15626         LDKCResult_PaymentSecretNoneZ* orig_conv = (LDKCResult_PaymentSecretNoneZ*)(orig & ~1);
15627         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
15628         *ret_conv = CResult_PaymentSecretNoneZ_clone(orig_conv);
15629         return (uint32_t)ret_conv;
15630 }
15631
15632 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_ok"))) TS_CResult_PaymentSecretAPIErrorZ_ok(int8_tArray o) {
15633         LDKThirtyTwoBytes o_ref;
15634         CHECK(o->arr_len == 32);
15635         memcpy(o_ref.data, o->elems, 32); FREE(o);
15636         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
15637         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
15638         return (uint32_t)ret_conv;
15639 }
15640
15641 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_err"))) TS_CResult_PaymentSecretAPIErrorZ_err(uint32_t e) {
15642         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15643         CHECK_ACCESS(e_ptr);
15644         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
15645         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
15646         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
15647         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
15648         return (uint32_t)ret_conv;
15649 }
15650
15651 jboolean  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_is_ok"))) TS_CResult_PaymentSecretAPIErrorZ_is_ok(uint32_t o) {
15652         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(o & ~1);
15653         jboolean ret_conv = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
15654         return ret_conv;
15655 }
15656
15657 void  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_free"))) TS_CResult_PaymentSecretAPIErrorZ_free(uint32_t _res) {
15658         if ((_res & 1) != 0) return;
15659         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15660         CHECK_ACCESS(_res_ptr);
15661         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
15662         FREE((void*)_res);
15663         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
15664 }
15665
15666 static inline uintptr_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
15667         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
15668         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
15669         return (uint32_t)ret_conv;
15670 }
15671 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_clone_ptr"))) TS_CResult_PaymentSecretAPIErrorZ_clone_ptr(uint32_t arg) {
15672         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
15673         uint32_t ret_conv = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
15674         return ret_conv;
15675 }
15676
15677 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_clone"))) TS_CResult_PaymentSecretAPIErrorZ_clone(uint32_t orig) {
15678         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
15679         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
15680         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
15681         return (uint32_t)ret_conv;
15682 }
15683
15684 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_ok(int8_tArray o) {
15685         LDKThirtyTwoBytes o_ref;
15686         CHECK(o->arr_len == 32);
15687         memcpy(o_ref.data, o->elems, 32); FREE(o);
15688         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
15689         *ret_conv = CResult_PaymentPreimageAPIErrorZ_ok(o_ref);
15690         return (uint32_t)ret_conv;
15691 }
15692
15693 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_err"))) TS_CResult_PaymentPreimageAPIErrorZ_err(uint32_t e) {
15694         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15695         CHECK_ACCESS(e_ptr);
15696         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
15697         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
15698         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
15699         *ret_conv = CResult_PaymentPreimageAPIErrorZ_err(e_conv);
15700         return (uint32_t)ret_conv;
15701 }
15702
15703 jboolean  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_is_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_is_ok(uint32_t o) {
15704         LDKCResult_PaymentPreimageAPIErrorZ* o_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(o & ~1);
15705         jboolean ret_conv = CResult_PaymentPreimageAPIErrorZ_is_ok(o_conv);
15706         return ret_conv;
15707 }
15708
15709 void  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_free"))) TS_CResult_PaymentPreimageAPIErrorZ_free(uint32_t _res) {
15710         if ((_res & 1) != 0) return;
15711         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15712         CHECK_ACCESS(_res_ptr);
15713         LDKCResult_PaymentPreimageAPIErrorZ _res_conv = *(LDKCResult_PaymentPreimageAPIErrorZ*)(_res_ptr);
15714         FREE((void*)_res);
15715         CResult_PaymentPreimageAPIErrorZ_free(_res_conv);
15716 }
15717
15718 static inline uintptr_t CResult_PaymentPreimageAPIErrorZ_clone_ptr(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR arg) {
15719         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
15720         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(arg);
15721         return (uint32_t)ret_conv;
15722 }
15723 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_clone_ptr"))) TS_CResult_PaymentPreimageAPIErrorZ_clone_ptr(uint32_t arg) {
15724         LDKCResult_PaymentPreimageAPIErrorZ* arg_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(arg & ~1);
15725         uint32_t ret_conv = CResult_PaymentPreimageAPIErrorZ_clone_ptr(arg_conv);
15726         return ret_conv;
15727 }
15728
15729 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_clone"))) TS_CResult_PaymentPreimageAPIErrorZ_clone(uint32_t orig) {
15730         LDKCResult_PaymentPreimageAPIErrorZ* orig_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(orig & ~1);
15731         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
15732         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(orig_conv);
15733         return (uint32_t)ret_conv;
15734 }
15735
15736 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_ok"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(uint32_t o) {
15737         LDKCounterpartyForwardingInfo o_conv;
15738         o_conv.inner = (void*)(o & (~1));
15739         o_conv.is_owned = (o & 1) || (o == 0);
15740         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15741         o_conv = CounterpartyForwardingInfo_clone(&o_conv);
15742         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
15743         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(o_conv);
15744         return (uint32_t)ret_conv;
15745 }
15746
15747 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_err"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_err(uint32_t e) {
15748         LDKDecodeError e_conv;
15749         e_conv.inner = (void*)(e & (~1));
15750         e_conv.is_owned = (e & 1) || (e == 0);
15751         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15752         e_conv = DecodeError_clone(&e_conv);
15753         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
15754         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e_conv);
15755         return (uint32_t)ret_conv;
15756 }
15757
15758 jboolean  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(uint32_t o) {
15759         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* o_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(o & ~1);
15760         jboolean ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(o_conv);
15761         return ret_conv;
15762 }
15763
15764 void  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_free"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_free(uint32_t _res) {
15765         if ((_res & 1) != 0) return;
15766         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15767         CHECK_ACCESS(_res_ptr);
15768         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(_res_ptr);
15769         FREE((void*)_res);
15770         CResult_CounterpartyForwardingInfoDecodeErrorZ_free(_res_conv);
15771 }
15772
15773 static inline uintptr_t CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR arg) {
15774         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
15775         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(arg);
15776         return (uint32_t)ret_conv;
15777 }
15778 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
15779         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(arg & ~1);
15780         uint32_t ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(arg_conv);
15781         return ret_conv;
15782 }
15783
15784 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(uint32_t orig) {
15785         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(orig & ~1);
15786         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
15787         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(orig_conv);
15788         return (uint32_t)ret_conv;
15789 }
15790
15791 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_ok"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_ok(uint32_t o) {
15792         LDKChannelCounterparty o_conv;
15793         o_conv.inner = (void*)(o & (~1));
15794         o_conv.is_owned = (o & 1) || (o == 0);
15795         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15796         o_conv = ChannelCounterparty_clone(&o_conv);
15797         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
15798         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_ok(o_conv);
15799         return (uint32_t)ret_conv;
15800 }
15801
15802 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_err"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_err(uint32_t e) {
15803         LDKDecodeError e_conv;
15804         e_conv.inner = (void*)(e & (~1));
15805         e_conv.is_owned = (e & 1) || (e == 0);
15806         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15807         e_conv = DecodeError_clone(&e_conv);
15808         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
15809         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_err(e_conv);
15810         return (uint32_t)ret_conv;
15811 }
15812
15813 jboolean  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_is_ok"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_is_ok(uint32_t o) {
15814         LDKCResult_ChannelCounterpartyDecodeErrorZ* o_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(o & ~1);
15815         jboolean ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_is_ok(o_conv);
15816         return ret_conv;
15817 }
15818
15819 void  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_free"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_free(uint32_t _res) {
15820         if ((_res & 1) != 0) return;
15821         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15822         CHECK_ACCESS(_res_ptr);
15823         LDKCResult_ChannelCounterpartyDecodeErrorZ _res_conv = *(LDKCResult_ChannelCounterpartyDecodeErrorZ*)(_res_ptr);
15824         FREE((void*)_res);
15825         CResult_ChannelCounterpartyDecodeErrorZ_free(_res_conv);
15826 }
15827
15828 static inline uintptr_t CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR arg) {
15829         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
15830         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(arg);
15831         return (uint32_t)ret_conv;
15832 }
15833 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(uint32_t arg) {
15834         LDKCResult_ChannelCounterpartyDecodeErrorZ* arg_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(arg & ~1);
15835         uint32_t ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(arg_conv);
15836         return ret_conv;
15837 }
15838
15839 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_clone"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_clone(uint32_t orig) {
15840         LDKCResult_ChannelCounterpartyDecodeErrorZ* orig_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(orig & ~1);
15841         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
15842         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(orig_conv);
15843         return (uint32_t)ret_conv;
15844 }
15845
15846 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_ok"))) TS_CResult_ChannelDetailsDecodeErrorZ_ok(uint32_t o) {
15847         LDKChannelDetails o_conv;
15848         o_conv.inner = (void*)(o & (~1));
15849         o_conv.is_owned = (o & 1) || (o == 0);
15850         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15851         o_conv = ChannelDetails_clone(&o_conv);
15852         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
15853         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_ok(o_conv);
15854         return (uint32_t)ret_conv;
15855 }
15856
15857 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_err"))) TS_CResult_ChannelDetailsDecodeErrorZ_err(uint32_t e) {
15858         LDKDecodeError e_conv;
15859         e_conv.inner = (void*)(e & (~1));
15860         e_conv.is_owned = (e & 1) || (e == 0);
15861         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15862         e_conv = DecodeError_clone(&e_conv);
15863         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
15864         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_err(e_conv);
15865         return (uint32_t)ret_conv;
15866 }
15867
15868 jboolean  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_is_ok"))) TS_CResult_ChannelDetailsDecodeErrorZ_is_ok(uint32_t o) {
15869         LDKCResult_ChannelDetailsDecodeErrorZ* o_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(o & ~1);
15870         jboolean ret_conv = CResult_ChannelDetailsDecodeErrorZ_is_ok(o_conv);
15871         return ret_conv;
15872 }
15873
15874 void  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_free"))) TS_CResult_ChannelDetailsDecodeErrorZ_free(uint32_t _res) {
15875         if ((_res & 1) != 0) return;
15876         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15877         CHECK_ACCESS(_res_ptr);
15878         LDKCResult_ChannelDetailsDecodeErrorZ _res_conv = *(LDKCResult_ChannelDetailsDecodeErrorZ*)(_res_ptr);
15879         FREE((void*)_res);
15880         CResult_ChannelDetailsDecodeErrorZ_free(_res_conv);
15881 }
15882
15883 static inline uintptr_t CResult_ChannelDetailsDecodeErrorZ_clone_ptr(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR arg) {
15884         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
15885         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(arg);
15886         return (uint32_t)ret_conv;
15887 }
15888 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelDetailsDecodeErrorZ_clone_ptr(uint32_t arg) {
15889         LDKCResult_ChannelDetailsDecodeErrorZ* arg_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(arg & ~1);
15890         uint32_t ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone_ptr(arg_conv);
15891         return ret_conv;
15892 }
15893
15894 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_clone"))) TS_CResult_ChannelDetailsDecodeErrorZ_clone(uint32_t orig) {
15895         LDKCResult_ChannelDetailsDecodeErrorZ* orig_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(orig & ~1);
15896         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
15897         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(orig_conv);
15898         return (uint32_t)ret_conv;
15899 }
15900
15901 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_ok"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_ok(uint32_t o) {
15902         LDKPhantomRouteHints o_conv;
15903         o_conv.inner = (void*)(o & (~1));
15904         o_conv.is_owned = (o & 1) || (o == 0);
15905         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15906         o_conv = PhantomRouteHints_clone(&o_conv);
15907         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
15908         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_ok(o_conv);
15909         return (uint32_t)ret_conv;
15910 }
15911
15912 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_err"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_err(uint32_t e) {
15913         LDKDecodeError e_conv;
15914         e_conv.inner = (void*)(e & (~1));
15915         e_conv.is_owned = (e & 1) || (e == 0);
15916         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15917         e_conv = DecodeError_clone(&e_conv);
15918         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
15919         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_err(e_conv);
15920         return (uint32_t)ret_conv;
15921 }
15922
15923 jboolean  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_is_ok"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_is_ok(uint32_t o) {
15924         LDKCResult_PhantomRouteHintsDecodeErrorZ* o_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(o & ~1);
15925         jboolean ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_is_ok(o_conv);
15926         return ret_conv;
15927 }
15928
15929 void  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_free"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_free(uint32_t _res) {
15930         if ((_res & 1) != 0) return;
15931         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15932         CHECK_ACCESS(_res_ptr);
15933         LDKCResult_PhantomRouteHintsDecodeErrorZ _res_conv = *(LDKCResult_PhantomRouteHintsDecodeErrorZ*)(_res_ptr);
15934         FREE((void*)_res);
15935         CResult_PhantomRouteHintsDecodeErrorZ_free(_res_conv);
15936 }
15937
15938 static inline uintptr_t CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR arg) {
15939         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
15940         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(arg);
15941         return (uint32_t)ret_conv;
15942 }
15943 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(uint32_t arg) {
15944         LDKCResult_PhantomRouteHintsDecodeErrorZ* arg_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(arg & ~1);
15945         uint32_t ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(arg_conv);
15946         return ret_conv;
15947 }
15948
15949 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_clone"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_clone(uint32_t orig) {
15950         LDKCResult_PhantomRouteHintsDecodeErrorZ* orig_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(orig & ~1);
15951         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
15952         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(orig_conv);
15953         return (uint32_t)ret_conv;
15954 }
15955
15956 void  __attribute__((export_name("TS_CVec_ChannelMonitorZ_free"))) TS_CVec_ChannelMonitorZ_free(uint32_tArray _res) {
15957         LDKCVec_ChannelMonitorZ _res_constr;
15958         _res_constr.datalen = _res->arr_len;
15959         if (_res_constr.datalen > 0)
15960                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
15961         else
15962                 _res_constr.data = NULL;
15963         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
15964         for (size_t q = 0; q < _res_constr.datalen; q++) {
15965                 uint32_t _res_conv_16 = _res_vals[q];
15966                 LDKChannelMonitor _res_conv_16_conv;
15967                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
15968                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
15969                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
15970                 _res_constr.data[q] = _res_conv_16_conv;
15971         }
15972         CVec_ChannelMonitorZ_free(_res_constr);
15973 }
15974
15975 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_new"))) TS_C2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
15976         LDKThirtyTwoBytes a_ref;
15977         CHECK(a->arr_len == 32);
15978         memcpy(a_ref.data, a->elems, 32); FREE(a);
15979         LDKChannelManager b_conv;
15980         b_conv.inner = (void*)(b & (~1));
15981         b_conv.is_owned = (b & 1) || (b == 0);
15982         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
15983         // WARNING: we need a move here but no clone is available for LDKChannelManager
15984         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
15985         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
15986         return ((uint32_t)ret_conv);
15987 }
15988
15989 void  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_free"))) TS_C2Tuple_BlockHashChannelManagerZ_free(uint32_t _res) {
15990         if ((_res & 1) != 0) return;
15991         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15992         CHECK_ACCESS(_res_ptr);
15993         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
15994         FREE((void*)_res);
15995         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
15996 }
15997
15998 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(uint32_t o) {
15999         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16000         CHECK_ACCESS(o_ptr);
16001         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
16002         // WARNING: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
16003         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
16004         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
16005         return (uint32_t)ret_conv;
16006 }
16007
16008 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(uint32_t e) {
16009         LDKDecodeError e_conv;
16010         e_conv.inner = (void*)(e & (~1));
16011         e_conv.is_owned = (e & 1) || (e == 0);
16012         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16013         e_conv = DecodeError_clone(&e_conv);
16014         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
16015         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
16016         return (uint32_t)ret_conv;
16017 }
16018
16019 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(uint32_t o) {
16020         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(o & ~1);
16021         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
16022         return ret_conv;
16023 }
16024
16025 void  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(uint32_t _res) {
16026         if ((_res & 1) != 0) return;
16027         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16028         CHECK_ACCESS(_res_ptr);
16029         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
16030         FREE((void*)_res);
16031         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
16032 }
16033
16034 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_ok(uint32_t o) {
16035         LDKChannelConfig o_conv;
16036         o_conv.inner = (void*)(o & (~1));
16037         o_conv.is_owned = (o & 1) || (o == 0);
16038         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16039         o_conv = ChannelConfig_clone(&o_conv);
16040         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
16041         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
16042         return (uint32_t)ret_conv;
16043 }
16044
16045 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_err"))) TS_CResult_ChannelConfigDecodeErrorZ_err(uint32_t e) {
16046         LDKDecodeError e_conv;
16047         e_conv.inner = (void*)(e & (~1));
16048         e_conv.is_owned = (e & 1) || (e == 0);
16049         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16050         e_conv = DecodeError_clone(&e_conv);
16051         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
16052         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
16053         return (uint32_t)ret_conv;
16054 }
16055
16056 jboolean  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_is_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_is_ok(uint32_t o) {
16057         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(o & ~1);
16058         jboolean ret_conv = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
16059         return ret_conv;
16060 }
16061
16062 void  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_free"))) TS_CResult_ChannelConfigDecodeErrorZ_free(uint32_t _res) {
16063         if ((_res & 1) != 0) return;
16064         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16065         CHECK_ACCESS(_res_ptr);
16066         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
16067         FREE((void*)_res);
16068         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
16069 }
16070
16071 static inline uintptr_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
16072         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
16073         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
16074         return (uint32_t)ret_conv;
16075 }
16076 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelConfigDecodeErrorZ_clone_ptr(uint32_t arg) {
16077         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
16078         uint32_t ret_conv = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
16079         return ret_conv;
16080 }
16081
16082 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_clone"))) TS_CResult_ChannelConfigDecodeErrorZ_clone(uint32_t orig) {
16083         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
16084         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
16085         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
16086         return (uint32_t)ret_conv;
16087 }
16088
16089 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_ok"))) TS_CResult_OutPointDecodeErrorZ_ok(uint32_t o) {
16090         LDKOutPoint o_conv;
16091         o_conv.inner = (void*)(o & (~1));
16092         o_conv.is_owned = (o & 1) || (o == 0);
16093         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16094         o_conv = OutPoint_clone(&o_conv);
16095         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
16096         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
16097         return (uint32_t)ret_conv;
16098 }
16099
16100 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_err"))) TS_CResult_OutPointDecodeErrorZ_err(uint32_t e) {
16101         LDKDecodeError e_conv;
16102         e_conv.inner = (void*)(e & (~1));
16103         e_conv.is_owned = (e & 1) || (e == 0);
16104         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16105         e_conv = DecodeError_clone(&e_conv);
16106         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
16107         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
16108         return (uint32_t)ret_conv;
16109 }
16110
16111 jboolean  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_is_ok"))) TS_CResult_OutPointDecodeErrorZ_is_ok(uint32_t o) {
16112         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)(o & ~1);
16113         jboolean ret_conv = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
16114         return ret_conv;
16115 }
16116
16117 void  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_free"))) TS_CResult_OutPointDecodeErrorZ_free(uint32_t _res) {
16118         if ((_res & 1) != 0) return;
16119         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16120         CHECK_ACCESS(_res_ptr);
16121         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
16122         FREE((void*)_res);
16123         CResult_OutPointDecodeErrorZ_free(_res_conv);
16124 }
16125
16126 static inline uintptr_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
16127         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
16128         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
16129         return (uint32_t)ret_conv;
16130 }
16131 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_clone_ptr"))) TS_CResult_OutPointDecodeErrorZ_clone_ptr(uint32_t arg) {
16132         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
16133         uint32_t ret_conv = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
16134         return ret_conv;
16135 }
16136
16137 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_clone"))) TS_CResult_OutPointDecodeErrorZ_clone(uint32_t orig) {
16138         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
16139         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
16140         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
16141         return (uint32_t)ret_conv;
16142 }
16143
16144 uint32_t  __attribute__((export_name("TS_COption_TypeZ_some"))) TS_COption_TypeZ_some(uint32_t o) {
16145         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16146         CHECK_ACCESS(o_ptr);
16147         LDKType o_conv = *(LDKType*)(o_ptr);
16148         if (o_conv.free == LDKType_JCalls_free) {
16149                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16150                 LDKType_JCalls_cloned(&o_conv);
16151         }
16152         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
16153         *ret_copy = COption_TypeZ_some(o_conv);
16154         uint32_t ret_ref = (uintptr_t)ret_copy;
16155         return ret_ref;
16156 }
16157
16158 uint32_t  __attribute__((export_name("TS_COption_TypeZ_none"))) TS_COption_TypeZ_none() {
16159         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
16160         *ret_copy = COption_TypeZ_none();
16161         uint32_t ret_ref = (uintptr_t)ret_copy;
16162         return ret_ref;
16163 }
16164
16165 void  __attribute__((export_name("TS_COption_TypeZ_free"))) TS_COption_TypeZ_free(uint32_t _res) {
16166         if ((_res & 1) != 0) return;
16167         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16168         CHECK_ACCESS(_res_ptr);
16169         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
16170         FREE((void*)_res);
16171         COption_TypeZ_free(_res_conv);
16172 }
16173
16174 static inline uintptr_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
16175         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
16176         *ret_copy = COption_TypeZ_clone(arg);
16177 uint32_t ret_ref = (uintptr_t)ret_copy;
16178         return ret_ref;
16179 }
16180 uint32_t  __attribute__((export_name("TS_COption_TypeZ_clone_ptr"))) TS_COption_TypeZ_clone_ptr(uint32_t arg) {
16181         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)arg;
16182         uint32_t ret_conv = COption_TypeZ_clone_ptr(arg_conv);
16183         return ret_conv;
16184 }
16185
16186 uint32_t  __attribute__((export_name("TS_COption_TypeZ_clone"))) TS_COption_TypeZ_clone(uint32_t orig) {
16187         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig;
16188         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
16189         *ret_copy = COption_TypeZ_clone(orig_conv);
16190         uint32_t ret_ref = (uintptr_t)ret_copy;
16191         return ret_ref;
16192 }
16193
16194 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_ok(uint32_t o) {
16195         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16196         CHECK_ACCESS(o_ptr);
16197         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
16198         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uintptr_t)o) & ~1));
16199         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
16200         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
16201         return (uint32_t)ret_conv;
16202 }
16203
16204 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_err"))) TS_CResult_COption_TypeZDecodeErrorZ_err(uint32_t e) {
16205         LDKDecodeError e_conv;
16206         e_conv.inner = (void*)(e & (~1));
16207         e_conv.is_owned = (e & 1) || (e == 0);
16208         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16209         e_conv = DecodeError_clone(&e_conv);
16210         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
16211         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
16212         return (uint32_t)ret_conv;
16213 }
16214
16215 jboolean  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_is_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_is_ok(uint32_t o) {
16216         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(o & ~1);
16217         jboolean ret_conv = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
16218         return ret_conv;
16219 }
16220
16221 void  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_free"))) TS_CResult_COption_TypeZDecodeErrorZ_free(uint32_t _res) {
16222         if ((_res & 1) != 0) return;
16223         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16224         CHECK_ACCESS(_res_ptr);
16225         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
16226         FREE((void*)_res);
16227         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
16228 }
16229
16230 static inline uintptr_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
16231         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
16232         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
16233         return (uint32_t)ret_conv;
16234 }
16235 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_TypeZDecodeErrorZ_clone_ptr(uint32_t arg) {
16236         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
16237         uint32_t ret_conv = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
16238         return ret_conv;
16239 }
16240
16241 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_clone"))) TS_CResult_COption_TypeZDecodeErrorZ_clone(uint32_t orig) {
16242         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1);
16243         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
16244         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
16245         return (uint32_t)ret_conv;
16246 }
16247
16248 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_ok"))) TS_CResult_PaymentIdPaymentErrorZ_ok(int8_tArray o) {
16249         LDKThirtyTwoBytes o_ref;
16250         CHECK(o->arr_len == 32);
16251         memcpy(o_ref.data, o->elems, 32); FREE(o);
16252         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
16253         *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
16254         return (uint32_t)ret_conv;
16255 }
16256
16257 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_err"))) TS_CResult_PaymentIdPaymentErrorZ_err(uint32_t e) {
16258         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16259         CHECK_ACCESS(e_ptr);
16260         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
16261         e_conv = PaymentError_clone((LDKPaymentError*)(((uintptr_t)e) & ~1));
16262         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
16263         *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
16264         return (uint32_t)ret_conv;
16265 }
16266
16267 jboolean  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_is_ok"))) TS_CResult_PaymentIdPaymentErrorZ_is_ok(uint32_t o) {
16268         LDKCResult_PaymentIdPaymentErrorZ* o_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(o & ~1);
16269         jboolean ret_conv = CResult_PaymentIdPaymentErrorZ_is_ok(o_conv);
16270         return ret_conv;
16271 }
16272
16273 void  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_free"))) TS_CResult_PaymentIdPaymentErrorZ_free(uint32_t _res) {
16274         if ((_res & 1) != 0) return;
16275         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16276         CHECK_ACCESS(_res_ptr);
16277         LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
16278         FREE((void*)_res);
16279         CResult_PaymentIdPaymentErrorZ_free(_res_conv);
16280 }
16281
16282 static inline uintptr_t CResult_PaymentIdPaymentErrorZ_clone_ptr(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR arg) {
16283         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
16284         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(arg);
16285         return (uint32_t)ret_conv;
16286 }
16287 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_clone_ptr"))) TS_CResult_PaymentIdPaymentErrorZ_clone_ptr(uint32_t arg) {
16288         LDKCResult_PaymentIdPaymentErrorZ* arg_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
16289         uint32_t ret_conv = CResult_PaymentIdPaymentErrorZ_clone_ptr(arg_conv);
16290         return ret_conv;
16291 }
16292
16293 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_clone"))) TS_CResult_PaymentIdPaymentErrorZ_clone(uint32_t orig) {
16294         LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(orig & ~1);
16295         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
16296         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(orig_conv);
16297         return (uint32_t)ret_conv;
16298 }
16299
16300 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_ok"))) TS_CResult_SiPrefixParseErrorZ_ok(uint32_t o) {
16301         LDKSiPrefix o_conv = LDKSiPrefix_from_js(o);
16302         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
16303         *ret_conv = CResult_SiPrefixParseErrorZ_ok(o_conv);
16304         return (uint32_t)ret_conv;
16305 }
16306
16307 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_err"))) TS_CResult_SiPrefixParseErrorZ_err(uint32_t e) {
16308         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16309         CHECK_ACCESS(e_ptr);
16310         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
16311         e_conv = ParseError_clone((LDKParseError*)(((uintptr_t)e) & ~1));
16312         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
16313         *ret_conv = CResult_SiPrefixParseErrorZ_err(e_conv);
16314         return (uint32_t)ret_conv;
16315 }
16316
16317 jboolean  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_is_ok"))) TS_CResult_SiPrefixParseErrorZ_is_ok(uint32_t o) {
16318         LDKCResult_SiPrefixParseErrorZ* o_conv = (LDKCResult_SiPrefixParseErrorZ*)(o & ~1);
16319         jboolean ret_conv = CResult_SiPrefixParseErrorZ_is_ok(o_conv);
16320         return ret_conv;
16321 }
16322
16323 void  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_free"))) TS_CResult_SiPrefixParseErrorZ_free(uint32_t _res) {
16324         if ((_res & 1) != 0) return;
16325         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16326         CHECK_ACCESS(_res_ptr);
16327         LDKCResult_SiPrefixParseErrorZ _res_conv = *(LDKCResult_SiPrefixParseErrorZ*)(_res_ptr);
16328         FREE((void*)_res);
16329         CResult_SiPrefixParseErrorZ_free(_res_conv);
16330 }
16331
16332 static inline uintptr_t CResult_SiPrefixParseErrorZ_clone_ptr(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR arg) {
16333         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
16334         *ret_conv = CResult_SiPrefixParseErrorZ_clone(arg);
16335         return (uint32_t)ret_conv;
16336 }
16337 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_clone_ptr"))) TS_CResult_SiPrefixParseErrorZ_clone_ptr(uint32_t arg) {
16338         LDKCResult_SiPrefixParseErrorZ* arg_conv = (LDKCResult_SiPrefixParseErrorZ*)(arg & ~1);
16339         uint32_t ret_conv = CResult_SiPrefixParseErrorZ_clone_ptr(arg_conv);
16340         return ret_conv;
16341 }
16342
16343 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_clone"))) TS_CResult_SiPrefixParseErrorZ_clone(uint32_t orig) {
16344         LDKCResult_SiPrefixParseErrorZ* orig_conv = (LDKCResult_SiPrefixParseErrorZ*)(orig & ~1);
16345         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
16346         *ret_conv = CResult_SiPrefixParseErrorZ_clone(orig_conv);
16347         return (uint32_t)ret_conv;
16348 }
16349
16350 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_ok"))) TS_CResult_InvoiceParseOrSemanticErrorZ_ok(uint32_t o) {
16351         LDKInvoice o_conv;
16352         o_conv.inner = (void*)(o & (~1));
16353         o_conv.is_owned = (o & 1) || (o == 0);
16354         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16355         o_conv = Invoice_clone(&o_conv);
16356         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
16357         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_ok(o_conv);
16358         return (uint32_t)ret_conv;
16359 }
16360
16361 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_err"))) TS_CResult_InvoiceParseOrSemanticErrorZ_err(uint32_t e) {
16362         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16363         CHECK_ACCESS(e_ptr);
16364         LDKParseOrSemanticError e_conv = *(LDKParseOrSemanticError*)(e_ptr);
16365         e_conv = ParseOrSemanticError_clone((LDKParseOrSemanticError*)(((uintptr_t)e) & ~1));
16366         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
16367         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_err(e_conv);
16368         return (uint32_t)ret_conv;
16369 }
16370
16371 jboolean  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_is_ok"))) TS_CResult_InvoiceParseOrSemanticErrorZ_is_ok(uint32_t o) {
16372         LDKCResult_InvoiceParseOrSemanticErrorZ* o_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(o & ~1);
16373         jboolean ret_conv = CResult_InvoiceParseOrSemanticErrorZ_is_ok(o_conv);
16374         return ret_conv;
16375 }
16376
16377 void  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_free"))) TS_CResult_InvoiceParseOrSemanticErrorZ_free(uint32_t _res) {
16378         if ((_res & 1) != 0) return;
16379         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16380         CHECK_ACCESS(_res_ptr);
16381         LDKCResult_InvoiceParseOrSemanticErrorZ _res_conv = *(LDKCResult_InvoiceParseOrSemanticErrorZ*)(_res_ptr);
16382         FREE((void*)_res);
16383         CResult_InvoiceParseOrSemanticErrorZ_free(_res_conv);
16384 }
16385
16386 static inline uintptr_t CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR arg) {
16387         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
16388         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(arg);
16389         return (uint32_t)ret_conv;
16390 }
16391 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_clone_ptr"))) TS_CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(uint32_t arg) {
16392         LDKCResult_InvoiceParseOrSemanticErrorZ* arg_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(arg & ~1);
16393         uint32_t ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(arg_conv);
16394         return ret_conv;
16395 }
16396
16397 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_clone"))) TS_CResult_InvoiceParseOrSemanticErrorZ_clone(uint32_t orig) {
16398         LDKCResult_InvoiceParseOrSemanticErrorZ* orig_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(orig & ~1);
16399         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
16400         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(orig_conv);
16401         return (uint32_t)ret_conv;
16402 }
16403
16404 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_ok"))) TS_CResult_SignedRawInvoiceParseErrorZ_ok(uint32_t o) {
16405         LDKSignedRawInvoice o_conv;
16406         o_conv.inner = (void*)(o & (~1));
16407         o_conv.is_owned = (o & 1) || (o == 0);
16408         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16409         o_conv = SignedRawInvoice_clone(&o_conv);
16410         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
16411         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_ok(o_conv);
16412         return (uint32_t)ret_conv;
16413 }
16414
16415 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_err"))) TS_CResult_SignedRawInvoiceParseErrorZ_err(uint32_t e) {
16416         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
16417         CHECK_ACCESS(e_ptr);
16418         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
16419         e_conv = ParseError_clone((LDKParseError*)(((uintptr_t)e) & ~1));
16420         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
16421         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_err(e_conv);
16422         return (uint32_t)ret_conv;
16423 }
16424
16425 jboolean  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_is_ok"))) TS_CResult_SignedRawInvoiceParseErrorZ_is_ok(uint32_t o) {
16426         LDKCResult_SignedRawInvoiceParseErrorZ* o_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(o & ~1);
16427         jboolean ret_conv = CResult_SignedRawInvoiceParseErrorZ_is_ok(o_conv);
16428         return ret_conv;
16429 }
16430
16431 void  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_free"))) TS_CResult_SignedRawInvoiceParseErrorZ_free(uint32_t _res) {
16432         if ((_res & 1) != 0) return;
16433         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16434         CHECK_ACCESS(_res_ptr);
16435         LDKCResult_SignedRawInvoiceParseErrorZ _res_conv = *(LDKCResult_SignedRawInvoiceParseErrorZ*)(_res_ptr);
16436         FREE((void*)_res);
16437         CResult_SignedRawInvoiceParseErrorZ_free(_res_conv);
16438 }
16439
16440 static inline uintptr_t CResult_SignedRawInvoiceParseErrorZ_clone_ptr(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR arg) {
16441         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
16442         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(arg);
16443         return (uint32_t)ret_conv;
16444 }
16445 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_clone_ptr"))) TS_CResult_SignedRawInvoiceParseErrorZ_clone_ptr(uint32_t arg) {
16446         LDKCResult_SignedRawInvoiceParseErrorZ* arg_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(arg & ~1);
16447         uint32_t ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone_ptr(arg_conv);
16448         return ret_conv;
16449 }
16450
16451 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_clone"))) TS_CResult_SignedRawInvoiceParseErrorZ_clone(uint32_t orig) {
16452         LDKCResult_SignedRawInvoiceParseErrorZ* orig_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(orig & ~1);
16453         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
16454         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(orig_conv);
16455         return (uint32_t)ret_conv;
16456 }
16457
16458 static inline uintptr_t C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR arg) {
16459         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
16460         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(arg);
16461         return ((uint32_t)ret_conv);
16462 }
16463 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(uint32_t arg) {
16464         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* arg_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(arg & ~1);
16465         uint32_t ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(arg_conv);
16466         return ret_conv;
16467 }
16468
16469 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(uint32_t orig) {
16470         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
16471         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
16472         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
16473         return ((uint32_t)ret_conv);
16474 }
16475
16476 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_new"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(uint32_t a, int8_tArray b, uint32_t c) {
16477         LDKRawInvoice a_conv;
16478         a_conv.inner = (void*)(a & (~1));
16479         a_conv.is_owned = (a & 1) || (a == 0);
16480         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
16481         a_conv = RawInvoice_clone(&a_conv);
16482         LDKThirtyTwoBytes b_ref;
16483         CHECK(b->arr_len == 32);
16484         memcpy(b_ref.data, b->elems, 32); FREE(b);
16485         LDKInvoiceSignature c_conv;
16486         c_conv.inner = (void*)(c & (~1));
16487         c_conv.is_owned = (c & 1) || (c == 0);
16488         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
16489         c_conv = InvoiceSignature_clone(&c_conv);
16490         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
16491         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
16492         return ((uint32_t)ret_conv);
16493 }
16494
16495 void  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_free"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(uint32_t _res) {
16496         if ((_res & 1) != 0) return;
16497         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16498         CHECK_ACCESS(_res_ptr);
16499         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
16500         FREE((void*)_res);
16501         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
16502 }
16503
16504 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_ok"))) TS_CResult_PayeePubKeyErrorZ_ok(uint32_t o) {
16505         LDKPayeePubKey o_conv;
16506         o_conv.inner = (void*)(o & (~1));
16507         o_conv.is_owned = (o & 1) || (o == 0);
16508         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16509         o_conv = PayeePubKey_clone(&o_conv);
16510         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
16511         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
16512         return (uint32_t)ret_conv;
16513 }
16514
16515 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_err"))) TS_CResult_PayeePubKeyErrorZ_err(uint32_t e) {
16516         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
16517         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
16518         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
16519         return (uint32_t)ret_conv;
16520 }
16521
16522 jboolean  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_is_ok"))) TS_CResult_PayeePubKeyErrorZ_is_ok(uint32_t o) {
16523         LDKCResult_PayeePubKeyErrorZ* o_conv = (LDKCResult_PayeePubKeyErrorZ*)(o & ~1);
16524         jboolean ret_conv = CResult_PayeePubKeyErrorZ_is_ok(o_conv);
16525         return ret_conv;
16526 }
16527
16528 void  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_free"))) TS_CResult_PayeePubKeyErrorZ_free(uint32_t _res) {
16529         if ((_res & 1) != 0) return;
16530         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16531         CHECK_ACCESS(_res_ptr);
16532         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
16533         FREE((void*)_res);
16534         CResult_PayeePubKeyErrorZ_free(_res_conv);
16535 }
16536
16537 static inline uintptr_t CResult_PayeePubKeyErrorZ_clone_ptr(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR arg) {
16538         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
16539         *ret_conv = CResult_PayeePubKeyErrorZ_clone(arg);
16540         return (uint32_t)ret_conv;
16541 }
16542 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_clone_ptr"))) TS_CResult_PayeePubKeyErrorZ_clone_ptr(uint32_t arg) {
16543         LDKCResult_PayeePubKeyErrorZ* arg_conv = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
16544         uint32_t ret_conv = CResult_PayeePubKeyErrorZ_clone_ptr(arg_conv);
16545         return ret_conv;
16546 }
16547
16548 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_clone"))) TS_CResult_PayeePubKeyErrorZ_clone(uint32_t orig) {
16549         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
16550         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
16551         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
16552         return (uint32_t)ret_conv;
16553 }
16554
16555 void  __attribute__((export_name("TS_CVec_PrivateRouteZ_free"))) TS_CVec_PrivateRouteZ_free(uint32_tArray _res) {
16556         LDKCVec_PrivateRouteZ _res_constr;
16557         _res_constr.datalen = _res->arr_len;
16558         if (_res_constr.datalen > 0)
16559                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
16560         else
16561                 _res_constr.data = NULL;
16562         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16563         for (size_t o = 0; o < _res_constr.datalen; o++) {
16564                 uint32_t _res_conv_14 = _res_vals[o];
16565                 LDKPrivateRoute _res_conv_14_conv;
16566                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
16567                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
16568                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
16569                 _res_constr.data[o] = _res_conv_14_conv;
16570         }
16571         CVec_PrivateRouteZ_free(_res_constr);
16572 }
16573
16574 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_ok"))) TS_CResult_PositiveTimestampCreationErrorZ_ok(uint32_t o) {
16575         LDKPositiveTimestamp o_conv;
16576         o_conv.inner = (void*)(o & (~1));
16577         o_conv.is_owned = (o & 1) || (o == 0);
16578         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16579         o_conv = PositiveTimestamp_clone(&o_conv);
16580         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
16581         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
16582         return (uint32_t)ret_conv;
16583 }
16584
16585 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_err"))) TS_CResult_PositiveTimestampCreationErrorZ_err(uint32_t e) {
16586         LDKCreationError e_conv = LDKCreationError_from_js(e);
16587         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
16588         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
16589         return (uint32_t)ret_conv;
16590 }
16591
16592 jboolean  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_is_ok"))) TS_CResult_PositiveTimestampCreationErrorZ_is_ok(uint32_t o) {
16593         LDKCResult_PositiveTimestampCreationErrorZ* o_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(o & ~1);
16594         jboolean ret_conv = CResult_PositiveTimestampCreationErrorZ_is_ok(o_conv);
16595         return ret_conv;
16596 }
16597
16598 void  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_free"))) TS_CResult_PositiveTimestampCreationErrorZ_free(uint32_t _res) {
16599         if ((_res & 1) != 0) return;
16600         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16601         CHECK_ACCESS(_res_ptr);
16602         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
16603         FREE((void*)_res);
16604         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
16605 }
16606
16607 static inline uintptr_t CResult_PositiveTimestampCreationErrorZ_clone_ptr(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR arg) {
16608         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
16609         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(arg);
16610         return (uint32_t)ret_conv;
16611 }
16612 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_clone_ptr"))) TS_CResult_PositiveTimestampCreationErrorZ_clone_ptr(uint32_t arg) {
16613         LDKCResult_PositiveTimestampCreationErrorZ* arg_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
16614         uint32_t ret_conv = CResult_PositiveTimestampCreationErrorZ_clone_ptr(arg_conv);
16615         return ret_conv;
16616 }
16617
16618 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_clone"))) TS_CResult_PositiveTimestampCreationErrorZ_clone(uint32_t orig) {
16619         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
16620         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
16621         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
16622         return (uint32_t)ret_conv;
16623 }
16624
16625 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_ok"))) TS_CResult_NoneSemanticErrorZ_ok() {
16626         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
16627         *ret_conv = CResult_NoneSemanticErrorZ_ok();
16628         return (uint32_t)ret_conv;
16629 }
16630
16631 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_err"))) TS_CResult_NoneSemanticErrorZ_err(uint32_t e) {
16632         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
16633         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
16634         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
16635         return (uint32_t)ret_conv;
16636 }
16637
16638 jboolean  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_is_ok"))) TS_CResult_NoneSemanticErrorZ_is_ok(uint32_t o) {
16639         LDKCResult_NoneSemanticErrorZ* o_conv = (LDKCResult_NoneSemanticErrorZ*)(o & ~1);
16640         jboolean ret_conv = CResult_NoneSemanticErrorZ_is_ok(o_conv);
16641         return ret_conv;
16642 }
16643
16644 void  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_free"))) TS_CResult_NoneSemanticErrorZ_free(uint32_t _res) {
16645         if ((_res & 1) != 0) return;
16646         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16647         CHECK_ACCESS(_res_ptr);
16648         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
16649         FREE((void*)_res);
16650         CResult_NoneSemanticErrorZ_free(_res_conv);
16651 }
16652
16653 static inline uintptr_t CResult_NoneSemanticErrorZ_clone_ptr(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR arg) {
16654         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
16655         *ret_conv = CResult_NoneSemanticErrorZ_clone(arg);
16656         return (uint32_t)ret_conv;
16657 }
16658 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_clone_ptr"))) TS_CResult_NoneSemanticErrorZ_clone_ptr(uint32_t arg) {
16659         LDKCResult_NoneSemanticErrorZ* arg_conv = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
16660         uint32_t ret_conv = CResult_NoneSemanticErrorZ_clone_ptr(arg_conv);
16661         return ret_conv;
16662 }
16663
16664 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_clone"))) TS_CResult_NoneSemanticErrorZ_clone(uint32_t orig) {
16665         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
16666         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
16667         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
16668         return (uint32_t)ret_conv;
16669 }
16670
16671 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_ok"))) TS_CResult_InvoiceSemanticErrorZ_ok(uint32_t o) {
16672         LDKInvoice o_conv;
16673         o_conv.inner = (void*)(o & (~1));
16674         o_conv.is_owned = (o & 1) || (o == 0);
16675         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16676         o_conv = Invoice_clone(&o_conv);
16677         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
16678         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
16679         return (uint32_t)ret_conv;
16680 }
16681
16682 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_err"))) TS_CResult_InvoiceSemanticErrorZ_err(uint32_t e) {
16683         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
16684         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
16685         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
16686         return (uint32_t)ret_conv;
16687 }
16688
16689 jboolean  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_is_ok"))) TS_CResult_InvoiceSemanticErrorZ_is_ok(uint32_t o) {
16690         LDKCResult_InvoiceSemanticErrorZ* o_conv = (LDKCResult_InvoiceSemanticErrorZ*)(o & ~1);
16691         jboolean ret_conv = CResult_InvoiceSemanticErrorZ_is_ok(o_conv);
16692         return ret_conv;
16693 }
16694
16695 void  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_free"))) TS_CResult_InvoiceSemanticErrorZ_free(uint32_t _res) {
16696         if ((_res & 1) != 0) return;
16697         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16698         CHECK_ACCESS(_res_ptr);
16699         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
16700         FREE((void*)_res);
16701         CResult_InvoiceSemanticErrorZ_free(_res_conv);
16702 }
16703
16704 static inline uintptr_t CResult_InvoiceSemanticErrorZ_clone_ptr(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR arg) {
16705         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
16706         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(arg);
16707         return (uint32_t)ret_conv;
16708 }
16709 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_clone_ptr"))) TS_CResult_InvoiceSemanticErrorZ_clone_ptr(uint32_t arg) {
16710         LDKCResult_InvoiceSemanticErrorZ* arg_conv = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
16711         uint32_t ret_conv = CResult_InvoiceSemanticErrorZ_clone_ptr(arg_conv);
16712         return ret_conv;
16713 }
16714
16715 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_clone"))) TS_CResult_InvoiceSemanticErrorZ_clone(uint32_t orig) {
16716         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
16717         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
16718         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
16719         return (uint32_t)ret_conv;
16720 }
16721
16722 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_ok"))) TS_CResult_DescriptionCreationErrorZ_ok(uint32_t o) {
16723         LDKDescription o_conv;
16724         o_conv.inner = (void*)(o & (~1));
16725         o_conv.is_owned = (o & 1) || (o == 0);
16726         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16727         o_conv = Description_clone(&o_conv);
16728         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
16729         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
16730         return (uint32_t)ret_conv;
16731 }
16732
16733 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_err"))) TS_CResult_DescriptionCreationErrorZ_err(uint32_t e) {
16734         LDKCreationError e_conv = LDKCreationError_from_js(e);
16735         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
16736         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
16737         return (uint32_t)ret_conv;
16738 }
16739
16740 jboolean  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_is_ok"))) TS_CResult_DescriptionCreationErrorZ_is_ok(uint32_t o) {
16741         LDKCResult_DescriptionCreationErrorZ* o_conv = (LDKCResult_DescriptionCreationErrorZ*)(o & ~1);
16742         jboolean ret_conv = CResult_DescriptionCreationErrorZ_is_ok(o_conv);
16743         return ret_conv;
16744 }
16745
16746 void  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_free"))) TS_CResult_DescriptionCreationErrorZ_free(uint32_t _res) {
16747         if ((_res & 1) != 0) return;
16748         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16749         CHECK_ACCESS(_res_ptr);
16750         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
16751         FREE((void*)_res);
16752         CResult_DescriptionCreationErrorZ_free(_res_conv);
16753 }
16754
16755 static inline uintptr_t CResult_DescriptionCreationErrorZ_clone_ptr(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR arg) {
16756         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
16757         *ret_conv = CResult_DescriptionCreationErrorZ_clone(arg);
16758         return (uint32_t)ret_conv;
16759 }
16760 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_clone_ptr"))) TS_CResult_DescriptionCreationErrorZ_clone_ptr(uint32_t arg) {
16761         LDKCResult_DescriptionCreationErrorZ* arg_conv = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
16762         uint32_t ret_conv = CResult_DescriptionCreationErrorZ_clone_ptr(arg_conv);
16763         return ret_conv;
16764 }
16765
16766 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_clone"))) TS_CResult_DescriptionCreationErrorZ_clone(uint32_t orig) {
16767         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
16768         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
16769         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
16770         return (uint32_t)ret_conv;
16771 }
16772
16773 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_ok"))) TS_CResult_PrivateRouteCreationErrorZ_ok(uint32_t o) {
16774         LDKPrivateRoute o_conv;
16775         o_conv.inner = (void*)(o & (~1));
16776         o_conv.is_owned = (o & 1) || (o == 0);
16777         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16778         o_conv = PrivateRoute_clone(&o_conv);
16779         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
16780         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
16781         return (uint32_t)ret_conv;
16782 }
16783
16784 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_err"))) TS_CResult_PrivateRouteCreationErrorZ_err(uint32_t e) {
16785         LDKCreationError e_conv = LDKCreationError_from_js(e);
16786         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
16787         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
16788         return (uint32_t)ret_conv;
16789 }
16790
16791 jboolean  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_is_ok"))) TS_CResult_PrivateRouteCreationErrorZ_is_ok(uint32_t o) {
16792         LDKCResult_PrivateRouteCreationErrorZ* o_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(o & ~1);
16793         jboolean ret_conv = CResult_PrivateRouteCreationErrorZ_is_ok(o_conv);
16794         return ret_conv;
16795 }
16796
16797 void  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_free"))) TS_CResult_PrivateRouteCreationErrorZ_free(uint32_t _res) {
16798         if ((_res & 1) != 0) return;
16799         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16800         CHECK_ACCESS(_res_ptr);
16801         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
16802         FREE((void*)_res);
16803         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
16804 }
16805
16806 static inline uintptr_t CResult_PrivateRouteCreationErrorZ_clone_ptr(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR arg) {
16807         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
16808         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(arg);
16809         return (uint32_t)ret_conv;
16810 }
16811 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_clone_ptr"))) TS_CResult_PrivateRouteCreationErrorZ_clone_ptr(uint32_t arg) {
16812         LDKCResult_PrivateRouteCreationErrorZ* arg_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
16813         uint32_t ret_conv = CResult_PrivateRouteCreationErrorZ_clone_ptr(arg_conv);
16814         return ret_conv;
16815 }
16816
16817 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_clone"))) TS_CResult_PrivateRouteCreationErrorZ_clone(uint32_t orig) {
16818         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
16819         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
16820         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
16821         return (uint32_t)ret_conv;
16822 }
16823
16824 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_ok"))) TS_CResult_StringErrorZ_ok(jstring o) {
16825         LDKStr o_conv = str_ref_to_owned_c(o);
16826         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
16827         *ret_conv = CResult_StringErrorZ_ok(o_conv);
16828         return (uint32_t)ret_conv;
16829 }
16830
16831 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_err"))) TS_CResult_StringErrorZ_err(uint32_t e) {
16832         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
16833         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
16834         *ret_conv = CResult_StringErrorZ_err(e_conv);
16835         return (uint32_t)ret_conv;
16836 }
16837
16838 jboolean  __attribute__((export_name("TS_CResult_StringErrorZ_is_ok"))) TS_CResult_StringErrorZ_is_ok(uint32_t o) {
16839         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)(o & ~1);
16840         jboolean ret_conv = CResult_StringErrorZ_is_ok(o_conv);
16841         return ret_conv;
16842 }
16843
16844 void  __attribute__((export_name("TS_CResult_StringErrorZ_free"))) TS_CResult_StringErrorZ_free(uint32_t _res) {
16845         if ((_res & 1) != 0) return;
16846         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16847         CHECK_ACCESS(_res_ptr);
16848         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
16849         FREE((void*)_res);
16850         CResult_StringErrorZ_free(_res_conv);
16851 }
16852
16853 static inline uintptr_t CResult_StringErrorZ_clone_ptr(LDKCResult_StringErrorZ *NONNULL_PTR arg) {
16854         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
16855         *ret_conv = CResult_StringErrorZ_clone(arg);
16856         return (uint32_t)ret_conv;
16857 }
16858 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_clone_ptr"))) TS_CResult_StringErrorZ_clone_ptr(uint32_t arg) {
16859         LDKCResult_StringErrorZ* arg_conv = (LDKCResult_StringErrorZ*)(arg & ~1);
16860         uint32_t ret_conv = CResult_StringErrorZ_clone_ptr(arg_conv);
16861         return ret_conv;
16862 }
16863
16864 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_clone"))) TS_CResult_StringErrorZ_clone(uint32_t orig) {
16865         LDKCResult_StringErrorZ* orig_conv = (LDKCResult_StringErrorZ*)(orig & ~1);
16866         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
16867         *ret_conv = CResult_StringErrorZ_clone(orig_conv);
16868         return (uint32_t)ret_conv;
16869 }
16870
16871 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok(uint32_t o) {
16872         LDKChannelMonitorUpdate o_conv;
16873         o_conv.inner = (void*)(o & (~1));
16874         o_conv.is_owned = (o & 1) || (o == 0);
16875         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16876         o_conv = ChannelMonitorUpdate_clone(&o_conv);
16877         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
16878         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
16879         return (uint32_t)ret_conv;
16880 }
16881
16882 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err(uint32_t e) {
16883         LDKDecodeError e_conv;
16884         e_conv.inner = (void*)(e & (~1));
16885         e_conv.is_owned = (e & 1) || (e == 0);
16886         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16887         e_conv = DecodeError_clone(&e_conv);
16888         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
16889         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
16890         return (uint32_t)ret_conv;
16891 }
16892
16893 jboolean  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(uint32_t o) {
16894         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(o & ~1);
16895         jboolean ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
16896         return ret_conv;
16897 }
16898
16899 void  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free(uint32_t _res) {
16900         if ((_res & 1) != 0) return;
16901         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16902         CHECK_ACCESS(_res_ptr);
16903         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
16904         FREE((void*)_res);
16905         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
16906 }
16907
16908 static inline uintptr_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
16909         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
16910         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
16911         return (uint32_t)ret_conv;
16912 }
16913 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
16914         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
16915         uint32_t ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
16916         return ret_conv;
16917 }
16918
16919 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone(uint32_t orig) {
16920         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
16921         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
16922         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
16923         return (uint32_t)ret_conv;
16924 }
16925
16926 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_some"))) TS_COption_MonitorEventZ_some(uint32_t o) {
16927         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16928         CHECK_ACCESS(o_ptr);
16929         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
16930         o_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uintptr_t)o) & ~1));
16931         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
16932         *ret_copy = COption_MonitorEventZ_some(o_conv);
16933         uint32_t ret_ref = (uintptr_t)ret_copy;
16934         return ret_ref;
16935 }
16936
16937 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_none"))) TS_COption_MonitorEventZ_none() {
16938         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
16939         *ret_copy = COption_MonitorEventZ_none();
16940         uint32_t ret_ref = (uintptr_t)ret_copy;
16941         return ret_ref;
16942 }
16943
16944 void  __attribute__((export_name("TS_COption_MonitorEventZ_free"))) TS_COption_MonitorEventZ_free(uint32_t _res) {
16945         if ((_res & 1) != 0) return;
16946         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16947         CHECK_ACCESS(_res_ptr);
16948         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
16949         FREE((void*)_res);
16950         COption_MonitorEventZ_free(_res_conv);
16951 }
16952
16953 static inline uintptr_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
16954         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
16955         *ret_copy = COption_MonitorEventZ_clone(arg);
16956 uint32_t ret_ref = (uintptr_t)ret_copy;
16957         return ret_ref;
16958 }
16959 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_clone_ptr"))) TS_COption_MonitorEventZ_clone_ptr(uint32_t arg) {
16960         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)arg;
16961         uint32_t ret_conv = COption_MonitorEventZ_clone_ptr(arg_conv);
16962         return ret_conv;
16963 }
16964
16965 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_clone"))) TS_COption_MonitorEventZ_clone(uint32_t orig) {
16966         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)orig;
16967         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
16968         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
16969         uint32_t ret_ref = (uintptr_t)ret_copy;
16970         return ret_ref;
16971 }
16972
16973 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_ok(uint32_t o) {
16974         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16975         CHECK_ACCESS(o_ptr);
16976         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
16977         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)(((uintptr_t)o) & ~1));
16978         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
16979         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
16980         return (uint32_t)ret_conv;
16981 }
16982
16983 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_err"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_err(uint32_t e) {
16984         LDKDecodeError e_conv;
16985         e_conv.inner = (void*)(e & (~1));
16986         e_conv.is_owned = (e & 1) || (e == 0);
16987         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16988         e_conv = DecodeError_clone(&e_conv);
16989         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
16990         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
16991         return (uint32_t)ret_conv;
16992 }
16993
16994 jboolean  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_is_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_is_ok(uint32_t o) {
16995         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(o & ~1);
16996         jboolean ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
16997         return ret_conv;
16998 }
16999
17000 void  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_free"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_free(uint32_t _res) {
17001         if ((_res & 1) != 0) return;
17002         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17003         CHECK_ACCESS(_res_ptr);
17004         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
17005         FREE((void*)_res);
17006         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
17007 }
17008
17009 static inline uintptr_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
17010         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
17011         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
17012         return (uint32_t)ret_conv;
17013 }
17014 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(uint32_t arg) {
17015         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(arg & ~1);
17016         uint32_t ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
17017         return ret_conv;
17018 }
17019
17020 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_clone"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_clone(uint32_t orig) {
17021         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(orig & ~1);
17022         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
17023         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
17024         return (uint32_t)ret_conv;
17025 }
17026
17027 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_ok(uint32_t o) {
17028         LDKHTLCUpdate o_conv;
17029         o_conv.inner = (void*)(o & (~1));
17030         o_conv.is_owned = (o & 1) || (o == 0);
17031         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17032         o_conv = HTLCUpdate_clone(&o_conv);
17033         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
17034         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
17035         return (uint32_t)ret_conv;
17036 }
17037
17038 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_err"))) TS_CResult_HTLCUpdateDecodeErrorZ_err(uint32_t e) {
17039         LDKDecodeError e_conv;
17040         e_conv.inner = (void*)(e & (~1));
17041         e_conv.is_owned = (e & 1) || (e == 0);
17042         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17043         e_conv = DecodeError_clone(&e_conv);
17044         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
17045         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
17046         return (uint32_t)ret_conv;
17047 }
17048
17049 jboolean  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_is_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_is_ok(uint32_t o) {
17050         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(o & ~1);
17051         jboolean ret_conv = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
17052         return ret_conv;
17053 }
17054
17055 void  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_free"))) TS_CResult_HTLCUpdateDecodeErrorZ_free(uint32_t _res) {
17056         if ((_res & 1) != 0) return;
17057         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17058         CHECK_ACCESS(_res_ptr);
17059         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
17060         FREE((void*)_res);
17061         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
17062 }
17063
17064 static inline uintptr_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
17065         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
17066         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
17067         return (uint32_t)ret_conv;
17068 }
17069 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
17070         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
17071         uint32_t ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
17072         return ret_conv;
17073 }
17074
17075 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_clone"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone(uint32_t orig) {
17076         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
17077         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
17078         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
17079         return (uint32_t)ret_conv;
17080 }
17081
17082 static inline uintptr_t C2Tuple_OutPointScriptZ_clone_ptr(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR arg) {
17083         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
17084         *ret_conv = C2Tuple_OutPointScriptZ_clone(arg);
17085         return ((uint32_t)ret_conv);
17086 }
17087 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_clone_ptr"))) TS_C2Tuple_OutPointScriptZ_clone_ptr(uint32_t arg) {
17088         LDKC2Tuple_OutPointScriptZ* arg_conv = (LDKC2Tuple_OutPointScriptZ*)(arg & ~1);
17089         uint32_t ret_conv = C2Tuple_OutPointScriptZ_clone_ptr(arg_conv);
17090         return ret_conv;
17091 }
17092
17093 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_clone"))) TS_C2Tuple_OutPointScriptZ_clone(uint32_t orig) {
17094         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
17095         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
17096         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
17097         return ((uint32_t)ret_conv);
17098 }
17099
17100 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_new"))) TS_C2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
17101         LDKOutPoint a_conv;
17102         a_conv.inner = (void*)(a & (~1));
17103         a_conv.is_owned = (a & 1) || (a == 0);
17104         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
17105         a_conv = OutPoint_clone(&a_conv);
17106         LDKCVec_u8Z b_ref;
17107         b_ref.datalen = b->arr_len;
17108         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
17109         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
17110         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
17111         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
17112         return ((uint32_t)ret_conv);
17113 }
17114
17115 void  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_free"))) TS_C2Tuple_OutPointScriptZ_free(uint32_t _res) {
17116         if ((_res & 1) != 0) return;
17117         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17118         CHECK_ACCESS(_res_ptr);
17119         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
17120         FREE((void*)_res);
17121         C2Tuple_OutPointScriptZ_free(_res_conv);
17122 }
17123
17124 static inline uintptr_t C2Tuple_u32ScriptZ_clone_ptr(LDKC2Tuple_u32ScriptZ *NONNULL_PTR arg) {
17125         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
17126         *ret_conv = C2Tuple_u32ScriptZ_clone(arg);
17127         return ((uint32_t)ret_conv);
17128 }
17129 uint32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_clone_ptr"))) TS_C2Tuple_u32ScriptZ_clone_ptr(uint32_t arg) {
17130         LDKC2Tuple_u32ScriptZ* arg_conv = (LDKC2Tuple_u32ScriptZ*)(arg & ~1);
17131         uint32_t ret_conv = C2Tuple_u32ScriptZ_clone_ptr(arg_conv);
17132         return ret_conv;
17133 }
17134
17135 uint32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_clone"))) TS_C2Tuple_u32ScriptZ_clone(uint32_t orig) {
17136         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
17137         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
17138         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
17139         return ((uint32_t)ret_conv);
17140 }
17141
17142 uint32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_new"))) TS_C2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
17143         LDKCVec_u8Z b_ref;
17144         b_ref.datalen = b->arr_len;
17145         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
17146         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
17147         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
17148         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
17149         return ((uint32_t)ret_conv);
17150 }
17151
17152 void  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_free"))) TS_C2Tuple_u32ScriptZ_free(uint32_t _res) {
17153         if ((_res & 1) != 0) return;
17154         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17155         CHECK_ACCESS(_res_ptr);
17156         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
17157         FREE((void*)_res);
17158         C2Tuple_u32ScriptZ_free(_res_conv);
17159 }
17160
17161 void  __attribute__((export_name("TS_CVec_C2Tuple_u32ScriptZZ_free"))) TS_CVec_C2Tuple_u32ScriptZZ_free(uint32_tArray _res) {
17162         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
17163         _res_constr.datalen = _res->arr_len;
17164         if (_res_constr.datalen > 0)
17165                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
17166         else
17167                 _res_constr.data = NULL;
17168         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
17169         for (size_t v = 0; v < _res_constr.datalen; v++) {
17170                 uint32_t _res_conv_21 = _res_vals[v];
17171                 void* _res_conv_21_ptr = (void*)(((uintptr_t)_res_conv_21) & ~1);
17172                 CHECK_ACCESS(_res_conv_21_ptr);
17173                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
17174                 FREE((void*)_res_conv_21);
17175                 _res_constr.data[v] = _res_conv_21_conv;
17176         }
17177         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
17178 }
17179
17180 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR arg) {
17181         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
17182         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(arg);
17183         return ((uint32_t)ret_conv);
17184 }
17185 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(uint32_t arg) {
17186         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(arg & ~1);
17187         uint32_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(arg_conv);
17188         return ret_conv;
17189 }
17190
17191 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(uint32_t orig) {
17192         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
17193         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
17194         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
17195         return ((uint32_t)ret_conv);
17196 }
17197
17198 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
17199         LDKThirtyTwoBytes a_ref;
17200         CHECK(a->arr_len == 32);
17201         memcpy(a_ref.data, a->elems, 32); FREE(a);
17202         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
17203         b_constr.datalen = b->arr_len;
17204         if (b_constr.datalen > 0)
17205                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
17206         else
17207                 b_constr.data = NULL;
17208         uint32_t* b_vals = b->elems /* XXX b leaks */;
17209         for (size_t v = 0; v < b_constr.datalen; v++) {
17210                 uint32_t b_conv_21 = b_vals[v];
17211                 void* b_conv_21_ptr = (void*)(((uintptr_t)b_conv_21) & ~1);
17212                 CHECK_ACCESS(b_conv_21_ptr);
17213                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
17214                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uintptr_t)b_conv_21) & ~1));
17215                 b_constr.data[v] = b_conv_21_conv;
17216         }
17217         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
17218         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
17219         return ((uint32_t)ret_conv);
17220 }
17221
17222 void  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(uint32_t _res) {
17223         if ((_res & 1) != 0) return;
17224         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17225         CHECK_ACCESS(_res_ptr);
17226         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
17227         FREE((void*)_res);
17228         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
17229 }
17230
17231 void  __attribute__((export_name("TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(uint32_tArray _res) {
17232         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
17233         _res_constr.datalen = _res->arr_len;
17234         if (_res_constr.datalen > 0)
17235                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
17236         else
17237                 _res_constr.data = NULL;
17238         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
17239         for (size_t o = 0; o < _res_constr.datalen; o++) {
17240                 uint32_t _res_conv_40 = _res_vals[o];
17241                 void* _res_conv_40_ptr = (void*)(((uintptr_t)_res_conv_40) & ~1);
17242                 CHECK_ACCESS(_res_conv_40_ptr);
17243                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
17244                 FREE((void*)_res_conv_40);
17245                 _res_constr.data[o] = _res_conv_40_conv;
17246         }
17247         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
17248 }
17249
17250 void  __attribute__((export_name("TS_CVec_EventZ_free"))) TS_CVec_EventZ_free(uint32_tArray _res) {
17251         LDKCVec_EventZ _res_constr;
17252         _res_constr.datalen = _res->arr_len;
17253         if (_res_constr.datalen > 0)
17254                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
17255         else
17256                 _res_constr.data = NULL;
17257         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
17258         for (size_t h = 0; h < _res_constr.datalen; h++) {
17259                 uint32_t _res_conv_7 = _res_vals[h];
17260                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
17261                 CHECK_ACCESS(_res_conv_7_ptr);
17262                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
17263                 FREE((void*)_res_conv_7);
17264                 _res_constr.data[h] = _res_conv_7_conv;
17265         }
17266         CVec_EventZ_free(_res_constr);
17267 }
17268
17269 void  __attribute__((export_name("TS_CVec_TransactionZ_free"))) TS_CVec_TransactionZ_free(ptrArray _res) {
17270         LDKCVec_TransactionZ _res_constr;
17271         _res_constr.datalen = _res->arr_len;
17272         if (_res_constr.datalen > 0)
17273                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
17274         else
17275                 _res_constr.data = NULL;
17276         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
17277         for (size_t m = 0; m < _res_constr.datalen; m++) {
17278                 int8_tArray _res_conv_12 = _res_vals[m];
17279                 LDKTransaction _res_conv_12_ref;
17280                 _res_conv_12_ref.datalen = _res_conv_12->arr_len;
17281                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKTransaction Bytes");
17282                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, _res_conv_12_ref.datalen); FREE(_res_conv_12);
17283                 _res_conv_12_ref.data_is_owned = true;
17284                 _res_constr.data[m] = _res_conv_12_ref;
17285         }
17286         CVec_TransactionZ_free(_res_constr);
17287 }
17288
17289 static inline uintptr_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
17290         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
17291         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
17292         return ((uint32_t)ret_conv);
17293 }
17294 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_clone_ptr"))) TS_C2Tuple_u32TxOutZ_clone_ptr(uint32_t arg) {
17295         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)(arg & ~1);
17296         uint32_t ret_conv = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
17297         return ret_conv;
17298 }
17299
17300 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_clone"))) TS_C2Tuple_u32TxOutZ_clone(uint32_t orig) {
17301         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
17302         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
17303         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
17304         return ((uint32_t)ret_conv);
17305 }
17306
17307 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_new"))) TS_C2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
17308         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
17309         CHECK_ACCESS(b_ptr);
17310         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
17311         b_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)b) & ~1));
17312         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
17313         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
17314         return ((uint32_t)ret_conv);
17315 }
17316
17317 void  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_free"))) TS_C2Tuple_u32TxOutZ_free(uint32_t _res) {
17318         if ((_res & 1) != 0) return;
17319         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17320         CHECK_ACCESS(_res_ptr);
17321         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
17322         FREE((void*)_res);
17323         C2Tuple_u32TxOutZ_free(_res_conv);
17324 }
17325
17326 void  __attribute__((export_name("TS_CVec_C2Tuple_u32TxOutZZ_free"))) TS_CVec_C2Tuple_u32TxOutZZ_free(uint32_tArray _res) {
17327         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
17328         _res_constr.datalen = _res->arr_len;
17329         if (_res_constr.datalen > 0)
17330                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
17331         else
17332                 _res_constr.data = NULL;
17333         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
17334         for (size_t u = 0; u < _res_constr.datalen; u++) {
17335                 uint32_t _res_conv_20 = _res_vals[u];
17336                 void* _res_conv_20_ptr = (void*)(((uintptr_t)_res_conv_20) & ~1);
17337                 CHECK_ACCESS(_res_conv_20_ptr);
17338                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
17339                 FREE((void*)_res_conv_20);
17340                 _res_constr.data[u] = _res_conv_20_conv;
17341         }
17342         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
17343 }
17344
17345 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
17346         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
17347         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
17348         return ((uint32_t)ret_conv);
17349 }
17350 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(uint32_t arg) {
17351         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(arg & ~1);
17352         uint32_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
17353         return ret_conv;
17354 }
17355
17356 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(uint32_t orig) {
17357         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
17358         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
17359         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
17360         return ((uint32_t)ret_conv);
17361 }
17362
17363 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
17364         LDKThirtyTwoBytes a_ref;
17365         CHECK(a->arr_len == 32);
17366         memcpy(a_ref.data, a->elems, 32); FREE(a);
17367         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
17368         b_constr.datalen = b->arr_len;
17369         if (b_constr.datalen > 0)
17370                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
17371         else
17372                 b_constr.data = NULL;
17373         uint32_t* b_vals = b->elems /* XXX b leaks */;
17374         for (size_t u = 0; u < b_constr.datalen; u++) {
17375                 uint32_t b_conv_20 = b_vals[u];
17376                 void* b_conv_20_ptr = (void*)(((uintptr_t)b_conv_20) & ~1);
17377                 CHECK_ACCESS(b_conv_20_ptr);
17378                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
17379                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uintptr_t)b_conv_20) & ~1));
17380                 b_constr.data[u] = b_conv_20_conv;
17381         }
17382         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
17383         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
17384         return ((uint32_t)ret_conv);
17385 }
17386
17387 void  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(uint32_t _res) {
17388         if ((_res & 1) != 0) return;
17389         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17390         CHECK_ACCESS(_res_ptr);
17391         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
17392         FREE((void*)_res);
17393         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
17394 }
17395
17396 void  __attribute__((export_name("TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(uint32_tArray _res) {
17397         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
17398         _res_constr.datalen = _res->arr_len;
17399         if (_res_constr.datalen > 0)
17400                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
17401         else
17402                 _res_constr.data = NULL;
17403         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
17404         for (size_t n = 0; n < _res_constr.datalen; n++) {
17405                 uint32_t _res_conv_39 = _res_vals[n];
17406                 void* _res_conv_39_ptr = (void*)(((uintptr_t)_res_conv_39) & ~1);
17407                 CHECK_ACCESS(_res_conv_39_ptr);
17408                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
17409                 FREE((void*)_res_conv_39);
17410                 _res_constr.data[n] = _res_conv_39_conv;
17411         }
17412         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
17413 }
17414
17415 void  __attribute__((export_name("TS_CVec_BalanceZ_free"))) TS_CVec_BalanceZ_free(uint32_tArray _res) {
17416         LDKCVec_BalanceZ _res_constr;
17417         _res_constr.datalen = _res->arr_len;
17418         if (_res_constr.datalen > 0)
17419                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
17420         else
17421                 _res_constr.data = NULL;
17422         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
17423         for (size_t j = 0; j < _res_constr.datalen; j++) {
17424                 uint32_t _res_conv_9 = _res_vals[j];
17425                 void* _res_conv_9_ptr = (void*)(((uintptr_t)_res_conv_9) & ~1);
17426                 CHECK_ACCESS(_res_conv_9_ptr);
17427                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
17428                 FREE((void*)_res_conv_9);
17429                 _res_constr.data[j] = _res_conv_9_conv;
17430         }
17431         CVec_BalanceZ_free(_res_constr);
17432 }
17433
17434 static inline uintptr_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
17435         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
17436         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
17437         return ((uint32_t)ret_conv);
17438 }
17439 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_clone_ptr"))) TS_C2Tuple_BlockHashChannelMonitorZ_clone_ptr(uint32_t arg) {
17440         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(arg & ~1);
17441         uint32_t ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
17442         return ret_conv;
17443 }
17444
17445 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_clone"))) TS_C2Tuple_BlockHashChannelMonitorZ_clone(uint32_t orig) {
17446         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(orig & ~1);
17447         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
17448         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
17449         return ((uint32_t)ret_conv);
17450 }
17451
17452 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_new"))) TS_C2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
17453         LDKThirtyTwoBytes a_ref;
17454         CHECK(a->arr_len == 32);
17455         memcpy(a_ref.data, a->elems, 32); FREE(a);
17456         LDKChannelMonitor b_conv;
17457         b_conv.inner = (void*)(b & (~1));
17458         b_conv.is_owned = (b & 1) || (b == 0);
17459         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
17460         b_conv = ChannelMonitor_clone(&b_conv);
17461         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
17462         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
17463         return ((uint32_t)ret_conv);
17464 }
17465
17466 void  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_free"))) TS_C2Tuple_BlockHashChannelMonitorZ_free(uint32_t _res) {
17467         if ((_res & 1) != 0) return;
17468         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17469         CHECK_ACCESS(_res_ptr);
17470         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
17471         FREE((void*)_res);
17472         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
17473 }
17474
17475 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(uint32_t o) {
17476         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17477         CHECK_ACCESS(o_ptr);
17478         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
17479         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uintptr_t)o) & ~1));
17480         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
17481         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
17482         return (uint32_t)ret_conv;
17483 }
17484
17485 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(uint32_t e) {
17486         LDKDecodeError e_conv;
17487         e_conv.inner = (void*)(e & (~1));
17488         e_conv.is_owned = (e & 1) || (e == 0);
17489         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17490         e_conv = DecodeError_clone(&e_conv);
17491         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
17492         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
17493         return (uint32_t)ret_conv;
17494 }
17495
17496 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(uint32_t o) {
17497         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(o & ~1);
17498         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
17499         return ret_conv;
17500 }
17501
17502 void  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(uint32_t _res) {
17503         if ((_res & 1) != 0) return;
17504         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17505         CHECK_ACCESS(_res_ptr);
17506         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
17507         FREE((void*)_res);
17508         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
17509 }
17510
17511 static inline uintptr_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
17512         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
17513         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
17514         return (uint32_t)ret_conv;
17515 }
17516 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(uint32_t arg) {
17517         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
17518         uint32_t ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
17519         return ret_conv;
17520 }
17521
17522 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(uint32_t orig) {
17523         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(orig & ~1);
17524         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
17525         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
17526         return (uint32_t)ret_conv;
17527 }
17528
17529 static inline uintptr_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
17530         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
17531         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
17532         return ((uint32_t)ret_conv);
17533 }
17534 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_clone_ptr"))) TS_C2Tuple_PublicKeyTypeZ_clone_ptr(uint32_t arg) {
17535         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)(arg & ~1);
17536         uint32_t ret_conv = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
17537         return ret_conv;
17538 }
17539
17540 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_clone"))) TS_C2Tuple_PublicKeyTypeZ_clone(uint32_t orig) {
17541         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1);
17542         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
17543         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
17544         return ((uint32_t)ret_conv);
17545 }
17546
17547 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_new"))) TS_C2Tuple_PublicKeyTypeZ_new(int8_tArray a, uint32_t b) {
17548         LDKPublicKey a_ref;
17549         CHECK(a->arr_len == 33);
17550         memcpy(a_ref.compressed_form, a->elems, 33); FREE(a);
17551         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
17552         CHECK_ACCESS(b_ptr);
17553         LDKType b_conv = *(LDKType*)(b_ptr);
17554         if (b_conv.free == LDKType_JCalls_free) {
17555                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
17556                 LDKType_JCalls_cloned(&b_conv);
17557         }
17558         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
17559         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
17560         return ((uint32_t)ret_conv);
17561 }
17562
17563 void  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_free"))) TS_C2Tuple_PublicKeyTypeZ_free(uint32_t _res) {
17564         if ((_res & 1) != 0) return;
17565         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17566         CHECK_ACCESS(_res_ptr);
17567         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
17568         FREE((void*)_res);
17569         C2Tuple_PublicKeyTypeZ_free(_res_conv);
17570 }
17571
17572 void  __attribute__((export_name("TS_CVec_C2Tuple_PublicKeyTypeZZ_free"))) TS_CVec_C2Tuple_PublicKeyTypeZZ_free(uint32_tArray _res) {
17573         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
17574         _res_constr.datalen = _res->arr_len;
17575         if (_res_constr.datalen > 0)
17576                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
17577         else
17578                 _res_constr.data = NULL;
17579         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
17580         for (size_t z = 0; z < _res_constr.datalen; z++) {
17581                 uint32_t _res_conv_25 = _res_vals[z];
17582                 void* _res_conv_25_ptr = (void*)(((uintptr_t)_res_conv_25) & ~1);
17583                 CHECK_ACCESS(_res_conv_25_ptr);
17584                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
17585                 FREE((void*)_res_conv_25);
17586                 _res_constr.data[z] = _res_conv_25_conv;
17587         }
17588         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
17589 }
17590
17591 uint32_t  __attribute__((export_name("TS_COption_NetAddressZ_some"))) TS_COption_NetAddressZ_some(uint32_t o) {
17592         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17593         CHECK_ACCESS(o_ptr);
17594         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
17595         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
17596         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
17597         *ret_copy = COption_NetAddressZ_some(o_conv);
17598         uint32_t ret_ref = (uintptr_t)ret_copy;
17599         return ret_ref;
17600 }
17601
17602 uint32_t  __attribute__((export_name("TS_COption_NetAddressZ_none"))) TS_COption_NetAddressZ_none() {
17603         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
17604         *ret_copy = COption_NetAddressZ_none();
17605         uint32_t ret_ref = (uintptr_t)ret_copy;
17606         return ret_ref;
17607 }
17608
17609 void  __attribute__((export_name("TS_COption_NetAddressZ_free"))) TS_COption_NetAddressZ_free(uint32_t _res) {
17610         if ((_res & 1) != 0) return;
17611         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17612         CHECK_ACCESS(_res_ptr);
17613         LDKCOption_NetAddressZ _res_conv = *(LDKCOption_NetAddressZ*)(_res_ptr);
17614         FREE((void*)_res);
17615         COption_NetAddressZ_free(_res_conv);
17616 }
17617
17618 static inline uintptr_t COption_NetAddressZ_clone_ptr(LDKCOption_NetAddressZ *NONNULL_PTR arg) {
17619         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
17620         *ret_copy = COption_NetAddressZ_clone(arg);
17621 uint32_t ret_ref = (uintptr_t)ret_copy;
17622         return ret_ref;
17623 }
17624 uint32_t  __attribute__((export_name("TS_COption_NetAddressZ_clone_ptr"))) TS_COption_NetAddressZ_clone_ptr(uint32_t arg) {
17625         LDKCOption_NetAddressZ* arg_conv = (LDKCOption_NetAddressZ*)arg;
17626         uint32_t ret_conv = COption_NetAddressZ_clone_ptr(arg_conv);
17627         return ret_conv;
17628 }
17629
17630 uint32_t  __attribute__((export_name("TS_COption_NetAddressZ_clone"))) TS_COption_NetAddressZ_clone(uint32_t orig) {
17631         LDKCOption_NetAddressZ* orig_conv = (LDKCOption_NetAddressZ*)orig;
17632         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
17633         *ret_copy = COption_NetAddressZ_clone(orig_conv);
17634         uint32_t ret_ref = (uintptr_t)ret_copy;
17635         return ret_ref;
17636 }
17637
17638 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_ok(int8_tArray o) {
17639         LDKCVec_u8Z o_ref;
17640         o_ref.datalen = o->arr_len;
17641         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
17642         memcpy(o_ref.data, o->elems, o_ref.datalen); FREE(o);
17643         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
17644         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
17645         return (uint32_t)ret_conv;
17646 }
17647
17648 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_err"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_err(uint32_t e) {
17649         LDKPeerHandleError e_conv;
17650         e_conv.inner = (void*)(e & (~1));
17651         e_conv.is_owned = (e & 1) || (e == 0);
17652         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17653         e_conv = PeerHandleError_clone(&e_conv);
17654         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
17655         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
17656         return (uint32_t)ret_conv;
17657 }
17658
17659 jboolean  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_is_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_is_ok(uint32_t o) {
17660         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(o & ~1);
17661         jboolean ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
17662         return ret_conv;
17663 }
17664
17665 void  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_free"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_free(uint32_t _res) {
17666         if ((_res & 1) != 0) return;
17667         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17668         CHECK_ACCESS(_res_ptr);
17669         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
17670         FREE((void*)_res);
17671         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
17672 }
17673
17674 static inline uintptr_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
17675         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
17676         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
17677         return (uint32_t)ret_conv;
17678 }
17679 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(uint32_t arg) {
17680         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
17681         uint32_t ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
17682         return ret_conv;
17683 }
17684
17685 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_clone"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone(uint32_t orig) {
17686         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
17687         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
17688         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
17689         return (uint32_t)ret_conv;
17690 }
17691
17692 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_ok"))) TS_CResult_NonePeerHandleErrorZ_ok() {
17693         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
17694         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
17695         return (uint32_t)ret_conv;
17696 }
17697
17698 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_err"))) TS_CResult_NonePeerHandleErrorZ_err(uint32_t e) {
17699         LDKPeerHandleError e_conv;
17700         e_conv.inner = (void*)(e & (~1));
17701         e_conv.is_owned = (e & 1) || (e == 0);
17702         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17703         e_conv = PeerHandleError_clone(&e_conv);
17704         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
17705         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
17706         return (uint32_t)ret_conv;
17707 }
17708
17709 jboolean  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_is_ok"))) TS_CResult_NonePeerHandleErrorZ_is_ok(uint32_t o) {
17710         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)(o & ~1);
17711         jboolean ret_conv = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
17712         return ret_conv;
17713 }
17714
17715 void  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_free"))) TS_CResult_NonePeerHandleErrorZ_free(uint32_t _res) {
17716         if ((_res & 1) != 0) return;
17717         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17718         CHECK_ACCESS(_res_ptr);
17719         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
17720         FREE((void*)_res);
17721         CResult_NonePeerHandleErrorZ_free(_res_conv);
17722 }
17723
17724 static inline uintptr_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
17725         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
17726         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
17727         return (uint32_t)ret_conv;
17728 }
17729 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_clone_ptr"))) TS_CResult_NonePeerHandleErrorZ_clone_ptr(uint32_t arg) {
17730         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
17731         uint32_t ret_conv = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
17732         return ret_conv;
17733 }
17734
17735 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_clone"))) TS_CResult_NonePeerHandleErrorZ_clone(uint32_t orig) {
17736         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
17737         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
17738         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
17739         return (uint32_t)ret_conv;
17740 }
17741
17742 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_ok"))) TS_CResult_boolPeerHandleErrorZ_ok(jboolean o) {
17743         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
17744         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
17745         return (uint32_t)ret_conv;
17746 }
17747
17748 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_err"))) TS_CResult_boolPeerHandleErrorZ_err(uint32_t e) {
17749         LDKPeerHandleError e_conv;
17750         e_conv.inner = (void*)(e & (~1));
17751         e_conv.is_owned = (e & 1) || (e == 0);
17752         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17753         e_conv = PeerHandleError_clone(&e_conv);
17754         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
17755         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
17756         return (uint32_t)ret_conv;
17757 }
17758
17759 jboolean  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_is_ok"))) TS_CResult_boolPeerHandleErrorZ_is_ok(uint32_t o) {
17760         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)(o & ~1);
17761         jboolean ret_conv = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
17762         return ret_conv;
17763 }
17764
17765 void  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_free"))) TS_CResult_boolPeerHandleErrorZ_free(uint32_t _res) {
17766         if ((_res & 1) != 0) return;
17767         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17768         CHECK_ACCESS(_res_ptr);
17769         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
17770         FREE((void*)_res);
17771         CResult_boolPeerHandleErrorZ_free(_res_conv);
17772 }
17773
17774 static inline uintptr_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
17775         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
17776         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
17777         return (uint32_t)ret_conv;
17778 }
17779 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_clone_ptr"))) TS_CResult_boolPeerHandleErrorZ_clone_ptr(uint32_t arg) {
17780         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
17781         uint32_t ret_conv = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
17782         return ret_conv;
17783 }
17784
17785 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_clone"))) TS_CResult_boolPeerHandleErrorZ_clone(uint32_t orig) {
17786         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
17787         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
17788         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
17789         return (uint32_t)ret_conv;
17790 }
17791
17792 uint32_t  __attribute__((export_name("TS_CResult_NoneErrorZ_ok"))) TS_CResult_NoneErrorZ_ok() {
17793         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
17794         *ret_conv = CResult_NoneErrorZ_ok();
17795         return (uint32_t)ret_conv;
17796 }
17797
17798 uint32_t  __attribute__((export_name("TS_CResult_NoneErrorZ_err"))) TS_CResult_NoneErrorZ_err(uint32_t e) {
17799         LDKIOError e_conv = LDKIOError_from_js(e);
17800         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
17801         *ret_conv = CResult_NoneErrorZ_err(e_conv);
17802         return (uint32_t)ret_conv;
17803 }
17804
17805 jboolean  __attribute__((export_name("TS_CResult_NoneErrorZ_is_ok"))) TS_CResult_NoneErrorZ_is_ok(uint32_t o) {
17806         LDKCResult_NoneErrorZ* o_conv = (LDKCResult_NoneErrorZ*)(o & ~1);
17807         jboolean ret_conv = CResult_NoneErrorZ_is_ok(o_conv);
17808         return ret_conv;
17809 }
17810
17811 void  __attribute__((export_name("TS_CResult_NoneErrorZ_free"))) TS_CResult_NoneErrorZ_free(uint32_t _res) {
17812         if ((_res & 1) != 0) return;
17813         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17814         CHECK_ACCESS(_res_ptr);
17815         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(_res_ptr);
17816         FREE((void*)_res);
17817         CResult_NoneErrorZ_free(_res_conv);
17818 }
17819
17820 static inline uintptr_t CResult_NoneErrorZ_clone_ptr(LDKCResult_NoneErrorZ *NONNULL_PTR arg) {
17821         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
17822         *ret_conv = CResult_NoneErrorZ_clone(arg);
17823         return (uint32_t)ret_conv;
17824 }
17825 uint32_t  __attribute__((export_name("TS_CResult_NoneErrorZ_clone_ptr"))) TS_CResult_NoneErrorZ_clone_ptr(uint32_t arg) {
17826         LDKCResult_NoneErrorZ* arg_conv = (LDKCResult_NoneErrorZ*)(arg & ~1);
17827         uint32_t ret_conv = CResult_NoneErrorZ_clone_ptr(arg_conv);
17828         return ret_conv;
17829 }
17830
17831 uint32_t  __attribute__((export_name("TS_CResult_NoneErrorZ_clone"))) TS_CResult_NoneErrorZ_clone(uint32_t orig) {
17832         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
17833         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
17834         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
17835         return (uint32_t)ret_conv;
17836 }
17837
17838 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_ok"))) TS_CResult_NetAddressDecodeErrorZ_ok(uint32_t o) {
17839         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17840         CHECK_ACCESS(o_ptr);
17841         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
17842         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
17843         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17844         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
17845         return (uint32_t)ret_conv;
17846 }
17847
17848 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_err"))) TS_CResult_NetAddressDecodeErrorZ_err(uint32_t e) {
17849         LDKDecodeError e_conv;
17850         e_conv.inner = (void*)(e & (~1));
17851         e_conv.is_owned = (e & 1) || (e == 0);
17852         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17853         e_conv = DecodeError_clone(&e_conv);
17854         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17855         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
17856         return (uint32_t)ret_conv;
17857 }
17858
17859 jboolean  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_is_ok"))) TS_CResult_NetAddressDecodeErrorZ_is_ok(uint32_t o) {
17860         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)(o & ~1);
17861         jboolean ret_conv = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
17862         return ret_conv;
17863 }
17864
17865 void  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_free"))) TS_CResult_NetAddressDecodeErrorZ_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         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
17870         FREE((void*)_res);
17871         CResult_NetAddressDecodeErrorZ_free(_res_conv);
17872 }
17873
17874 static inline uintptr_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
17875         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17876         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
17877         return (uint32_t)ret_conv;
17878 }
17879 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_clone_ptr"))) TS_CResult_NetAddressDecodeErrorZ_clone_ptr(uint32_t arg) {
17880         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
17881         uint32_t ret_conv = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
17882         return ret_conv;
17883 }
17884
17885 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_clone"))) TS_CResult_NetAddressDecodeErrorZ_clone(uint32_t orig) {
17886         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
17887         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17888         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
17889         return (uint32_t)ret_conv;
17890 }
17891
17892 void  __attribute__((export_name("TS_CVec_UpdateAddHTLCZ_free"))) TS_CVec_UpdateAddHTLCZ_free(uint32_tArray _res) {
17893         LDKCVec_UpdateAddHTLCZ _res_constr;
17894         _res_constr.datalen = _res->arr_len;
17895         if (_res_constr.datalen > 0)
17896                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
17897         else
17898                 _res_constr.data = NULL;
17899         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
17900         for (size_t p = 0; p < _res_constr.datalen; p++) {
17901                 uint32_t _res_conv_15 = _res_vals[p];
17902                 LDKUpdateAddHTLC _res_conv_15_conv;
17903                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
17904                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
17905                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
17906                 _res_constr.data[p] = _res_conv_15_conv;
17907         }
17908         CVec_UpdateAddHTLCZ_free(_res_constr);
17909 }
17910
17911 void  __attribute__((export_name("TS_CVec_UpdateFulfillHTLCZ_free"))) TS_CVec_UpdateFulfillHTLCZ_free(uint32_tArray _res) {
17912         LDKCVec_UpdateFulfillHTLCZ _res_constr;
17913         _res_constr.datalen = _res->arr_len;
17914         if (_res_constr.datalen > 0)
17915                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
17916         else
17917                 _res_constr.data = NULL;
17918         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
17919         for (size_t t = 0; t < _res_constr.datalen; t++) {
17920                 uint32_t _res_conv_19 = _res_vals[t];
17921                 LDKUpdateFulfillHTLC _res_conv_19_conv;
17922                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
17923                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
17924                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
17925                 _res_constr.data[t] = _res_conv_19_conv;
17926         }
17927         CVec_UpdateFulfillHTLCZ_free(_res_constr);
17928 }
17929
17930 void  __attribute__((export_name("TS_CVec_UpdateFailHTLCZ_free"))) TS_CVec_UpdateFailHTLCZ_free(uint32_tArray _res) {
17931         LDKCVec_UpdateFailHTLCZ _res_constr;
17932         _res_constr.datalen = _res->arr_len;
17933         if (_res_constr.datalen > 0)
17934                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
17935         else
17936                 _res_constr.data = NULL;
17937         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
17938         for (size_t q = 0; q < _res_constr.datalen; q++) {
17939                 uint32_t _res_conv_16 = _res_vals[q];
17940                 LDKUpdateFailHTLC _res_conv_16_conv;
17941                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
17942                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
17943                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
17944                 _res_constr.data[q] = _res_conv_16_conv;
17945         }
17946         CVec_UpdateFailHTLCZ_free(_res_constr);
17947 }
17948
17949 void  __attribute__((export_name("TS_CVec_UpdateFailMalformedHTLCZ_free"))) TS_CVec_UpdateFailMalformedHTLCZ_free(uint32_tArray _res) {
17950         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
17951         _res_constr.datalen = _res->arr_len;
17952         if (_res_constr.datalen > 0)
17953                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
17954         else
17955                 _res_constr.data = NULL;
17956         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
17957         for (size_t z = 0; z < _res_constr.datalen; z++) {
17958                 uint32_t _res_conv_25 = _res_vals[z];
17959                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
17960                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
17961                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
17962                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
17963                 _res_constr.data[z] = _res_conv_25_conv;
17964         }
17965         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
17966 }
17967
17968 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_ok(uint32_t o) {
17969         LDKAcceptChannel o_conv;
17970         o_conv.inner = (void*)(o & (~1));
17971         o_conv.is_owned = (o & 1) || (o == 0);
17972         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17973         o_conv = AcceptChannel_clone(&o_conv);
17974         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
17975         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
17976         return (uint32_t)ret_conv;
17977 }
17978
17979 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_err"))) TS_CResult_AcceptChannelDecodeErrorZ_err(uint32_t e) {
17980         LDKDecodeError e_conv;
17981         e_conv.inner = (void*)(e & (~1));
17982         e_conv.is_owned = (e & 1) || (e == 0);
17983         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17984         e_conv = DecodeError_clone(&e_conv);
17985         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
17986         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
17987         return (uint32_t)ret_conv;
17988 }
17989
17990 jboolean  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_is_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_is_ok(uint32_t o) {
17991         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(o & ~1);
17992         jboolean ret_conv = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
17993         return ret_conv;
17994 }
17995
17996 void  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_free"))) TS_CResult_AcceptChannelDecodeErrorZ_free(uint32_t _res) {
17997         if ((_res & 1) != 0) return;
17998         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17999         CHECK_ACCESS(_res_ptr);
18000         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
18001         FREE((void*)_res);
18002         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
18003 }
18004
18005 static inline uintptr_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
18006         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
18007         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
18008         return (uint32_t)ret_conv;
18009 }
18010 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_clone_ptr"))) TS_CResult_AcceptChannelDecodeErrorZ_clone_ptr(uint32_t arg) {
18011         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
18012         uint32_t ret_conv = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
18013         return ret_conv;
18014 }
18015
18016 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_clone"))) TS_CResult_AcceptChannelDecodeErrorZ_clone(uint32_t orig) {
18017         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
18018         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
18019         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
18020         return (uint32_t)ret_conv;
18021 }
18022
18023 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok(uint32_t o) {
18024         LDKAnnouncementSignatures o_conv;
18025         o_conv.inner = (void*)(o & (~1));
18026         o_conv.is_owned = (o & 1) || (o == 0);
18027         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18028         o_conv = AnnouncementSignatures_clone(&o_conv);
18029         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
18030         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
18031         return (uint32_t)ret_conv;
18032 }
18033
18034 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_err"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_err(uint32_t e) {
18035         LDKDecodeError e_conv;
18036         e_conv.inner = (void*)(e & (~1));
18037         e_conv.is_owned = (e & 1) || (e == 0);
18038         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18039         e_conv = DecodeError_clone(&e_conv);
18040         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
18041         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
18042         return (uint32_t)ret_conv;
18043 }
18044
18045 jboolean  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_is_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(uint32_t o) {
18046         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(o & ~1);
18047         jboolean ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
18048         return ret_conv;
18049 }
18050
18051 void  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_free"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_free(uint32_t _res) {
18052         if ((_res & 1) != 0) return;
18053         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18054         CHECK_ACCESS(_res_ptr);
18055         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
18056         FREE((void*)_res);
18057         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
18058 }
18059
18060 static inline uintptr_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
18061         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
18062         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
18063         return (uint32_t)ret_conv;
18064 }
18065 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
18066         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
18067         uint32_t ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
18068         return ret_conv;
18069 }
18070
18071 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone(uint32_t orig) {
18072         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
18073         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
18074         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
18075         return (uint32_t)ret_conv;
18076 }
18077
18078 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_ok(uint32_t o) {
18079         LDKChannelReestablish o_conv;
18080         o_conv.inner = (void*)(o & (~1));
18081         o_conv.is_owned = (o & 1) || (o == 0);
18082         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18083         o_conv = ChannelReestablish_clone(&o_conv);
18084         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
18085         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
18086         return (uint32_t)ret_conv;
18087 }
18088
18089 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_err"))) TS_CResult_ChannelReestablishDecodeErrorZ_err(uint32_t e) {
18090         LDKDecodeError e_conv;
18091         e_conv.inner = (void*)(e & (~1));
18092         e_conv.is_owned = (e & 1) || (e == 0);
18093         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18094         e_conv = DecodeError_clone(&e_conv);
18095         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
18096         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
18097         return (uint32_t)ret_conv;
18098 }
18099
18100 jboolean  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_is_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_is_ok(uint32_t o) {
18101         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(o & ~1);
18102         jboolean ret_conv = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
18103         return ret_conv;
18104 }
18105
18106 void  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_free"))) TS_CResult_ChannelReestablishDecodeErrorZ_free(uint32_t _res) {
18107         if ((_res & 1) != 0) return;
18108         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18109         CHECK_ACCESS(_res_ptr);
18110         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
18111         FREE((void*)_res);
18112         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
18113 }
18114
18115 static inline uintptr_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
18116         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
18117         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
18118         return (uint32_t)ret_conv;
18119 }
18120 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone_ptr(uint32_t arg) {
18121         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
18122         uint32_t ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
18123         return ret_conv;
18124 }
18125
18126 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_clone"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone(uint32_t orig) {
18127         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
18128         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
18129         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
18130         return (uint32_t)ret_conv;
18131 }
18132
18133 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_ok(uint32_t o) {
18134         LDKClosingSigned o_conv;
18135         o_conv.inner = (void*)(o & (~1));
18136         o_conv.is_owned = (o & 1) || (o == 0);
18137         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18138         o_conv = ClosingSigned_clone(&o_conv);
18139         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
18140         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
18141         return (uint32_t)ret_conv;
18142 }
18143
18144 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_err"))) TS_CResult_ClosingSignedDecodeErrorZ_err(uint32_t e) {
18145         LDKDecodeError e_conv;
18146         e_conv.inner = (void*)(e & (~1));
18147         e_conv.is_owned = (e & 1) || (e == 0);
18148         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18149         e_conv = DecodeError_clone(&e_conv);
18150         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
18151         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
18152         return (uint32_t)ret_conv;
18153 }
18154
18155 jboolean  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_is_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_is_ok(uint32_t o) {
18156         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(o & ~1);
18157         jboolean ret_conv = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
18158         return ret_conv;
18159 }
18160
18161 void  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_free"))) TS_CResult_ClosingSignedDecodeErrorZ_free(uint32_t _res) {
18162         if ((_res & 1) != 0) return;
18163         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18164         CHECK_ACCESS(_res_ptr);
18165         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
18166         FREE((void*)_res);
18167         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
18168 }
18169
18170 static inline uintptr_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
18171         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
18172         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
18173         return (uint32_t)ret_conv;
18174 }
18175 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_clone_ptr"))) TS_CResult_ClosingSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
18176         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
18177         uint32_t ret_conv = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
18178         return ret_conv;
18179 }
18180
18181 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_clone"))) TS_CResult_ClosingSignedDecodeErrorZ_clone(uint32_t orig) {
18182         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
18183         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
18184         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
18185         return (uint32_t)ret_conv;
18186 }
18187
18188 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(uint32_t o) {
18189         LDKClosingSignedFeeRange o_conv;
18190         o_conv.inner = (void*)(o & (~1));
18191         o_conv.is_owned = (o & 1) || (o == 0);
18192         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18193         o_conv = ClosingSignedFeeRange_clone(&o_conv);
18194         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
18195         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
18196         return (uint32_t)ret_conv;
18197 }
18198
18199 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_err"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_err(uint32_t e) {
18200         LDKDecodeError e_conv;
18201         e_conv.inner = (void*)(e & (~1));
18202         e_conv.is_owned = (e & 1) || (e == 0);
18203         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18204         e_conv = DecodeError_clone(&e_conv);
18205         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
18206         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
18207         return (uint32_t)ret_conv;
18208 }
18209
18210 jboolean  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(uint32_t o) {
18211         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(o & ~1);
18212         jboolean ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
18213         return ret_conv;
18214 }
18215
18216 void  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_free"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_free(uint32_t _res) {
18217         if ((_res & 1) != 0) return;
18218         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18219         CHECK_ACCESS(_res_ptr);
18220         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
18221         FREE((void*)_res);
18222         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
18223 }
18224
18225 static inline uintptr_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
18226         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
18227         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
18228         return (uint32_t)ret_conv;
18229 }
18230 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
18231         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
18232         uint32_t ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
18233         return ret_conv;
18234 }
18235
18236 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(uint32_t orig) {
18237         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1);
18238         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
18239         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
18240         return (uint32_t)ret_conv;
18241 }
18242
18243 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_ok(uint32_t o) {
18244         LDKCommitmentSigned o_conv;
18245         o_conv.inner = (void*)(o & (~1));
18246         o_conv.is_owned = (o & 1) || (o == 0);
18247         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18248         o_conv = CommitmentSigned_clone(&o_conv);
18249         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
18250         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
18251         return (uint32_t)ret_conv;
18252 }
18253
18254 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_err"))) TS_CResult_CommitmentSignedDecodeErrorZ_err(uint32_t e) {
18255         LDKDecodeError e_conv;
18256         e_conv.inner = (void*)(e & (~1));
18257         e_conv.is_owned = (e & 1) || (e == 0);
18258         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18259         e_conv = DecodeError_clone(&e_conv);
18260         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
18261         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
18262         return (uint32_t)ret_conv;
18263 }
18264
18265 jboolean  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_is_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_is_ok(uint32_t o) {
18266         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(o & ~1);
18267         jboolean ret_conv = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
18268         return ret_conv;
18269 }
18270
18271 void  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_free"))) TS_CResult_CommitmentSignedDecodeErrorZ_free(uint32_t _res) {
18272         if ((_res & 1) != 0) return;
18273         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18274         CHECK_ACCESS(_res_ptr);
18275         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
18276         FREE((void*)_res);
18277         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
18278 }
18279
18280 static inline uintptr_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
18281         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
18282         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
18283         return (uint32_t)ret_conv;
18284 }
18285 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_clone_ptr"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
18286         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
18287         uint32_t ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
18288         return ret_conv;
18289 }
18290
18291 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_clone"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone(uint32_t orig) {
18292         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
18293         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
18294         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
18295         return (uint32_t)ret_conv;
18296 }
18297
18298 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_ok(uint32_t o) {
18299         LDKFundingCreated o_conv;
18300         o_conv.inner = (void*)(o & (~1));
18301         o_conv.is_owned = (o & 1) || (o == 0);
18302         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18303         o_conv = FundingCreated_clone(&o_conv);
18304         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
18305         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
18306         return (uint32_t)ret_conv;
18307 }
18308
18309 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_err"))) TS_CResult_FundingCreatedDecodeErrorZ_err(uint32_t e) {
18310         LDKDecodeError e_conv;
18311         e_conv.inner = (void*)(e & (~1));
18312         e_conv.is_owned = (e & 1) || (e == 0);
18313         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18314         e_conv = DecodeError_clone(&e_conv);
18315         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
18316         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
18317         return (uint32_t)ret_conv;
18318 }
18319
18320 jboolean  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_is_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_is_ok(uint32_t o) {
18321         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(o & ~1);
18322         jboolean ret_conv = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
18323         return ret_conv;
18324 }
18325
18326 void  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_free"))) TS_CResult_FundingCreatedDecodeErrorZ_free(uint32_t _res) {
18327         if ((_res & 1) != 0) return;
18328         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18329         CHECK_ACCESS(_res_ptr);
18330         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
18331         FREE((void*)_res);
18332         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
18333 }
18334
18335 static inline uintptr_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
18336         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
18337         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
18338         return (uint32_t)ret_conv;
18339 }
18340 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_clone_ptr"))) TS_CResult_FundingCreatedDecodeErrorZ_clone_ptr(uint32_t arg) {
18341         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
18342         uint32_t ret_conv = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
18343         return ret_conv;
18344 }
18345
18346 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_clone"))) TS_CResult_FundingCreatedDecodeErrorZ_clone(uint32_t orig) {
18347         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
18348         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
18349         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
18350         return (uint32_t)ret_conv;
18351 }
18352
18353 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_ok"))) TS_CResult_FundingSignedDecodeErrorZ_ok(uint32_t o) {
18354         LDKFundingSigned o_conv;
18355         o_conv.inner = (void*)(o & (~1));
18356         o_conv.is_owned = (o & 1) || (o == 0);
18357         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18358         o_conv = FundingSigned_clone(&o_conv);
18359         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
18360         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
18361         return (uint32_t)ret_conv;
18362 }
18363
18364 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_err"))) TS_CResult_FundingSignedDecodeErrorZ_err(uint32_t e) {
18365         LDKDecodeError e_conv;
18366         e_conv.inner = (void*)(e & (~1));
18367         e_conv.is_owned = (e & 1) || (e == 0);
18368         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18369         e_conv = DecodeError_clone(&e_conv);
18370         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
18371         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
18372         return (uint32_t)ret_conv;
18373 }
18374
18375 jboolean  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_is_ok"))) TS_CResult_FundingSignedDecodeErrorZ_is_ok(uint32_t o) {
18376         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(o & ~1);
18377         jboolean ret_conv = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
18378         return ret_conv;
18379 }
18380
18381 void  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_free"))) TS_CResult_FundingSignedDecodeErrorZ_free(uint32_t _res) {
18382         if ((_res & 1) != 0) return;
18383         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18384         CHECK_ACCESS(_res_ptr);
18385         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
18386         FREE((void*)_res);
18387         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
18388 }
18389
18390 static inline uintptr_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
18391         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
18392         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
18393         return (uint32_t)ret_conv;
18394 }
18395 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_clone_ptr"))) TS_CResult_FundingSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
18396         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
18397         uint32_t ret_conv = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
18398         return ret_conv;
18399 }
18400
18401 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_clone"))) TS_CResult_FundingSignedDecodeErrorZ_clone(uint32_t orig) {
18402         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
18403         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
18404         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
18405         return (uint32_t)ret_conv;
18406 }
18407
18408 uint32_t  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_ok"))) TS_CResult_ChannelReadyDecodeErrorZ_ok(uint32_t o) {
18409         LDKChannelReady o_conv;
18410         o_conv.inner = (void*)(o & (~1));
18411         o_conv.is_owned = (o & 1) || (o == 0);
18412         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18413         o_conv = ChannelReady_clone(&o_conv);
18414         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
18415         *ret_conv = CResult_ChannelReadyDecodeErrorZ_ok(o_conv);
18416         return (uint32_t)ret_conv;
18417 }
18418
18419 uint32_t  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_err"))) TS_CResult_ChannelReadyDecodeErrorZ_err(uint32_t e) {
18420         LDKDecodeError e_conv;
18421         e_conv.inner = (void*)(e & (~1));
18422         e_conv.is_owned = (e & 1) || (e == 0);
18423         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18424         e_conv = DecodeError_clone(&e_conv);
18425         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
18426         *ret_conv = CResult_ChannelReadyDecodeErrorZ_err(e_conv);
18427         return (uint32_t)ret_conv;
18428 }
18429
18430 jboolean  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_is_ok"))) TS_CResult_ChannelReadyDecodeErrorZ_is_ok(uint32_t o) {
18431         LDKCResult_ChannelReadyDecodeErrorZ* o_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(o & ~1);
18432         jboolean ret_conv = CResult_ChannelReadyDecodeErrorZ_is_ok(o_conv);
18433         return ret_conv;
18434 }
18435
18436 void  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_free"))) TS_CResult_ChannelReadyDecodeErrorZ_free(uint32_t _res) {
18437         if ((_res & 1) != 0) return;
18438         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18439         CHECK_ACCESS(_res_ptr);
18440         LDKCResult_ChannelReadyDecodeErrorZ _res_conv = *(LDKCResult_ChannelReadyDecodeErrorZ*)(_res_ptr);
18441         FREE((void*)_res);
18442         CResult_ChannelReadyDecodeErrorZ_free(_res_conv);
18443 }
18444
18445 static inline uintptr_t CResult_ChannelReadyDecodeErrorZ_clone_ptr(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR arg) {
18446         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
18447         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(arg);
18448         return (uint32_t)ret_conv;
18449 }
18450 uint32_t  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelReadyDecodeErrorZ_clone_ptr(uint32_t arg) {
18451         LDKCResult_ChannelReadyDecodeErrorZ* arg_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(arg & ~1);
18452         uint32_t ret_conv = CResult_ChannelReadyDecodeErrorZ_clone_ptr(arg_conv);
18453         return ret_conv;
18454 }
18455
18456 uint32_t  __attribute__((export_name("TS_CResult_ChannelReadyDecodeErrorZ_clone"))) TS_CResult_ChannelReadyDecodeErrorZ_clone(uint32_t orig) {
18457         LDKCResult_ChannelReadyDecodeErrorZ* orig_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)(orig & ~1);
18458         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
18459         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(orig_conv);
18460         return (uint32_t)ret_conv;
18461 }
18462
18463 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_ok"))) TS_CResult_InitDecodeErrorZ_ok(uint32_t o) {
18464         LDKInit o_conv;
18465         o_conv.inner = (void*)(o & (~1));
18466         o_conv.is_owned = (o & 1) || (o == 0);
18467         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18468         o_conv = Init_clone(&o_conv);
18469         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
18470         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
18471         return (uint32_t)ret_conv;
18472 }
18473
18474 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_err"))) TS_CResult_InitDecodeErrorZ_err(uint32_t e) {
18475         LDKDecodeError e_conv;
18476         e_conv.inner = (void*)(e & (~1));
18477         e_conv.is_owned = (e & 1) || (e == 0);
18478         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18479         e_conv = DecodeError_clone(&e_conv);
18480         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
18481         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
18482         return (uint32_t)ret_conv;
18483 }
18484
18485 jboolean  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_is_ok"))) TS_CResult_InitDecodeErrorZ_is_ok(uint32_t o) {
18486         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)(o & ~1);
18487         jboolean ret_conv = CResult_InitDecodeErrorZ_is_ok(o_conv);
18488         return ret_conv;
18489 }
18490
18491 void  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_free"))) TS_CResult_InitDecodeErrorZ_free(uint32_t _res) {
18492         if ((_res & 1) != 0) return;
18493         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18494         CHECK_ACCESS(_res_ptr);
18495         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
18496         FREE((void*)_res);
18497         CResult_InitDecodeErrorZ_free(_res_conv);
18498 }
18499
18500 static inline uintptr_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
18501         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
18502         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
18503         return (uint32_t)ret_conv;
18504 }
18505 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_clone_ptr"))) TS_CResult_InitDecodeErrorZ_clone_ptr(uint32_t arg) {
18506         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
18507         uint32_t ret_conv = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
18508         return ret_conv;
18509 }
18510
18511 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_clone"))) TS_CResult_InitDecodeErrorZ_clone(uint32_t orig) {
18512         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
18513         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
18514         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
18515         return (uint32_t)ret_conv;
18516 }
18517
18518 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_ok"))) TS_CResult_OpenChannelDecodeErrorZ_ok(uint32_t o) {
18519         LDKOpenChannel o_conv;
18520         o_conv.inner = (void*)(o & (~1));
18521         o_conv.is_owned = (o & 1) || (o == 0);
18522         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18523         o_conv = OpenChannel_clone(&o_conv);
18524         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
18525         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
18526         return (uint32_t)ret_conv;
18527 }
18528
18529 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_err"))) TS_CResult_OpenChannelDecodeErrorZ_err(uint32_t e) {
18530         LDKDecodeError e_conv;
18531         e_conv.inner = (void*)(e & (~1));
18532         e_conv.is_owned = (e & 1) || (e == 0);
18533         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18534         e_conv = DecodeError_clone(&e_conv);
18535         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
18536         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
18537         return (uint32_t)ret_conv;
18538 }
18539
18540 jboolean  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_is_ok"))) TS_CResult_OpenChannelDecodeErrorZ_is_ok(uint32_t o) {
18541         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(o & ~1);
18542         jboolean ret_conv = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
18543         return ret_conv;
18544 }
18545
18546 void  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_free"))) TS_CResult_OpenChannelDecodeErrorZ_free(uint32_t _res) {
18547         if ((_res & 1) != 0) return;
18548         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18549         CHECK_ACCESS(_res_ptr);
18550         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
18551         FREE((void*)_res);
18552         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
18553 }
18554
18555 static inline uintptr_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
18556         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
18557         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
18558         return (uint32_t)ret_conv;
18559 }
18560 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_clone_ptr"))) TS_CResult_OpenChannelDecodeErrorZ_clone_ptr(uint32_t arg) {
18561         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
18562         uint32_t ret_conv = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
18563         return ret_conv;
18564 }
18565
18566 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_clone"))) TS_CResult_OpenChannelDecodeErrorZ_clone(uint32_t orig) {
18567         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
18568         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
18569         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
18570         return (uint32_t)ret_conv;
18571 }
18572
18573 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_ok(uint32_t o) {
18574         LDKRevokeAndACK o_conv;
18575         o_conv.inner = (void*)(o & (~1));
18576         o_conv.is_owned = (o & 1) || (o == 0);
18577         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18578         o_conv = RevokeAndACK_clone(&o_conv);
18579         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
18580         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
18581         return (uint32_t)ret_conv;
18582 }
18583
18584 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_err"))) TS_CResult_RevokeAndACKDecodeErrorZ_err(uint32_t e) {
18585         LDKDecodeError e_conv;
18586         e_conv.inner = (void*)(e & (~1));
18587         e_conv.is_owned = (e & 1) || (e == 0);
18588         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18589         e_conv = DecodeError_clone(&e_conv);
18590         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
18591         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
18592         return (uint32_t)ret_conv;
18593 }
18594
18595 jboolean  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_is_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_is_ok(uint32_t o) {
18596         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(o & ~1);
18597         jboolean ret_conv = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
18598         return ret_conv;
18599 }
18600
18601 void  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_free"))) TS_CResult_RevokeAndACKDecodeErrorZ_free(uint32_t _res) {
18602         if ((_res & 1) != 0) return;
18603         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18604         CHECK_ACCESS(_res_ptr);
18605         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
18606         FREE((void*)_res);
18607         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
18608 }
18609
18610 static inline uintptr_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
18611         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
18612         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
18613         return (uint32_t)ret_conv;
18614 }
18615 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_clone_ptr"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone_ptr(uint32_t arg) {
18616         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
18617         uint32_t ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
18618         return ret_conv;
18619 }
18620
18621 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_clone"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone(uint32_t orig) {
18622         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
18623         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
18624         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
18625         return (uint32_t)ret_conv;
18626 }
18627
18628 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_ok"))) TS_CResult_ShutdownDecodeErrorZ_ok(uint32_t o) {
18629         LDKShutdown o_conv;
18630         o_conv.inner = (void*)(o & (~1));
18631         o_conv.is_owned = (o & 1) || (o == 0);
18632         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18633         o_conv = Shutdown_clone(&o_conv);
18634         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
18635         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
18636         return (uint32_t)ret_conv;
18637 }
18638
18639 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_err"))) TS_CResult_ShutdownDecodeErrorZ_err(uint32_t e) {
18640         LDKDecodeError e_conv;
18641         e_conv.inner = (void*)(e & (~1));
18642         e_conv.is_owned = (e & 1) || (e == 0);
18643         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18644         e_conv = DecodeError_clone(&e_conv);
18645         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
18646         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
18647         return (uint32_t)ret_conv;
18648 }
18649
18650 jboolean  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_is_ok"))) TS_CResult_ShutdownDecodeErrorZ_is_ok(uint32_t o) {
18651         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)(o & ~1);
18652         jboolean ret_conv = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
18653         return ret_conv;
18654 }
18655
18656 void  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_free"))) TS_CResult_ShutdownDecodeErrorZ_free(uint32_t _res) {
18657         if ((_res & 1) != 0) return;
18658         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18659         CHECK_ACCESS(_res_ptr);
18660         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
18661         FREE((void*)_res);
18662         CResult_ShutdownDecodeErrorZ_free(_res_conv);
18663 }
18664
18665 static inline uintptr_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
18666         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
18667         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
18668         return (uint32_t)ret_conv;
18669 }
18670 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_clone_ptr"))) TS_CResult_ShutdownDecodeErrorZ_clone_ptr(uint32_t arg) {
18671         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
18672         uint32_t ret_conv = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
18673         return ret_conv;
18674 }
18675
18676 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_clone"))) TS_CResult_ShutdownDecodeErrorZ_clone(uint32_t orig) {
18677         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
18678         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
18679         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
18680         return (uint32_t)ret_conv;
18681 }
18682
18683 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_ok(uint32_t o) {
18684         LDKUpdateFailHTLC o_conv;
18685         o_conv.inner = (void*)(o & (~1));
18686         o_conv.is_owned = (o & 1) || (o == 0);
18687         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18688         o_conv = UpdateFailHTLC_clone(&o_conv);
18689         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
18690         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
18691         return (uint32_t)ret_conv;
18692 }
18693
18694 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_err(uint32_t e) {
18695         LDKDecodeError e_conv;
18696         e_conv.inner = (void*)(e & (~1));
18697         e_conv.is_owned = (e & 1) || (e == 0);
18698         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18699         e_conv = DecodeError_clone(&e_conv);
18700         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
18701         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
18702         return (uint32_t)ret_conv;
18703 }
18704
18705 jboolean  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_is_ok(uint32_t o) {
18706         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(o & ~1);
18707         jboolean ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
18708         return ret_conv;
18709 }
18710
18711 void  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_free(uint32_t _res) {
18712         if ((_res & 1) != 0) return;
18713         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18714         CHECK_ACCESS(_res_ptr);
18715         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
18716         FREE((void*)_res);
18717         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
18718 }
18719
18720 static inline uintptr_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
18721         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
18722         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
18723         return (uint32_t)ret_conv;
18724 }
18725 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
18726         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
18727         uint32_t ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
18728         return ret_conv;
18729 }
18730
18731 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone(uint32_t orig) {
18732         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
18733         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
18734         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
18735         return (uint32_t)ret_conv;
18736 }
18737
18738 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(uint32_t o) {
18739         LDKUpdateFailMalformedHTLC o_conv;
18740         o_conv.inner = (void*)(o & (~1));
18741         o_conv.is_owned = (o & 1) || (o == 0);
18742         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18743         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
18744         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
18745         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
18746         return (uint32_t)ret_conv;
18747 }
18748
18749 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(uint32_t e) {
18750         LDKDecodeError e_conv;
18751         e_conv.inner = (void*)(e & (~1));
18752         e_conv.is_owned = (e & 1) || (e == 0);
18753         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18754         e_conv = DecodeError_clone(&e_conv);
18755         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
18756         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
18757         return (uint32_t)ret_conv;
18758 }
18759
18760 jboolean  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(uint32_t o) {
18761         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(o & ~1);
18762         jboolean ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
18763         return ret_conv;
18764 }
18765
18766 void  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(uint32_t _res) {
18767         if ((_res & 1) != 0) return;
18768         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18769         CHECK_ACCESS(_res_ptr);
18770         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
18771         FREE((void*)_res);
18772         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
18773 }
18774
18775 static inline uintptr_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
18776         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
18777         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
18778         return (uint32_t)ret_conv;
18779 }
18780 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
18781         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
18782         uint32_t ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
18783         return ret_conv;
18784 }
18785
18786 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(uint32_t orig) {
18787         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
18788         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
18789         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
18790         return (uint32_t)ret_conv;
18791 }
18792
18793 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_ok(uint32_t o) {
18794         LDKUpdateFee o_conv;
18795         o_conv.inner = (void*)(o & (~1));
18796         o_conv.is_owned = (o & 1) || (o == 0);
18797         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18798         o_conv = UpdateFee_clone(&o_conv);
18799         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18800         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
18801         return (uint32_t)ret_conv;
18802 }
18803
18804 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_err"))) TS_CResult_UpdateFeeDecodeErrorZ_err(uint32_t e) {
18805         LDKDecodeError e_conv;
18806         e_conv.inner = (void*)(e & (~1));
18807         e_conv.is_owned = (e & 1) || (e == 0);
18808         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18809         e_conv = DecodeError_clone(&e_conv);
18810         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18811         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
18812         return (uint32_t)ret_conv;
18813 }
18814
18815 jboolean  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_is_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_is_ok(uint32_t o) {
18816         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(o & ~1);
18817         jboolean ret_conv = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
18818         return ret_conv;
18819 }
18820
18821 void  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_free"))) TS_CResult_UpdateFeeDecodeErrorZ_free(uint32_t _res) {
18822         if ((_res & 1) != 0) return;
18823         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18824         CHECK_ACCESS(_res_ptr);
18825         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
18826         FREE((void*)_res);
18827         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
18828 }
18829
18830 static inline uintptr_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
18831         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18832         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
18833         return (uint32_t)ret_conv;
18834 }
18835 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFeeDecodeErrorZ_clone_ptr(uint32_t arg) {
18836         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
18837         uint32_t ret_conv = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
18838         return ret_conv;
18839 }
18840
18841 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_clone"))) TS_CResult_UpdateFeeDecodeErrorZ_clone(uint32_t orig) {
18842         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
18843         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18844         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
18845         return (uint32_t)ret_conv;
18846 }
18847
18848 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok(uint32_t o) {
18849         LDKUpdateFulfillHTLC o_conv;
18850         o_conv.inner = (void*)(o & (~1));
18851         o_conv.is_owned = (o & 1) || (o == 0);
18852         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18853         o_conv = UpdateFulfillHTLC_clone(&o_conv);
18854         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18855         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
18856         return (uint32_t)ret_conv;
18857 }
18858
18859 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err(uint32_t e) {
18860         LDKDecodeError e_conv;
18861         e_conv.inner = (void*)(e & (~1));
18862         e_conv.is_owned = (e & 1) || (e == 0);
18863         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18864         e_conv = DecodeError_clone(&e_conv);
18865         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18866         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
18867         return (uint32_t)ret_conv;
18868 }
18869
18870 jboolean  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(uint32_t o) {
18871         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(o & ~1);
18872         jboolean ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
18873         return ret_conv;
18874 }
18875
18876 void  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free(uint32_t _res) {
18877         if ((_res & 1) != 0) return;
18878         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18879         CHECK_ACCESS(_res_ptr);
18880         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
18881         FREE((void*)_res);
18882         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
18883 }
18884
18885 static inline uintptr_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
18886         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18887         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
18888         return (uint32_t)ret_conv;
18889 }
18890 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
18891         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
18892         uint32_t ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
18893         return ret_conv;
18894 }
18895
18896 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone(uint32_t orig) {
18897         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
18898         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18899         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
18900         return (uint32_t)ret_conv;
18901 }
18902
18903 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_ok(uint32_t o) {
18904         LDKUpdateAddHTLC o_conv;
18905         o_conv.inner = (void*)(o & (~1));
18906         o_conv.is_owned = (o & 1) || (o == 0);
18907         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18908         o_conv = UpdateAddHTLC_clone(&o_conv);
18909         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18910         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
18911         return (uint32_t)ret_conv;
18912 }
18913
18914 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_err"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_err(uint32_t e) {
18915         LDKDecodeError e_conv;
18916         e_conv.inner = (void*)(e & (~1));
18917         e_conv.is_owned = (e & 1) || (e == 0);
18918         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18919         e_conv = DecodeError_clone(&e_conv);
18920         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18921         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
18922         return (uint32_t)ret_conv;
18923 }
18924
18925 jboolean  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_is_ok(uint32_t o) {
18926         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(o & ~1);
18927         jboolean ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
18928         return ret_conv;
18929 }
18930
18931 void  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_free"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_free(uint32_t _res) {
18932         if ((_res & 1) != 0) return;
18933         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18934         CHECK_ACCESS(_res_ptr);
18935         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
18936         FREE((void*)_res);
18937         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
18938 }
18939
18940 static inline uintptr_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
18941         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18942         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
18943         return (uint32_t)ret_conv;
18944 }
18945 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
18946         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
18947         uint32_t ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
18948         return ret_conv;
18949 }
18950
18951 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone(uint32_t orig) {
18952         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
18953         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18954         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
18955         return (uint32_t)ret_conv;
18956 }
18957
18958 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_ok"))) TS_CResult_PingDecodeErrorZ_ok(uint32_t o) {
18959         LDKPing o_conv;
18960         o_conv.inner = (void*)(o & (~1));
18961         o_conv.is_owned = (o & 1) || (o == 0);
18962         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18963         o_conv = Ping_clone(&o_conv);
18964         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
18965         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
18966         return (uint32_t)ret_conv;
18967 }
18968
18969 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_err"))) TS_CResult_PingDecodeErrorZ_err(uint32_t e) {
18970         LDKDecodeError e_conv;
18971         e_conv.inner = (void*)(e & (~1));
18972         e_conv.is_owned = (e & 1) || (e == 0);
18973         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18974         e_conv = DecodeError_clone(&e_conv);
18975         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
18976         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
18977         return (uint32_t)ret_conv;
18978 }
18979
18980 jboolean  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_is_ok"))) TS_CResult_PingDecodeErrorZ_is_ok(uint32_t o) {
18981         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)(o & ~1);
18982         jboolean ret_conv = CResult_PingDecodeErrorZ_is_ok(o_conv);
18983         return ret_conv;
18984 }
18985
18986 void  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_free"))) TS_CResult_PingDecodeErrorZ_free(uint32_t _res) {
18987         if ((_res & 1) != 0) return;
18988         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18989         CHECK_ACCESS(_res_ptr);
18990         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
18991         FREE((void*)_res);
18992         CResult_PingDecodeErrorZ_free(_res_conv);
18993 }
18994
18995 static inline uintptr_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
18996         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
18997         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
18998         return (uint32_t)ret_conv;
18999 }
19000 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_clone_ptr"))) TS_CResult_PingDecodeErrorZ_clone_ptr(uint32_t arg) {
19001         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
19002         uint32_t ret_conv = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
19003         return ret_conv;
19004 }
19005
19006 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_clone"))) TS_CResult_PingDecodeErrorZ_clone(uint32_t orig) {
19007         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
19008         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
19009         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
19010         return (uint32_t)ret_conv;
19011 }
19012
19013 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_ok"))) TS_CResult_PongDecodeErrorZ_ok(uint32_t o) {
19014         LDKPong o_conv;
19015         o_conv.inner = (void*)(o & (~1));
19016         o_conv.is_owned = (o & 1) || (o == 0);
19017         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19018         o_conv = Pong_clone(&o_conv);
19019         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
19020         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
19021         return (uint32_t)ret_conv;
19022 }
19023
19024 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_err"))) TS_CResult_PongDecodeErrorZ_err(uint32_t e) {
19025         LDKDecodeError e_conv;
19026         e_conv.inner = (void*)(e & (~1));
19027         e_conv.is_owned = (e & 1) || (e == 0);
19028         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19029         e_conv = DecodeError_clone(&e_conv);
19030         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
19031         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
19032         return (uint32_t)ret_conv;
19033 }
19034
19035 jboolean  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_is_ok"))) TS_CResult_PongDecodeErrorZ_is_ok(uint32_t o) {
19036         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)(o & ~1);
19037         jboolean ret_conv = CResult_PongDecodeErrorZ_is_ok(o_conv);
19038         return ret_conv;
19039 }
19040
19041 void  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_free"))) TS_CResult_PongDecodeErrorZ_free(uint32_t _res) {
19042         if ((_res & 1) != 0) return;
19043         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19044         CHECK_ACCESS(_res_ptr);
19045         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
19046         FREE((void*)_res);
19047         CResult_PongDecodeErrorZ_free(_res_conv);
19048 }
19049
19050 static inline uintptr_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
19051         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
19052         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
19053         return (uint32_t)ret_conv;
19054 }
19055 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_clone_ptr"))) TS_CResult_PongDecodeErrorZ_clone_ptr(uint32_t arg) {
19056         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
19057         uint32_t ret_conv = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
19058         return ret_conv;
19059 }
19060
19061 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_clone"))) TS_CResult_PongDecodeErrorZ_clone(uint32_t orig) {
19062         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
19063         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
19064         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
19065         return (uint32_t)ret_conv;
19066 }
19067
19068 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
19069         LDKUnsignedChannelAnnouncement o_conv;
19070         o_conv.inner = (void*)(o & (~1));
19071         o_conv.is_owned = (o & 1) || (o == 0);
19072         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19073         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
19074         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
19075         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
19076         return (uint32_t)ret_conv;
19077 }
19078
19079 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
19080         LDKDecodeError e_conv;
19081         e_conv.inner = (void*)(e & (~1));
19082         e_conv.is_owned = (e & 1) || (e == 0);
19083         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19084         e_conv = DecodeError_clone(&e_conv);
19085         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
19086         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
19087         return (uint32_t)ret_conv;
19088 }
19089
19090 jboolean  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
19091         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(o & ~1);
19092         jboolean ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
19093         return ret_conv;
19094 }
19095
19096 void  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
19097         if ((_res & 1) != 0) return;
19098         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19099         CHECK_ACCESS(_res_ptr);
19100         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
19101         FREE((void*)_res);
19102         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
19103 }
19104
19105 static inline uintptr_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
19106         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
19107         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
19108         return (uint32_t)ret_conv;
19109 }
19110 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
19111         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
19112         uint32_t ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
19113         return ret_conv;
19114 }
19115
19116 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
19117         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
19118         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
19119         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
19120         return (uint32_t)ret_conv;
19121 }
19122
19123 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
19124         LDKChannelAnnouncement o_conv;
19125         o_conv.inner = (void*)(o & (~1));
19126         o_conv.is_owned = (o & 1) || (o == 0);
19127         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19128         o_conv = ChannelAnnouncement_clone(&o_conv);
19129         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
19130         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
19131         return (uint32_t)ret_conv;
19132 }
19133
19134 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_err"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
19135         LDKDecodeError e_conv;
19136         e_conv.inner = (void*)(e & (~1));
19137         e_conv.is_owned = (e & 1) || (e == 0);
19138         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19139         e_conv = DecodeError_clone(&e_conv);
19140         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
19141         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
19142         return (uint32_t)ret_conv;
19143 }
19144
19145 jboolean  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
19146         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(o & ~1);
19147         jboolean ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
19148         return ret_conv;
19149 }
19150
19151 void  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_free"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
19152         if ((_res & 1) != 0) return;
19153         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19154         CHECK_ACCESS(_res_ptr);
19155         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
19156         FREE((void*)_res);
19157         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
19158 }
19159
19160 static inline uintptr_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
19161         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
19162         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
19163         return (uint32_t)ret_conv;
19164 }
19165 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
19166         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
19167         uint32_t ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
19168         return ret_conv;
19169 }
19170
19171 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_clone"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
19172         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
19173         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
19174         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
19175         return (uint32_t)ret_conv;
19176 }
19177
19178 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok(uint32_t o) {
19179         LDKUnsignedChannelUpdate o_conv;
19180         o_conv.inner = (void*)(o & (~1));
19181         o_conv.is_owned = (o & 1) || (o == 0);
19182         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19183         o_conv = UnsignedChannelUpdate_clone(&o_conv);
19184         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
19185         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
19186         return (uint32_t)ret_conv;
19187 }
19188
19189 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err(uint32_t e) {
19190         LDKDecodeError e_conv;
19191         e_conv.inner = (void*)(e & (~1));
19192         e_conv.is_owned = (e & 1) || (e == 0);
19193         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19194         e_conv = DecodeError_clone(&e_conv);
19195         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
19196         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
19197         return (uint32_t)ret_conv;
19198 }
19199
19200 jboolean  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(uint32_t o) {
19201         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(o & ~1);
19202         jboolean ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
19203         return ret_conv;
19204 }
19205
19206 void  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free(uint32_t _res) {
19207         if ((_res & 1) != 0) return;
19208         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19209         CHECK_ACCESS(_res_ptr);
19210         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
19211         FREE((void*)_res);
19212         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
19213 }
19214
19215 static inline uintptr_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
19216         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
19217         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
19218         return (uint32_t)ret_conv;
19219 }
19220 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
19221         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
19222         uint32_t ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
19223         return ret_conv;
19224 }
19225
19226 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
19227         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
19228         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
19229         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
19230         return (uint32_t)ret_conv;
19231 }
19232
19233 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_ok(uint32_t o) {
19234         LDKChannelUpdate o_conv;
19235         o_conv.inner = (void*)(o & (~1));
19236         o_conv.is_owned = (o & 1) || (o == 0);
19237         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19238         o_conv = ChannelUpdate_clone(&o_conv);
19239         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
19240         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
19241         return (uint32_t)ret_conv;
19242 }
19243
19244 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_err"))) TS_CResult_ChannelUpdateDecodeErrorZ_err(uint32_t e) {
19245         LDKDecodeError e_conv;
19246         e_conv.inner = (void*)(e & (~1));
19247         e_conv.is_owned = (e & 1) || (e == 0);
19248         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19249         e_conv = DecodeError_clone(&e_conv);
19250         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
19251         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
19252         return (uint32_t)ret_conv;
19253 }
19254
19255 jboolean  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_is_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_is_ok(uint32_t o) {
19256         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(o & ~1);
19257         jboolean ret_conv = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
19258         return ret_conv;
19259 }
19260
19261 void  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_free"))) TS_CResult_ChannelUpdateDecodeErrorZ_free(uint32_t _res) {
19262         if ((_res & 1) != 0) return;
19263         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19264         CHECK_ACCESS(_res_ptr);
19265         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
19266         FREE((void*)_res);
19267         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
19268 }
19269
19270 static inline uintptr_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
19271         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
19272         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
19273         return (uint32_t)ret_conv;
19274 }
19275 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
19276         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
19277         uint32_t ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
19278         return ret_conv;
19279 }
19280
19281 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_clone"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
19282         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
19283         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
19284         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
19285         return (uint32_t)ret_conv;
19286 }
19287
19288 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_ok(uint32_t o) {
19289         LDKErrorMessage o_conv;
19290         o_conv.inner = (void*)(o & (~1));
19291         o_conv.is_owned = (o & 1) || (o == 0);
19292         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19293         o_conv = ErrorMessage_clone(&o_conv);
19294         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
19295         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
19296         return (uint32_t)ret_conv;
19297 }
19298
19299 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_err"))) TS_CResult_ErrorMessageDecodeErrorZ_err(uint32_t e) {
19300         LDKDecodeError e_conv;
19301         e_conv.inner = (void*)(e & (~1));
19302         e_conv.is_owned = (e & 1) || (e == 0);
19303         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19304         e_conv = DecodeError_clone(&e_conv);
19305         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
19306         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
19307         return (uint32_t)ret_conv;
19308 }
19309
19310 jboolean  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_is_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_is_ok(uint32_t o) {
19311         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(o & ~1);
19312         jboolean ret_conv = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
19313         return ret_conv;
19314 }
19315
19316 void  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_free"))) TS_CResult_ErrorMessageDecodeErrorZ_free(uint32_t _res) {
19317         if ((_res & 1) != 0) return;
19318         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19319         CHECK_ACCESS(_res_ptr);
19320         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
19321         FREE((void*)_res);
19322         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
19323 }
19324
19325 static inline uintptr_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
19326         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
19327         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
19328         return (uint32_t)ret_conv;
19329 }
19330 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_clone_ptr"))) TS_CResult_ErrorMessageDecodeErrorZ_clone_ptr(uint32_t arg) {
19331         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
19332         uint32_t ret_conv = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
19333         return ret_conv;
19334 }
19335
19336 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_clone"))) TS_CResult_ErrorMessageDecodeErrorZ_clone(uint32_t orig) {
19337         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
19338         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
19339         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
19340         return (uint32_t)ret_conv;
19341 }
19342
19343 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_ok"))) TS_CResult_WarningMessageDecodeErrorZ_ok(uint32_t o) {
19344         LDKWarningMessage o_conv;
19345         o_conv.inner = (void*)(o & (~1));
19346         o_conv.is_owned = (o & 1) || (o == 0);
19347         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19348         o_conv = WarningMessage_clone(&o_conv);
19349         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
19350         *ret_conv = CResult_WarningMessageDecodeErrorZ_ok(o_conv);
19351         return (uint32_t)ret_conv;
19352 }
19353
19354 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_err"))) TS_CResult_WarningMessageDecodeErrorZ_err(uint32_t e) {
19355         LDKDecodeError e_conv;
19356         e_conv.inner = (void*)(e & (~1));
19357         e_conv.is_owned = (e & 1) || (e == 0);
19358         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19359         e_conv = DecodeError_clone(&e_conv);
19360         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
19361         *ret_conv = CResult_WarningMessageDecodeErrorZ_err(e_conv);
19362         return (uint32_t)ret_conv;
19363 }
19364
19365 jboolean  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_is_ok"))) TS_CResult_WarningMessageDecodeErrorZ_is_ok(uint32_t o) {
19366         LDKCResult_WarningMessageDecodeErrorZ* o_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(o & ~1);
19367         jboolean ret_conv = CResult_WarningMessageDecodeErrorZ_is_ok(o_conv);
19368         return ret_conv;
19369 }
19370
19371 void  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_free"))) TS_CResult_WarningMessageDecodeErrorZ_free(uint32_t _res) {
19372         if ((_res & 1) != 0) return;
19373         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19374         CHECK_ACCESS(_res_ptr);
19375         LDKCResult_WarningMessageDecodeErrorZ _res_conv = *(LDKCResult_WarningMessageDecodeErrorZ*)(_res_ptr);
19376         FREE((void*)_res);
19377         CResult_WarningMessageDecodeErrorZ_free(_res_conv);
19378 }
19379
19380 static inline uintptr_t CResult_WarningMessageDecodeErrorZ_clone_ptr(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR arg) {
19381         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
19382         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(arg);
19383         return (uint32_t)ret_conv;
19384 }
19385 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_clone_ptr"))) TS_CResult_WarningMessageDecodeErrorZ_clone_ptr(uint32_t arg) {
19386         LDKCResult_WarningMessageDecodeErrorZ* arg_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(arg & ~1);
19387         uint32_t ret_conv = CResult_WarningMessageDecodeErrorZ_clone_ptr(arg_conv);
19388         return ret_conv;
19389 }
19390
19391 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_clone"))) TS_CResult_WarningMessageDecodeErrorZ_clone(uint32_t orig) {
19392         LDKCResult_WarningMessageDecodeErrorZ* orig_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(orig & ~1);
19393         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
19394         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(orig_conv);
19395         return (uint32_t)ret_conv;
19396 }
19397
19398 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
19399         LDKUnsignedNodeAnnouncement o_conv;
19400         o_conv.inner = (void*)(o & (~1));
19401         o_conv.is_owned = (o & 1) || (o == 0);
19402         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19403         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
19404         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
19405         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
19406         return (uint32_t)ret_conv;
19407 }
19408
19409 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(uint32_t e) {
19410         LDKDecodeError e_conv;
19411         e_conv.inner = (void*)(e & (~1));
19412         e_conv.is_owned = (e & 1) || (e == 0);
19413         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19414         e_conv = DecodeError_clone(&e_conv);
19415         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
19416         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
19417         return (uint32_t)ret_conv;
19418 }
19419
19420 jboolean  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
19421         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(o & ~1);
19422         jboolean ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
19423         return ret_conv;
19424 }
19425
19426 void  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
19427         if ((_res & 1) != 0) return;
19428         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19429         CHECK_ACCESS(_res_ptr);
19430         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
19431         FREE((void*)_res);
19432         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
19433 }
19434
19435 static inline uintptr_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
19436         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
19437         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
19438         return (uint32_t)ret_conv;
19439 }
19440 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
19441         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
19442         uint32_t ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
19443         return ret_conv;
19444 }
19445
19446 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
19447         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
19448         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
19449         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
19450         return (uint32_t)ret_conv;
19451 }
19452
19453 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
19454         LDKNodeAnnouncement o_conv;
19455         o_conv.inner = (void*)(o & (~1));
19456         o_conv.is_owned = (o & 1) || (o == 0);
19457         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19458         o_conv = NodeAnnouncement_clone(&o_conv);
19459         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
19460         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
19461         return (uint32_t)ret_conv;
19462 }
19463
19464 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_err"))) TS_CResult_NodeAnnouncementDecodeErrorZ_err(uint32_t e) {
19465         LDKDecodeError e_conv;
19466         e_conv.inner = (void*)(e & (~1));
19467         e_conv.is_owned = (e & 1) || (e == 0);
19468         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19469         e_conv = DecodeError_clone(&e_conv);
19470         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
19471         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
19472         return (uint32_t)ret_conv;
19473 }
19474
19475 jboolean  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
19476         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(o & ~1);
19477         jboolean ret_conv = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
19478         return ret_conv;
19479 }
19480
19481 void  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_free"))) TS_CResult_NodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
19482         if ((_res & 1) != 0) return;
19483         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19484         CHECK_ACCESS(_res_ptr);
19485         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
19486         FREE((void*)_res);
19487         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
19488 }
19489
19490 static inline uintptr_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
19491         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
19492         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
19493         return (uint32_t)ret_conv;
19494 }
19495 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
19496         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
19497         uint32_t ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
19498         return ret_conv;
19499 }
19500
19501 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_clone"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
19502         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
19503         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
19504         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
19505         return (uint32_t)ret_conv;
19506 }
19507
19508 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok(uint32_t o) {
19509         LDKQueryShortChannelIds o_conv;
19510         o_conv.inner = (void*)(o & (~1));
19511         o_conv.is_owned = (o & 1) || (o == 0);
19512         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19513         o_conv = QueryShortChannelIds_clone(&o_conv);
19514         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
19515         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
19516         return (uint32_t)ret_conv;
19517 }
19518
19519 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_err"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_err(uint32_t e) {
19520         LDKDecodeError e_conv;
19521         e_conv.inner = (void*)(e & (~1));
19522         e_conv.is_owned = (e & 1) || (e == 0);
19523         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19524         e_conv = DecodeError_clone(&e_conv);
19525         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
19526         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
19527         return (uint32_t)ret_conv;
19528 }
19529
19530 jboolean  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_is_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(uint32_t o) {
19531         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(o & ~1);
19532         jboolean ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
19533         return ret_conv;
19534 }
19535
19536 void  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_free"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_free(uint32_t _res) {
19537         if ((_res & 1) != 0) return;
19538         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19539         CHECK_ACCESS(_res_ptr);
19540         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
19541         FREE((void*)_res);
19542         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
19543 }
19544
19545 static inline uintptr_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
19546         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
19547         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
19548         return (uint32_t)ret_conv;
19549 }
19550 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(uint32_t arg) {
19551         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
19552         uint32_t ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
19553         return ret_conv;
19554 }
19555
19556 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone(uint32_t orig) {
19557         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
19558         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
19559         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
19560         return (uint32_t)ret_conv;
19561 }
19562
19563 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(uint32_t o) {
19564         LDKReplyShortChannelIdsEnd o_conv;
19565         o_conv.inner = (void*)(o & (~1));
19566         o_conv.is_owned = (o & 1) || (o == 0);
19567         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19568         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
19569         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
19570         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
19571         return (uint32_t)ret_conv;
19572 }
19573
19574 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(uint32_t e) {
19575         LDKDecodeError e_conv;
19576         e_conv.inner = (void*)(e & (~1));
19577         e_conv.is_owned = (e & 1) || (e == 0);
19578         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19579         e_conv = DecodeError_clone(&e_conv);
19580         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
19581         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
19582         return (uint32_t)ret_conv;
19583 }
19584
19585 jboolean  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(uint32_t o) {
19586         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(o & ~1);
19587         jboolean ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
19588         return ret_conv;
19589 }
19590
19591 void  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(uint32_t _res) {
19592         if ((_res & 1) != 0) return;
19593         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19594         CHECK_ACCESS(_res_ptr);
19595         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
19596         FREE((void*)_res);
19597         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
19598 }
19599
19600 static inline uintptr_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
19601         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
19602         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
19603         return (uint32_t)ret_conv;
19604 }
19605 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(uint32_t arg) {
19606         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
19607         uint32_t ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
19608         return ret_conv;
19609 }
19610
19611 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(uint32_t orig) {
19612         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
19613         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
19614         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
19615         return (uint32_t)ret_conv;
19616 }
19617
19618 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_ok(uint32_t o) {
19619         LDKQueryChannelRange o_conv;
19620         o_conv.inner = (void*)(o & (~1));
19621         o_conv.is_owned = (o & 1) || (o == 0);
19622         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19623         o_conv = QueryChannelRange_clone(&o_conv);
19624         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
19625         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
19626         return (uint32_t)ret_conv;
19627 }
19628
19629 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_err"))) TS_CResult_QueryChannelRangeDecodeErrorZ_err(uint32_t e) {
19630         LDKDecodeError e_conv;
19631         e_conv.inner = (void*)(e & (~1));
19632         e_conv.is_owned = (e & 1) || (e == 0);
19633         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19634         e_conv = DecodeError_clone(&e_conv);
19635         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
19636         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
19637         return (uint32_t)ret_conv;
19638 }
19639
19640 jboolean  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_is_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_is_ok(uint32_t o) {
19641         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(o & ~1);
19642         jboolean ret_conv = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
19643         return ret_conv;
19644 }
19645
19646 void  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_free"))) TS_CResult_QueryChannelRangeDecodeErrorZ_free(uint32_t _res) {
19647         if ((_res & 1) != 0) return;
19648         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19649         CHECK_ACCESS(_res_ptr);
19650         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
19651         FREE((void*)_res);
19652         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
19653 }
19654
19655 static inline uintptr_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
19656         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
19657         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
19658         return (uint32_t)ret_conv;
19659 }
19660 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_clone_ptr"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
19661         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
19662         uint32_t ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
19663         return ret_conv;
19664 }
19665
19666 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_clone"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone(uint32_t orig) {
19667         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
19668         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
19669         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
19670         return (uint32_t)ret_conv;
19671 }
19672
19673 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_ok(uint32_t o) {
19674         LDKReplyChannelRange o_conv;
19675         o_conv.inner = (void*)(o & (~1));
19676         o_conv.is_owned = (o & 1) || (o == 0);
19677         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19678         o_conv = ReplyChannelRange_clone(&o_conv);
19679         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
19680         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
19681         return (uint32_t)ret_conv;
19682 }
19683
19684 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_err"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_err(uint32_t e) {
19685         LDKDecodeError e_conv;
19686         e_conv.inner = (void*)(e & (~1));
19687         e_conv.is_owned = (e & 1) || (e == 0);
19688         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19689         e_conv = DecodeError_clone(&e_conv);
19690         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
19691         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
19692         return (uint32_t)ret_conv;
19693 }
19694
19695 jboolean  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_is_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_is_ok(uint32_t o) {
19696         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(o & ~1);
19697         jboolean ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
19698         return ret_conv;
19699 }
19700
19701 void  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_free"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_free(uint32_t _res) {
19702         if ((_res & 1) != 0) return;
19703         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19704         CHECK_ACCESS(_res_ptr);
19705         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
19706         FREE((void*)_res);
19707         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
19708 }
19709
19710 static inline uintptr_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
19711         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
19712         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
19713         return (uint32_t)ret_conv;
19714 }
19715 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
19716         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
19717         uint32_t ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
19718         return ret_conv;
19719 }
19720
19721 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_clone"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone(uint32_t orig) {
19722         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
19723         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
19724         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
19725         return (uint32_t)ret_conv;
19726 }
19727
19728 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_ok(uint32_t o) {
19729         LDKGossipTimestampFilter o_conv;
19730         o_conv.inner = (void*)(o & (~1));
19731         o_conv.is_owned = (o & 1) || (o == 0);
19732         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19733         o_conv = GossipTimestampFilter_clone(&o_conv);
19734         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
19735         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
19736         return (uint32_t)ret_conv;
19737 }
19738
19739 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_err"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_err(uint32_t e) {
19740         LDKDecodeError e_conv;
19741         e_conv.inner = (void*)(e & (~1));
19742         e_conv.is_owned = (e & 1) || (e == 0);
19743         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19744         e_conv = DecodeError_clone(&e_conv);
19745         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
19746         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
19747         return (uint32_t)ret_conv;
19748 }
19749
19750 jboolean  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_is_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_is_ok(uint32_t o) {
19751         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(o & ~1);
19752         jboolean ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
19753         return ret_conv;
19754 }
19755
19756 void  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_free"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_free(uint32_t _res) {
19757         if ((_res & 1) != 0) return;
19758         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19759         CHECK_ACCESS(_res_ptr);
19760         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
19761         FREE((void*)_res);
19762         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
19763 }
19764
19765 static inline uintptr_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
19766         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
19767         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
19768         return (uint32_t)ret_conv;
19769 }
19770 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(uint32_t arg) {
19771         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
19772         uint32_t ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
19773         return ret_conv;
19774 }
19775
19776 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_clone"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone(uint32_t orig) {
19777         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
19778         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
19779         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
19780         return (uint32_t)ret_conv;
19781 }
19782
19783 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_ok"))) TS_CResult_InvoiceSignOrCreationErrorZ_ok(uint32_t o) {
19784         LDKInvoice o_conv;
19785         o_conv.inner = (void*)(o & (~1));
19786         o_conv.is_owned = (o & 1) || (o == 0);
19787         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19788         o_conv = Invoice_clone(&o_conv);
19789         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
19790         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
19791         return (uint32_t)ret_conv;
19792 }
19793
19794 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_err"))) TS_CResult_InvoiceSignOrCreationErrorZ_err(uint32_t e) {
19795         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19796         CHECK_ACCESS(e_ptr);
19797         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
19798         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)(((uintptr_t)e) & ~1));
19799         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
19800         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
19801         return (uint32_t)ret_conv;
19802 }
19803
19804 jboolean  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_is_ok"))) TS_CResult_InvoiceSignOrCreationErrorZ_is_ok(uint32_t o) {
19805         LDKCResult_InvoiceSignOrCreationErrorZ* o_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(o & ~1);
19806         jboolean ret_conv = CResult_InvoiceSignOrCreationErrorZ_is_ok(o_conv);
19807         return ret_conv;
19808 }
19809
19810 void  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_free"))) TS_CResult_InvoiceSignOrCreationErrorZ_free(uint32_t _res) {
19811         if ((_res & 1) != 0) return;
19812         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19813         CHECK_ACCESS(_res_ptr);
19814         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
19815         FREE((void*)_res);
19816         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
19817 }
19818
19819 static inline uintptr_t CResult_InvoiceSignOrCreationErrorZ_clone_ptr(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR arg) {
19820         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
19821         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(arg);
19822         return (uint32_t)ret_conv;
19823 }
19824 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_clone_ptr"))) TS_CResult_InvoiceSignOrCreationErrorZ_clone_ptr(uint32_t arg) {
19825         LDKCResult_InvoiceSignOrCreationErrorZ* arg_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
19826         uint32_t ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone_ptr(arg_conv);
19827         return ret_conv;
19828 }
19829
19830 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_clone"))) TS_CResult_InvoiceSignOrCreationErrorZ_clone(uint32_t orig) {
19831         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
19832         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
19833         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
19834         return (uint32_t)ret_conv;
19835 }
19836
19837 uint32_t  __attribute__((export_name("TS_COption_FilterZ_some"))) TS_COption_FilterZ_some(uint32_t o) {
19838         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19839         CHECK_ACCESS(o_ptr);
19840         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
19841         if (o_conv.free == LDKFilter_JCalls_free) {
19842                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19843                 LDKFilter_JCalls_cloned(&o_conv);
19844         }
19845         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
19846         *ret_copy = COption_FilterZ_some(o_conv);
19847         uint32_t ret_ref = (uintptr_t)ret_copy;
19848         return ret_ref;
19849 }
19850
19851 uint32_t  __attribute__((export_name("TS_COption_FilterZ_none"))) TS_COption_FilterZ_none() {
19852         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
19853         *ret_copy = COption_FilterZ_none();
19854         uint32_t ret_ref = (uintptr_t)ret_copy;
19855         return ret_ref;
19856 }
19857
19858 void  __attribute__((export_name("TS_COption_FilterZ_free"))) TS_COption_FilterZ_free(uint32_t _res) {
19859         if ((_res & 1) != 0) return;
19860         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19861         CHECK_ACCESS(_res_ptr);
19862         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
19863         FREE((void*)_res);
19864         COption_FilterZ_free(_res_conv);
19865 }
19866
19867 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_ok"))) TS_CResult_LockedChannelMonitorNoneZ_ok(uint32_t o) {
19868         LDKLockedChannelMonitor o_conv;
19869         o_conv.inner = (void*)(o & (~1));
19870         o_conv.is_owned = (o & 1) || (o == 0);
19871         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19872         // WARNING: we need a move here but no clone is available for LDKLockedChannelMonitor
19873         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
19874         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
19875         return (uint32_t)ret_conv;
19876 }
19877
19878 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_err"))) TS_CResult_LockedChannelMonitorNoneZ_err() {
19879         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
19880         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
19881         return (uint32_t)ret_conv;
19882 }
19883
19884 jboolean  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_is_ok"))) TS_CResult_LockedChannelMonitorNoneZ_is_ok(uint32_t o) {
19885         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(o & ~1);
19886         jboolean ret_conv = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
19887         return ret_conv;
19888 }
19889
19890 void  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_free"))) TS_CResult_LockedChannelMonitorNoneZ_free(uint32_t _res) {
19891         if ((_res & 1) != 0) return;
19892         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19893         CHECK_ACCESS(_res_ptr);
19894         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
19895         FREE((void*)_res);
19896         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
19897 }
19898
19899 void  __attribute__((export_name("TS_CVec_OutPointZ_free"))) TS_CVec_OutPointZ_free(uint32_tArray _res) {
19900         LDKCVec_OutPointZ _res_constr;
19901         _res_constr.datalen = _res->arr_len;
19902         if (_res_constr.datalen > 0)
19903                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
19904         else
19905                 _res_constr.data = NULL;
19906         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
19907         for (size_t k = 0; k < _res_constr.datalen; k++) {
19908                 uint32_t _res_conv_10 = _res_vals[k];
19909                 LDKOutPoint _res_conv_10_conv;
19910                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
19911                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
19912                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
19913                 _res_constr.data[k] = _res_conv_10_conv;
19914         }
19915         CVec_OutPointZ_free(_res_constr);
19916 }
19917
19918 void  __attribute__((export_name("TS_PaymentPurpose_free"))) TS_PaymentPurpose_free(uint32_t this_ptr) {
19919         if ((this_ptr & 1) != 0) return;
19920         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
19921         CHECK_ACCESS(this_ptr_ptr);
19922         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
19923         FREE((void*)this_ptr);
19924         PaymentPurpose_free(this_ptr_conv);
19925 }
19926
19927 static inline uintptr_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
19928         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
19929         *ret_copy = PaymentPurpose_clone(arg);
19930 uint32_t ret_ref = (uintptr_t)ret_copy;
19931         return ret_ref;
19932 }
19933 uint32_t  __attribute__((export_name("TS_PaymentPurpose_clone_ptr"))) TS_PaymentPurpose_clone_ptr(uint32_t arg) {
19934         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)arg;
19935         uint32_t ret_conv = PaymentPurpose_clone_ptr(arg_conv);
19936         return ret_conv;
19937 }
19938
19939 uint32_t  __attribute__((export_name("TS_PaymentPurpose_clone"))) TS_PaymentPurpose_clone(uint32_t orig) {
19940         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
19941         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
19942         *ret_copy = PaymentPurpose_clone(orig_conv);
19943         uint32_t ret_ref = (uintptr_t)ret_copy;
19944         return ret_ref;
19945 }
19946
19947 uint32_t  __attribute__((export_name("TS_PaymentPurpose_invoice_payment"))) TS_PaymentPurpose_invoice_payment(int8_tArray payment_preimage, int8_tArray payment_secret) {
19948         LDKThirtyTwoBytes payment_preimage_ref;
19949         CHECK(payment_preimage->arr_len == 32);
19950         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
19951         LDKThirtyTwoBytes payment_secret_ref;
19952         CHECK(payment_secret->arr_len == 32);
19953         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
19954         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
19955         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref);
19956         uint32_t ret_ref = (uintptr_t)ret_copy;
19957         return ret_ref;
19958 }
19959
19960 uint32_t  __attribute__((export_name("TS_PaymentPurpose_spontaneous_payment"))) TS_PaymentPurpose_spontaneous_payment(int8_tArray a) {
19961         LDKThirtyTwoBytes a_ref;
19962         CHECK(a->arr_len == 32);
19963         memcpy(a_ref.data, a->elems, 32); FREE(a);
19964         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
19965         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
19966         uint32_t ret_ref = (uintptr_t)ret_copy;
19967         return ret_ref;
19968 }
19969
19970 int8_tArray  __attribute__((export_name("TS_PaymentPurpose_write"))) TS_PaymentPurpose_write(uint32_t obj) {
19971         LDKPaymentPurpose* obj_conv = (LDKPaymentPurpose*)obj;
19972         LDKCVec_u8Z ret_var = PaymentPurpose_write(obj_conv);
19973         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
19974         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
19975         CVec_u8Z_free(ret_var);
19976         return ret_arr;
19977 }
19978
19979 uint32_t  __attribute__((export_name("TS_PaymentPurpose_read"))) TS_PaymentPurpose_read(int8_tArray ser) {
19980         LDKu8slice ser_ref;
19981         ser_ref.datalen = ser->arr_len;
19982         ser_ref.data = ser->elems /* XXX ser leaks */;
19983         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
19984         *ret_conv = PaymentPurpose_read(ser_ref);
19985         return (uint32_t)ret_conv;
19986 }
19987
19988 void  __attribute__((export_name("TS_ClosureReason_free"))) TS_ClosureReason_free(uint32_t this_ptr) {
19989         if ((this_ptr & 1) != 0) return;
19990         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
19991         CHECK_ACCESS(this_ptr_ptr);
19992         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
19993         FREE((void*)this_ptr);
19994         ClosureReason_free(this_ptr_conv);
19995 }
19996
19997 static inline uintptr_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
19998         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19999         *ret_copy = ClosureReason_clone(arg);
20000 uint32_t ret_ref = (uintptr_t)ret_copy;
20001         return ret_ref;
20002 }
20003 uint32_t  __attribute__((export_name("TS_ClosureReason_clone_ptr"))) TS_ClosureReason_clone_ptr(uint32_t arg) {
20004         LDKClosureReason* arg_conv = (LDKClosureReason*)arg;
20005         uint32_t ret_conv = ClosureReason_clone_ptr(arg_conv);
20006         return ret_conv;
20007 }
20008
20009 uint32_t  __attribute__((export_name("TS_ClosureReason_clone"))) TS_ClosureReason_clone(uint32_t orig) {
20010         LDKClosureReason* orig_conv = (LDKClosureReason*)orig;
20011         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20012         *ret_copy = ClosureReason_clone(orig_conv);
20013         uint32_t ret_ref = (uintptr_t)ret_copy;
20014         return ret_ref;
20015 }
20016
20017 uint32_t  __attribute__((export_name("TS_ClosureReason_counterparty_force_closed"))) TS_ClosureReason_counterparty_force_closed(jstring peer_msg) {
20018         LDKStr peer_msg_conv = str_ref_to_owned_c(peer_msg);
20019         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20020         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
20021         uint32_t ret_ref = (uintptr_t)ret_copy;
20022         return ret_ref;
20023 }
20024
20025 uint32_t  __attribute__((export_name("TS_ClosureReason_holder_force_closed"))) TS_ClosureReason_holder_force_closed() {
20026         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20027         *ret_copy = ClosureReason_holder_force_closed();
20028         uint32_t ret_ref = (uintptr_t)ret_copy;
20029         return ret_ref;
20030 }
20031
20032 uint32_t  __attribute__((export_name("TS_ClosureReason_cooperative_closure"))) TS_ClosureReason_cooperative_closure() {
20033         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20034         *ret_copy = ClosureReason_cooperative_closure();
20035         uint32_t ret_ref = (uintptr_t)ret_copy;
20036         return ret_ref;
20037 }
20038
20039 uint32_t  __attribute__((export_name("TS_ClosureReason_commitment_tx_confirmed"))) TS_ClosureReason_commitment_tx_confirmed() {
20040         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20041         *ret_copy = ClosureReason_commitment_tx_confirmed();
20042         uint32_t ret_ref = (uintptr_t)ret_copy;
20043         return ret_ref;
20044 }
20045
20046 uint32_t  __attribute__((export_name("TS_ClosureReason_funding_timed_out"))) TS_ClosureReason_funding_timed_out() {
20047         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20048         *ret_copy = ClosureReason_funding_timed_out();
20049         uint32_t ret_ref = (uintptr_t)ret_copy;
20050         return ret_ref;
20051 }
20052
20053 uint32_t  __attribute__((export_name("TS_ClosureReason_processing_error"))) TS_ClosureReason_processing_error(jstring err) {
20054         LDKStr err_conv = str_ref_to_owned_c(err);
20055         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20056         *ret_copy = ClosureReason_processing_error(err_conv);
20057         uint32_t ret_ref = (uintptr_t)ret_copy;
20058         return ret_ref;
20059 }
20060
20061 uint32_t  __attribute__((export_name("TS_ClosureReason_disconnected_peer"))) TS_ClosureReason_disconnected_peer() {
20062         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20063         *ret_copy = ClosureReason_disconnected_peer();
20064         uint32_t ret_ref = (uintptr_t)ret_copy;
20065         return ret_ref;
20066 }
20067
20068 uint32_t  __attribute__((export_name("TS_ClosureReason_outdated_channel_manager"))) TS_ClosureReason_outdated_channel_manager() {
20069         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
20070         *ret_copy = ClosureReason_outdated_channel_manager();
20071         uint32_t ret_ref = (uintptr_t)ret_copy;
20072         return ret_ref;
20073 }
20074
20075 int8_tArray  __attribute__((export_name("TS_ClosureReason_write"))) TS_ClosureReason_write(uint32_t obj) {
20076         LDKClosureReason* obj_conv = (LDKClosureReason*)obj;
20077         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
20078         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
20079         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
20080         CVec_u8Z_free(ret_var);
20081         return ret_arr;
20082 }
20083
20084 uint32_t  __attribute__((export_name("TS_ClosureReason_read"))) TS_ClosureReason_read(int8_tArray ser) {
20085         LDKu8slice ser_ref;
20086         ser_ref.datalen = ser->arr_len;
20087         ser_ref.data = ser->elems /* XXX ser leaks */;
20088         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
20089         *ret_conv = ClosureReason_read(ser_ref);
20090         return (uint32_t)ret_conv;
20091 }
20092
20093 void  __attribute__((export_name("TS_Event_free"))) TS_Event_free(uint32_t this_ptr) {
20094         if ((this_ptr & 1) != 0) return;
20095         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20096         CHECK_ACCESS(this_ptr_ptr);
20097         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
20098         FREE((void*)this_ptr);
20099         Event_free(this_ptr_conv);
20100 }
20101
20102 static inline uintptr_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
20103         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20104         *ret_copy = Event_clone(arg);
20105 uint32_t ret_ref = (uintptr_t)ret_copy;
20106         return ret_ref;
20107 }
20108 uint32_t  __attribute__((export_name("TS_Event_clone_ptr"))) TS_Event_clone_ptr(uint32_t arg) {
20109         LDKEvent* arg_conv = (LDKEvent*)arg;
20110         uint32_t ret_conv = Event_clone_ptr(arg_conv);
20111         return ret_conv;
20112 }
20113
20114 uint32_t  __attribute__((export_name("TS_Event_clone"))) TS_Event_clone(uint32_t orig) {
20115         LDKEvent* orig_conv = (LDKEvent*)orig;
20116         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20117         *ret_copy = Event_clone(orig_conv);
20118         uint32_t ret_ref = (uintptr_t)ret_copy;
20119         return ret_ref;
20120 }
20121
20122 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) {
20123         LDKThirtyTwoBytes temporary_channel_id_ref;
20124         CHECK(temporary_channel_id->arr_len == 32);
20125         memcpy(temporary_channel_id_ref.data, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
20126         LDKPublicKey counterparty_node_id_ref;
20127         CHECK(counterparty_node_id->arr_len == 33);
20128         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
20129         LDKCVec_u8Z output_script_ref;
20130         output_script_ref.datalen = output_script->arr_len;
20131         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
20132         memcpy(output_script_ref.data, output_script->elems, output_script_ref.datalen); FREE(output_script);
20133         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20134         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, counterparty_node_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
20135         uint32_t ret_ref = (uintptr_t)ret_copy;
20136         return ret_ref;
20137 }
20138
20139 uint32_t  __attribute__((export_name("TS_Event_payment_received"))) TS_Event_payment_received(int8_tArray payment_hash, int64_t amount_msat, uint32_t purpose) {
20140         LDKThirtyTwoBytes payment_hash_ref;
20141         CHECK(payment_hash->arr_len == 32);
20142         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
20143         void* purpose_ptr = (void*)(((uintptr_t)purpose) & ~1);
20144         CHECK_ACCESS(purpose_ptr);
20145         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
20146         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)purpose) & ~1));
20147         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20148         *ret_copy = Event_payment_received(payment_hash_ref, amount_msat, purpose_conv);
20149         uint32_t ret_ref = (uintptr_t)ret_copy;
20150         return ret_ref;
20151 }
20152
20153 uint32_t  __attribute__((export_name("TS_Event_payment_claimed"))) TS_Event_payment_claimed(int8_tArray payment_hash, int64_t amount_msat, uint32_t purpose) {
20154         LDKThirtyTwoBytes payment_hash_ref;
20155         CHECK(payment_hash->arr_len == 32);
20156         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
20157         void* purpose_ptr = (void*)(((uintptr_t)purpose) & ~1);
20158         CHECK_ACCESS(purpose_ptr);
20159         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
20160         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)purpose) & ~1));
20161         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20162         *ret_copy = Event_payment_claimed(payment_hash_ref, amount_msat, purpose_conv);
20163         uint32_t ret_ref = (uintptr_t)ret_copy;
20164         return ret_ref;
20165 }
20166
20167 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) {
20168         LDKThirtyTwoBytes payment_id_ref;
20169         CHECK(payment_id->arr_len == 32);
20170         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
20171         LDKThirtyTwoBytes payment_preimage_ref;
20172         CHECK(payment_preimage->arr_len == 32);
20173         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
20174         LDKThirtyTwoBytes payment_hash_ref;
20175         CHECK(payment_hash->arr_len == 32);
20176         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
20177         void* fee_paid_msat_ptr = (void*)(((uintptr_t)fee_paid_msat) & ~1);
20178         CHECK_ACCESS(fee_paid_msat_ptr);
20179         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
20180         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_paid_msat) & ~1));
20181         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20182         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
20183         uint32_t ret_ref = (uintptr_t)ret_copy;
20184         return ret_ref;
20185 }
20186
20187 uint32_t  __attribute__((export_name("TS_Event_payment_failed"))) TS_Event_payment_failed(int8_tArray payment_id, int8_tArray payment_hash) {
20188         LDKThirtyTwoBytes payment_id_ref;
20189         CHECK(payment_id->arr_len == 32);
20190         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
20191         LDKThirtyTwoBytes payment_hash_ref;
20192         CHECK(payment_hash->arr_len == 32);
20193         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
20194         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20195         *ret_copy = Event_payment_failed(payment_id_ref, payment_hash_ref);
20196         uint32_t ret_ref = (uintptr_t)ret_copy;
20197         return ret_ref;
20198 }
20199
20200 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) {
20201         LDKThirtyTwoBytes payment_id_ref;
20202         CHECK(payment_id->arr_len == 32);
20203         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
20204         LDKThirtyTwoBytes payment_hash_ref;
20205         CHECK(payment_hash->arr_len == 32);
20206         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
20207         LDKCVec_RouteHopZ path_constr;
20208         path_constr.datalen = path->arr_len;
20209         if (path_constr.datalen > 0)
20210                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
20211         else
20212                 path_constr.data = NULL;
20213         uint32_t* path_vals = path->elems /* XXX path leaks */;
20214         for (size_t k = 0; k < path_constr.datalen; k++) {
20215                 uint32_t path_conv_10 = path_vals[k];
20216                 LDKRouteHop path_conv_10_conv;
20217                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
20218                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
20219                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
20220                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
20221                 path_constr.data[k] = path_conv_10_conv;
20222         }
20223         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20224         *ret_copy = Event_payment_path_successful(payment_id_ref, payment_hash_ref, path_constr);
20225         uint32_t ret_ref = (uintptr_t)ret_copy;
20226         return ret_ref;
20227 }
20228
20229 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) {
20230         LDKThirtyTwoBytes payment_id_ref;
20231         CHECK(payment_id->arr_len == 32);
20232         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
20233         LDKThirtyTwoBytes payment_hash_ref;
20234         CHECK(payment_hash->arr_len == 32);
20235         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
20236         void* network_update_ptr = (void*)(((uintptr_t)network_update) & ~1);
20237         CHECK_ACCESS(network_update_ptr);
20238         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
20239         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)network_update) & ~1));
20240         LDKCVec_RouteHopZ path_constr;
20241         path_constr.datalen = path->arr_len;
20242         if (path_constr.datalen > 0)
20243                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
20244         else
20245                 path_constr.data = NULL;
20246         uint32_t* path_vals = path->elems /* XXX path leaks */;
20247         for (size_t k = 0; k < path_constr.datalen; k++) {
20248                 uint32_t path_conv_10 = path_vals[k];
20249                 LDKRouteHop path_conv_10_conv;
20250                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
20251                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
20252                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
20253                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
20254                 path_constr.data[k] = path_conv_10_conv;
20255         }
20256         void* short_channel_id_ptr = (void*)(((uintptr_t)short_channel_id) & ~1);
20257         CHECK_ACCESS(short_channel_id_ptr);
20258         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
20259         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id) & ~1));
20260         LDKRouteParameters retry_conv;
20261         retry_conv.inner = (void*)(retry & (~1));
20262         retry_conv.is_owned = (retry & 1) || (retry == 0);
20263         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_conv);
20264         retry_conv = RouteParameters_clone(&retry_conv);
20265         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20266         *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);
20267         uint32_t ret_ref = (uintptr_t)ret_copy;
20268         return ret_ref;
20269 }
20270
20271 uint32_t  __attribute__((export_name("TS_Event_pending_htlcs_forwardable"))) TS_Event_pending_htlcs_forwardable(int64_t time_forwardable) {
20272         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20273         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
20274         uint32_t ret_ref = (uintptr_t)ret_copy;
20275         return ret_ref;
20276 }
20277
20278 uint32_t  __attribute__((export_name("TS_Event_spendable_outputs"))) TS_Event_spendable_outputs(uint32_tArray outputs) {
20279         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
20280         outputs_constr.datalen = outputs->arr_len;
20281         if (outputs_constr.datalen > 0)
20282                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
20283         else
20284                 outputs_constr.data = NULL;
20285         uint32_t* outputs_vals = outputs->elems /* XXX outputs leaks */;
20286         for (size_t b = 0; b < outputs_constr.datalen; b++) {
20287                 uint32_t outputs_conv_27 = outputs_vals[b];
20288                 void* outputs_conv_27_ptr = (void*)(((uintptr_t)outputs_conv_27) & ~1);
20289                 CHECK_ACCESS(outputs_conv_27_ptr);
20290                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
20291                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)outputs_conv_27) & ~1));
20292                 outputs_constr.data[b] = outputs_conv_27_conv;
20293         }
20294         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20295         *ret_copy = Event_spendable_outputs(outputs_constr);
20296         uint32_t ret_ref = (uintptr_t)ret_copy;
20297         return ret_ref;
20298 }
20299
20300 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) {
20301         LDKThirtyTwoBytes prev_channel_id_ref;
20302         CHECK(prev_channel_id->arr_len == 32);
20303         memcpy(prev_channel_id_ref.data, prev_channel_id->elems, 32); FREE(prev_channel_id);
20304         LDKThirtyTwoBytes next_channel_id_ref;
20305         CHECK(next_channel_id->arr_len == 32);
20306         memcpy(next_channel_id_ref.data, next_channel_id->elems, 32); FREE(next_channel_id);
20307         void* fee_earned_msat_ptr = (void*)(((uintptr_t)fee_earned_msat) & ~1);
20308         CHECK_ACCESS(fee_earned_msat_ptr);
20309         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
20310         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_earned_msat) & ~1));
20311         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20312         *ret_copy = Event_payment_forwarded(prev_channel_id_ref, next_channel_id_ref, fee_earned_msat_conv, claim_from_onchain_tx);
20313         uint32_t ret_ref = (uintptr_t)ret_copy;
20314         return ret_ref;
20315 }
20316
20317 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) {
20318         LDKThirtyTwoBytes channel_id_ref;
20319         CHECK(channel_id->arr_len == 32);
20320         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
20321         void* reason_ptr = (void*)(((uintptr_t)reason) & ~1);
20322         CHECK_ACCESS(reason_ptr);
20323         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
20324         reason_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)reason) & ~1));
20325         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20326         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
20327         uint32_t ret_ref = (uintptr_t)ret_copy;
20328         return ret_ref;
20329 }
20330
20331 uint32_t  __attribute__((export_name("TS_Event_discard_funding"))) TS_Event_discard_funding(int8_tArray channel_id, int8_tArray transaction) {
20332         LDKThirtyTwoBytes channel_id_ref;
20333         CHECK(channel_id->arr_len == 32);
20334         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
20335         LDKTransaction transaction_ref;
20336         transaction_ref.datalen = transaction->arr_len;
20337         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
20338         memcpy(transaction_ref.data, transaction->elems, transaction_ref.datalen); FREE(transaction);
20339         transaction_ref.data_is_owned = true;
20340         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20341         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
20342         uint32_t ret_ref = (uintptr_t)ret_copy;
20343         return ret_ref;
20344 }
20345
20346 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) {
20347         LDKThirtyTwoBytes temporary_channel_id_ref;
20348         CHECK(temporary_channel_id->arr_len == 32);
20349         memcpy(temporary_channel_id_ref.data, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
20350         LDKPublicKey counterparty_node_id_ref;
20351         CHECK(counterparty_node_id->arr_len == 33);
20352         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
20353         LDKChannelTypeFeatures channel_type_conv;
20354         channel_type_conv.inner = (void*)(channel_type & (~1));
20355         channel_type_conv.is_owned = (channel_type & 1) || (channel_type == 0);
20356         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_conv);
20357         channel_type_conv = ChannelTypeFeatures_clone(&channel_type_conv);
20358         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
20359         *ret_copy = Event_open_channel_request(temporary_channel_id_ref, counterparty_node_id_ref, funding_satoshis, push_msat, channel_type_conv);
20360         uint32_t ret_ref = (uintptr_t)ret_copy;
20361         return ret_ref;
20362 }
20363
20364 int8_tArray  __attribute__((export_name("TS_Event_write"))) TS_Event_write(uint32_t obj) {
20365         LDKEvent* obj_conv = (LDKEvent*)obj;
20366         LDKCVec_u8Z ret_var = Event_write(obj_conv);
20367         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
20368         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
20369         CVec_u8Z_free(ret_var);
20370         return ret_arr;
20371 }
20372
20373 uint32_t  __attribute__((export_name("TS_Event_read"))) TS_Event_read(int8_tArray ser) {
20374         LDKu8slice ser_ref;
20375         ser_ref.datalen = ser->arr_len;
20376         ser_ref.data = ser->elems /* XXX ser leaks */;
20377         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
20378         *ret_conv = Event_read(ser_ref);
20379         return (uint32_t)ret_conv;
20380 }
20381
20382 void  __attribute__((export_name("TS_MessageSendEvent_free"))) TS_MessageSendEvent_free(uint32_t this_ptr) {
20383         if ((this_ptr & 1) != 0) return;
20384         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20385         CHECK_ACCESS(this_ptr_ptr);
20386         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
20387         FREE((void*)this_ptr);
20388         MessageSendEvent_free(this_ptr_conv);
20389 }
20390
20391 static inline uintptr_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
20392         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20393         *ret_copy = MessageSendEvent_clone(arg);
20394 uint32_t ret_ref = (uintptr_t)ret_copy;
20395         return ret_ref;
20396 }
20397 uint32_t  __attribute__((export_name("TS_MessageSendEvent_clone_ptr"))) TS_MessageSendEvent_clone_ptr(uint32_t arg) {
20398         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)arg;
20399         uint32_t ret_conv = MessageSendEvent_clone_ptr(arg_conv);
20400         return ret_conv;
20401 }
20402
20403 uint32_t  __attribute__((export_name("TS_MessageSendEvent_clone"))) TS_MessageSendEvent_clone(uint32_t orig) {
20404         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
20405         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20406         *ret_copy = MessageSendEvent_clone(orig_conv);
20407         uint32_t ret_ref = (uintptr_t)ret_copy;
20408         return ret_ref;
20409 }
20410
20411 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_accept_channel"))) TS_MessageSendEvent_send_accept_channel(int8_tArray node_id, uint32_t msg) {
20412         LDKPublicKey node_id_ref;
20413         CHECK(node_id->arr_len == 33);
20414         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20415         LDKAcceptChannel msg_conv;
20416         msg_conv.inner = (void*)(msg & (~1));
20417         msg_conv.is_owned = (msg & 1) || (msg == 0);
20418         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20419         msg_conv = AcceptChannel_clone(&msg_conv);
20420         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20421         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
20422         uint32_t ret_ref = (uintptr_t)ret_copy;
20423         return ret_ref;
20424 }
20425
20426 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_open_channel"))) TS_MessageSendEvent_send_open_channel(int8_tArray node_id, uint32_t msg) {
20427         LDKPublicKey node_id_ref;
20428         CHECK(node_id->arr_len == 33);
20429         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20430         LDKOpenChannel msg_conv;
20431         msg_conv.inner = (void*)(msg & (~1));
20432         msg_conv.is_owned = (msg & 1) || (msg == 0);
20433         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20434         msg_conv = OpenChannel_clone(&msg_conv);
20435         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20436         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
20437         uint32_t ret_ref = (uintptr_t)ret_copy;
20438         return ret_ref;
20439 }
20440
20441 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_funding_created"))) TS_MessageSendEvent_send_funding_created(int8_tArray node_id, uint32_t msg) {
20442         LDKPublicKey node_id_ref;
20443         CHECK(node_id->arr_len == 33);
20444         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20445         LDKFundingCreated msg_conv;
20446         msg_conv.inner = (void*)(msg & (~1));
20447         msg_conv.is_owned = (msg & 1) || (msg == 0);
20448         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20449         msg_conv = FundingCreated_clone(&msg_conv);
20450         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20451         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
20452         uint32_t ret_ref = (uintptr_t)ret_copy;
20453         return ret_ref;
20454 }
20455
20456 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_funding_signed"))) TS_MessageSendEvent_send_funding_signed(int8_tArray node_id, uint32_t msg) {
20457         LDKPublicKey node_id_ref;
20458         CHECK(node_id->arr_len == 33);
20459         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20460         LDKFundingSigned msg_conv;
20461         msg_conv.inner = (void*)(msg & (~1));
20462         msg_conv.is_owned = (msg & 1) || (msg == 0);
20463         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20464         msg_conv = FundingSigned_clone(&msg_conv);
20465         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20466         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
20467         uint32_t ret_ref = (uintptr_t)ret_copy;
20468         return ret_ref;
20469 }
20470
20471 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_ready"))) TS_MessageSendEvent_send_channel_ready(int8_tArray node_id, uint32_t msg) {
20472         LDKPublicKey node_id_ref;
20473         CHECK(node_id->arr_len == 33);
20474         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20475         LDKChannelReady msg_conv;
20476         msg_conv.inner = (void*)(msg & (~1));
20477         msg_conv.is_owned = (msg & 1) || (msg == 0);
20478         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20479         msg_conv = ChannelReady_clone(&msg_conv);
20480         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20481         *ret_copy = MessageSendEvent_send_channel_ready(node_id_ref, msg_conv);
20482         uint32_t ret_ref = (uintptr_t)ret_copy;
20483         return ret_ref;
20484 }
20485
20486 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_announcement_signatures"))) TS_MessageSendEvent_send_announcement_signatures(int8_tArray node_id, uint32_t msg) {
20487         LDKPublicKey node_id_ref;
20488         CHECK(node_id->arr_len == 33);
20489         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20490         LDKAnnouncementSignatures msg_conv;
20491         msg_conv.inner = (void*)(msg & (~1));
20492         msg_conv.is_owned = (msg & 1) || (msg == 0);
20493         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20494         msg_conv = AnnouncementSignatures_clone(&msg_conv);
20495         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20496         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
20497         uint32_t ret_ref = (uintptr_t)ret_copy;
20498         return ret_ref;
20499 }
20500
20501 uint32_t  __attribute__((export_name("TS_MessageSendEvent_update_htlcs"))) TS_MessageSendEvent_update_htlcs(int8_tArray node_id, uint32_t updates) {
20502         LDKPublicKey node_id_ref;
20503         CHECK(node_id->arr_len == 33);
20504         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20505         LDKCommitmentUpdate updates_conv;
20506         updates_conv.inner = (void*)(updates & (~1));
20507         updates_conv.is_owned = (updates & 1) || (updates == 0);
20508         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
20509         updates_conv = CommitmentUpdate_clone(&updates_conv);
20510         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20511         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
20512         uint32_t ret_ref = (uintptr_t)ret_copy;
20513         return ret_ref;
20514 }
20515
20516 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_revoke_and_ack"))) TS_MessageSendEvent_send_revoke_and_ack(int8_tArray node_id, uint32_t msg) {
20517         LDKPublicKey node_id_ref;
20518         CHECK(node_id->arr_len == 33);
20519         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20520         LDKRevokeAndACK msg_conv;
20521         msg_conv.inner = (void*)(msg & (~1));
20522         msg_conv.is_owned = (msg & 1) || (msg == 0);
20523         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20524         msg_conv = RevokeAndACK_clone(&msg_conv);
20525         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20526         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
20527         uint32_t ret_ref = (uintptr_t)ret_copy;
20528         return ret_ref;
20529 }
20530
20531 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_closing_signed"))) TS_MessageSendEvent_send_closing_signed(int8_tArray node_id, uint32_t msg) {
20532         LDKPublicKey node_id_ref;
20533         CHECK(node_id->arr_len == 33);
20534         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20535         LDKClosingSigned msg_conv;
20536         msg_conv.inner = (void*)(msg & (~1));
20537         msg_conv.is_owned = (msg & 1) || (msg == 0);
20538         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20539         msg_conv = ClosingSigned_clone(&msg_conv);
20540         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20541         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
20542         uint32_t ret_ref = (uintptr_t)ret_copy;
20543         return ret_ref;
20544 }
20545
20546 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_shutdown"))) TS_MessageSendEvent_send_shutdown(int8_tArray node_id, uint32_t msg) {
20547         LDKPublicKey node_id_ref;
20548         CHECK(node_id->arr_len == 33);
20549         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20550         LDKShutdown msg_conv;
20551         msg_conv.inner = (void*)(msg & (~1));
20552         msg_conv.is_owned = (msg & 1) || (msg == 0);
20553         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20554         msg_conv = Shutdown_clone(&msg_conv);
20555         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20556         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
20557         uint32_t ret_ref = (uintptr_t)ret_copy;
20558         return ret_ref;
20559 }
20560
20561 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_reestablish"))) TS_MessageSendEvent_send_channel_reestablish(int8_tArray node_id, uint32_t msg) {
20562         LDKPublicKey node_id_ref;
20563         CHECK(node_id->arr_len == 33);
20564         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20565         LDKChannelReestablish msg_conv;
20566         msg_conv.inner = (void*)(msg & (~1));
20567         msg_conv.is_owned = (msg & 1) || (msg == 0);
20568         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20569         msg_conv = ChannelReestablish_clone(&msg_conv);
20570         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20571         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
20572         uint32_t ret_ref = (uintptr_t)ret_copy;
20573         return ret_ref;
20574 }
20575
20576 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_channel_announcement"))) TS_MessageSendEvent_broadcast_channel_announcement(uint32_t msg, uint32_t update_msg) {
20577         LDKChannelAnnouncement msg_conv;
20578         msg_conv.inner = (void*)(msg & (~1));
20579         msg_conv.is_owned = (msg & 1) || (msg == 0);
20580         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20581         msg_conv = ChannelAnnouncement_clone(&msg_conv);
20582         LDKChannelUpdate update_msg_conv;
20583         update_msg_conv.inner = (void*)(update_msg & (~1));
20584         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
20585         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
20586         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
20587         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20588         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
20589         uint32_t ret_ref = (uintptr_t)ret_copy;
20590         return ret_ref;
20591 }
20592
20593 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_node_announcement"))) TS_MessageSendEvent_broadcast_node_announcement(uint32_t msg) {
20594         LDKNodeAnnouncement msg_conv;
20595         msg_conv.inner = (void*)(msg & (~1));
20596         msg_conv.is_owned = (msg & 1) || (msg == 0);
20597         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20598         msg_conv = NodeAnnouncement_clone(&msg_conv);
20599         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20600         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
20601         uint32_t ret_ref = (uintptr_t)ret_copy;
20602         return ret_ref;
20603 }
20604
20605 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_channel_update"))) TS_MessageSendEvent_broadcast_channel_update(uint32_t msg) {
20606         LDKChannelUpdate msg_conv;
20607         msg_conv.inner = (void*)(msg & (~1));
20608         msg_conv.is_owned = (msg & 1) || (msg == 0);
20609         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20610         msg_conv = ChannelUpdate_clone(&msg_conv);
20611         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20612         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
20613         uint32_t ret_ref = (uintptr_t)ret_copy;
20614         return ret_ref;
20615 }
20616
20617 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_update"))) TS_MessageSendEvent_send_channel_update(int8_tArray node_id, uint32_t msg) {
20618         LDKPublicKey node_id_ref;
20619         CHECK(node_id->arr_len == 33);
20620         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20621         LDKChannelUpdate msg_conv;
20622         msg_conv.inner = (void*)(msg & (~1));
20623         msg_conv.is_owned = (msg & 1) || (msg == 0);
20624         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20625         msg_conv = ChannelUpdate_clone(&msg_conv);
20626         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20627         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
20628         uint32_t ret_ref = (uintptr_t)ret_copy;
20629         return ret_ref;
20630 }
20631
20632 uint32_t  __attribute__((export_name("TS_MessageSendEvent_handle_error"))) TS_MessageSendEvent_handle_error(int8_tArray node_id, uint32_t action) {
20633         LDKPublicKey node_id_ref;
20634         CHECK(node_id->arr_len == 33);
20635         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20636         void* action_ptr = (void*)(((uintptr_t)action) & ~1);
20637         CHECK_ACCESS(action_ptr);
20638         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
20639         action_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action) & ~1));
20640         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20641         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
20642         uint32_t ret_ref = (uintptr_t)ret_copy;
20643         return ret_ref;
20644 }
20645
20646 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_range_query"))) TS_MessageSendEvent_send_channel_range_query(int8_tArray node_id, uint32_t msg) {
20647         LDKPublicKey node_id_ref;
20648         CHECK(node_id->arr_len == 33);
20649         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20650         LDKQueryChannelRange msg_conv;
20651         msg_conv.inner = (void*)(msg & (~1));
20652         msg_conv.is_owned = (msg & 1) || (msg == 0);
20653         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20654         msg_conv = QueryChannelRange_clone(&msg_conv);
20655         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20656         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
20657         uint32_t ret_ref = (uintptr_t)ret_copy;
20658         return ret_ref;
20659 }
20660
20661 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_short_ids_query"))) TS_MessageSendEvent_send_short_ids_query(int8_tArray node_id, uint32_t msg) {
20662         LDKPublicKey node_id_ref;
20663         CHECK(node_id->arr_len == 33);
20664         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20665         LDKQueryShortChannelIds msg_conv;
20666         msg_conv.inner = (void*)(msg & (~1));
20667         msg_conv.is_owned = (msg & 1) || (msg == 0);
20668         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20669         msg_conv = QueryShortChannelIds_clone(&msg_conv);
20670         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20671         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
20672         uint32_t ret_ref = (uintptr_t)ret_copy;
20673         return ret_ref;
20674 }
20675
20676 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_reply_channel_range"))) TS_MessageSendEvent_send_reply_channel_range(int8_tArray node_id, uint32_t msg) {
20677         LDKPublicKey node_id_ref;
20678         CHECK(node_id->arr_len == 33);
20679         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20680         LDKReplyChannelRange msg_conv;
20681         msg_conv.inner = (void*)(msg & (~1));
20682         msg_conv.is_owned = (msg & 1) || (msg == 0);
20683         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20684         msg_conv = ReplyChannelRange_clone(&msg_conv);
20685         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20686         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
20687         uint32_t ret_ref = (uintptr_t)ret_copy;
20688         return ret_ref;
20689 }
20690
20691 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_gossip_timestamp_filter"))) TS_MessageSendEvent_send_gossip_timestamp_filter(int8_tArray node_id, uint32_t msg) {
20692         LDKPublicKey node_id_ref;
20693         CHECK(node_id->arr_len == 33);
20694         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20695         LDKGossipTimestampFilter msg_conv;
20696         msg_conv.inner = (void*)(msg & (~1));
20697         msg_conv.is_owned = (msg & 1) || (msg == 0);
20698         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20699         msg_conv = GossipTimestampFilter_clone(&msg_conv);
20700         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20701         *ret_copy = MessageSendEvent_send_gossip_timestamp_filter(node_id_ref, msg_conv);
20702         uint32_t ret_ref = (uintptr_t)ret_copy;
20703         return ret_ref;
20704 }
20705
20706 void  __attribute__((export_name("TS_MessageSendEventsProvider_free"))) TS_MessageSendEventsProvider_free(uint32_t this_ptr) {
20707         if ((this_ptr & 1) != 0) return;
20708         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20709         CHECK_ACCESS(this_ptr_ptr);
20710         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
20711         FREE((void*)this_ptr);
20712         MessageSendEventsProvider_free(this_ptr_conv);
20713 }
20714
20715 void  __attribute__((export_name("TS_EventsProvider_free"))) TS_EventsProvider_free(uint32_t this_ptr) {
20716         if ((this_ptr & 1) != 0) return;
20717         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20718         CHECK_ACCESS(this_ptr_ptr);
20719         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
20720         FREE((void*)this_ptr);
20721         EventsProvider_free(this_ptr_conv);
20722 }
20723
20724 void  __attribute__((export_name("TS_EventHandler_free"))) TS_EventHandler_free(uint32_t this_ptr) {
20725         if ((this_ptr & 1) != 0) return;
20726         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20727         CHECK_ACCESS(this_ptr_ptr);
20728         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
20729         FREE((void*)this_ptr);
20730         EventHandler_free(this_ptr_conv);
20731 }
20732
20733 void  __attribute__((export_name("TS_APIError_free"))) TS_APIError_free(uint32_t this_ptr) {
20734         if ((this_ptr & 1) != 0) return;
20735         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20736         CHECK_ACCESS(this_ptr_ptr);
20737         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
20738         FREE((void*)this_ptr);
20739         APIError_free(this_ptr_conv);
20740 }
20741
20742 static inline uintptr_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
20743         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20744         *ret_copy = APIError_clone(arg);
20745 uint32_t ret_ref = (uintptr_t)ret_copy;
20746         return ret_ref;
20747 }
20748 uint32_t  __attribute__((export_name("TS_APIError_clone_ptr"))) TS_APIError_clone_ptr(uint32_t arg) {
20749         LDKAPIError* arg_conv = (LDKAPIError*)arg;
20750         uint32_t ret_conv = APIError_clone_ptr(arg_conv);
20751         return ret_conv;
20752 }
20753
20754 uint32_t  __attribute__((export_name("TS_APIError_clone"))) TS_APIError_clone(uint32_t orig) {
20755         LDKAPIError* orig_conv = (LDKAPIError*)orig;
20756         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20757         *ret_copy = APIError_clone(orig_conv);
20758         uint32_t ret_ref = (uintptr_t)ret_copy;
20759         return ret_ref;
20760 }
20761
20762 uint32_t  __attribute__((export_name("TS_APIError_apimisuse_error"))) TS_APIError_apimisuse_error(jstring err) {
20763         LDKStr err_conv = str_ref_to_owned_c(err);
20764         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20765         *ret_copy = APIError_apimisuse_error(err_conv);
20766         uint32_t ret_ref = (uintptr_t)ret_copy;
20767         return ret_ref;
20768 }
20769
20770 uint32_t  __attribute__((export_name("TS_APIError_fee_rate_too_high"))) TS_APIError_fee_rate_too_high(jstring err, int32_t feerate) {
20771         LDKStr err_conv = str_ref_to_owned_c(err);
20772         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20773         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
20774         uint32_t ret_ref = (uintptr_t)ret_copy;
20775         return ret_ref;
20776 }
20777
20778 uint32_t  __attribute__((export_name("TS_APIError_route_error"))) TS_APIError_route_error(jstring err) {
20779         LDKStr err_conv = str_ref_to_owned_c(err);
20780         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20781         *ret_copy = APIError_route_error(err_conv);
20782         uint32_t ret_ref = (uintptr_t)ret_copy;
20783         return ret_ref;
20784 }
20785
20786 uint32_t  __attribute__((export_name("TS_APIError_channel_unavailable"))) TS_APIError_channel_unavailable(jstring err) {
20787         LDKStr err_conv = str_ref_to_owned_c(err);
20788         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20789         *ret_copy = APIError_channel_unavailable(err_conv);
20790         uint32_t ret_ref = (uintptr_t)ret_copy;
20791         return ret_ref;
20792 }
20793
20794 uint32_t  __attribute__((export_name("TS_APIError_monitor_update_failed"))) TS_APIError_monitor_update_failed() {
20795         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20796         *ret_copy = APIError_monitor_update_failed();
20797         uint32_t ret_ref = (uintptr_t)ret_copy;
20798         return ret_ref;
20799 }
20800
20801 uint32_t  __attribute__((export_name("TS_APIError_incompatible_shutdown_script"))) TS_APIError_incompatible_shutdown_script(uint32_t script) {
20802         LDKShutdownScript script_conv;
20803         script_conv.inner = (void*)(script & (~1));
20804         script_conv.is_owned = (script & 1) || (script == 0);
20805         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
20806         script_conv = ShutdownScript_clone(&script_conv);
20807         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20808         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
20809         uint32_t ret_ref = (uintptr_t)ret_copy;
20810         return ret_ref;
20811 }
20812
20813 void  __attribute__((export_name("TS_BigSize_free"))) TS_BigSize_free(uint32_t this_obj) {
20814         LDKBigSize this_obj_conv;
20815         this_obj_conv.inner = (void*)(this_obj & (~1));
20816         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20818         BigSize_free(this_obj_conv);
20819 }
20820
20821 int64_t  __attribute__((export_name("TS_BigSize_get_a"))) TS_BigSize_get_a(uint32_t this_ptr) {
20822         LDKBigSize this_ptr_conv;
20823         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20824         this_ptr_conv.is_owned = false;
20825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20826         int64_t ret_conv = BigSize_get_a(&this_ptr_conv);
20827         return ret_conv;
20828 }
20829
20830 void  __attribute__((export_name("TS_BigSize_set_a"))) TS_BigSize_set_a(uint32_t this_ptr, int64_t val) {
20831         LDKBigSize this_ptr_conv;
20832         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20833         this_ptr_conv.is_owned = false;
20834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20835         BigSize_set_a(&this_ptr_conv, val);
20836 }
20837
20838 uint32_t  __attribute__((export_name("TS_BigSize_new"))) TS_BigSize_new(int64_t a_arg) {
20839         LDKBigSize ret_var = BigSize_new(a_arg);
20840         uint32_t ret_ref = 0;
20841         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20842         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20843         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20844         ret_ref = (uintptr_t)ret_var.inner;
20845         if (ret_var.is_owned) {
20846                 ret_ref |= 1;
20847         }
20848         return ret_ref;
20849 }
20850
20851 uint32_t  __attribute__((export_name("TS_sign"))) TS_sign(int8_tArray msg, int8_tArray sk) {
20852         LDKu8slice msg_ref;
20853         msg_ref.datalen = msg->arr_len;
20854         msg_ref.data = msg->elems /* XXX msg leaks */;
20855         unsigned char sk_arr[32];
20856         CHECK(sk->arr_len == 32);
20857         memcpy(sk_arr, sk->elems, 32); FREE(sk);
20858         unsigned char (*sk_ref)[32] = &sk_arr;
20859         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
20860         *ret_conv = sign(msg_ref, sk_ref);
20861         return (uint32_t)ret_conv;
20862 }
20863
20864 uint32_t  __attribute__((export_name("TS_recover_pk"))) TS_recover_pk(int8_tArray msg, jstring sig) {
20865         LDKu8slice msg_ref;
20866         msg_ref.datalen = msg->arr_len;
20867         msg_ref.data = msg->elems /* XXX msg leaks */;
20868         LDKStr sig_conv = str_ref_to_owned_c(sig);
20869         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
20870         *ret_conv = recover_pk(msg_ref, sig_conv);
20871         return (uint32_t)ret_conv;
20872 }
20873
20874 jboolean  __attribute__((export_name("TS_verify"))) TS_verify(int8_tArray msg, jstring sig, int8_tArray pk) {
20875         LDKu8slice msg_ref;
20876         msg_ref.datalen = msg->arr_len;
20877         msg_ref.data = msg->elems /* XXX msg leaks */;
20878         LDKStr sig_conv = str_ref_to_owned_c(sig);
20879         LDKPublicKey pk_ref;
20880         CHECK(pk->arr_len == 33);
20881         memcpy(pk_ref.compressed_form, pk->elems, 33); FREE(pk);
20882         jboolean ret_conv = verify(msg_ref, sig_conv, pk_ref);
20883         return ret_conv;
20884 }
20885
20886 int8_tArray  __attribute__((export_name("TS_construct_invoice_preimage"))) TS_construct_invoice_preimage(int8_tArray hrp_bytes, ptrArray data_without_signature) {
20887         LDKu8slice hrp_bytes_ref;
20888         hrp_bytes_ref.datalen = hrp_bytes->arr_len;
20889         hrp_bytes_ref.data = hrp_bytes->elems /* XXX hrp_bytes leaks */;
20890         LDKCVec_u5Z data_without_signature_constr;
20891         data_without_signature_constr.datalen = data_without_signature->arr_len;
20892         if (data_without_signature_constr.datalen > 0)
20893                 data_without_signature_constr.data = MALLOC(data_without_signature_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
20894         else
20895                 data_without_signature_constr.data = NULL;
20896         int8_t* data_without_signature_vals = (void*) data_without_signature->elems /* XXX data_without_signature leaks */;
20897         for (size_t h = 0; h < data_without_signature_constr.datalen; h++) {
20898                 int8_t data_without_signature_conv_7 = data_without_signature_vals[h];
20899                 
20900                 data_without_signature_constr.data[h] = (LDKu5){ ._0 = data_without_signature_conv_7 };
20901         }
20902         LDKCVec_u8Z ret_var = construct_invoice_preimage(hrp_bytes_ref, data_without_signature_constr);
20903         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
20904         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
20905         CVec_u8Z_free(ret_var);
20906         return ret_arr;
20907 }
20908
20909 void  __attribute__((export_name("TS_Persister_free"))) TS_Persister_free(uint32_t this_ptr) {
20910         if ((this_ptr & 1) != 0) return;
20911         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20912         CHECK_ACCESS(this_ptr_ptr);
20913         LDKPersister this_ptr_conv = *(LDKPersister*)(this_ptr_ptr);
20914         FREE((void*)this_ptr);
20915         Persister_free(this_ptr_conv);
20916 }
20917
20918 uint32_t  __attribute__((export_name("TS_Level_clone"))) TS_Level_clone(uint32_t orig) {
20919         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
20920         uint32_t ret_conv = LDKLevel_to_js(Level_clone(orig_conv));
20921         return ret_conv;
20922 }
20923
20924 uint32_t  __attribute__((export_name("TS_Level_gossip"))) TS_Level_gossip() {
20925         uint32_t ret_conv = LDKLevel_to_js(Level_gossip());
20926         return ret_conv;
20927 }
20928
20929 uint32_t  __attribute__((export_name("TS_Level_trace"))) TS_Level_trace() {
20930         uint32_t ret_conv = LDKLevel_to_js(Level_trace());
20931         return ret_conv;
20932 }
20933
20934 uint32_t  __attribute__((export_name("TS_Level_debug"))) TS_Level_debug() {
20935         uint32_t ret_conv = LDKLevel_to_js(Level_debug());
20936         return ret_conv;
20937 }
20938
20939 uint32_t  __attribute__((export_name("TS_Level_info"))) TS_Level_info() {
20940         uint32_t ret_conv = LDKLevel_to_js(Level_info());
20941         return ret_conv;
20942 }
20943
20944 uint32_t  __attribute__((export_name("TS_Level_warn"))) TS_Level_warn() {
20945         uint32_t ret_conv = LDKLevel_to_js(Level_warn());
20946         return ret_conv;
20947 }
20948
20949 uint32_t  __attribute__((export_name("TS_Level_error"))) TS_Level_error() {
20950         uint32_t ret_conv = LDKLevel_to_js(Level_error());
20951         return ret_conv;
20952 }
20953
20954 jboolean  __attribute__((export_name("TS_Level_eq"))) TS_Level_eq(uint32_t a, uint32_t b) {
20955         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
20956         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
20957         jboolean ret_conv = Level_eq(a_conv, b_conv);
20958         return ret_conv;
20959 }
20960
20961 int64_t  __attribute__((export_name("TS_Level_hash"))) TS_Level_hash(uint32_t o) {
20962         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
20963         int64_t ret_conv = Level_hash(o_conv);
20964         return ret_conv;
20965 }
20966
20967 uint32_t  __attribute__((export_name("TS_Level_max"))) TS_Level_max() {
20968         uint32_t ret_conv = LDKLevel_to_js(Level_max());
20969         return ret_conv;
20970 }
20971
20972 void  __attribute__((export_name("TS_Record_free"))) TS_Record_free(uint32_t this_obj) {
20973         LDKRecord this_obj_conv;
20974         this_obj_conv.inner = (void*)(this_obj & (~1));
20975         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20977         Record_free(this_obj_conv);
20978 }
20979
20980 uint32_t  __attribute__((export_name("TS_Record_get_level"))) TS_Record_get_level(uint32_t this_ptr) {
20981         LDKRecord this_ptr_conv;
20982         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20983         this_ptr_conv.is_owned = false;
20984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20985         uint32_t ret_conv = LDKLevel_to_js(Record_get_level(&this_ptr_conv));
20986         return ret_conv;
20987 }
20988
20989 void  __attribute__((export_name("TS_Record_set_level"))) TS_Record_set_level(uint32_t this_ptr, uint32_t val) {
20990         LDKRecord this_ptr_conv;
20991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20992         this_ptr_conv.is_owned = false;
20993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20994         LDKLevel val_conv = LDKLevel_from_js(val);
20995         Record_set_level(&this_ptr_conv, val_conv);
20996 }
20997
20998 jstring  __attribute__((export_name("TS_Record_get_args"))) TS_Record_get_args(uint32_t this_ptr) {
20999         LDKRecord this_ptr_conv;
21000         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21001         this_ptr_conv.is_owned = false;
21002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21003         LDKStr ret_str = Record_get_args(&this_ptr_conv);
21004         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
21005         Str_free(ret_str);
21006         return ret_conv;
21007 }
21008
21009 void  __attribute__((export_name("TS_Record_set_args"))) TS_Record_set_args(uint32_t this_ptr, jstring val) {
21010         LDKRecord this_ptr_conv;
21011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21012         this_ptr_conv.is_owned = false;
21013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21014         LDKStr val_conv = str_ref_to_owned_c(val);
21015         Record_set_args(&this_ptr_conv, val_conv);
21016 }
21017
21018 jstring  __attribute__((export_name("TS_Record_get_module_path"))) TS_Record_get_module_path(uint32_t this_ptr) {
21019         LDKRecord this_ptr_conv;
21020         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21021         this_ptr_conv.is_owned = false;
21022         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21023         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
21024         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
21025         Str_free(ret_str);
21026         return ret_conv;
21027 }
21028
21029 void  __attribute__((export_name("TS_Record_set_module_path"))) TS_Record_set_module_path(uint32_t this_ptr, jstring val) {
21030         LDKRecord this_ptr_conv;
21031         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21032         this_ptr_conv.is_owned = false;
21033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21034         LDKStr val_conv = str_ref_to_owned_c(val);
21035         Record_set_module_path(&this_ptr_conv, val_conv);
21036 }
21037
21038 jstring  __attribute__((export_name("TS_Record_get_file"))) TS_Record_get_file(uint32_t this_ptr) {
21039         LDKRecord this_ptr_conv;
21040         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21041         this_ptr_conv.is_owned = false;
21042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21043         LDKStr ret_str = Record_get_file(&this_ptr_conv);
21044         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
21045         Str_free(ret_str);
21046         return ret_conv;
21047 }
21048
21049 void  __attribute__((export_name("TS_Record_set_file"))) TS_Record_set_file(uint32_t this_ptr, jstring val) {
21050         LDKRecord this_ptr_conv;
21051         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21052         this_ptr_conv.is_owned = false;
21053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21054         LDKStr val_conv = str_ref_to_owned_c(val);
21055         Record_set_file(&this_ptr_conv, val_conv);
21056 }
21057
21058 int32_t  __attribute__((export_name("TS_Record_get_line"))) TS_Record_get_line(uint32_t this_ptr) {
21059         LDKRecord this_ptr_conv;
21060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21061         this_ptr_conv.is_owned = false;
21062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21063         int32_t ret_conv = Record_get_line(&this_ptr_conv);
21064         return ret_conv;
21065 }
21066
21067 void  __attribute__((export_name("TS_Record_set_line"))) TS_Record_set_line(uint32_t this_ptr, int32_t val) {
21068         LDKRecord this_ptr_conv;
21069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21070         this_ptr_conv.is_owned = false;
21071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21072         Record_set_line(&this_ptr_conv, val);
21073 }
21074
21075 static inline uintptr_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
21076         LDKRecord ret_var = Record_clone(arg);
21077 uint32_t ret_ref = 0;
21078 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21079 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21080 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21081 ret_ref = (uintptr_t)ret_var.inner;
21082 if (ret_var.is_owned) {
21083         ret_ref |= 1;
21084 }
21085         return ret_ref;
21086 }
21087 uint32_t  __attribute__((export_name("TS_Record_clone_ptr"))) TS_Record_clone_ptr(uint32_t arg) {
21088         LDKRecord arg_conv;
21089         arg_conv.inner = (void*)(arg & (~1));
21090         arg_conv.is_owned = false;
21091         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21092         uint32_t ret_conv = Record_clone_ptr(&arg_conv);
21093         return ret_conv;
21094 }
21095
21096 uint32_t  __attribute__((export_name("TS_Record_clone"))) TS_Record_clone(uint32_t orig) {
21097         LDKRecord orig_conv;
21098         orig_conv.inner = (void*)(orig & (~1));
21099         orig_conv.is_owned = false;
21100         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21101         LDKRecord ret_var = Record_clone(&orig_conv);
21102         uint32_t ret_ref = 0;
21103         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21104         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21105         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21106         ret_ref = (uintptr_t)ret_var.inner;
21107         if (ret_var.is_owned) {
21108                 ret_ref |= 1;
21109         }
21110         return ret_ref;
21111 }
21112
21113 void  __attribute__((export_name("TS_Logger_free"))) TS_Logger_free(uint32_t this_ptr) {
21114         if ((this_ptr & 1) != 0) return;
21115         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21116         CHECK_ACCESS(this_ptr_ptr);
21117         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
21118         FREE((void*)this_ptr);
21119         Logger_free(this_ptr_conv);
21120 }
21121
21122 void  __attribute__((export_name("TS_ChannelHandshakeConfig_free"))) TS_ChannelHandshakeConfig_free(uint32_t this_obj) {
21123         LDKChannelHandshakeConfig this_obj_conv;
21124         this_obj_conv.inner = (void*)(this_obj & (~1));
21125         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21127         ChannelHandshakeConfig_free(this_obj_conv);
21128 }
21129
21130 int32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_minimum_depth"))) TS_ChannelHandshakeConfig_get_minimum_depth(uint32_t this_ptr) {
21131         LDKChannelHandshakeConfig this_ptr_conv;
21132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21133         this_ptr_conv.is_owned = false;
21134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21135         int32_t ret_conv = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
21136         return ret_conv;
21137 }
21138
21139 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_minimum_depth"))) TS_ChannelHandshakeConfig_set_minimum_depth(uint32_t this_ptr, int32_t val) {
21140         LDKChannelHandshakeConfig this_ptr_conv;
21141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21142         this_ptr_conv.is_owned = false;
21143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21144         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
21145 }
21146
21147 int16_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_our_to_self_delay"))) TS_ChannelHandshakeConfig_get_our_to_self_delay(uint32_t this_ptr) {
21148         LDKChannelHandshakeConfig this_ptr_conv;
21149         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21150         this_ptr_conv.is_owned = false;
21151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21152         int16_t ret_conv = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
21153         return ret_conv;
21154 }
21155
21156 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) {
21157         LDKChannelHandshakeConfig this_ptr_conv;
21158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21159         this_ptr_conv.is_owned = false;
21160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21161         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
21162 }
21163
21164 int64_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat"))) TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat(uint32_t this_ptr) {
21165         LDKChannelHandshakeConfig this_ptr_conv;
21166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21167         this_ptr_conv.is_owned = false;
21168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21169         int64_t ret_conv = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
21170         return ret_conv;
21171 }
21172
21173 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) {
21174         LDKChannelHandshakeConfig this_ptr_conv;
21175         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21176         this_ptr_conv.is_owned = false;
21177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21178         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
21179 }
21180
21181 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) {
21182         LDKChannelHandshakeConfig this_ptr_conv;
21183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21184         this_ptr_conv.is_owned = false;
21185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21186         int8_t ret_conv = ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv);
21187         return ret_conv;
21188 }
21189
21190 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) {
21191         LDKChannelHandshakeConfig this_ptr_conv;
21192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21193         this_ptr_conv.is_owned = false;
21194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21195         ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv, val);
21196 }
21197
21198 jboolean  __attribute__((export_name("TS_ChannelHandshakeConfig_get_negotiate_scid_privacy"))) TS_ChannelHandshakeConfig_get_negotiate_scid_privacy(uint32_t this_ptr) {
21199         LDKChannelHandshakeConfig this_ptr_conv;
21200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21201         this_ptr_conv.is_owned = false;
21202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21203         jboolean ret_conv = ChannelHandshakeConfig_get_negotiate_scid_privacy(&this_ptr_conv);
21204         return ret_conv;
21205 }
21206
21207 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_negotiate_scid_privacy"))) TS_ChannelHandshakeConfig_set_negotiate_scid_privacy(uint32_t this_ptr, jboolean val) {
21208         LDKChannelHandshakeConfig this_ptr_conv;
21209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21210         this_ptr_conv.is_owned = false;
21211         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21212         ChannelHandshakeConfig_set_negotiate_scid_privacy(&this_ptr_conv, val);
21213 }
21214
21215 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) {
21216         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);
21217         uint32_t ret_ref = 0;
21218         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21219         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21220         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21221         ret_ref = (uintptr_t)ret_var.inner;
21222         if (ret_var.is_owned) {
21223                 ret_ref |= 1;
21224         }
21225         return ret_ref;
21226 }
21227
21228 static inline uintptr_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
21229         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
21230 uint32_t ret_ref = 0;
21231 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21232 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21233 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21234 ret_ref = (uintptr_t)ret_var.inner;
21235 if (ret_var.is_owned) {
21236         ret_ref |= 1;
21237 }
21238         return ret_ref;
21239 }
21240 uint32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_clone_ptr"))) TS_ChannelHandshakeConfig_clone_ptr(uint32_t arg) {
21241         LDKChannelHandshakeConfig arg_conv;
21242         arg_conv.inner = (void*)(arg & (~1));
21243         arg_conv.is_owned = false;
21244         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21245         uint32_t ret_conv = ChannelHandshakeConfig_clone_ptr(&arg_conv);
21246         return ret_conv;
21247 }
21248
21249 uint32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_clone"))) TS_ChannelHandshakeConfig_clone(uint32_t orig) {
21250         LDKChannelHandshakeConfig orig_conv;
21251         orig_conv.inner = (void*)(orig & (~1));
21252         orig_conv.is_owned = false;
21253         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21254         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
21255         uint32_t ret_ref = 0;
21256         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21257         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21258         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21259         ret_ref = (uintptr_t)ret_var.inner;
21260         if (ret_var.is_owned) {
21261                 ret_ref |= 1;
21262         }
21263         return ret_ref;
21264 }
21265
21266 uint32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_default"))) TS_ChannelHandshakeConfig_default() {
21267         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
21268         uint32_t ret_ref = 0;
21269         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21270         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21271         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21272         ret_ref = (uintptr_t)ret_var.inner;
21273         if (ret_var.is_owned) {
21274                 ret_ref |= 1;
21275         }
21276         return ret_ref;
21277 }
21278
21279 void  __attribute__((export_name("TS_ChannelHandshakeLimits_free"))) TS_ChannelHandshakeLimits_free(uint32_t this_obj) {
21280         LDKChannelHandshakeLimits this_obj_conv;
21281         this_obj_conv.inner = (void*)(this_obj & (~1));
21282         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21284         ChannelHandshakeLimits_free(this_obj_conv);
21285 }
21286
21287 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_min_funding_satoshis"))) TS_ChannelHandshakeLimits_get_min_funding_satoshis(uint32_t this_ptr) {
21288         LDKChannelHandshakeLimits this_ptr_conv;
21289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21290         this_ptr_conv.is_owned = false;
21291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21292         int64_t ret_conv = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
21293         return ret_conv;
21294 }
21295
21296 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_min_funding_satoshis"))) TS_ChannelHandshakeLimits_set_min_funding_satoshis(uint32_t this_ptr, int64_t val) {
21297         LDKChannelHandshakeLimits this_ptr_conv;
21298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21299         this_ptr_conv.is_owned = false;
21300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21301         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
21302 }
21303
21304 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_funding_satoshis"))) TS_ChannelHandshakeLimits_get_max_funding_satoshis(uint32_t this_ptr) {
21305         LDKChannelHandshakeLimits this_ptr_conv;
21306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21307         this_ptr_conv.is_owned = false;
21308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21309         int64_t ret_conv = ChannelHandshakeLimits_get_max_funding_satoshis(&this_ptr_conv);
21310         return ret_conv;
21311 }
21312
21313 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_max_funding_satoshis"))) TS_ChannelHandshakeLimits_set_max_funding_satoshis(uint32_t this_ptr, int64_t val) {
21314         LDKChannelHandshakeLimits this_ptr_conv;
21315         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21316         this_ptr_conv.is_owned = false;
21317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21318         ChannelHandshakeLimits_set_max_funding_satoshis(&this_ptr_conv, val);
21319 }
21320
21321 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat"))) TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat(uint32_t this_ptr) {
21322         LDKChannelHandshakeLimits this_ptr_conv;
21323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21324         this_ptr_conv.is_owned = false;
21325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21326         int64_t ret_conv = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
21327         return ret_conv;
21328 }
21329
21330 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) {
21331         LDKChannelHandshakeLimits this_ptr_conv;
21332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21333         this_ptr_conv.is_owned = false;
21334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21335         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
21336 }
21337
21338 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) {
21339         LDKChannelHandshakeLimits this_ptr_conv;
21340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21341         this_ptr_conv.is_owned = false;
21342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21343         int64_t ret_conv = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
21344         return ret_conv;
21345 }
21346
21347 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) {
21348         LDKChannelHandshakeLimits this_ptr_conv;
21349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21350         this_ptr_conv.is_owned = false;
21351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21352         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
21353 }
21354
21355 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis"))) TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis(uint32_t this_ptr) {
21356         LDKChannelHandshakeLimits this_ptr_conv;
21357         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21358         this_ptr_conv.is_owned = false;
21359         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21360         int64_t ret_conv = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
21361         return ret_conv;
21362 }
21363
21364 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) {
21365         LDKChannelHandshakeLimits this_ptr_conv;
21366         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21367         this_ptr_conv.is_owned = false;
21368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21369         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
21370 }
21371
21372 int16_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs"))) TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs(uint32_t this_ptr) {
21373         LDKChannelHandshakeLimits this_ptr_conv;
21374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21375         this_ptr_conv.is_owned = false;
21376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21377         int16_t ret_conv = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
21378         return ret_conv;
21379 }
21380
21381 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) {
21382         LDKChannelHandshakeLimits this_ptr_conv;
21383         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21384         this_ptr_conv.is_owned = false;
21385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21386         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
21387 }
21388
21389 int32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_minimum_depth"))) TS_ChannelHandshakeLimits_get_max_minimum_depth(uint32_t this_ptr) {
21390         LDKChannelHandshakeLimits this_ptr_conv;
21391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21392         this_ptr_conv.is_owned = false;
21393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21394         int32_t ret_conv = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
21395         return ret_conv;
21396 }
21397
21398 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_max_minimum_depth"))) TS_ChannelHandshakeLimits_set_max_minimum_depth(uint32_t this_ptr, int32_t val) {
21399         LDKChannelHandshakeLimits this_ptr_conv;
21400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21401         this_ptr_conv.is_owned = false;
21402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21403         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
21404 }
21405
21406 jboolean  __attribute__((export_name("TS_ChannelHandshakeLimits_get_trust_own_funding_0conf"))) TS_ChannelHandshakeLimits_get_trust_own_funding_0conf(uint32_t this_ptr) {
21407         LDKChannelHandshakeLimits this_ptr_conv;
21408         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21409         this_ptr_conv.is_owned = false;
21410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21411         jboolean ret_conv = ChannelHandshakeLimits_get_trust_own_funding_0conf(&this_ptr_conv);
21412         return ret_conv;
21413 }
21414
21415 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_trust_own_funding_0conf"))) TS_ChannelHandshakeLimits_set_trust_own_funding_0conf(uint32_t this_ptr, jboolean val) {
21416         LDKChannelHandshakeLimits this_ptr_conv;
21417         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21418         this_ptr_conv.is_owned = false;
21419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21420         ChannelHandshakeLimits_set_trust_own_funding_0conf(&this_ptr_conv, val);
21421 }
21422
21423 jboolean  __attribute__((export_name("TS_ChannelHandshakeLimits_get_force_announced_channel_preference"))) TS_ChannelHandshakeLimits_get_force_announced_channel_preference(uint32_t this_ptr) {
21424         LDKChannelHandshakeLimits this_ptr_conv;
21425         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21426         this_ptr_conv.is_owned = false;
21427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21428         jboolean ret_conv = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
21429         return ret_conv;
21430 }
21431
21432 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_force_announced_channel_preference"))) TS_ChannelHandshakeLimits_set_force_announced_channel_preference(uint32_t this_ptr, jboolean val) {
21433         LDKChannelHandshakeLimits this_ptr_conv;
21434         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21435         this_ptr_conv.is_owned = false;
21436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21437         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
21438 }
21439
21440 int16_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_their_to_self_delay"))) TS_ChannelHandshakeLimits_get_their_to_self_delay(uint32_t this_ptr) {
21441         LDKChannelHandshakeLimits this_ptr_conv;
21442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21443         this_ptr_conv.is_owned = false;
21444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21445         int16_t ret_conv = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
21446         return ret_conv;
21447 }
21448
21449 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) {
21450         LDKChannelHandshakeLimits this_ptr_conv;
21451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21452         this_ptr_conv.is_owned = false;
21453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21454         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
21455 }
21456
21457 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) {
21458         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);
21459         uint32_t ret_ref = 0;
21460         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21461         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21462         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21463         ret_ref = (uintptr_t)ret_var.inner;
21464         if (ret_var.is_owned) {
21465                 ret_ref |= 1;
21466         }
21467         return ret_ref;
21468 }
21469
21470 static inline uintptr_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
21471         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
21472 uint32_t ret_ref = 0;
21473 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21474 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21475 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21476 ret_ref = (uintptr_t)ret_var.inner;
21477 if (ret_var.is_owned) {
21478         ret_ref |= 1;
21479 }
21480         return ret_ref;
21481 }
21482 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_clone_ptr"))) TS_ChannelHandshakeLimits_clone_ptr(uint32_t arg) {
21483         LDKChannelHandshakeLimits arg_conv;
21484         arg_conv.inner = (void*)(arg & (~1));
21485         arg_conv.is_owned = false;
21486         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21487         uint32_t ret_conv = ChannelHandshakeLimits_clone_ptr(&arg_conv);
21488         return ret_conv;
21489 }
21490
21491 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_clone"))) TS_ChannelHandshakeLimits_clone(uint32_t orig) {
21492         LDKChannelHandshakeLimits orig_conv;
21493         orig_conv.inner = (void*)(orig & (~1));
21494         orig_conv.is_owned = false;
21495         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21496         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
21497         uint32_t ret_ref = 0;
21498         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21499         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21500         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21501         ret_ref = (uintptr_t)ret_var.inner;
21502         if (ret_var.is_owned) {
21503                 ret_ref |= 1;
21504         }
21505         return ret_ref;
21506 }
21507
21508 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_default"))) TS_ChannelHandshakeLimits_default() {
21509         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
21510         uint32_t ret_ref = 0;
21511         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21512         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21513         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21514         ret_ref = (uintptr_t)ret_var.inner;
21515         if (ret_var.is_owned) {
21516                 ret_ref |= 1;
21517         }
21518         return ret_ref;
21519 }
21520
21521 void  __attribute__((export_name("TS_ChannelConfig_free"))) TS_ChannelConfig_free(uint32_t this_obj) {
21522         LDKChannelConfig this_obj_conv;
21523         this_obj_conv.inner = (void*)(this_obj & (~1));
21524         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21526         ChannelConfig_free(this_obj_conv);
21527 }
21528
21529 int32_t  __attribute__((export_name("TS_ChannelConfig_get_forwarding_fee_proportional_millionths"))) TS_ChannelConfig_get_forwarding_fee_proportional_millionths(uint32_t this_ptr) {
21530         LDKChannelConfig this_ptr_conv;
21531         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21532         this_ptr_conv.is_owned = false;
21533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21534         int32_t ret_conv = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
21535         return ret_conv;
21536 }
21537
21538 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) {
21539         LDKChannelConfig this_ptr_conv;
21540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21541         this_ptr_conv.is_owned = false;
21542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21543         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
21544 }
21545
21546 int32_t  __attribute__((export_name("TS_ChannelConfig_get_forwarding_fee_base_msat"))) TS_ChannelConfig_get_forwarding_fee_base_msat(uint32_t this_ptr) {
21547         LDKChannelConfig this_ptr_conv;
21548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21549         this_ptr_conv.is_owned = false;
21550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21551         int32_t ret_conv = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
21552         return ret_conv;
21553 }
21554
21555 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) {
21556         LDKChannelConfig this_ptr_conv;
21557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21558         this_ptr_conv.is_owned = false;
21559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21560         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
21561 }
21562
21563 int16_t  __attribute__((export_name("TS_ChannelConfig_get_cltv_expiry_delta"))) TS_ChannelConfig_get_cltv_expiry_delta(uint32_t this_ptr) {
21564         LDKChannelConfig this_ptr_conv;
21565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21566         this_ptr_conv.is_owned = false;
21567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21568         int16_t ret_conv = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
21569         return ret_conv;
21570 }
21571
21572 void  __attribute__((export_name("TS_ChannelConfig_set_cltv_expiry_delta"))) TS_ChannelConfig_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
21573         LDKChannelConfig this_ptr_conv;
21574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21575         this_ptr_conv.is_owned = false;
21576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21577         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
21578 }
21579
21580 jboolean  __attribute__((export_name("TS_ChannelConfig_get_announced_channel"))) TS_ChannelConfig_get_announced_channel(uint32_t this_ptr) {
21581         LDKChannelConfig this_ptr_conv;
21582         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21583         this_ptr_conv.is_owned = false;
21584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21585         jboolean ret_conv = ChannelConfig_get_announced_channel(&this_ptr_conv);
21586         return ret_conv;
21587 }
21588
21589 void  __attribute__((export_name("TS_ChannelConfig_set_announced_channel"))) TS_ChannelConfig_set_announced_channel(uint32_t this_ptr, jboolean val) {
21590         LDKChannelConfig this_ptr_conv;
21591         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21592         this_ptr_conv.is_owned = false;
21593         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21594         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
21595 }
21596
21597 jboolean  __attribute__((export_name("TS_ChannelConfig_get_commit_upfront_shutdown_pubkey"))) TS_ChannelConfig_get_commit_upfront_shutdown_pubkey(uint32_t this_ptr) {
21598         LDKChannelConfig this_ptr_conv;
21599         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21600         this_ptr_conv.is_owned = false;
21601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21602         jboolean ret_conv = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
21603         return ret_conv;
21604 }
21605
21606 void  __attribute__((export_name("TS_ChannelConfig_set_commit_upfront_shutdown_pubkey"))) TS_ChannelConfig_set_commit_upfront_shutdown_pubkey(uint32_t this_ptr, jboolean val) {
21607         LDKChannelConfig this_ptr_conv;
21608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21609         this_ptr_conv.is_owned = false;
21610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21611         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
21612 }
21613
21614 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) {
21615         LDKChannelConfig this_ptr_conv;
21616         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21617         this_ptr_conv.is_owned = false;
21618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21619         int64_t ret_conv = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
21620         return ret_conv;
21621 }
21622
21623 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) {
21624         LDKChannelConfig this_ptr_conv;
21625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21626         this_ptr_conv.is_owned = false;
21627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21628         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
21629 }
21630
21631 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) {
21632         LDKChannelConfig this_ptr_conv;
21633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21634         this_ptr_conv.is_owned = false;
21635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21636         int64_t ret_conv = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
21637         return ret_conv;
21638 }
21639
21640 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) {
21641         LDKChannelConfig this_ptr_conv;
21642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21643         this_ptr_conv.is_owned = false;
21644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21645         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
21646 }
21647
21648 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, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg, int64_t max_dust_htlc_exposure_msat_arg, int64_t force_close_avoidance_max_fee_satoshis_arg) {
21649         LDKChannelConfig ret_var = ChannelConfig_new(forwarding_fee_proportional_millionths_arg, forwarding_fee_base_msat_arg, cltv_expiry_delta_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg, max_dust_htlc_exposure_msat_arg, force_close_avoidance_max_fee_satoshis_arg);
21650         uint32_t ret_ref = 0;
21651         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21652         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21653         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21654         ret_ref = (uintptr_t)ret_var.inner;
21655         if (ret_var.is_owned) {
21656                 ret_ref |= 1;
21657         }
21658         return ret_ref;
21659 }
21660
21661 static inline uintptr_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
21662         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
21663 uint32_t ret_ref = 0;
21664 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21665 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21666 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21667 ret_ref = (uintptr_t)ret_var.inner;
21668 if (ret_var.is_owned) {
21669         ret_ref |= 1;
21670 }
21671         return ret_ref;
21672 }
21673 uint32_t  __attribute__((export_name("TS_ChannelConfig_clone_ptr"))) TS_ChannelConfig_clone_ptr(uint32_t arg) {
21674         LDKChannelConfig arg_conv;
21675         arg_conv.inner = (void*)(arg & (~1));
21676         arg_conv.is_owned = false;
21677         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21678         uint32_t ret_conv = ChannelConfig_clone_ptr(&arg_conv);
21679         return ret_conv;
21680 }
21681
21682 uint32_t  __attribute__((export_name("TS_ChannelConfig_clone"))) TS_ChannelConfig_clone(uint32_t orig) {
21683         LDKChannelConfig orig_conv;
21684         orig_conv.inner = (void*)(orig & (~1));
21685         orig_conv.is_owned = false;
21686         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21687         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
21688         uint32_t ret_ref = 0;
21689         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21690         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21691         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21692         ret_ref = (uintptr_t)ret_var.inner;
21693         if (ret_var.is_owned) {
21694                 ret_ref |= 1;
21695         }
21696         return ret_ref;
21697 }
21698
21699 uint32_t  __attribute__((export_name("TS_ChannelConfig_default"))) TS_ChannelConfig_default() {
21700         LDKChannelConfig ret_var = ChannelConfig_default();
21701         uint32_t ret_ref = 0;
21702         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21703         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21704         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21705         ret_ref = (uintptr_t)ret_var.inner;
21706         if (ret_var.is_owned) {
21707                 ret_ref |= 1;
21708         }
21709         return ret_ref;
21710 }
21711
21712 int8_tArray  __attribute__((export_name("TS_ChannelConfig_write"))) TS_ChannelConfig_write(uint32_t obj) {
21713         LDKChannelConfig obj_conv;
21714         obj_conv.inner = (void*)(obj & (~1));
21715         obj_conv.is_owned = false;
21716         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
21717         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
21718         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
21719         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
21720         CVec_u8Z_free(ret_var);
21721         return ret_arr;
21722 }
21723
21724 uint32_t  __attribute__((export_name("TS_ChannelConfig_read"))) TS_ChannelConfig_read(int8_tArray ser) {
21725         LDKu8slice ser_ref;
21726         ser_ref.datalen = ser->arr_len;
21727         ser_ref.data = ser->elems /* XXX ser leaks */;
21728         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
21729         *ret_conv = ChannelConfig_read(ser_ref);
21730         return (uint32_t)ret_conv;
21731 }
21732
21733 void  __attribute__((export_name("TS_UserConfig_free"))) TS_UserConfig_free(uint32_t this_obj) {
21734         LDKUserConfig this_obj_conv;
21735         this_obj_conv.inner = (void*)(this_obj & (~1));
21736         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21738         UserConfig_free(this_obj_conv);
21739 }
21740
21741 uint32_t  __attribute__((export_name("TS_UserConfig_get_own_channel_config"))) TS_UserConfig_get_own_channel_config(uint32_t this_ptr) {
21742         LDKUserConfig this_ptr_conv;
21743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21744         this_ptr_conv.is_owned = false;
21745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21746         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
21747         uint32_t ret_ref = 0;
21748         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21749         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21750         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21751         ret_ref = (uintptr_t)ret_var.inner;
21752         if (ret_var.is_owned) {
21753                 ret_ref |= 1;
21754         }
21755         return ret_ref;
21756 }
21757
21758 void  __attribute__((export_name("TS_UserConfig_set_own_channel_config"))) TS_UserConfig_set_own_channel_config(uint32_t this_ptr, uint32_t val) {
21759         LDKUserConfig this_ptr_conv;
21760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21761         this_ptr_conv.is_owned = false;
21762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21763         LDKChannelHandshakeConfig val_conv;
21764         val_conv.inner = (void*)(val & (~1));
21765         val_conv.is_owned = (val & 1) || (val == 0);
21766         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
21767         val_conv = ChannelHandshakeConfig_clone(&val_conv);
21768         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
21769 }
21770
21771 uint32_t  __attribute__((export_name("TS_UserConfig_get_peer_channel_config_limits"))) TS_UserConfig_get_peer_channel_config_limits(uint32_t this_ptr) {
21772         LDKUserConfig this_ptr_conv;
21773         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21774         this_ptr_conv.is_owned = false;
21775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21776         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
21777         uint32_t ret_ref = 0;
21778         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21779         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21780         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21781         ret_ref = (uintptr_t)ret_var.inner;
21782         if (ret_var.is_owned) {
21783                 ret_ref |= 1;
21784         }
21785         return ret_ref;
21786 }
21787
21788 void  __attribute__((export_name("TS_UserConfig_set_peer_channel_config_limits"))) TS_UserConfig_set_peer_channel_config_limits(uint32_t this_ptr, uint32_t val) {
21789         LDKUserConfig this_ptr_conv;
21790         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21791         this_ptr_conv.is_owned = false;
21792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21793         LDKChannelHandshakeLimits val_conv;
21794         val_conv.inner = (void*)(val & (~1));
21795         val_conv.is_owned = (val & 1) || (val == 0);
21796         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
21797         val_conv = ChannelHandshakeLimits_clone(&val_conv);
21798         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
21799 }
21800
21801 uint32_t  __attribute__((export_name("TS_UserConfig_get_channel_options"))) TS_UserConfig_get_channel_options(uint32_t this_ptr) {
21802         LDKUserConfig this_ptr_conv;
21803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21804         this_ptr_conv.is_owned = false;
21805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21806         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
21807         uint32_t ret_ref = 0;
21808         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21809         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21810         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21811         ret_ref = (uintptr_t)ret_var.inner;
21812         if (ret_var.is_owned) {
21813                 ret_ref |= 1;
21814         }
21815         return ret_ref;
21816 }
21817
21818 void  __attribute__((export_name("TS_UserConfig_set_channel_options"))) TS_UserConfig_set_channel_options(uint32_t this_ptr, uint32_t val) {
21819         LDKUserConfig this_ptr_conv;
21820         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21821         this_ptr_conv.is_owned = false;
21822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21823         LDKChannelConfig val_conv;
21824         val_conv.inner = (void*)(val & (~1));
21825         val_conv.is_owned = (val & 1) || (val == 0);
21826         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
21827         val_conv = ChannelConfig_clone(&val_conv);
21828         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
21829 }
21830
21831 jboolean  __attribute__((export_name("TS_UserConfig_get_accept_forwards_to_priv_channels"))) TS_UserConfig_get_accept_forwards_to_priv_channels(uint32_t this_ptr) {
21832         LDKUserConfig this_ptr_conv;
21833         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21834         this_ptr_conv.is_owned = false;
21835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21836         jboolean ret_conv = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
21837         return ret_conv;
21838 }
21839
21840 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) {
21841         LDKUserConfig this_ptr_conv;
21842         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21843         this_ptr_conv.is_owned = false;
21844         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21845         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
21846 }
21847
21848 jboolean  __attribute__((export_name("TS_UserConfig_get_accept_inbound_channels"))) TS_UserConfig_get_accept_inbound_channels(uint32_t this_ptr) {
21849         LDKUserConfig this_ptr_conv;
21850         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21851         this_ptr_conv.is_owned = false;
21852         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21853         jboolean ret_conv = UserConfig_get_accept_inbound_channels(&this_ptr_conv);
21854         return ret_conv;
21855 }
21856
21857 void  __attribute__((export_name("TS_UserConfig_set_accept_inbound_channels"))) TS_UserConfig_set_accept_inbound_channels(uint32_t this_ptr, jboolean val) {
21858         LDKUserConfig this_ptr_conv;
21859         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21860         this_ptr_conv.is_owned = false;
21861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21862         UserConfig_set_accept_inbound_channels(&this_ptr_conv, val);
21863 }
21864
21865 jboolean  __attribute__((export_name("TS_UserConfig_get_manually_accept_inbound_channels"))) TS_UserConfig_get_manually_accept_inbound_channels(uint32_t this_ptr) {
21866         LDKUserConfig this_ptr_conv;
21867         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21868         this_ptr_conv.is_owned = false;
21869         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21870         jboolean ret_conv = UserConfig_get_manually_accept_inbound_channels(&this_ptr_conv);
21871         return ret_conv;
21872 }
21873
21874 void  __attribute__((export_name("TS_UserConfig_set_manually_accept_inbound_channels"))) TS_UserConfig_set_manually_accept_inbound_channels(uint32_t this_ptr, jboolean val) {
21875         LDKUserConfig this_ptr_conv;
21876         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21877         this_ptr_conv.is_owned = false;
21878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21879         UserConfig_set_manually_accept_inbound_channels(&this_ptr_conv, val);
21880 }
21881
21882 uint32_t  __attribute__((export_name("TS_UserConfig_new"))) TS_UserConfig_new(uint32_t own_channel_config_arg, uint32_t peer_channel_config_limits_arg, uint32_t channel_options_arg, jboolean accept_forwards_to_priv_channels_arg, jboolean accept_inbound_channels_arg, jboolean manually_accept_inbound_channels_arg) {
21883         LDKChannelHandshakeConfig own_channel_config_arg_conv;
21884         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
21885         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
21886         CHECK_INNER_FIELD_ACCESS_OR_NULL(own_channel_config_arg_conv);
21887         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
21888         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
21889         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
21890         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
21891         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_channel_config_limits_arg_conv);
21892         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
21893         LDKChannelConfig channel_options_arg_conv;
21894         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
21895         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
21896         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_options_arg_conv);
21897         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
21898         LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv, accept_forwards_to_priv_channels_arg, accept_inbound_channels_arg, manually_accept_inbound_channels_arg);
21899         uint32_t ret_ref = 0;
21900         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21901         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21902         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21903         ret_ref = (uintptr_t)ret_var.inner;
21904         if (ret_var.is_owned) {
21905                 ret_ref |= 1;
21906         }
21907         return ret_ref;
21908 }
21909
21910 static inline uintptr_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
21911         LDKUserConfig ret_var = UserConfig_clone(arg);
21912 uint32_t ret_ref = 0;
21913 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21914 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21915 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21916 ret_ref = (uintptr_t)ret_var.inner;
21917 if (ret_var.is_owned) {
21918         ret_ref |= 1;
21919 }
21920         return ret_ref;
21921 }
21922 uint32_t  __attribute__((export_name("TS_UserConfig_clone_ptr"))) TS_UserConfig_clone_ptr(uint32_t arg) {
21923         LDKUserConfig arg_conv;
21924         arg_conv.inner = (void*)(arg & (~1));
21925         arg_conv.is_owned = false;
21926         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21927         uint32_t ret_conv = UserConfig_clone_ptr(&arg_conv);
21928         return ret_conv;
21929 }
21930
21931 uint32_t  __attribute__((export_name("TS_UserConfig_clone"))) TS_UserConfig_clone(uint32_t orig) {
21932         LDKUserConfig orig_conv;
21933         orig_conv.inner = (void*)(orig & (~1));
21934         orig_conv.is_owned = false;
21935         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21936         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
21937         uint32_t ret_ref = 0;
21938         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21939         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21940         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21941         ret_ref = (uintptr_t)ret_var.inner;
21942         if (ret_var.is_owned) {
21943                 ret_ref |= 1;
21944         }
21945         return ret_ref;
21946 }
21947
21948 uint32_t  __attribute__((export_name("TS_UserConfig_default"))) TS_UserConfig_default() {
21949         LDKUserConfig ret_var = UserConfig_default();
21950         uint32_t ret_ref = 0;
21951         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21952         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21953         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21954         ret_ref = (uintptr_t)ret_var.inner;
21955         if (ret_var.is_owned) {
21956                 ret_ref |= 1;
21957         }
21958         return ret_ref;
21959 }
21960
21961 void  __attribute__((export_name("TS_BestBlock_free"))) TS_BestBlock_free(uint32_t this_obj) {
21962         LDKBestBlock this_obj_conv;
21963         this_obj_conv.inner = (void*)(this_obj & (~1));
21964         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21966         BestBlock_free(this_obj_conv);
21967 }
21968
21969 static inline uintptr_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
21970         LDKBestBlock ret_var = BestBlock_clone(arg);
21971 uint32_t ret_ref = 0;
21972 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21973 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21974 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21975 ret_ref = (uintptr_t)ret_var.inner;
21976 if (ret_var.is_owned) {
21977         ret_ref |= 1;
21978 }
21979         return ret_ref;
21980 }
21981 uint32_t  __attribute__((export_name("TS_BestBlock_clone_ptr"))) TS_BestBlock_clone_ptr(uint32_t arg) {
21982         LDKBestBlock arg_conv;
21983         arg_conv.inner = (void*)(arg & (~1));
21984         arg_conv.is_owned = false;
21985         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21986         uint32_t ret_conv = BestBlock_clone_ptr(&arg_conv);
21987         return ret_conv;
21988 }
21989
21990 uint32_t  __attribute__((export_name("TS_BestBlock_clone"))) TS_BestBlock_clone(uint32_t orig) {
21991         LDKBestBlock orig_conv;
21992         orig_conv.inner = (void*)(orig & (~1));
21993         orig_conv.is_owned = false;
21994         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21995         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
21996         uint32_t ret_ref = 0;
21997         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21998         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21999         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22000         ret_ref = (uintptr_t)ret_var.inner;
22001         if (ret_var.is_owned) {
22002                 ret_ref |= 1;
22003         }
22004         return ret_ref;
22005 }
22006
22007 uint32_t  __attribute__((export_name("TS_BestBlock_from_genesis"))) TS_BestBlock_from_genesis(uint32_t network) {
22008         LDKNetwork network_conv = LDKNetwork_from_js(network);
22009         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
22010         uint32_t ret_ref = 0;
22011         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22012         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22013         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22014         ret_ref = (uintptr_t)ret_var.inner;
22015         if (ret_var.is_owned) {
22016                 ret_ref |= 1;
22017         }
22018         return ret_ref;
22019 }
22020
22021 uint32_t  __attribute__((export_name("TS_BestBlock_new"))) TS_BestBlock_new(int8_tArray block_hash, int32_t height) {
22022         LDKThirtyTwoBytes block_hash_ref;
22023         CHECK(block_hash->arr_len == 32);
22024         memcpy(block_hash_ref.data, block_hash->elems, 32); FREE(block_hash);
22025         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
22026         uint32_t ret_ref = 0;
22027         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22028         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22029         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22030         ret_ref = (uintptr_t)ret_var.inner;
22031         if (ret_var.is_owned) {
22032                 ret_ref |= 1;
22033         }
22034         return ret_ref;
22035 }
22036
22037 int8_tArray  __attribute__((export_name("TS_BestBlock_block_hash"))) TS_BestBlock_block_hash(uint32_t this_arg) {
22038         LDKBestBlock this_arg_conv;
22039         this_arg_conv.inner = (void*)(this_arg & (~1));
22040         this_arg_conv.is_owned = false;
22041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22042         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
22043         memcpy(ret_arr->elems, BestBlock_block_hash(&this_arg_conv).data, 32);
22044         return ret_arr;
22045 }
22046
22047 int32_t  __attribute__((export_name("TS_BestBlock_height"))) TS_BestBlock_height(uint32_t this_arg) {
22048         LDKBestBlock this_arg_conv;
22049         this_arg_conv.inner = (void*)(this_arg & (~1));
22050         this_arg_conv.is_owned = false;
22051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22052         int32_t ret_conv = BestBlock_height(&this_arg_conv);
22053         return ret_conv;
22054 }
22055
22056 uint32_t  __attribute__((export_name("TS_AccessError_clone"))) TS_AccessError_clone(uint32_t orig) {
22057         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
22058         uint32_t ret_conv = LDKAccessError_to_js(AccessError_clone(orig_conv));
22059         return ret_conv;
22060 }
22061
22062 uint32_t  __attribute__((export_name("TS_AccessError_unknown_chain"))) TS_AccessError_unknown_chain() {
22063         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_chain());
22064         return ret_conv;
22065 }
22066
22067 uint32_t  __attribute__((export_name("TS_AccessError_unknown_tx"))) TS_AccessError_unknown_tx() {
22068         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_tx());
22069         return ret_conv;
22070 }
22071
22072 void  __attribute__((export_name("TS_Access_free"))) TS_Access_free(uint32_t this_ptr) {
22073         if ((this_ptr & 1) != 0) return;
22074         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22075         CHECK_ACCESS(this_ptr_ptr);
22076         LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
22077         FREE((void*)this_ptr);
22078         Access_free(this_ptr_conv);
22079 }
22080
22081 void  __attribute__((export_name("TS_Listen_free"))) TS_Listen_free(uint32_t this_ptr) {
22082         if ((this_ptr & 1) != 0) return;
22083         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22084         CHECK_ACCESS(this_ptr_ptr);
22085         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
22086         FREE((void*)this_ptr);
22087         Listen_free(this_ptr_conv);
22088 }
22089
22090 void  __attribute__((export_name("TS_Confirm_free"))) TS_Confirm_free(uint32_t this_ptr) {
22091         if ((this_ptr & 1) != 0) return;
22092         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22093         CHECK_ACCESS(this_ptr_ptr);
22094         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
22095         FREE((void*)this_ptr);
22096         Confirm_free(this_ptr_conv);
22097 }
22098
22099 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_clone"))) TS_ChannelMonitorUpdateErr_clone(uint32_t orig) {
22100         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
22101         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_clone(orig_conv));
22102         return ret_conv;
22103 }
22104
22105 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_temporary_failure"))) TS_ChannelMonitorUpdateErr_temporary_failure() {
22106         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_temporary_failure());
22107         return ret_conv;
22108 }
22109
22110 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_permanent_failure"))) TS_ChannelMonitorUpdateErr_permanent_failure() {
22111         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_permanent_failure());
22112         return ret_conv;
22113 }
22114
22115 void  __attribute__((export_name("TS_Watch_free"))) TS_Watch_free(uint32_t this_ptr) {
22116         if ((this_ptr & 1) != 0) return;
22117         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22118         CHECK_ACCESS(this_ptr_ptr);
22119         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
22120         FREE((void*)this_ptr);
22121         Watch_free(this_ptr_conv);
22122 }
22123
22124 void  __attribute__((export_name("TS_Filter_free"))) TS_Filter_free(uint32_t this_ptr) {
22125         if ((this_ptr & 1) != 0) return;
22126         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22127         CHECK_ACCESS(this_ptr_ptr);
22128         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
22129         FREE((void*)this_ptr);
22130         Filter_free(this_ptr_conv);
22131 }
22132
22133 void  __attribute__((export_name("TS_WatchedOutput_free"))) TS_WatchedOutput_free(uint32_t this_obj) {
22134         LDKWatchedOutput this_obj_conv;
22135         this_obj_conv.inner = (void*)(this_obj & (~1));
22136         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22138         WatchedOutput_free(this_obj_conv);
22139 }
22140
22141 int8_tArray  __attribute__((export_name("TS_WatchedOutput_get_block_hash"))) TS_WatchedOutput_get_block_hash(uint32_t this_ptr) {
22142         LDKWatchedOutput this_ptr_conv;
22143         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22144         this_ptr_conv.is_owned = false;
22145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22146         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
22147         memcpy(ret_arr->elems, WatchedOutput_get_block_hash(&this_ptr_conv).data, 32);
22148         return ret_arr;
22149 }
22150
22151 void  __attribute__((export_name("TS_WatchedOutput_set_block_hash"))) TS_WatchedOutput_set_block_hash(uint32_t this_ptr, int8_tArray val) {
22152         LDKWatchedOutput this_ptr_conv;
22153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22154         this_ptr_conv.is_owned = false;
22155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22156         LDKThirtyTwoBytes val_ref;
22157         CHECK(val->arr_len == 32);
22158         memcpy(val_ref.data, val->elems, 32); FREE(val);
22159         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
22160 }
22161
22162 uint32_t  __attribute__((export_name("TS_WatchedOutput_get_outpoint"))) TS_WatchedOutput_get_outpoint(uint32_t this_ptr) {
22163         LDKWatchedOutput this_ptr_conv;
22164         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22165         this_ptr_conv.is_owned = false;
22166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22167         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
22168         uint32_t ret_ref = 0;
22169         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22170         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22171         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22172         ret_ref = (uintptr_t)ret_var.inner;
22173         if (ret_var.is_owned) {
22174                 ret_ref |= 1;
22175         }
22176         return ret_ref;
22177 }
22178
22179 void  __attribute__((export_name("TS_WatchedOutput_set_outpoint"))) TS_WatchedOutput_set_outpoint(uint32_t this_ptr, uint32_t val) {
22180         LDKWatchedOutput this_ptr_conv;
22181         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22182         this_ptr_conv.is_owned = false;
22183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22184         LDKOutPoint val_conv;
22185         val_conv.inner = (void*)(val & (~1));
22186         val_conv.is_owned = (val & 1) || (val == 0);
22187         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
22188         val_conv = OutPoint_clone(&val_conv);
22189         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
22190 }
22191
22192 int8_tArray  __attribute__((export_name("TS_WatchedOutput_get_script_pubkey"))) TS_WatchedOutput_get_script_pubkey(uint32_t this_ptr) {
22193         LDKWatchedOutput this_ptr_conv;
22194         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22195         this_ptr_conv.is_owned = false;
22196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22197         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
22198         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22199         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22200         return ret_arr;
22201 }
22202
22203 void  __attribute__((export_name("TS_WatchedOutput_set_script_pubkey"))) TS_WatchedOutput_set_script_pubkey(uint32_t this_ptr, int8_tArray val) {
22204         LDKWatchedOutput this_ptr_conv;
22205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22206         this_ptr_conv.is_owned = false;
22207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22208         LDKCVec_u8Z val_ref;
22209         val_ref.datalen = val->arr_len;
22210         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
22211         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
22212         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
22213 }
22214
22215 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) {
22216         LDKThirtyTwoBytes block_hash_arg_ref;
22217         CHECK(block_hash_arg->arr_len == 32);
22218         memcpy(block_hash_arg_ref.data, block_hash_arg->elems, 32); FREE(block_hash_arg);
22219         LDKOutPoint outpoint_arg_conv;
22220         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
22221         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
22222         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
22223         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
22224         LDKCVec_u8Z script_pubkey_arg_ref;
22225         script_pubkey_arg_ref.datalen = script_pubkey_arg->arr_len;
22226         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
22227         memcpy(script_pubkey_arg_ref.data, script_pubkey_arg->elems, script_pubkey_arg_ref.datalen); FREE(script_pubkey_arg);
22228         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
22229         uint32_t ret_ref = 0;
22230         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22231         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22232         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22233         ret_ref = (uintptr_t)ret_var.inner;
22234         if (ret_var.is_owned) {
22235                 ret_ref |= 1;
22236         }
22237         return ret_ref;
22238 }
22239
22240 static inline uintptr_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
22241         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
22242 uint32_t ret_ref = 0;
22243 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22244 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22245 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22246 ret_ref = (uintptr_t)ret_var.inner;
22247 if (ret_var.is_owned) {
22248         ret_ref |= 1;
22249 }
22250         return ret_ref;
22251 }
22252 uint32_t  __attribute__((export_name("TS_WatchedOutput_clone_ptr"))) TS_WatchedOutput_clone_ptr(uint32_t arg) {
22253         LDKWatchedOutput arg_conv;
22254         arg_conv.inner = (void*)(arg & (~1));
22255         arg_conv.is_owned = false;
22256         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22257         uint32_t ret_conv = WatchedOutput_clone_ptr(&arg_conv);
22258         return ret_conv;
22259 }
22260
22261 uint32_t  __attribute__((export_name("TS_WatchedOutput_clone"))) TS_WatchedOutput_clone(uint32_t orig) {
22262         LDKWatchedOutput orig_conv;
22263         orig_conv.inner = (void*)(orig & (~1));
22264         orig_conv.is_owned = false;
22265         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22266         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
22267         uint32_t ret_ref = 0;
22268         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22269         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22270         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22271         ret_ref = (uintptr_t)ret_var.inner;
22272         if (ret_var.is_owned) {
22273                 ret_ref |= 1;
22274         }
22275         return ret_ref;
22276 }
22277
22278 int64_t  __attribute__((export_name("TS_WatchedOutput_hash"))) TS_WatchedOutput_hash(uint32_t o) {
22279         LDKWatchedOutput o_conv;
22280         o_conv.inner = (void*)(o & (~1));
22281         o_conv.is_owned = false;
22282         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22283         int64_t ret_conv = WatchedOutput_hash(&o_conv);
22284         return ret_conv;
22285 }
22286
22287 void  __attribute__((export_name("TS_BroadcasterInterface_free"))) TS_BroadcasterInterface_free(uint32_t this_ptr) {
22288         if ((this_ptr & 1) != 0) return;
22289         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22290         CHECK_ACCESS(this_ptr_ptr);
22291         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
22292         FREE((void*)this_ptr);
22293         BroadcasterInterface_free(this_ptr_conv);
22294 }
22295
22296 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_clone"))) TS_ConfirmationTarget_clone(uint32_t orig) {
22297         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
22298         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_clone(orig_conv));
22299         return ret_conv;
22300 }
22301
22302 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_background"))) TS_ConfirmationTarget_background() {
22303         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_background());
22304         return ret_conv;
22305 }
22306
22307 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_normal"))) TS_ConfirmationTarget_normal() {
22308         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_normal());
22309         return ret_conv;
22310 }
22311
22312 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_high_priority"))) TS_ConfirmationTarget_high_priority() {
22313         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_high_priority());
22314         return ret_conv;
22315 }
22316
22317 jboolean  __attribute__((export_name("TS_ConfirmationTarget_eq"))) TS_ConfirmationTarget_eq(uint32_t a, uint32_t b) {
22318         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1);
22319         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1);
22320         jboolean ret_conv = ConfirmationTarget_eq(a_conv, b_conv);
22321         return ret_conv;
22322 }
22323
22324 void  __attribute__((export_name("TS_FeeEstimator_free"))) TS_FeeEstimator_free(uint32_t this_ptr) {
22325         if ((this_ptr & 1) != 0) return;
22326         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22327         CHECK_ACCESS(this_ptr_ptr);
22328         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
22329         FREE((void*)this_ptr);
22330         FeeEstimator_free(this_ptr_conv);
22331 }
22332
22333 void  __attribute__((export_name("TS_MonitorUpdateId_free"))) TS_MonitorUpdateId_free(uint32_t this_obj) {
22334         LDKMonitorUpdateId this_obj_conv;
22335         this_obj_conv.inner = (void*)(this_obj & (~1));
22336         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22338         MonitorUpdateId_free(this_obj_conv);
22339 }
22340
22341 static inline uintptr_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
22342         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
22343 uint32_t ret_ref = 0;
22344 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22345 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22346 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22347 ret_ref = (uintptr_t)ret_var.inner;
22348 if (ret_var.is_owned) {
22349         ret_ref |= 1;
22350 }
22351         return ret_ref;
22352 }
22353 uint32_t  __attribute__((export_name("TS_MonitorUpdateId_clone_ptr"))) TS_MonitorUpdateId_clone_ptr(uint32_t arg) {
22354         LDKMonitorUpdateId arg_conv;
22355         arg_conv.inner = (void*)(arg & (~1));
22356         arg_conv.is_owned = false;
22357         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22358         uint32_t ret_conv = MonitorUpdateId_clone_ptr(&arg_conv);
22359         return ret_conv;
22360 }
22361
22362 uint32_t  __attribute__((export_name("TS_MonitorUpdateId_clone"))) TS_MonitorUpdateId_clone(uint32_t orig) {
22363         LDKMonitorUpdateId orig_conv;
22364         orig_conv.inner = (void*)(orig & (~1));
22365         orig_conv.is_owned = false;
22366         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22367         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
22368         uint32_t ret_ref = 0;
22369         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22370         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22371         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22372         ret_ref = (uintptr_t)ret_var.inner;
22373         if (ret_var.is_owned) {
22374                 ret_ref |= 1;
22375         }
22376         return ret_ref;
22377 }
22378
22379 int64_t  __attribute__((export_name("TS_MonitorUpdateId_hash"))) TS_MonitorUpdateId_hash(uint32_t o) {
22380         LDKMonitorUpdateId o_conv;
22381         o_conv.inner = (void*)(o & (~1));
22382         o_conv.is_owned = false;
22383         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22384         int64_t ret_conv = MonitorUpdateId_hash(&o_conv);
22385         return ret_conv;
22386 }
22387
22388 jboolean  __attribute__((export_name("TS_MonitorUpdateId_eq"))) TS_MonitorUpdateId_eq(uint32_t a, uint32_t b) {
22389         LDKMonitorUpdateId a_conv;
22390         a_conv.inner = (void*)(a & (~1));
22391         a_conv.is_owned = false;
22392         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
22393         LDKMonitorUpdateId b_conv;
22394         b_conv.inner = (void*)(b & (~1));
22395         b_conv.is_owned = false;
22396         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
22397         jboolean ret_conv = MonitorUpdateId_eq(&a_conv, &b_conv);
22398         return ret_conv;
22399 }
22400
22401 void  __attribute__((export_name("TS_Persist_free"))) TS_Persist_free(uint32_t this_ptr) {
22402         if ((this_ptr & 1) != 0) return;
22403         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22404         CHECK_ACCESS(this_ptr_ptr);
22405         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
22406         FREE((void*)this_ptr);
22407         Persist_free(this_ptr_conv);
22408 }
22409
22410 void  __attribute__((export_name("TS_LockedChannelMonitor_free"))) TS_LockedChannelMonitor_free(uint32_t this_obj) {
22411         LDKLockedChannelMonitor this_obj_conv;
22412         this_obj_conv.inner = (void*)(this_obj & (~1));
22413         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22415         LockedChannelMonitor_free(this_obj_conv);
22416 }
22417
22418 void  __attribute__((export_name("TS_ChainMonitor_free"))) TS_ChainMonitor_free(uint32_t this_obj) {
22419         LDKChainMonitor this_obj_conv;
22420         this_obj_conv.inner = (void*)(this_obj & (~1));
22421         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22423         ChainMonitor_free(this_obj_conv);
22424 }
22425
22426 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) {
22427         void* chain_source_ptr = (void*)(((uintptr_t)chain_source) & ~1);
22428         CHECK_ACCESS(chain_source_ptr);
22429         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
22430         // WARNING: we may need a move here but no clone is available for LDKCOption_FilterZ
22431         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
22432                 // Manually implement clone for Java trait instances
22433                 if (chain_source_conv.some.free == LDKFilter_JCalls_free) {
22434                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22435                         LDKFilter_JCalls_cloned(&chain_source_conv.some);
22436                 }
22437         }
22438         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22439         CHECK_ACCESS(broadcaster_ptr);
22440         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22441         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
22442                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22443                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
22444         }
22445         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22446         CHECK_ACCESS(logger_ptr);
22447         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22448         if (logger_conv.free == LDKLogger_JCalls_free) {
22449                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22450                 LDKLogger_JCalls_cloned(&logger_conv);
22451         }
22452         void* feeest_ptr = (void*)(((uintptr_t)feeest) & ~1);
22453         CHECK_ACCESS(feeest_ptr);
22454         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
22455         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
22456                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22457                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
22458         }
22459         void* persister_ptr = (void*)(((uintptr_t)persister) & ~1);
22460         CHECK_ACCESS(persister_ptr);
22461         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
22462         if (persister_conv.free == LDKPersist_JCalls_free) {
22463                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22464                 LDKPersist_JCalls_cloned(&persister_conv);
22465         }
22466         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
22467         uint32_t ret_ref = 0;
22468         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22469         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22470         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22471         ret_ref = (uintptr_t)ret_var.inner;
22472         if (ret_var.is_owned) {
22473                 ret_ref |= 1;
22474         }
22475         return ret_ref;
22476 }
22477
22478 uint32_tArray  __attribute__((export_name("TS_ChainMonitor_get_claimable_balances"))) TS_ChainMonitor_get_claimable_balances(uint32_t this_arg, uint32_tArray ignored_channels) {
22479         LDKChainMonitor this_arg_conv;
22480         this_arg_conv.inner = (void*)(this_arg & (~1));
22481         this_arg_conv.is_owned = false;
22482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22483         LDKCVec_ChannelDetailsZ ignored_channels_constr;
22484         ignored_channels_constr.datalen = ignored_channels->arr_len;
22485         if (ignored_channels_constr.datalen > 0)
22486                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
22487         else
22488                 ignored_channels_constr.data = NULL;
22489         uint32_t* ignored_channels_vals = ignored_channels->elems /* XXX ignored_channels leaks */;
22490         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
22491                 uint32_t ignored_channels_conv_16 = ignored_channels_vals[q];
22492                 LDKChannelDetails ignored_channels_conv_16_conv;
22493                 ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1));
22494                 ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0);
22495                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
22496                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
22497                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
22498         }
22499         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
22500         uint32_tArray ret_arr = NULL;
22501         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22502         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22503         for (size_t j = 0; j < ret_var.datalen; j++) {
22504                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22505                 *ret_conv_9_copy = ret_var.data[j];
22506                 uint32_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
22507                 ret_arr_ptr[j] = ret_conv_9_ref;
22508         }
22509         
22510         FREE(ret_var.data);
22511         return ret_arr;
22512 }
22513
22514 uint32_t  __attribute__((export_name("TS_ChainMonitor_get_monitor"))) TS_ChainMonitor_get_monitor(uint32_t this_arg, uint32_t funding_txo) {
22515         LDKChainMonitor this_arg_conv;
22516         this_arg_conv.inner = (void*)(this_arg & (~1));
22517         this_arg_conv.is_owned = false;
22518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22519         LDKOutPoint funding_txo_conv;
22520         funding_txo_conv.inner = (void*)(funding_txo & (~1));
22521         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
22522         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
22523         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
22524         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
22525         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
22526         return (uint32_t)ret_conv;
22527 }
22528
22529 uint32_tArray  __attribute__((export_name("TS_ChainMonitor_list_monitors"))) TS_ChainMonitor_list_monitors(uint32_t this_arg) {
22530         LDKChainMonitor this_arg_conv;
22531         this_arg_conv.inner = (void*)(this_arg & (~1));
22532         this_arg_conv.is_owned = false;
22533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22534         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
22535         uint32_tArray ret_arr = NULL;
22536         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22537         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22538         for (size_t k = 0; k < ret_var.datalen; k++) {
22539                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
22540                 uint32_t ret_conv_10_ref = 0;
22541                 CHECK((((uintptr_t)ret_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22542                 CHECK((((uintptr_t)&ret_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22543                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
22544                 ret_conv_10_ref = (uintptr_t)ret_conv_10_var.inner;
22545                 if (ret_conv_10_var.is_owned) {
22546                         ret_conv_10_ref |= 1;
22547                 }
22548                 ret_arr_ptr[k] = ret_conv_10_ref;
22549         }
22550         
22551         FREE(ret_var.data);
22552         return ret_arr;
22553 }
22554
22555 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) {
22556         LDKChainMonitor this_arg_conv;
22557         this_arg_conv.inner = (void*)(this_arg & (~1));
22558         this_arg_conv.is_owned = false;
22559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22560         LDKOutPoint funding_txo_conv;
22561         funding_txo_conv.inner = (void*)(funding_txo & (~1));
22562         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
22563         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
22564         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
22565         LDKMonitorUpdateId completed_update_id_conv;
22566         completed_update_id_conv.inner = (void*)(completed_update_id & (~1));
22567         completed_update_id_conv.is_owned = (completed_update_id & 1) || (completed_update_id == 0);
22568         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
22569         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
22570         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
22571         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
22572         return (uint32_t)ret_conv;
22573 }
22574
22575 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Listen"))) TS_ChainMonitor_as_Listen(uint32_t this_arg) {
22576         LDKChainMonitor this_arg_conv;
22577         this_arg_conv.inner = (void*)(this_arg & (~1));
22578         this_arg_conv.is_owned = false;
22579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22580         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
22581         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
22582         return (uint32_t)ret_ret;
22583 }
22584
22585 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Confirm"))) TS_ChainMonitor_as_Confirm(uint32_t this_arg) {
22586         LDKChainMonitor this_arg_conv;
22587         this_arg_conv.inner = (void*)(this_arg & (~1));
22588         this_arg_conv.is_owned = false;
22589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22590         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
22591         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
22592         return (uint32_t)ret_ret;
22593 }
22594
22595 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Watch"))) TS_ChainMonitor_as_Watch(uint32_t this_arg) {
22596         LDKChainMonitor this_arg_conv;
22597         this_arg_conv.inner = (void*)(this_arg & (~1));
22598         this_arg_conv.is_owned = false;
22599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22600         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
22601         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
22602         return (uint32_t)ret_ret;
22603 }
22604
22605 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_EventsProvider"))) TS_ChainMonitor_as_EventsProvider(uint32_t this_arg) {
22606         LDKChainMonitor this_arg_conv;
22607         this_arg_conv.inner = (void*)(this_arg & (~1));
22608         this_arg_conv.is_owned = false;
22609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22610         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
22611         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
22612         return (uint32_t)ret_ret;
22613 }
22614
22615 void  __attribute__((export_name("TS_ChannelMonitorUpdate_free"))) TS_ChannelMonitorUpdate_free(uint32_t this_obj) {
22616         LDKChannelMonitorUpdate this_obj_conv;
22617         this_obj_conv.inner = (void*)(this_obj & (~1));
22618         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22620         ChannelMonitorUpdate_free(this_obj_conv);
22621 }
22622
22623 int64_t  __attribute__((export_name("TS_ChannelMonitorUpdate_get_update_id"))) TS_ChannelMonitorUpdate_get_update_id(uint32_t this_ptr) {
22624         LDKChannelMonitorUpdate this_ptr_conv;
22625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22626         this_ptr_conv.is_owned = false;
22627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22628         int64_t ret_conv = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
22629         return ret_conv;
22630 }
22631
22632 void  __attribute__((export_name("TS_ChannelMonitorUpdate_set_update_id"))) TS_ChannelMonitorUpdate_set_update_id(uint32_t this_ptr, int64_t val) {
22633         LDKChannelMonitorUpdate this_ptr_conv;
22634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22635         this_ptr_conv.is_owned = false;
22636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22637         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
22638 }
22639
22640 static inline uintptr_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
22641         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
22642 uint32_t ret_ref = 0;
22643 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22644 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22645 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22646 ret_ref = (uintptr_t)ret_var.inner;
22647 if (ret_var.is_owned) {
22648         ret_ref |= 1;
22649 }
22650         return ret_ref;
22651 }
22652 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdate_clone_ptr"))) TS_ChannelMonitorUpdate_clone_ptr(uint32_t arg) {
22653         LDKChannelMonitorUpdate arg_conv;
22654         arg_conv.inner = (void*)(arg & (~1));
22655         arg_conv.is_owned = false;
22656         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22657         uint32_t ret_conv = ChannelMonitorUpdate_clone_ptr(&arg_conv);
22658         return ret_conv;
22659 }
22660
22661 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdate_clone"))) TS_ChannelMonitorUpdate_clone(uint32_t orig) {
22662         LDKChannelMonitorUpdate orig_conv;
22663         orig_conv.inner = (void*)(orig & (~1));
22664         orig_conv.is_owned = false;
22665         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22666         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
22667         uint32_t ret_ref = 0;
22668         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22669         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22670         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22671         ret_ref = (uintptr_t)ret_var.inner;
22672         if (ret_var.is_owned) {
22673                 ret_ref |= 1;
22674         }
22675         return ret_ref;
22676 }
22677
22678 int8_tArray  __attribute__((export_name("TS_ChannelMonitorUpdate_write"))) TS_ChannelMonitorUpdate_write(uint32_t obj) {
22679         LDKChannelMonitorUpdate obj_conv;
22680         obj_conv.inner = (void*)(obj & (~1));
22681         obj_conv.is_owned = false;
22682         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22683         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
22684         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22685         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22686         CVec_u8Z_free(ret_var);
22687         return ret_arr;
22688 }
22689
22690 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdate_read"))) TS_ChannelMonitorUpdate_read(int8_tArray ser) {
22691         LDKu8slice ser_ref;
22692         ser_ref.datalen = ser->arr_len;
22693         ser_ref.data = ser->elems /* XXX ser leaks */;
22694         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
22695         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
22696         return (uint32_t)ret_conv;
22697 }
22698
22699 void  __attribute__((export_name("TS_MonitorEvent_free"))) TS_MonitorEvent_free(uint32_t this_ptr) {
22700         if ((this_ptr & 1) != 0) return;
22701         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22702         CHECK_ACCESS(this_ptr_ptr);
22703         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
22704         FREE((void*)this_ptr);
22705         MonitorEvent_free(this_ptr_conv);
22706 }
22707
22708 static inline uintptr_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
22709         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22710         *ret_copy = MonitorEvent_clone(arg);
22711 uint32_t ret_ref = (uintptr_t)ret_copy;
22712         return ret_ref;
22713 }
22714 uint32_t  __attribute__((export_name("TS_MonitorEvent_clone_ptr"))) TS_MonitorEvent_clone_ptr(uint32_t arg) {
22715         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)arg;
22716         uint32_t ret_conv = MonitorEvent_clone_ptr(arg_conv);
22717         return ret_conv;
22718 }
22719
22720 uint32_t  __attribute__((export_name("TS_MonitorEvent_clone"))) TS_MonitorEvent_clone(uint32_t orig) {
22721         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
22722         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22723         *ret_copy = MonitorEvent_clone(orig_conv);
22724         uint32_t ret_ref = (uintptr_t)ret_copy;
22725         return ret_ref;
22726 }
22727
22728 uint32_t  __attribute__((export_name("TS_MonitorEvent_htlcevent"))) TS_MonitorEvent_htlcevent(uint32_t a) {
22729         LDKHTLCUpdate a_conv;
22730         a_conv.inner = (void*)(a & (~1));
22731         a_conv.is_owned = (a & 1) || (a == 0);
22732         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
22733         a_conv = HTLCUpdate_clone(&a_conv);
22734         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22735         *ret_copy = MonitorEvent_htlcevent(a_conv);
22736         uint32_t ret_ref = (uintptr_t)ret_copy;
22737         return ret_ref;
22738 }
22739
22740 uint32_t  __attribute__((export_name("TS_MonitorEvent_commitment_tx_confirmed"))) TS_MonitorEvent_commitment_tx_confirmed(uint32_t a) {
22741         LDKOutPoint a_conv;
22742         a_conv.inner = (void*)(a & (~1));
22743         a_conv.is_owned = (a & 1) || (a == 0);
22744         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
22745         a_conv = OutPoint_clone(&a_conv);
22746         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22747         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
22748         uint32_t ret_ref = (uintptr_t)ret_copy;
22749         return ret_ref;
22750 }
22751
22752 uint32_t  __attribute__((export_name("TS_MonitorEvent_update_completed"))) TS_MonitorEvent_update_completed(uint32_t funding_txo, int64_t monitor_update_id) {
22753         LDKOutPoint funding_txo_conv;
22754         funding_txo_conv.inner = (void*)(funding_txo & (~1));
22755         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
22756         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
22757         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
22758         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22759         *ret_copy = MonitorEvent_update_completed(funding_txo_conv, monitor_update_id);
22760         uint32_t ret_ref = (uintptr_t)ret_copy;
22761         return ret_ref;
22762 }
22763
22764 uint32_t  __attribute__((export_name("TS_MonitorEvent_update_failed"))) TS_MonitorEvent_update_failed(uint32_t a) {
22765         LDKOutPoint a_conv;
22766         a_conv.inner = (void*)(a & (~1));
22767         a_conv.is_owned = (a & 1) || (a == 0);
22768         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
22769         a_conv = OutPoint_clone(&a_conv);
22770         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22771         *ret_copy = MonitorEvent_update_failed(a_conv);
22772         uint32_t ret_ref = (uintptr_t)ret_copy;
22773         return ret_ref;
22774 }
22775
22776 int8_tArray  __attribute__((export_name("TS_MonitorEvent_write"))) TS_MonitorEvent_write(uint32_t obj) {
22777         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)obj;
22778         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
22779         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22780         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22781         CVec_u8Z_free(ret_var);
22782         return ret_arr;
22783 }
22784
22785 uint32_t  __attribute__((export_name("TS_MonitorEvent_read"))) TS_MonitorEvent_read(int8_tArray ser) {
22786         LDKu8slice ser_ref;
22787         ser_ref.datalen = ser->arr_len;
22788         ser_ref.data = ser->elems /* XXX ser leaks */;
22789         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
22790         *ret_conv = MonitorEvent_read(ser_ref);
22791         return (uint32_t)ret_conv;
22792 }
22793
22794 void  __attribute__((export_name("TS_HTLCUpdate_free"))) TS_HTLCUpdate_free(uint32_t this_obj) {
22795         LDKHTLCUpdate this_obj_conv;
22796         this_obj_conv.inner = (void*)(this_obj & (~1));
22797         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22799         HTLCUpdate_free(this_obj_conv);
22800 }
22801
22802 static inline uintptr_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
22803         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
22804 uint32_t ret_ref = 0;
22805 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22806 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22807 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22808 ret_ref = (uintptr_t)ret_var.inner;
22809 if (ret_var.is_owned) {
22810         ret_ref |= 1;
22811 }
22812         return ret_ref;
22813 }
22814 uint32_t  __attribute__((export_name("TS_HTLCUpdate_clone_ptr"))) TS_HTLCUpdate_clone_ptr(uint32_t arg) {
22815         LDKHTLCUpdate arg_conv;
22816         arg_conv.inner = (void*)(arg & (~1));
22817         arg_conv.is_owned = false;
22818         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22819         uint32_t ret_conv = HTLCUpdate_clone_ptr(&arg_conv);
22820         return ret_conv;
22821 }
22822
22823 uint32_t  __attribute__((export_name("TS_HTLCUpdate_clone"))) TS_HTLCUpdate_clone(uint32_t orig) {
22824         LDKHTLCUpdate orig_conv;
22825         orig_conv.inner = (void*)(orig & (~1));
22826         orig_conv.is_owned = false;
22827         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22828         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
22829         uint32_t ret_ref = 0;
22830         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22831         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22832         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22833         ret_ref = (uintptr_t)ret_var.inner;
22834         if (ret_var.is_owned) {
22835                 ret_ref |= 1;
22836         }
22837         return ret_ref;
22838 }
22839
22840 int8_tArray  __attribute__((export_name("TS_HTLCUpdate_write"))) TS_HTLCUpdate_write(uint32_t obj) {
22841         LDKHTLCUpdate obj_conv;
22842         obj_conv.inner = (void*)(obj & (~1));
22843         obj_conv.is_owned = false;
22844         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22845         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
22846         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22847         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22848         CVec_u8Z_free(ret_var);
22849         return ret_arr;
22850 }
22851
22852 uint32_t  __attribute__((export_name("TS_HTLCUpdate_read"))) TS_HTLCUpdate_read(int8_tArray ser) {
22853         LDKu8slice ser_ref;
22854         ser_ref.datalen = ser->arr_len;
22855         ser_ref.data = ser->elems /* XXX ser leaks */;
22856         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
22857         *ret_conv = HTLCUpdate_read(ser_ref);
22858         return (uint32_t)ret_conv;
22859 }
22860
22861 void  __attribute__((export_name("TS_Balance_free"))) TS_Balance_free(uint32_t this_ptr) {
22862         if ((this_ptr & 1) != 0) return;
22863         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22864         CHECK_ACCESS(this_ptr_ptr);
22865         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
22866         FREE((void*)this_ptr);
22867         Balance_free(this_ptr_conv);
22868 }
22869
22870 static inline uintptr_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
22871         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22872         *ret_copy = Balance_clone(arg);
22873 uint32_t ret_ref = (uintptr_t)ret_copy;
22874         return ret_ref;
22875 }
22876 uint32_t  __attribute__((export_name("TS_Balance_clone_ptr"))) TS_Balance_clone_ptr(uint32_t arg) {
22877         LDKBalance* arg_conv = (LDKBalance*)arg;
22878         uint32_t ret_conv = Balance_clone_ptr(arg_conv);
22879         return ret_conv;
22880 }
22881
22882 uint32_t  __attribute__((export_name("TS_Balance_clone"))) TS_Balance_clone(uint32_t orig) {
22883         LDKBalance* orig_conv = (LDKBalance*)orig;
22884         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22885         *ret_copy = Balance_clone(orig_conv);
22886         uint32_t ret_ref = (uintptr_t)ret_copy;
22887         return ret_ref;
22888 }
22889
22890 uint32_t  __attribute__((export_name("TS_Balance_claimable_on_channel_close"))) TS_Balance_claimable_on_channel_close(int64_t claimable_amount_satoshis) {
22891         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22892         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
22893         uint32_t ret_ref = (uintptr_t)ret_copy;
22894         return ret_ref;
22895 }
22896
22897 uint32_t  __attribute__((export_name("TS_Balance_claimable_awaiting_confirmations"))) TS_Balance_claimable_awaiting_confirmations(int64_t claimable_amount_satoshis, int32_t confirmation_height) {
22898         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22899         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
22900         uint32_t ret_ref = (uintptr_t)ret_copy;
22901         return ret_ref;
22902 }
22903
22904 uint32_t  __attribute__((export_name("TS_Balance_contentious_claimable"))) TS_Balance_contentious_claimable(int64_t claimable_amount_satoshis, int32_t timeout_height) {
22905         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22906         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
22907         uint32_t ret_ref = (uintptr_t)ret_copy;
22908         return ret_ref;
22909 }
22910
22911 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) {
22912         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22913         *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
22914         uint32_t ret_ref = (uintptr_t)ret_copy;
22915         return ret_ref;
22916 }
22917
22918 jboolean  __attribute__((export_name("TS_Balance_eq"))) TS_Balance_eq(uint32_t a, uint32_t b) {
22919         LDKBalance* a_conv = (LDKBalance*)a;
22920         LDKBalance* b_conv = (LDKBalance*)b;
22921         jboolean ret_conv = Balance_eq(a_conv, b_conv);
22922         return ret_conv;
22923 }
22924
22925 void  __attribute__((export_name("TS_ChannelMonitor_free"))) TS_ChannelMonitor_free(uint32_t this_obj) {
22926         LDKChannelMonitor this_obj_conv;
22927         this_obj_conv.inner = (void*)(this_obj & (~1));
22928         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22930         ChannelMonitor_free(this_obj_conv);
22931 }
22932
22933 static inline uintptr_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
22934         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
22935 uint32_t ret_ref = 0;
22936 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22937 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22938 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22939 ret_ref = (uintptr_t)ret_var.inner;
22940 if (ret_var.is_owned) {
22941         ret_ref |= 1;
22942 }
22943         return ret_ref;
22944 }
22945 uint32_t  __attribute__((export_name("TS_ChannelMonitor_clone_ptr"))) TS_ChannelMonitor_clone_ptr(uint32_t arg) {
22946         LDKChannelMonitor arg_conv;
22947         arg_conv.inner = (void*)(arg & (~1));
22948         arg_conv.is_owned = false;
22949         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22950         uint32_t ret_conv = ChannelMonitor_clone_ptr(&arg_conv);
22951         return ret_conv;
22952 }
22953
22954 uint32_t  __attribute__((export_name("TS_ChannelMonitor_clone"))) TS_ChannelMonitor_clone(uint32_t orig) {
22955         LDKChannelMonitor orig_conv;
22956         orig_conv.inner = (void*)(orig & (~1));
22957         orig_conv.is_owned = false;
22958         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22959         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
22960         uint32_t ret_ref = 0;
22961         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22962         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22963         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22964         ret_ref = (uintptr_t)ret_var.inner;
22965         if (ret_var.is_owned) {
22966                 ret_ref |= 1;
22967         }
22968         return ret_ref;
22969 }
22970
22971 int8_tArray  __attribute__((export_name("TS_ChannelMonitor_write"))) TS_ChannelMonitor_write(uint32_t obj) {
22972         LDKChannelMonitor obj_conv;
22973         obj_conv.inner = (void*)(obj & (~1));
22974         obj_conv.is_owned = false;
22975         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22976         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
22977         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22978         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22979         CVec_u8Z_free(ret_var);
22980         return ret_arr;
22981 }
22982
22983 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) {
22984         LDKChannelMonitor this_arg_conv;
22985         this_arg_conv.inner = (void*)(this_arg & (~1));
22986         this_arg_conv.is_owned = false;
22987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22988         LDKChannelMonitorUpdate updates_conv;
22989         updates_conv.inner = (void*)(updates & (~1));
22990         updates_conv.is_owned = false;
22991         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
22992         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22993         if (!(broadcaster & 1)) { CHECK_ACCESS(broadcaster_ptr); }
22994         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
22995         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22996         if (!(fee_estimator & 1)) { CHECK_ACCESS(fee_estimator_ptr); }
22997         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator_ptr;
22998         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22999         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
23000         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
23001         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
23002         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
23003         return (uint32_t)ret_conv;
23004 }
23005
23006 int64_t  __attribute__((export_name("TS_ChannelMonitor_get_latest_update_id"))) TS_ChannelMonitor_get_latest_update_id(uint32_t this_arg) {
23007         LDKChannelMonitor this_arg_conv;
23008         this_arg_conv.inner = (void*)(this_arg & (~1));
23009         this_arg_conv.is_owned = false;
23010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23011         int64_t ret_conv = ChannelMonitor_get_latest_update_id(&this_arg_conv);
23012         return ret_conv;
23013 }
23014
23015 uint32_t  __attribute__((export_name("TS_ChannelMonitor_get_funding_txo"))) TS_ChannelMonitor_get_funding_txo(uint32_t this_arg) {
23016         LDKChannelMonitor this_arg_conv;
23017         this_arg_conv.inner = (void*)(this_arg & (~1));
23018         this_arg_conv.is_owned = false;
23019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23020         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
23021         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
23022         return ((uint32_t)ret_conv);
23023 }
23024
23025 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_outputs_to_watch"))) TS_ChannelMonitor_get_outputs_to_watch(uint32_t this_arg) {
23026         LDKChannelMonitor this_arg_conv;
23027         this_arg_conv.inner = (void*)(this_arg & (~1));
23028         this_arg_conv.is_owned = false;
23029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23030         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
23031         uint32_tArray ret_arr = NULL;
23032         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
23033         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
23034         for (size_t o = 0; o < ret_var.datalen; o++) {
23035                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
23036                 *ret_conv_40_conv = ret_var.data[o];
23037                 ret_arr_ptr[o] = ((uint32_t)ret_conv_40_conv);
23038         }
23039         
23040         FREE(ret_var.data);
23041         return ret_arr;
23042 }
23043
23044 void  __attribute__((export_name("TS_ChannelMonitor_load_outputs_to_watch"))) TS_ChannelMonitor_load_outputs_to_watch(uint32_t this_arg, uint32_t filter) {
23045         LDKChannelMonitor this_arg_conv;
23046         this_arg_conv.inner = (void*)(this_arg & (~1));
23047         this_arg_conv.is_owned = false;
23048         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23049         void* filter_ptr = (void*)(((uintptr_t)filter) & ~1);
23050         if (!(filter & 1)) { CHECK_ACCESS(filter_ptr); }
23051         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
23052         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
23053 }
23054
23055 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) {
23056         LDKChannelMonitor this_arg_conv;
23057         this_arg_conv.inner = (void*)(this_arg & (~1));
23058         this_arg_conv.is_owned = false;
23059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23060         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
23061         uint32_tArray ret_arr = NULL;
23062         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
23063         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
23064         for (size_t o = 0; o < ret_var.datalen; o++) {
23065                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
23066                 *ret_conv_14_copy = ret_var.data[o];
23067                 uint32_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
23068                 ret_arr_ptr[o] = ret_conv_14_ref;
23069         }
23070         
23071         FREE(ret_var.data);
23072         return ret_arr;
23073 }
23074
23075 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_and_clear_pending_events"))) TS_ChannelMonitor_get_and_clear_pending_events(uint32_t this_arg) {
23076         LDKChannelMonitor this_arg_conv;
23077         this_arg_conv.inner = (void*)(this_arg & (~1));
23078         this_arg_conv.is_owned = false;
23079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23080         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
23081         uint32_tArray ret_arr = NULL;
23082         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
23083         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
23084         for (size_t h = 0; h < ret_var.datalen; h++) {
23085                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
23086                 *ret_conv_7_copy = ret_var.data[h];
23087                 uint32_t ret_conv_7_ref = (uintptr_t)ret_conv_7_copy;
23088                 ret_arr_ptr[h] = ret_conv_7_ref;
23089         }
23090         
23091         FREE(ret_var.data);
23092         return ret_arr;
23093 }
23094
23095 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) {
23096         LDKChannelMonitor this_arg_conv;
23097         this_arg_conv.inner = (void*)(this_arg & (~1));
23098         this_arg_conv.is_owned = false;
23099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23100         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
23101         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
23102         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
23103         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
23104         ptrArray ret_arr = NULL;
23105         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
23106         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
23107         for (size_t m = 0; m < ret_var.datalen; m++) {
23108                 LDKTransaction ret_conv_12_var = ret_var.data[m];
23109                 int8_tArray ret_conv_12_arr = init_int8_tArray(ret_conv_12_var.datalen, __LINE__);
23110                 memcpy(ret_conv_12_arr->elems, ret_conv_12_var.data, ret_conv_12_var.datalen);
23111                 Transaction_free(ret_conv_12_var);
23112                 ret_arr_ptr[m] = ret_conv_12_arr;
23113         }
23114         
23115         FREE(ret_var.data);
23116         return ret_arr;
23117 }
23118
23119 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) {
23120         LDKChannelMonitor this_arg_conv;
23121         this_arg_conv.inner = (void*)(this_arg & (~1));
23122         this_arg_conv.is_owned = false;
23123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23124         unsigned char header_arr[80];
23125         CHECK(header->arr_len == 80);
23126         memcpy(header_arr, header->elems, 80); FREE(header);
23127         unsigned char (*header_ref)[80] = &header_arr;
23128         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
23129         txdata_constr.datalen = txdata->arr_len;
23130         if (txdata_constr.datalen > 0)
23131                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
23132         else
23133                 txdata_constr.data = NULL;
23134         uint32_t* txdata_vals = txdata->elems /* XXX txdata leaks */;
23135         for (size_t c = 0; c < txdata_constr.datalen; c++) {
23136                 uint32_t txdata_conv_28 = txdata_vals[c];
23137                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
23138                 CHECK_ACCESS(txdata_conv_28_ptr);
23139                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
23140                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
23141                 txdata_constr.data[c] = txdata_conv_28_conv;
23142         }
23143         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
23144         CHECK_ACCESS(broadcaster_ptr);
23145         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
23146         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
23147                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23148                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
23149         }
23150         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
23151         CHECK_ACCESS(fee_estimator_ptr);
23152         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
23153         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
23154                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23155                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
23156         }
23157         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
23158         CHECK_ACCESS(logger_ptr);
23159         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
23160         if (logger_conv.free == LDKLogger_JCalls_free) {
23161                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23162                 LDKLogger_JCalls_cloned(&logger_conv);
23163         }
23164         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);
23165         uint32_tArray ret_arr = NULL;
23166         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
23167         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
23168         for (size_t n = 0; n < ret_var.datalen; n++) {
23169                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
23170                 *ret_conv_39_conv = ret_var.data[n];
23171                 ret_arr_ptr[n] = ((uint32_t)ret_conv_39_conv);
23172         }
23173         
23174         FREE(ret_var.data);
23175         return ret_arr;
23176 }
23177
23178 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) {
23179         LDKChannelMonitor this_arg_conv;
23180         this_arg_conv.inner = (void*)(this_arg & (~1));
23181         this_arg_conv.is_owned = false;
23182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23183         unsigned char header_arr[80];
23184         CHECK(header->arr_len == 80);
23185         memcpy(header_arr, header->elems, 80); FREE(header);
23186         unsigned char (*header_ref)[80] = &header_arr;
23187         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
23188         CHECK_ACCESS(broadcaster_ptr);
23189         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
23190         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
23191                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23192                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
23193         }
23194         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
23195         CHECK_ACCESS(fee_estimator_ptr);
23196         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
23197         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
23198                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23199                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
23200         }
23201         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
23202         CHECK_ACCESS(logger_ptr);
23203         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
23204         if (logger_conv.free == LDKLogger_JCalls_free) {
23205                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23206                 LDKLogger_JCalls_cloned(&logger_conv);
23207         }
23208         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
23209 }
23210
23211 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) {
23212         LDKChannelMonitor this_arg_conv;
23213         this_arg_conv.inner = (void*)(this_arg & (~1));
23214         this_arg_conv.is_owned = false;
23215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23216         unsigned char header_arr[80];
23217         CHECK(header->arr_len == 80);
23218         memcpy(header_arr, header->elems, 80); FREE(header);
23219         unsigned char (*header_ref)[80] = &header_arr;
23220         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
23221         txdata_constr.datalen = txdata->arr_len;
23222         if (txdata_constr.datalen > 0)
23223                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
23224         else
23225                 txdata_constr.data = NULL;
23226         uint32_t* txdata_vals = txdata->elems /* XXX txdata leaks */;
23227         for (size_t c = 0; c < txdata_constr.datalen; c++) {
23228                 uint32_t txdata_conv_28 = txdata_vals[c];
23229                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
23230                 CHECK_ACCESS(txdata_conv_28_ptr);
23231                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
23232                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
23233                 txdata_constr.data[c] = txdata_conv_28_conv;
23234         }
23235         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
23236         CHECK_ACCESS(broadcaster_ptr);
23237         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
23238         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
23239                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23240                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
23241         }
23242         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
23243         CHECK_ACCESS(fee_estimator_ptr);
23244         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
23245         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
23246                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23247                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
23248         }
23249         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
23250         CHECK_ACCESS(logger_ptr);
23251         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
23252         if (logger_conv.free == LDKLogger_JCalls_free) {
23253                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23254                 LDKLogger_JCalls_cloned(&logger_conv);
23255         }
23256         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);
23257         uint32_tArray ret_arr = NULL;
23258         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
23259         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
23260         for (size_t n = 0; n < ret_var.datalen; n++) {
23261                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
23262                 *ret_conv_39_conv = ret_var.data[n];
23263                 ret_arr_ptr[n] = ((uint32_t)ret_conv_39_conv);
23264         }
23265         
23266         FREE(ret_var.data);
23267         return ret_arr;
23268 }
23269
23270 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) {
23271         LDKChannelMonitor this_arg_conv;
23272         this_arg_conv.inner = (void*)(this_arg & (~1));
23273         this_arg_conv.is_owned = false;
23274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23275         unsigned char txid_arr[32];
23276         CHECK(txid->arr_len == 32);
23277         memcpy(txid_arr, txid->elems, 32); FREE(txid);
23278         unsigned char (*txid_ref)[32] = &txid_arr;
23279         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
23280         CHECK_ACCESS(broadcaster_ptr);
23281         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
23282         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
23283                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23284                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
23285         }
23286         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
23287         CHECK_ACCESS(fee_estimator_ptr);
23288         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
23289         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
23290                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23291                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
23292         }
23293         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
23294         CHECK_ACCESS(logger_ptr);
23295         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
23296         if (logger_conv.free == LDKLogger_JCalls_free) {
23297                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23298                 LDKLogger_JCalls_cloned(&logger_conv);
23299         }
23300         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
23301 }
23302
23303 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) {
23304         LDKChannelMonitor this_arg_conv;
23305         this_arg_conv.inner = (void*)(this_arg & (~1));
23306         this_arg_conv.is_owned = false;
23307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23308         unsigned char header_arr[80];
23309         CHECK(header->arr_len == 80);
23310         memcpy(header_arr, header->elems, 80); FREE(header);
23311         unsigned char (*header_ref)[80] = &header_arr;
23312         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
23313         CHECK_ACCESS(broadcaster_ptr);
23314         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
23315         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
23316                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23317                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
23318         }
23319         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
23320         CHECK_ACCESS(fee_estimator_ptr);
23321         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
23322         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
23323                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23324                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
23325         }
23326         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
23327         CHECK_ACCESS(logger_ptr);
23328         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
23329         if (logger_conv.free == LDKLogger_JCalls_free) {
23330                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
23331                 LDKLogger_JCalls_cloned(&logger_conv);
23332         }
23333         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
23334         uint32_tArray ret_arr = NULL;
23335         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
23336         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
23337         for (size_t n = 0; n < ret_var.datalen; n++) {
23338                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
23339                 *ret_conv_39_conv = ret_var.data[n];
23340                 ret_arr_ptr[n] = ((uint32_t)ret_conv_39_conv);
23341         }
23342         
23343         FREE(ret_var.data);
23344         return ret_arr;
23345 }
23346
23347 ptrArray  __attribute__((export_name("TS_ChannelMonitor_get_relevant_txids"))) TS_ChannelMonitor_get_relevant_txids(uint32_t this_arg) {
23348         LDKChannelMonitor this_arg_conv;
23349         this_arg_conv.inner = (void*)(this_arg & (~1));
23350         this_arg_conv.is_owned = false;
23351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23352         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
23353         ptrArray ret_arr = NULL;
23354         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
23355         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
23356         for (size_t m = 0; m < ret_var.datalen; m++) {
23357                 int8_tArray ret_conv_12_arr = init_int8_tArray(32, __LINE__);
23358                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].data, 32);
23359                 ret_arr_ptr[m] = ret_conv_12_arr;
23360         }
23361         
23362         FREE(ret_var.data);
23363         return ret_arr;
23364 }
23365
23366 uint32_t  __attribute__((export_name("TS_ChannelMonitor_current_best_block"))) TS_ChannelMonitor_current_best_block(uint32_t this_arg) {
23367         LDKChannelMonitor this_arg_conv;
23368         this_arg_conv.inner = (void*)(this_arg & (~1));
23369         this_arg_conv.is_owned = false;
23370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23371         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
23372         uint32_t ret_ref = 0;
23373         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23374         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23375         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23376         ret_ref = (uintptr_t)ret_var.inner;
23377         if (ret_var.is_owned) {
23378                 ret_ref |= 1;
23379         }
23380         return ret_ref;
23381 }
23382
23383 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_claimable_balances"))) TS_ChannelMonitor_get_claimable_balances(uint32_t this_arg) {
23384         LDKChannelMonitor this_arg_conv;
23385         this_arg_conv.inner = (void*)(this_arg & (~1));
23386         this_arg_conv.is_owned = false;
23387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23388         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
23389         uint32_tArray ret_arr = NULL;
23390         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
23391         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
23392         for (size_t j = 0; j < ret_var.datalen; j++) {
23393                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
23394                 *ret_conv_9_copy = ret_var.data[j];
23395                 uint32_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
23396                 ret_arr_ptr[j] = ret_conv_9_ref;
23397         }
23398         
23399         FREE(ret_var.data);
23400         return ret_arr;
23401 }
23402
23403 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_read"))) TS_C2Tuple_BlockHashChannelMonitorZ_read(int8_tArray ser, uint32_t arg) {
23404         LDKu8slice ser_ref;
23405         ser_ref.datalen = ser->arr_len;
23406         ser_ref.data = ser->elems /* XXX ser leaks */;
23407         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
23408         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
23409         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
23410         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
23411         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
23412         return (uint32_t)ret_conv;
23413 }
23414
23415 void  __attribute__((export_name("TS_OutPoint_free"))) TS_OutPoint_free(uint32_t this_obj) {
23416         LDKOutPoint this_obj_conv;
23417         this_obj_conv.inner = (void*)(this_obj & (~1));
23418         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23420         OutPoint_free(this_obj_conv);
23421 }
23422
23423 int8_tArray  __attribute__((export_name("TS_OutPoint_get_txid"))) TS_OutPoint_get_txid(uint32_t this_ptr) {
23424         LDKOutPoint this_ptr_conv;
23425         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23426         this_ptr_conv.is_owned = false;
23427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23428         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23429         memcpy(ret_arr->elems, *OutPoint_get_txid(&this_ptr_conv), 32);
23430         return ret_arr;
23431 }
23432
23433 void  __attribute__((export_name("TS_OutPoint_set_txid"))) TS_OutPoint_set_txid(uint32_t this_ptr, int8_tArray val) {
23434         LDKOutPoint this_ptr_conv;
23435         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23436         this_ptr_conv.is_owned = false;
23437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23438         LDKThirtyTwoBytes val_ref;
23439         CHECK(val->arr_len == 32);
23440         memcpy(val_ref.data, val->elems, 32); FREE(val);
23441         OutPoint_set_txid(&this_ptr_conv, val_ref);
23442 }
23443
23444 int16_t  __attribute__((export_name("TS_OutPoint_get_index"))) TS_OutPoint_get_index(uint32_t this_ptr) {
23445         LDKOutPoint this_ptr_conv;
23446         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23447         this_ptr_conv.is_owned = false;
23448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23449         int16_t ret_conv = OutPoint_get_index(&this_ptr_conv);
23450         return ret_conv;
23451 }
23452
23453 void  __attribute__((export_name("TS_OutPoint_set_index"))) TS_OutPoint_set_index(uint32_t this_ptr, int16_t val) {
23454         LDKOutPoint this_ptr_conv;
23455         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23456         this_ptr_conv.is_owned = false;
23457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23458         OutPoint_set_index(&this_ptr_conv, val);
23459 }
23460
23461 uint32_t  __attribute__((export_name("TS_OutPoint_new"))) TS_OutPoint_new(int8_tArray txid_arg, int16_t index_arg) {
23462         LDKThirtyTwoBytes txid_arg_ref;
23463         CHECK(txid_arg->arr_len == 32);
23464         memcpy(txid_arg_ref.data, txid_arg->elems, 32); FREE(txid_arg);
23465         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
23466         uint32_t ret_ref = 0;
23467         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23468         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23469         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23470         ret_ref = (uintptr_t)ret_var.inner;
23471         if (ret_var.is_owned) {
23472                 ret_ref |= 1;
23473         }
23474         return ret_ref;
23475 }
23476
23477 static inline uintptr_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
23478         LDKOutPoint ret_var = OutPoint_clone(arg);
23479 uint32_t ret_ref = 0;
23480 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23481 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23482 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23483 ret_ref = (uintptr_t)ret_var.inner;
23484 if (ret_var.is_owned) {
23485         ret_ref |= 1;
23486 }
23487         return ret_ref;
23488 }
23489 uint32_t  __attribute__((export_name("TS_OutPoint_clone_ptr"))) TS_OutPoint_clone_ptr(uint32_t arg) {
23490         LDKOutPoint arg_conv;
23491         arg_conv.inner = (void*)(arg & (~1));
23492         arg_conv.is_owned = false;
23493         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23494         uint32_t ret_conv = OutPoint_clone_ptr(&arg_conv);
23495         return ret_conv;
23496 }
23497
23498 uint32_t  __attribute__((export_name("TS_OutPoint_clone"))) TS_OutPoint_clone(uint32_t orig) {
23499         LDKOutPoint orig_conv;
23500         orig_conv.inner = (void*)(orig & (~1));
23501         orig_conv.is_owned = false;
23502         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23503         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
23504         uint32_t ret_ref = 0;
23505         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23506         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23507         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23508         ret_ref = (uintptr_t)ret_var.inner;
23509         if (ret_var.is_owned) {
23510                 ret_ref |= 1;
23511         }
23512         return ret_ref;
23513 }
23514
23515 jboolean  __attribute__((export_name("TS_OutPoint_eq"))) TS_OutPoint_eq(uint32_t a, uint32_t b) {
23516         LDKOutPoint a_conv;
23517         a_conv.inner = (void*)(a & (~1));
23518         a_conv.is_owned = false;
23519         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23520         LDKOutPoint b_conv;
23521         b_conv.inner = (void*)(b & (~1));
23522         b_conv.is_owned = false;
23523         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
23524         jboolean ret_conv = OutPoint_eq(&a_conv, &b_conv);
23525         return ret_conv;
23526 }
23527
23528 int64_t  __attribute__((export_name("TS_OutPoint_hash"))) TS_OutPoint_hash(uint32_t o) {
23529         LDKOutPoint o_conv;
23530         o_conv.inner = (void*)(o & (~1));
23531         o_conv.is_owned = false;
23532         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23533         int64_t ret_conv = OutPoint_hash(&o_conv);
23534         return ret_conv;
23535 }
23536
23537 int8_tArray  __attribute__((export_name("TS_OutPoint_to_channel_id"))) TS_OutPoint_to_channel_id(uint32_t this_arg) {
23538         LDKOutPoint 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         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23543         memcpy(ret_arr->elems, OutPoint_to_channel_id(&this_arg_conv).data, 32);
23544         return ret_arr;
23545 }
23546
23547 int8_tArray  __attribute__((export_name("TS_OutPoint_write"))) TS_OutPoint_write(uint32_t obj) {
23548         LDKOutPoint obj_conv;
23549         obj_conv.inner = (void*)(obj & (~1));
23550         obj_conv.is_owned = false;
23551         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23552         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
23553         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23554         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23555         CVec_u8Z_free(ret_var);
23556         return ret_arr;
23557 }
23558
23559 uint32_t  __attribute__((export_name("TS_OutPoint_read"))) TS_OutPoint_read(int8_tArray ser) {
23560         LDKu8slice ser_ref;
23561         ser_ref.datalen = ser->arr_len;
23562         ser_ref.data = ser->elems /* XXX ser leaks */;
23563         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
23564         *ret_conv = OutPoint_read(ser_ref);
23565         return (uint32_t)ret_conv;
23566 }
23567
23568 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_free"))) TS_DelayedPaymentOutputDescriptor_free(uint32_t this_obj) {
23569         LDKDelayedPaymentOutputDescriptor this_obj_conv;
23570         this_obj_conv.inner = (void*)(this_obj & (~1));
23571         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23573         DelayedPaymentOutputDescriptor_free(this_obj_conv);
23574 }
23575
23576 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_outpoint"))) TS_DelayedPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
23577         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23579         this_ptr_conv.is_owned = false;
23580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23581         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
23582         uint32_t ret_ref = 0;
23583         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23584         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23585         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23586         ret_ref = (uintptr_t)ret_var.inner;
23587         if (ret_var.is_owned) {
23588                 ret_ref |= 1;
23589         }
23590         return ret_ref;
23591 }
23592
23593 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_outpoint"))) TS_DelayedPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
23594         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23596         this_ptr_conv.is_owned = false;
23597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23598         LDKOutPoint val_conv;
23599         val_conv.inner = (void*)(val & (~1));
23600         val_conv.is_owned = (val & 1) || (val == 0);
23601         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
23602         val_conv = OutPoint_clone(&val_conv);
23603         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
23604 }
23605
23606 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_per_commitment_point"))) TS_DelayedPaymentOutputDescriptor_get_per_commitment_point(uint32_t this_ptr) {
23607         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23609         this_ptr_conv.is_owned = false;
23610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23611         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
23612         memcpy(ret_arr->elems, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
23613         return ret_arr;
23614 }
23615
23616 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_per_commitment_point"))) TS_DelayedPaymentOutputDescriptor_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
23617         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23619         this_ptr_conv.is_owned = false;
23620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23621         LDKPublicKey val_ref;
23622         CHECK(val->arr_len == 33);
23623         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
23624         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
23625 }
23626
23627 int16_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_to_self_delay"))) TS_DelayedPaymentOutputDescriptor_get_to_self_delay(uint32_t this_ptr) {
23628         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23629         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23630         this_ptr_conv.is_owned = false;
23631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23632         int16_t ret_conv = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
23633         return ret_conv;
23634 }
23635
23636 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_to_self_delay"))) TS_DelayedPaymentOutputDescriptor_set_to_self_delay(uint32_t this_ptr, int16_t val) {
23637         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23638         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23639         this_ptr_conv.is_owned = false;
23640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23641         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
23642 }
23643
23644 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_output"))) TS_DelayedPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
23645         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23647         this_ptr_conv.is_owned = false;
23648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23649         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
23650         CHECK_ACCESS(val_ptr);
23651         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
23652         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
23653         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
23654 }
23655
23656 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey"))) TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey(uint32_t this_ptr) {
23657         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23658         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23659         this_ptr_conv.is_owned = false;
23660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23661         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
23662         memcpy(ret_arr->elems, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form, 33);
23663         return ret_arr;
23664 }
23665
23666 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey"))) TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey(uint32_t this_ptr, int8_tArray val) {
23667         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23669         this_ptr_conv.is_owned = false;
23670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23671         LDKPublicKey val_ref;
23672         CHECK(val->arr_len == 33);
23673         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
23674         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
23675 }
23676
23677 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_channel_keys_id"))) TS_DelayedPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
23678         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23679         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23680         this_ptr_conv.is_owned = false;
23681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23682         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23683         memcpy(ret_arr->elems, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
23684         return ret_arr;
23685 }
23686
23687 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_channel_keys_id"))) TS_DelayedPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
23688         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23690         this_ptr_conv.is_owned = false;
23691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23692         LDKThirtyTwoBytes val_ref;
23693         CHECK(val->arr_len == 32);
23694         memcpy(val_ref.data, val->elems, 32); FREE(val);
23695         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
23696 }
23697
23698 int64_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis"))) TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
23699         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23700         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23701         this_ptr_conv.is_owned = false;
23702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23703         int64_t ret_conv = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
23704         return ret_conv;
23705 }
23706
23707 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis"))) TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
23708         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23710         this_ptr_conv.is_owned = false;
23711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23712         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
23713 }
23714
23715 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) {
23716         LDKOutPoint outpoint_arg_conv;
23717         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
23718         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
23719         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
23720         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
23721         LDKPublicKey per_commitment_point_arg_ref;
23722         CHECK(per_commitment_point_arg->arr_len == 33);
23723         memcpy(per_commitment_point_arg_ref.compressed_form, per_commitment_point_arg->elems, 33); FREE(per_commitment_point_arg);
23724         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
23725         CHECK_ACCESS(output_arg_ptr);
23726         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
23727         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
23728         LDKPublicKey revocation_pubkey_arg_ref;
23729         CHECK(revocation_pubkey_arg->arr_len == 33);
23730         memcpy(revocation_pubkey_arg_ref.compressed_form, revocation_pubkey_arg->elems, 33); FREE(revocation_pubkey_arg);
23731         LDKThirtyTwoBytes channel_keys_id_arg_ref;
23732         CHECK(channel_keys_id_arg->arr_len == 32);
23733         memcpy(channel_keys_id_arg_ref.data, channel_keys_id_arg->elems, 32); FREE(channel_keys_id_arg);
23734         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);
23735         uint32_t ret_ref = 0;
23736         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23737         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23738         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23739         ret_ref = (uintptr_t)ret_var.inner;
23740         if (ret_var.is_owned) {
23741                 ret_ref |= 1;
23742         }
23743         return ret_ref;
23744 }
23745
23746 static inline uintptr_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
23747         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
23748 uint32_t ret_ref = 0;
23749 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23750 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23751 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23752 ret_ref = (uintptr_t)ret_var.inner;
23753 if (ret_var.is_owned) {
23754         ret_ref |= 1;
23755 }
23756         return ret_ref;
23757 }
23758 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_clone_ptr"))) TS_DelayedPaymentOutputDescriptor_clone_ptr(uint32_t arg) {
23759         LDKDelayedPaymentOutputDescriptor arg_conv;
23760         arg_conv.inner = (void*)(arg & (~1));
23761         arg_conv.is_owned = false;
23762         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23763         uint32_t ret_conv = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
23764         return ret_conv;
23765 }
23766
23767 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_clone"))) TS_DelayedPaymentOutputDescriptor_clone(uint32_t orig) {
23768         LDKDelayedPaymentOutputDescriptor orig_conv;
23769         orig_conv.inner = (void*)(orig & (~1));
23770         orig_conv.is_owned = false;
23771         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23772         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
23773         uint32_t ret_ref = 0;
23774         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23775         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23776         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23777         ret_ref = (uintptr_t)ret_var.inner;
23778         if (ret_var.is_owned) {
23779                 ret_ref |= 1;
23780         }
23781         return ret_ref;
23782 }
23783
23784 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_write"))) TS_DelayedPaymentOutputDescriptor_write(uint32_t obj) {
23785         LDKDelayedPaymentOutputDescriptor obj_conv;
23786         obj_conv.inner = (void*)(obj & (~1));
23787         obj_conv.is_owned = false;
23788         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23789         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
23790         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23791         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23792         CVec_u8Z_free(ret_var);
23793         return ret_arr;
23794 }
23795
23796 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_read"))) TS_DelayedPaymentOutputDescriptor_read(int8_tArray ser) {
23797         LDKu8slice ser_ref;
23798         ser_ref.datalen = ser->arr_len;
23799         ser_ref.data = ser->elems /* XXX ser leaks */;
23800         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
23801         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
23802         return (uint32_t)ret_conv;
23803 }
23804
23805 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_free"))) TS_StaticPaymentOutputDescriptor_free(uint32_t this_obj) {
23806         LDKStaticPaymentOutputDescriptor this_obj_conv;
23807         this_obj_conv.inner = (void*)(this_obj & (~1));
23808         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23810         StaticPaymentOutputDescriptor_free(this_obj_conv);
23811 }
23812
23813 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_outpoint"))) TS_StaticPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
23814         LDKStaticPaymentOutputDescriptor this_ptr_conv;
23815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23816         this_ptr_conv.is_owned = false;
23817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23818         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
23819         uint32_t ret_ref = 0;
23820         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23821         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23822         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23823         ret_ref = (uintptr_t)ret_var.inner;
23824         if (ret_var.is_owned) {
23825                 ret_ref |= 1;
23826         }
23827         return ret_ref;
23828 }
23829
23830 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_outpoint"))) TS_StaticPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
23831         LDKStaticPaymentOutputDescriptor this_ptr_conv;
23832         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23833         this_ptr_conv.is_owned = false;
23834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23835         LDKOutPoint val_conv;
23836         val_conv.inner = (void*)(val & (~1));
23837         val_conv.is_owned = (val & 1) || (val == 0);
23838         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
23839         val_conv = OutPoint_clone(&val_conv);
23840         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
23841 }
23842
23843 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_output"))) TS_StaticPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
23844         LDKStaticPaymentOutputDescriptor this_ptr_conv;
23845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23846         this_ptr_conv.is_owned = false;
23847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23848         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
23849         CHECK_ACCESS(val_ptr);
23850         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
23851         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
23852         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
23853 }
23854
23855 int8_tArray  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_channel_keys_id"))) TS_StaticPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
23856         LDKStaticPaymentOutputDescriptor this_ptr_conv;
23857         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23858         this_ptr_conv.is_owned = false;
23859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23860         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23861         memcpy(ret_arr->elems, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
23862         return ret_arr;
23863 }
23864
23865 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_channel_keys_id"))) TS_StaticPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
23866         LDKStaticPaymentOutputDescriptor this_ptr_conv;
23867         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23868         this_ptr_conv.is_owned = false;
23869         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23870         LDKThirtyTwoBytes val_ref;
23871         CHECK(val->arr_len == 32);
23872         memcpy(val_ref.data, val->elems, 32); FREE(val);
23873         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
23874 }
23875
23876 int64_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis"))) TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
23877         LDKStaticPaymentOutputDescriptor this_ptr_conv;
23878         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23879         this_ptr_conv.is_owned = false;
23880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23881         int64_t ret_conv = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
23882         return ret_conv;
23883 }
23884
23885 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis"))) TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
23886         LDKStaticPaymentOutputDescriptor this_ptr_conv;
23887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23888         this_ptr_conv.is_owned = false;
23889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23890         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
23891 }
23892
23893 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) {
23894         LDKOutPoint outpoint_arg_conv;
23895         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
23896         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
23897         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
23898         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
23899         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
23900         CHECK_ACCESS(output_arg_ptr);
23901         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
23902         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
23903         LDKThirtyTwoBytes channel_keys_id_arg_ref;
23904         CHECK(channel_keys_id_arg->arr_len == 32);
23905         memcpy(channel_keys_id_arg_ref.data, channel_keys_id_arg->elems, 32); FREE(channel_keys_id_arg);
23906         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
23907         uint32_t ret_ref = 0;
23908         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23909         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23910         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23911         ret_ref = (uintptr_t)ret_var.inner;
23912         if (ret_var.is_owned) {
23913                 ret_ref |= 1;
23914         }
23915         return ret_ref;
23916 }
23917
23918 static inline uintptr_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
23919         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
23920 uint32_t ret_ref = 0;
23921 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23922 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23923 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23924 ret_ref = (uintptr_t)ret_var.inner;
23925 if (ret_var.is_owned) {
23926         ret_ref |= 1;
23927 }
23928         return ret_ref;
23929 }
23930 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_clone_ptr"))) TS_StaticPaymentOutputDescriptor_clone_ptr(uint32_t arg) {
23931         LDKStaticPaymentOutputDescriptor arg_conv;
23932         arg_conv.inner = (void*)(arg & (~1));
23933         arg_conv.is_owned = false;
23934         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23935         uint32_t ret_conv = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
23936         return ret_conv;
23937 }
23938
23939 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_clone"))) TS_StaticPaymentOutputDescriptor_clone(uint32_t orig) {
23940         LDKStaticPaymentOutputDescriptor orig_conv;
23941         orig_conv.inner = (void*)(orig & (~1));
23942         orig_conv.is_owned = false;
23943         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23944         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
23945         uint32_t ret_ref = 0;
23946         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23947         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23948         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23949         ret_ref = (uintptr_t)ret_var.inner;
23950         if (ret_var.is_owned) {
23951                 ret_ref |= 1;
23952         }
23953         return ret_ref;
23954 }
23955
23956 int8_tArray  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_write"))) TS_StaticPaymentOutputDescriptor_write(uint32_t obj) {
23957         LDKStaticPaymentOutputDescriptor obj_conv;
23958         obj_conv.inner = (void*)(obj & (~1));
23959         obj_conv.is_owned = false;
23960         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23961         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
23962         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23963         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23964         CVec_u8Z_free(ret_var);
23965         return ret_arr;
23966 }
23967
23968 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_read"))) TS_StaticPaymentOutputDescriptor_read(int8_tArray ser) {
23969         LDKu8slice ser_ref;
23970         ser_ref.datalen = ser->arr_len;
23971         ser_ref.data = ser->elems /* XXX ser leaks */;
23972         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
23973         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
23974         return (uint32_t)ret_conv;
23975 }
23976
23977 void  __attribute__((export_name("TS_SpendableOutputDescriptor_free"))) TS_SpendableOutputDescriptor_free(uint32_t this_ptr) {
23978         if ((this_ptr & 1) != 0) return;
23979         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23980         CHECK_ACCESS(this_ptr_ptr);
23981         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
23982         FREE((void*)this_ptr);
23983         SpendableOutputDescriptor_free(this_ptr_conv);
23984 }
23985
23986 static inline uintptr_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
23987         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
23988         *ret_copy = SpendableOutputDescriptor_clone(arg);
23989 uint32_t ret_ref = (uintptr_t)ret_copy;
23990         return ret_ref;
23991 }
23992 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_clone_ptr"))) TS_SpendableOutputDescriptor_clone_ptr(uint32_t arg) {
23993         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)arg;
23994         uint32_t ret_conv = SpendableOutputDescriptor_clone_ptr(arg_conv);
23995         return ret_conv;
23996 }
23997
23998 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_clone"))) TS_SpendableOutputDescriptor_clone(uint32_t orig) {
23999         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
24000         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
24001         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
24002         uint32_t ret_ref = (uintptr_t)ret_copy;
24003         return ret_ref;
24004 }
24005
24006 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_static_output"))) TS_SpendableOutputDescriptor_static_output(uint32_t outpoint, uint32_t output) {
24007         LDKOutPoint outpoint_conv;
24008         outpoint_conv.inner = (void*)(outpoint & (~1));
24009         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
24010         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
24011         outpoint_conv = OutPoint_clone(&outpoint_conv);
24012         void* output_ptr = (void*)(((uintptr_t)output) & ~1);
24013         CHECK_ACCESS(output_ptr);
24014         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
24015         output_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output) & ~1));
24016         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
24017         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
24018         uint32_t ret_ref = (uintptr_t)ret_copy;
24019         return ret_ref;
24020 }
24021
24022 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_delayed_payment_output"))) TS_SpendableOutputDescriptor_delayed_payment_output(uint32_t a) {
24023         LDKDelayedPaymentOutputDescriptor a_conv;
24024         a_conv.inner = (void*)(a & (~1));
24025         a_conv.is_owned = (a & 1) || (a == 0);
24026         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
24027         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
24028         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
24029         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
24030         uint32_t ret_ref = (uintptr_t)ret_copy;
24031         return ret_ref;
24032 }
24033
24034 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_static_payment_output"))) TS_SpendableOutputDescriptor_static_payment_output(uint32_t a) {
24035         LDKStaticPaymentOutputDescriptor a_conv;
24036         a_conv.inner = (void*)(a & (~1));
24037         a_conv.is_owned = (a & 1) || (a == 0);
24038         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
24039         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
24040         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
24041         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
24042         uint32_t ret_ref = (uintptr_t)ret_copy;
24043         return ret_ref;
24044 }
24045
24046 int8_tArray  __attribute__((export_name("TS_SpendableOutputDescriptor_write"))) TS_SpendableOutputDescriptor_write(uint32_t obj) {
24047         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
24048         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
24049         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
24050         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
24051         CVec_u8Z_free(ret_var);
24052         return ret_arr;
24053 }
24054
24055 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_read"))) TS_SpendableOutputDescriptor_read(int8_tArray ser) {
24056         LDKu8slice ser_ref;
24057         ser_ref.datalen = ser->arr_len;
24058         ser_ref.data = ser->elems /* XXX ser leaks */;
24059         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
24060         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
24061         return (uint32_t)ret_conv;
24062 }
24063
24064 void  __attribute__((export_name("TS_BaseSign_free"))) TS_BaseSign_free(uint32_t this_ptr) {
24065         if ((this_ptr & 1) != 0) return;
24066         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24067         CHECK_ACCESS(this_ptr_ptr);
24068         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
24069         FREE((void*)this_ptr);
24070         BaseSign_free(this_ptr_conv);
24071 }
24072
24073 static inline uintptr_t Sign_clone_ptr(LDKSign *NONNULL_PTR arg) {
24074         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
24075         *ret_ret = Sign_clone(arg);
24076         return (uint32_t)ret_ret;
24077 }
24078 uint32_t  __attribute__((export_name("TS_Sign_clone_ptr"))) TS_Sign_clone_ptr(uint32_t arg) {
24079         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
24080         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
24081         LDKSign* arg_conv = (LDKSign*)arg_ptr;
24082         uint32_t ret_conv = Sign_clone_ptr(arg_conv);
24083         return ret_conv;
24084 }
24085
24086 uint32_t  __attribute__((export_name("TS_Sign_clone"))) TS_Sign_clone(uint32_t orig) {
24087         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
24088         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
24089         LDKSign* orig_conv = (LDKSign*)orig_ptr;
24090         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
24091         *ret_ret = Sign_clone(orig_conv);
24092         return (uint32_t)ret_ret;
24093 }
24094
24095 void  __attribute__((export_name("TS_Sign_free"))) TS_Sign_free(uint32_t this_ptr) {
24096         if ((this_ptr & 1) != 0) return;
24097         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24098         CHECK_ACCESS(this_ptr_ptr);
24099         LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
24100         FREE((void*)this_ptr);
24101         Sign_free(this_ptr_conv);
24102 }
24103
24104 uint32_t  __attribute__((export_name("TS_Recipient_clone"))) TS_Recipient_clone(uint32_t orig) {
24105         LDKRecipient* orig_conv = (LDKRecipient*)(orig & ~1);
24106         uint32_t ret_conv = LDKRecipient_to_js(Recipient_clone(orig_conv));
24107         return ret_conv;
24108 }
24109
24110 uint32_t  __attribute__((export_name("TS_Recipient_node"))) TS_Recipient_node() {
24111         uint32_t ret_conv = LDKRecipient_to_js(Recipient_node());
24112         return ret_conv;
24113 }
24114
24115 uint32_t  __attribute__((export_name("TS_Recipient_phantom_node"))) TS_Recipient_phantom_node() {
24116         uint32_t ret_conv = LDKRecipient_to_js(Recipient_phantom_node());
24117         return ret_conv;
24118 }
24119
24120 void  __attribute__((export_name("TS_KeysInterface_free"))) TS_KeysInterface_free(uint32_t this_ptr) {
24121         if ((this_ptr & 1) != 0) return;
24122         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24123         CHECK_ACCESS(this_ptr_ptr);
24124         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
24125         FREE((void*)this_ptr);
24126         KeysInterface_free(this_ptr_conv);
24127 }
24128
24129 void  __attribute__((export_name("TS_InMemorySigner_free"))) TS_InMemorySigner_free(uint32_t this_obj) {
24130         LDKInMemorySigner this_obj_conv;
24131         this_obj_conv.inner = (void*)(this_obj & (~1));
24132         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24134         InMemorySigner_free(this_obj_conv);
24135 }
24136
24137 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_funding_key"))) TS_InMemorySigner_get_funding_key(uint32_t this_ptr) {
24138         LDKInMemorySigner this_ptr_conv;
24139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24140         this_ptr_conv.is_owned = false;
24141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24142         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24143         memcpy(ret_arr->elems, *InMemorySigner_get_funding_key(&this_ptr_conv), 32);
24144         return ret_arr;
24145 }
24146
24147 void  __attribute__((export_name("TS_InMemorySigner_set_funding_key"))) TS_InMemorySigner_set_funding_key(uint32_t this_ptr, int8_tArray val) {
24148         LDKInMemorySigner this_ptr_conv;
24149         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24150         this_ptr_conv.is_owned = false;
24151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24152         LDKSecretKey val_ref;
24153         CHECK(val->arr_len == 32);
24154         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
24155         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
24156 }
24157
24158 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_revocation_base_key"))) TS_InMemorySigner_get_revocation_base_key(uint32_t this_ptr) {
24159         LDKInMemorySigner this_ptr_conv;
24160         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24161         this_ptr_conv.is_owned = false;
24162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24163         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24164         memcpy(ret_arr->elems, *InMemorySigner_get_revocation_base_key(&this_ptr_conv), 32);
24165         return ret_arr;
24166 }
24167
24168 void  __attribute__((export_name("TS_InMemorySigner_set_revocation_base_key"))) TS_InMemorySigner_set_revocation_base_key(uint32_t this_ptr, int8_tArray val) {
24169         LDKInMemorySigner this_ptr_conv;
24170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24171         this_ptr_conv.is_owned = false;
24172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24173         LDKSecretKey val_ref;
24174         CHECK(val->arr_len == 32);
24175         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
24176         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
24177 }
24178
24179 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_payment_key"))) TS_InMemorySigner_get_payment_key(uint32_t this_ptr) {
24180         LDKInMemorySigner this_ptr_conv;
24181         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24182         this_ptr_conv.is_owned = false;
24183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24184         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24185         memcpy(ret_arr->elems, *InMemorySigner_get_payment_key(&this_ptr_conv), 32);
24186         return ret_arr;
24187 }
24188
24189 void  __attribute__((export_name("TS_InMemorySigner_set_payment_key"))) TS_InMemorySigner_set_payment_key(uint32_t this_ptr, int8_tArray val) {
24190         LDKInMemorySigner this_ptr_conv;
24191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24192         this_ptr_conv.is_owned = false;
24193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24194         LDKSecretKey val_ref;
24195         CHECK(val->arr_len == 32);
24196         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
24197         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
24198 }
24199
24200 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_delayed_payment_base_key"))) TS_InMemorySigner_get_delayed_payment_base_key(uint32_t this_ptr) {
24201         LDKInMemorySigner this_ptr_conv;
24202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24203         this_ptr_conv.is_owned = false;
24204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24205         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24206         memcpy(ret_arr->elems, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv), 32);
24207         return ret_arr;
24208 }
24209
24210 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) {
24211         LDKInMemorySigner this_ptr_conv;
24212         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24213         this_ptr_conv.is_owned = false;
24214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24215         LDKSecretKey val_ref;
24216         CHECK(val->arr_len == 32);
24217         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
24218         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
24219 }
24220
24221 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_htlc_base_key"))) TS_InMemorySigner_get_htlc_base_key(uint32_t this_ptr) {
24222         LDKInMemorySigner this_ptr_conv;
24223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24224         this_ptr_conv.is_owned = false;
24225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24226         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24227         memcpy(ret_arr->elems, *InMemorySigner_get_htlc_base_key(&this_ptr_conv), 32);
24228         return ret_arr;
24229 }
24230
24231 void  __attribute__((export_name("TS_InMemorySigner_set_htlc_base_key"))) TS_InMemorySigner_set_htlc_base_key(uint32_t this_ptr, int8_tArray val) {
24232         LDKInMemorySigner this_ptr_conv;
24233         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24234         this_ptr_conv.is_owned = false;
24235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24236         LDKSecretKey val_ref;
24237         CHECK(val->arr_len == 32);
24238         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
24239         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
24240 }
24241
24242 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_commitment_seed"))) TS_InMemorySigner_get_commitment_seed(uint32_t this_ptr) {
24243         LDKInMemorySigner this_ptr_conv;
24244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24245         this_ptr_conv.is_owned = false;
24246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24247         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24248         memcpy(ret_arr->elems, *InMemorySigner_get_commitment_seed(&this_ptr_conv), 32);
24249         return ret_arr;
24250 }
24251
24252 void  __attribute__((export_name("TS_InMemorySigner_set_commitment_seed"))) TS_InMemorySigner_set_commitment_seed(uint32_t this_ptr, int8_tArray val) {
24253         LDKInMemorySigner this_ptr_conv;
24254         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24255         this_ptr_conv.is_owned = false;
24256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24257         LDKThirtyTwoBytes val_ref;
24258         CHECK(val->arr_len == 32);
24259         memcpy(val_ref.data, val->elems, 32); FREE(val);
24260         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
24261 }
24262
24263 static inline uintptr_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
24264         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
24265 uint32_t ret_ref = 0;
24266 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24267 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24268 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24269 ret_ref = (uintptr_t)ret_var.inner;
24270 if (ret_var.is_owned) {
24271         ret_ref |= 1;
24272 }
24273         return ret_ref;
24274 }
24275 uint32_t  __attribute__((export_name("TS_InMemorySigner_clone_ptr"))) TS_InMemorySigner_clone_ptr(uint32_t arg) {
24276         LDKInMemorySigner arg_conv;
24277         arg_conv.inner = (void*)(arg & (~1));
24278         arg_conv.is_owned = false;
24279         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24280         uint32_t ret_conv = InMemorySigner_clone_ptr(&arg_conv);
24281         return ret_conv;
24282 }
24283
24284 uint32_t  __attribute__((export_name("TS_InMemorySigner_clone"))) TS_InMemorySigner_clone(uint32_t orig) {
24285         LDKInMemorySigner orig_conv;
24286         orig_conv.inner = (void*)(orig & (~1));
24287         orig_conv.is_owned = false;
24288         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24289         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
24290         uint32_t ret_ref = 0;
24291         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24292         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24293         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24294         ret_ref = (uintptr_t)ret_var.inner;
24295         if (ret_var.is_owned) {
24296                 ret_ref |= 1;
24297         }
24298         return ret_ref;
24299 }
24300
24301 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) {
24302         LDKSecretKey node_secret_ref;
24303         CHECK(node_secret->arr_len == 32);
24304         memcpy(node_secret_ref.bytes, node_secret->elems, 32); FREE(node_secret);
24305         LDKSecretKey funding_key_ref;
24306         CHECK(funding_key->arr_len == 32);
24307         memcpy(funding_key_ref.bytes, funding_key->elems, 32); FREE(funding_key);
24308         LDKSecretKey revocation_base_key_ref;
24309         CHECK(revocation_base_key->arr_len == 32);
24310         memcpy(revocation_base_key_ref.bytes, revocation_base_key->elems, 32); FREE(revocation_base_key);
24311         LDKSecretKey payment_key_ref;
24312         CHECK(payment_key->arr_len == 32);
24313         memcpy(payment_key_ref.bytes, payment_key->elems, 32); FREE(payment_key);
24314         LDKSecretKey delayed_payment_base_key_ref;
24315         CHECK(delayed_payment_base_key->arr_len == 32);
24316         memcpy(delayed_payment_base_key_ref.bytes, delayed_payment_base_key->elems, 32); FREE(delayed_payment_base_key);
24317         LDKSecretKey htlc_base_key_ref;
24318         CHECK(htlc_base_key->arr_len == 32);
24319         memcpy(htlc_base_key_ref.bytes, htlc_base_key->elems, 32); FREE(htlc_base_key);
24320         LDKThirtyTwoBytes commitment_seed_ref;
24321         CHECK(commitment_seed->arr_len == 32);
24322         memcpy(commitment_seed_ref.data, commitment_seed->elems, 32); FREE(commitment_seed);
24323         LDKThirtyTwoBytes channel_keys_id_ref;
24324         CHECK(channel_keys_id->arr_len == 32);
24325         memcpy(channel_keys_id_ref.data, channel_keys_id->elems, 32); FREE(channel_keys_id);
24326         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);
24327         uint32_t ret_ref = 0;
24328         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24329         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24330         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24331         ret_ref = (uintptr_t)ret_var.inner;
24332         if (ret_var.is_owned) {
24333                 ret_ref |= 1;
24334         }
24335         return ret_ref;
24336 }
24337
24338 uint32_t  __attribute__((export_name("TS_InMemorySigner_counterparty_pubkeys"))) TS_InMemorySigner_counterparty_pubkeys(uint32_t this_arg) {
24339         LDKInMemorySigner this_arg_conv;
24340         this_arg_conv.inner = (void*)(this_arg & (~1));
24341         this_arg_conv.is_owned = false;
24342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24343         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
24344         uint32_t ret_ref = 0;
24345         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24346         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24347         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24348         ret_ref = (uintptr_t)ret_var.inner;
24349         if (ret_var.is_owned) {
24350                 ret_ref |= 1;
24351         }
24352         return ret_ref;
24353 }
24354
24355 int16_t  __attribute__((export_name("TS_InMemorySigner_counterparty_selected_contest_delay"))) TS_InMemorySigner_counterparty_selected_contest_delay(uint32_t this_arg) {
24356         LDKInMemorySigner this_arg_conv;
24357         this_arg_conv.inner = (void*)(this_arg & (~1));
24358         this_arg_conv.is_owned = false;
24359         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24360         int16_t ret_conv = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
24361         return ret_conv;
24362 }
24363
24364 int16_t  __attribute__((export_name("TS_InMemorySigner_holder_selected_contest_delay"))) TS_InMemorySigner_holder_selected_contest_delay(uint32_t this_arg) {
24365         LDKInMemorySigner this_arg_conv;
24366         this_arg_conv.inner = (void*)(this_arg & (~1));
24367         this_arg_conv.is_owned = false;
24368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24369         int16_t ret_conv = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
24370         return ret_conv;
24371 }
24372
24373 jboolean  __attribute__((export_name("TS_InMemorySigner_is_outbound"))) TS_InMemorySigner_is_outbound(uint32_t this_arg) {
24374         LDKInMemorySigner this_arg_conv;
24375         this_arg_conv.inner = (void*)(this_arg & (~1));
24376         this_arg_conv.is_owned = false;
24377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24378         jboolean ret_conv = InMemorySigner_is_outbound(&this_arg_conv);
24379         return ret_conv;
24380 }
24381
24382 uint32_t  __attribute__((export_name("TS_InMemorySigner_funding_outpoint"))) TS_InMemorySigner_funding_outpoint(uint32_t this_arg) {
24383         LDKInMemorySigner this_arg_conv;
24384         this_arg_conv.inner = (void*)(this_arg & (~1));
24385         this_arg_conv.is_owned = false;
24386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24387         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
24388         uint32_t ret_ref = 0;
24389         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24390         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24391         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24392         ret_ref = (uintptr_t)ret_var.inner;
24393         if (ret_var.is_owned) {
24394                 ret_ref |= 1;
24395         }
24396         return ret_ref;
24397 }
24398
24399 uint32_t  __attribute__((export_name("TS_InMemorySigner_get_channel_parameters"))) TS_InMemorySigner_get_channel_parameters(uint32_t this_arg) {
24400         LDKInMemorySigner this_arg_conv;
24401         this_arg_conv.inner = (void*)(this_arg & (~1));
24402         this_arg_conv.is_owned = false;
24403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24404         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
24405         uint32_t ret_ref = 0;
24406         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24407         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24408         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24409         ret_ref = (uintptr_t)ret_var.inner;
24410         if (ret_var.is_owned) {
24411                 ret_ref |= 1;
24412         }
24413         return ret_ref;
24414 }
24415
24416 jboolean  __attribute__((export_name("TS_InMemorySigner_opt_anchors"))) TS_InMemorySigner_opt_anchors(uint32_t this_arg) {
24417         LDKInMemorySigner this_arg_conv;
24418         this_arg_conv.inner = (void*)(this_arg & (~1));
24419         this_arg_conv.is_owned = false;
24420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24421         jboolean ret_conv = InMemorySigner_opt_anchors(&this_arg_conv);
24422         return ret_conv;
24423 }
24424
24425 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) {
24426         LDKInMemorySigner this_arg_conv;
24427         this_arg_conv.inner = (void*)(this_arg & (~1));
24428         this_arg_conv.is_owned = false;
24429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24430         LDKTransaction spend_tx_ref;
24431         spend_tx_ref.datalen = spend_tx->arr_len;
24432         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
24433         memcpy(spend_tx_ref.data, spend_tx->elems, spend_tx_ref.datalen); FREE(spend_tx);
24434         spend_tx_ref.data_is_owned = true;
24435         LDKStaticPaymentOutputDescriptor descriptor_conv;
24436         descriptor_conv.inner = (void*)(descriptor & (~1));
24437         descriptor_conv.is_owned = false;
24438         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
24439         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
24440         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
24441         return (uint32_t)ret_conv;
24442 }
24443
24444 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) {
24445         LDKInMemorySigner this_arg_conv;
24446         this_arg_conv.inner = (void*)(this_arg & (~1));
24447         this_arg_conv.is_owned = false;
24448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24449         LDKTransaction spend_tx_ref;
24450         spend_tx_ref.datalen = spend_tx->arr_len;
24451         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
24452         memcpy(spend_tx_ref.data, spend_tx->elems, spend_tx_ref.datalen); FREE(spend_tx);
24453         spend_tx_ref.data_is_owned = true;
24454         LDKDelayedPaymentOutputDescriptor descriptor_conv;
24455         descriptor_conv.inner = (void*)(descriptor & (~1));
24456         descriptor_conv.is_owned = false;
24457         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
24458         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
24459         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
24460         return (uint32_t)ret_conv;
24461 }
24462
24463 uint32_t  __attribute__((export_name("TS_InMemorySigner_as_BaseSign"))) TS_InMemorySigner_as_BaseSign(uint32_t this_arg) {
24464         LDKInMemorySigner this_arg_conv;
24465         this_arg_conv.inner = (void*)(this_arg & (~1));
24466         this_arg_conv.is_owned = false;
24467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24468         LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
24469         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
24470         return (uint32_t)ret_ret;
24471 }
24472
24473 uint32_t  __attribute__((export_name("TS_InMemorySigner_as_Sign"))) TS_InMemorySigner_as_Sign(uint32_t this_arg) {
24474         LDKInMemorySigner this_arg_conv;
24475         this_arg_conv.inner = (void*)(this_arg & (~1));
24476         this_arg_conv.is_owned = false;
24477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24478         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
24479         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
24480         return (uint32_t)ret_ret;
24481 }
24482
24483 int8_tArray  __attribute__((export_name("TS_InMemorySigner_write"))) TS_InMemorySigner_write(uint32_t obj) {
24484         LDKInMemorySigner obj_conv;
24485         obj_conv.inner = (void*)(obj & (~1));
24486         obj_conv.is_owned = false;
24487         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
24488         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
24489         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
24490         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
24491         CVec_u8Z_free(ret_var);
24492         return ret_arr;
24493 }
24494
24495 uint32_t  __attribute__((export_name("TS_InMemorySigner_read"))) TS_InMemorySigner_read(int8_tArray ser, int8_tArray arg) {
24496         LDKu8slice ser_ref;
24497         ser_ref.datalen = ser->arr_len;
24498         ser_ref.data = ser->elems /* XXX ser leaks */;
24499         LDKSecretKey arg_ref;
24500         CHECK(arg->arr_len == 32);
24501         memcpy(arg_ref.bytes, arg->elems, 32); FREE(arg);
24502         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
24503         *ret_conv = InMemorySigner_read(ser_ref, arg_ref);
24504         return (uint32_t)ret_conv;
24505 }
24506
24507 void  __attribute__((export_name("TS_KeysManager_free"))) TS_KeysManager_free(uint32_t this_obj) {
24508         LDKKeysManager this_obj_conv;
24509         this_obj_conv.inner = (void*)(this_obj & (~1));
24510         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24512         KeysManager_free(this_obj_conv);
24513 }
24514
24515 uint32_t  __attribute__((export_name("TS_KeysManager_new"))) TS_KeysManager_new(int8_tArray seed, int64_t starting_time_secs, int32_t starting_time_nanos) {
24516         unsigned char seed_arr[32];
24517         CHECK(seed->arr_len == 32);
24518         memcpy(seed_arr, seed->elems, 32); FREE(seed);
24519         unsigned char (*seed_ref)[32] = &seed_arr;
24520         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
24521         uint32_t ret_ref = 0;
24522         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24523         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24524         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24525         ret_ref = (uintptr_t)ret_var.inner;
24526         if (ret_var.is_owned) {
24527                 ret_ref |= 1;
24528         }
24529         return ret_ref;
24530 }
24531
24532 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) {
24533         LDKKeysManager this_arg_conv;
24534         this_arg_conv.inner = (void*)(this_arg & (~1));
24535         this_arg_conv.is_owned = false;
24536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24537         unsigned char params_arr[32];
24538         CHECK(params->arr_len == 32);
24539         memcpy(params_arr, params->elems, 32); FREE(params);
24540         unsigned char (*params_ref)[32] = &params_arr;
24541         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
24542         uint32_t ret_ref = 0;
24543         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24544         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24545         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24546         ret_ref = (uintptr_t)ret_var.inner;
24547         if (ret_var.is_owned) {
24548                 ret_ref |= 1;
24549         }
24550         return ret_ref;
24551 }
24552
24553 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) {
24554         LDKKeysManager this_arg_conv;
24555         this_arg_conv.inner = (void*)(this_arg & (~1));
24556         this_arg_conv.is_owned = false;
24557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24558         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
24559         descriptors_constr.datalen = descriptors->arr_len;
24560         if (descriptors_constr.datalen > 0)
24561                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
24562         else
24563                 descriptors_constr.data = NULL;
24564         uint32_t* descriptors_vals = descriptors->elems /* XXX descriptors leaks */;
24565         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
24566                 uint32_t descriptors_conv_27 = descriptors_vals[b];
24567                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
24568                 CHECK_ACCESS(descriptors_conv_27_ptr);
24569                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
24570                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
24571                 descriptors_constr.data[b] = descriptors_conv_27_conv;
24572         }
24573         LDKCVec_TxOutZ outputs_constr;
24574         outputs_constr.datalen = outputs->arr_len;
24575         if (outputs_constr.datalen > 0)
24576                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
24577         else
24578                 outputs_constr.data = NULL;
24579         uint32_t* outputs_vals = outputs->elems /* XXX outputs leaks */;
24580         for (size_t h = 0; h < outputs_constr.datalen; h++) {
24581                 uint32_t outputs_conv_7 = outputs_vals[h];
24582                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
24583                 CHECK_ACCESS(outputs_conv_7_ptr);
24584                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
24585                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
24586                 outputs_constr.data[h] = outputs_conv_7_conv;
24587         }
24588         LDKCVec_u8Z change_destination_script_ref;
24589         change_destination_script_ref.datalen = change_destination_script->arr_len;
24590         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
24591         memcpy(change_destination_script_ref.data, change_destination_script->elems, change_destination_script_ref.datalen); FREE(change_destination_script);
24592         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
24593         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
24594         return (uint32_t)ret_conv;
24595 }
24596
24597 uint32_t  __attribute__((export_name("TS_KeysManager_as_KeysInterface"))) TS_KeysManager_as_KeysInterface(uint32_t this_arg) {
24598         LDKKeysManager this_arg_conv;
24599         this_arg_conv.inner = (void*)(this_arg & (~1));
24600         this_arg_conv.is_owned = false;
24601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24602         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
24603         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
24604         return (uint32_t)ret_ret;
24605 }
24606
24607 void  __attribute__((export_name("TS_PhantomKeysManager_free"))) TS_PhantomKeysManager_free(uint32_t this_obj) {
24608         LDKPhantomKeysManager this_obj_conv;
24609         this_obj_conv.inner = (void*)(this_obj & (~1));
24610         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24612         PhantomKeysManager_free(this_obj_conv);
24613 }
24614
24615 uint32_t  __attribute__((export_name("TS_PhantomKeysManager_as_KeysInterface"))) TS_PhantomKeysManager_as_KeysInterface(uint32_t this_arg) {
24616         LDKPhantomKeysManager this_arg_conv;
24617         this_arg_conv.inner = (void*)(this_arg & (~1));
24618         this_arg_conv.is_owned = false;
24619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24620         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
24621         *ret_ret = PhantomKeysManager_as_KeysInterface(&this_arg_conv);
24622         return (uint32_t)ret_ret;
24623 }
24624
24625 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) {
24626         unsigned char seed_arr[32];
24627         CHECK(seed->arr_len == 32);
24628         memcpy(seed_arr, seed->elems, 32); FREE(seed);
24629         unsigned char (*seed_ref)[32] = &seed_arr;
24630         unsigned char cross_node_seed_arr[32];
24631         CHECK(cross_node_seed->arr_len == 32);
24632         memcpy(cross_node_seed_arr, cross_node_seed->elems, 32); FREE(cross_node_seed);
24633         unsigned char (*cross_node_seed_ref)[32] = &cross_node_seed_arr;
24634         LDKPhantomKeysManager ret_var = PhantomKeysManager_new(seed_ref, starting_time_secs, starting_time_nanos, cross_node_seed_ref);
24635         uint32_t ret_ref = 0;
24636         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24637         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24638         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24639         ret_ref = (uintptr_t)ret_var.inner;
24640         if (ret_var.is_owned) {
24641                 ret_ref |= 1;
24642         }
24643         return ret_ref;
24644 }
24645
24646 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) {
24647         LDKPhantomKeysManager this_arg_conv;
24648         this_arg_conv.inner = (void*)(this_arg & (~1));
24649         this_arg_conv.is_owned = false;
24650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24651         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
24652         descriptors_constr.datalen = descriptors->arr_len;
24653         if (descriptors_constr.datalen > 0)
24654                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
24655         else
24656                 descriptors_constr.data = NULL;
24657         uint32_t* descriptors_vals = descriptors->elems /* XXX descriptors leaks */;
24658         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
24659                 uint32_t descriptors_conv_27 = descriptors_vals[b];
24660                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
24661                 CHECK_ACCESS(descriptors_conv_27_ptr);
24662                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
24663                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
24664                 descriptors_constr.data[b] = descriptors_conv_27_conv;
24665         }
24666         LDKCVec_TxOutZ outputs_constr;
24667         outputs_constr.datalen = outputs->arr_len;
24668         if (outputs_constr.datalen > 0)
24669                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
24670         else
24671                 outputs_constr.data = NULL;
24672         uint32_t* outputs_vals = outputs->elems /* XXX outputs leaks */;
24673         for (size_t h = 0; h < outputs_constr.datalen; h++) {
24674                 uint32_t outputs_conv_7 = outputs_vals[h];
24675                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
24676                 CHECK_ACCESS(outputs_conv_7_ptr);
24677                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
24678                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
24679                 outputs_constr.data[h] = outputs_conv_7_conv;
24680         }
24681         LDKCVec_u8Z change_destination_script_ref;
24682         change_destination_script_ref.datalen = change_destination_script->arr_len;
24683         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
24684         memcpy(change_destination_script_ref.data, change_destination_script->elems, change_destination_script_ref.datalen); FREE(change_destination_script);
24685         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
24686         *ret_conv = PhantomKeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
24687         return (uint32_t)ret_conv;
24688 }
24689
24690 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) {
24691         LDKPhantomKeysManager this_arg_conv;
24692         this_arg_conv.inner = (void*)(this_arg & (~1));
24693         this_arg_conv.is_owned = false;
24694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24695         unsigned char params_arr[32];
24696         CHECK(params->arr_len == 32);
24697         memcpy(params_arr, params->elems, 32); FREE(params);
24698         unsigned char (*params_ref)[32] = &params_arr;
24699         LDKInMemorySigner ret_var = PhantomKeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
24700         uint32_t ret_ref = 0;
24701         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24702         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24703         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24704         ret_ref = (uintptr_t)ret_var.inner;
24705         if (ret_var.is_owned) {
24706                 ret_ref |= 1;
24707         }
24708         return ret_ref;
24709 }
24710
24711 void  __attribute__((export_name("TS_ChannelManager_free"))) TS_ChannelManager_free(uint32_t this_obj) {
24712         LDKChannelManager this_obj_conv;
24713         this_obj_conv.inner = (void*)(this_obj & (~1));
24714         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24716         ChannelManager_free(this_obj_conv);
24717 }
24718
24719 void  __attribute__((export_name("TS_ChainParameters_free"))) TS_ChainParameters_free(uint32_t this_obj) {
24720         LDKChainParameters this_obj_conv;
24721         this_obj_conv.inner = (void*)(this_obj & (~1));
24722         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24724         ChainParameters_free(this_obj_conv);
24725 }
24726
24727 uint32_t  __attribute__((export_name("TS_ChainParameters_get_network"))) TS_ChainParameters_get_network(uint32_t this_ptr) {
24728         LDKChainParameters this_ptr_conv;
24729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24730         this_ptr_conv.is_owned = false;
24731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24732         uint32_t ret_conv = LDKNetwork_to_js(ChainParameters_get_network(&this_ptr_conv));
24733         return ret_conv;
24734 }
24735
24736 void  __attribute__((export_name("TS_ChainParameters_set_network"))) TS_ChainParameters_set_network(uint32_t this_ptr, uint32_t val) {
24737         LDKChainParameters this_ptr_conv;
24738         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24739         this_ptr_conv.is_owned = false;
24740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24741         LDKNetwork val_conv = LDKNetwork_from_js(val);
24742         ChainParameters_set_network(&this_ptr_conv, val_conv);
24743 }
24744
24745 uint32_t  __attribute__((export_name("TS_ChainParameters_get_best_block"))) TS_ChainParameters_get_best_block(uint32_t this_ptr) {
24746         LDKChainParameters this_ptr_conv;
24747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24748         this_ptr_conv.is_owned = false;
24749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24750         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
24751         uint32_t ret_ref = 0;
24752         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24753         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24754         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24755         ret_ref = (uintptr_t)ret_var.inner;
24756         if (ret_var.is_owned) {
24757                 ret_ref |= 1;
24758         }
24759         return ret_ref;
24760 }
24761
24762 void  __attribute__((export_name("TS_ChainParameters_set_best_block"))) TS_ChainParameters_set_best_block(uint32_t this_ptr, uint32_t val) {
24763         LDKChainParameters this_ptr_conv;
24764         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24765         this_ptr_conv.is_owned = false;
24766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24767         LDKBestBlock val_conv;
24768         val_conv.inner = (void*)(val & (~1));
24769         val_conv.is_owned = (val & 1) || (val == 0);
24770         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24771         val_conv = BestBlock_clone(&val_conv);
24772         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
24773 }
24774
24775 uint32_t  __attribute__((export_name("TS_ChainParameters_new"))) TS_ChainParameters_new(uint32_t network_arg, uint32_t best_block_arg) {
24776         LDKNetwork network_arg_conv = LDKNetwork_from_js(network_arg);
24777         LDKBestBlock best_block_arg_conv;
24778         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
24779         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
24780         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
24781         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
24782         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
24783         uint32_t ret_ref = 0;
24784         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24785         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24786         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24787         ret_ref = (uintptr_t)ret_var.inner;
24788         if (ret_var.is_owned) {
24789                 ret_ref |= 1;
24790         }
24791         return ret_ref;
24792 }
24793
24794 static inline uintptr_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
24795         LDKChainParameters ret_var = ChainParameters_clone(arg);
24796 uint32_t ret_ref = 0;
24797 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24798 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24799 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24800 ret_ref = (uintptr_t)ret_var.inner;
24801 if (ret_var.is_owned) {
24802         ret_ref |= 1;
24803 }
24804         return ret_ref;
24805 }
24806 uint32_t  __attribute__((export_name("TS_ChainParameters_clone_ptr"))) TS_ChainParameters_clone_ptr(uint32_t arg) {
24807         LDKChainParameters arg_conv;
24808         arg_conv.inner = (void*)(arg & (~1));
24809         arg_conv.is_owned = false;
24810         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24811         uint32_t ret_conv = ChainParameters_clone_ptr(&arg_conv);
24812         return ret_conv;
24813 }
24814
24815 uint32_t  __attribute__((export_name("TS_ChainParameters_clone"))) TS_ChainParameters_clone(uint32_t orig) {
24816         LDKChainParameters orig_conv;
24817         orig_conv.inner = (void*)(orig & (~1));
24818         orig_conv.is_owned = false;
24819         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24820         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
24821         uint32_t ret_ref = 0;
24822         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24823         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24824         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24825         ret_ref = (uintptr_t)ret_var.inner;
24826         if (ret_var.is_owned) {
24827                 ret_ref |= 1;
24828         }
24829         return ret_ref;
24830 }
24831
24832 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_free"))) TS_CounterpartyForwardingInfo_free(uint32_t this_obj) {
24833         LDKCounterpartyForwardingInfo this_obj_conv;
24834         this_obj_conv.inner = (void*)(this_obj & (~1));
24835         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24837         CounterpartyForwardingInfo_free(this_obj_conv);
24838 }
24839
24840 int32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_fee_base_msat"))) TS_CounterpartyForwardingInfo_get_fee_base_msat(uint32_t this_ptr) {
24841         LDKCounterpartyForwardingInfo this_ptr_conv;
24842         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24843         this_ptr_conv.is_owned = false;
24844         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24845         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
24846         return ret_conv;
24847 }
24848
24849 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_fee_base_msat"))) TS_CounterpartyForwardingInfo_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
24850         LDKCounterpartyForwardingInfo 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         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
24855 }
24856
24857 int32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_fee_proportional_millionths"))) TS_CounterpartyForwardingInfo_get_fee_proportional_millionths(uint32_t this_ptr) {
24858         LDKCounterpartyForwardingInfo this_ptr_conv;
24859         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24860         this_ptr_conv.is_owned = false;
24861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24862         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
24863         return ret_conv;
24864 }
24865
24866 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_fee_proportional_millionths"))) TS_CounterpartyForwardingInfo_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
24867         LDKCounterpartyForwardingInfo this_ptr_conv;
24868         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24869         this_ptr_conv.is_owned = false;
24870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24871         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
24872 }
24873
24874 int16_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_cltv_expiry_delta"))) TS_CounterpartyForwardingInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
24875         LDKCounterpartyForwardingInfo this_ptr_conv;
24876         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24877         this_ptr_conv.is_owned = false;
24878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24879         int16_t ret_conv = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
24880         return ret_conv;
24881 }
24882
24883 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_cltv_expiry_delta"))) TS_CounterpartyForwardingInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
24884         LDKCounterpartyForwardingInfo this_ptr_conv;
24885         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24886         this_ptr_conv.is_owned = false;
24887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24888         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
24889 }
24890
24891 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) {
24892         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
24893         uint32_t ret_ref = 0;
24894         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24895         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24896         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24897         ret_ref = (uintptr_t)ret_var.inner;
24898         if (ret_var.is_owned) {
24899                 ret_ref |= 1;
24900         }
24901         return ret_ref;
24902 }
24903
24904 static inline uintptr_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
24905         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
24906 uint32_t ret_ref = 0;
24907 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24908 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24909 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24910 ret_ref = (uintptr_t)ret_var.inner;
24911 if (ret_var.is_owned) {
24912         ret_ref |= 1;
24913 }
24914         return ret_ref;
24915 }
24916 uint32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_clone_ptr"))) TS_CounterpartyForwardingInfo_clone_ptr(uint32_t arg) {
24917         LDKCounterpartyForwardingInfo arg_conv;
24918         arg_conv.inner = (void*)(arg & (~1));
24919         arg_conv.is_owned = false;
24920         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24921         uint32_t ret_conv = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
24922         return ret_conv;
24923 }
24924
24925 uint32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_clone"))) TS_CounterpartyForwardingInfo_clone(uint32_t orig) {
24926         LDKCounterpartyForwardingInfo orig_conv;
24927         orig_conv.inner = (void*)(orig & (~1));
24928         orig_conv.is_owned = false;
24929         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24930         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
24931         uint32_t ret_ref = 0;
24932         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24933         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24934         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24935         ret_ref = (uintptr_t)ret_var.inner;
24936         if (ret_var.is_owned) {
24937                 ret_ref |= 1;
24938         }
24939         return ret_ref;
24940 }
24941
24942 void  __attribute__((export_name("TS_ChannelCounterparty_free"))) TS_ChannelCounterparty_free(uint32_t this_obj) {
24943         LDKChannelCounterparty this_obj_conv;
24944         this_obj_conv.inner = (void*)(this_obj & (~1));
24945         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24947         ChannelCounterparty_free(this_obj_conv);
24948 }
24949
24950 int8_tArray  __attribute__((export_name("TS_ChannelCounterparty_get_node_id"))) TS_ChannelCounterparty_get_node_id(uint32_t this_ptr) {
24951         LDKChannelCounterparty this_ptr_conv;
24952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24953         this_ptr_conv.is_owned = false;
24954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24955         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
24956         memcpy(ret_arr->elems, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form, 33);
24957         return ret_arr;
24958 }
24959
24960 void  __attribute__((export_name("TS_ChannelCounterparty_set_node_id"))) TS_ChannelCounterparty_set_node_id(uint32_t this_ptr, int8_tArray val) {
24961         LDKChannelCounterparty this_ptr_conv;
24962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24963         this_ptr_conv.is_owned = false;
24964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24965         LDKPublicKey val_ref;
24966         CHECK(val->arr_len == 33);
24967         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
24968         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
24969 }
24970
24971 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_get_features"))) TS_ChannelCounterparty_get_features(uint32_t this_ptr) {
24972         LDKChannelCounterparty this_ptr_conv;
24973         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24974         this_ptr_conv.is_owned = false;
24975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24976         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
24977         uint32_t ret_ref = 0;
24978         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24979         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24980         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24981         ret_ref = (uintptr_t)ret_var.inner;
24982         if (ret_var.is_owned) {
24983                 ret_ref |= 1;
24984         }
24985         return ret_ref;
24986 }
24987
24988 void  __attribute__((export_name("TS_ChannelCounterparty_set_features"))) TS_ChannelCounterparty_set_features(uint32_t this_ptr, uint32_t val) {
24989         LDKChannelCounterparty this_ptr_conv;
24990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24991         this_ptr_conv.is_owned = false;
24992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24993         LDKInitFeatures val_conv;
24994         val_conv.inner = (void*)(val & (~1));
24995         val_conv.is_owned = (val & 1) || (val == 0);
24996         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24997         val_conv = InitFeatures_clone(&val_conv);
24998         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
24999 }
25000
25001 int64_t  __attribute__((export_name("TS_ChannelCounterparty_get_unspendable_punishment_reserve"))) TS_ChannelCounterparty_get_unspendable_punishment_reserve(uint32_t this_ptr) {
25002         LDKChannelCounterparty this_ptr_conv;
25003         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25004         this_ptr_conv.is_owned = false;
25005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25006         int64_t ret_conv = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
25007         return ret_conv;
25008 }
25009
25010 void  __attribute__((export_name("TS_ChannelCounterparty_set_unspendable_punishment_reserve"))) TS_ChannelCounterparty_set_unspendable_punishment_reserve(uint32_t this_ptr, int64_t val) {
25011         LDKChannelCounterparty this_ptr_conv;
25012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25013         this_ptr_conv.is_owned = false;
25014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25015         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
25016 }
25017
25018 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_get_forwarding_info"))) TS_ChannelCounterparty_get_forwarding_info(uint32_t this_ptr) {
25019         LDKChannelCounterparty this_ptr_conv;
25020         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25021         this_ptr_conv.is_owned = false;
25022         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25023         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
25024         uint32_t ret_ref = 0;
25025         if ((uintptr_t)ret_var.inner > 4096) {
25026                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25027                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25028         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25029                 ret_ref = (uintptr_t)ret_var.inner;
25030                 if (ret_var.is_owned) {
25031                         ret_ref |= 1;
25032                 }
25033         }
25034         return ret_ref;
25035 }
25036
25037 void  __attribute__((export_name("TS_ChannelCounterparty_set_forwarding_info"))) TS_ChannelCounterparty_set_forwarding_info(uint32_t this_ptr, uint32_t val) {
25038         LDKChannelCounterparty this_ptr_conv;
25039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25040         this_ptr_conv.is_owned = false;
25041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25042         LDKCounterpartyForwardingInfo val_conv;
25043         val_conv.inner = (void*)(val & (~1));
25044         val_conv.is_owned = (val & 1) || (val == 0);
25045         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25046         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
25047         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
25048 }
25049
25050 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_get_outbound_htlc_minimum_msat"))) TS_ChannelCounterparty_get_outbound_htlc_minimum_msat(uint32_t this_ptr) {
25051         LDKChannelCounterparty this_ptr_conv;
25052         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25053         this_ptr_conv.is_owned = false;
25054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25055         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25056         *ret_copy = ChannelCounterparty_get_outbound_htlc_minimum_msat(&this_ptr_conv);
25057         uint32_t ret_ref = (uintptr_t)ret_copy;
25058         return ret_ref;
25059 }
25060
25061 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) {
25062         LDKChannelCounterparty this_ptr_conv;
25063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25064         this_ptr_conv.is_owned = false;
25065         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25066         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25067         CHECK_ACCESS(val_ptr);
25068         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
25069         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
25070         ChannelCounterparty_set_outbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
25071 }
25072
25073 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_get_outbound_htlc_maximum_msat"))) TS_ChannelCounterparty_get_outbound_htlc_maximum_msat(uint32_t this_ptr) {
25074         LDKChannelCounterparty this_ptr_conv;
25075         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25076         this_ptr_conv.is_owned = false;
25077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25078         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25079         *ret_copy = ChannelCounterparty_get_outbound_htlc_maximum_msat(&this_ptr_conv);
25080         uint32_t ret_ref = (uintptr_t)ret_copy;
25081         return ret_ref;
25082 }
25083
25084 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) {
25085         LDKChannelCounterparty this_ptr_conv;
25086         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25087         this_ptr_conv.is_owned = false;
25088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25089         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25090         CHECK_ACCESS(val_ptr);
25091         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
25092         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
25093         ChannelCounterparty_set_outbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
25094 }
25095
25096 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) {
25097         LDKPublicKey node_id_arg_ref;
25098         CHECK(node_id_arg->arr_len == 33);
25099         memcpy(node_id_arg_ref.compressed_form, node_id_arg->elems, 33); FREE(node_id_arg);
25100         LDKInitFeatures features_arg_conv;
25101         features_arg_conv.inner = (void*)(features_arg & (~1));
25102         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
25103         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
25104         features_arg_conv = InitFeatures_clone(&features_arg_conv);
25105         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
25106         forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1));
25107         forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0);
25108         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
25109         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
25110         void* outbound_htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)outbound_htlc_minimum_msat_arg) & ~1);
25111         CHECK_ACCESS(outbound_htlc_minimum_msat_arg_ptr);
25112         LDKCOption_u64Z outbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_minimum_msat_arg_ptr);
25113         outbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)outbound_htlc_minimum_msat_arg) & ~1));
25114         void* outbound_htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)outbound_htlc_maximum_msat_arg) & ~1);
25115         CHECK_ACCESS(outbound_htlc_maximum_msat_arg_ptr);
25116         LDKCOption_u64Z outbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_maximum_msat_arg_ptr);
25117         outbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)outbound_htlc_maximum_msat_arg) & ~1));
25118         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);
25119         uint32_t ret_ref = 0;
25120         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25121         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25122         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25123         ret_ref = (uintptr_t)ret_var.inner;
25124         if (ret_var.is_owned) {
25125                 ret_ref |= 1;
25126         }
25127         return ret_ref;
25128 }
25129
25130 static inline uintptr_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
25131         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
25132 uint32_t ret_ref = 0;
25133 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25134 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25135 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25136 ret_ref = (uintptr_t)ret_var.inner;
25137 if (ret_var.is_owned) {
25138         ret_ref |= 1;
25139 }
25140         return ret_ref;
25141 }
25142 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_clone_ptr"))) TS_ChannelCounterparty_clone_ptr(uint32_t arg) {
25143         LDKChannelCounterparty arg_conv;
25144         arg_conv.inner = (void*)(arg & (~1));
25145         arg_conv.is_owned = false;
25146         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25147         uint32_t ret_conv = ChannelCounterparty_clone_ptr(&arg_conv);
25148         return ret_conv;
25149 }
25150
25151 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_clone"))) TS_ChannelCounterparty_clone(uint32_t orig) {
25152         LDKChannelCounterparty orig_conv;
25153         orig_conv.inner = (void*)(orig & (~1));
25154         orig_conv.is_owned = false;
25155         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25156         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
25157         uint32_t ret_ref = 0;
25158         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25159         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25160         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25161         ret_ref = (uintptr_t)ret_var.inner;
25162         if (ret_var.is_owned) {
25163                 ret_ref |= 1;
25164         }
25165         return ret_ref;
25166 }
25167
25168 void  __attribute__((export_name("TS_ChannelDetails_free"))) TS_ChannelDetails_free(uint32_t this_obj) {
25169         LDKChannelDetails this_obj_conv;
25170         this_obj_conv.inner = (void*)(this_obj & (~1));
25171         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25173         ChannelDetails_free(this_obj_conv);
25174 }
25175
25176 int8_tArray  __attribute__((export_name("TS_ChannelDetails_get_channel_id"))) TS_ChannelDetails_get_channel_id(uint32_t this_ptr) {
25177         LDKChannelDetails this_ptr_conv;
25178         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25179         this_ptr_conv.is_owned = false;
25180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25181         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
25182         memcpy(ret_arr->elems, *ChannelDetails_get_channel_id(&this_ptr_conv), 32);
25183         return ret_arr;
25184 }
25185
25186 void  __attribute__((export_name("TS_ChannelDetails_set_channel_id"))) TS_ChannelDetails_set_channel_id(uint32_t this_ptr, int8_tArray val) {
25187         LDKChannelDetails this_ptr_conv;
25188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25189         this_ptr_conv.is_owned = false;
25190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25191         LDKThirtyTwoBytes val_ref;
25192         CHECK(val->arr_len == 32);
25193         memcpy(val_ref.data, val->elems, 32); FREE(val);
25194         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
25195 }
25196
25197 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_counterparty"))) TS_ChannelDetails_get_counterparty(uint32_t this_ptr) {
25198         LDKChannelDetails this_ptr_conv;
25199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25200         this_ptr_conv.is_owned = false;
25201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25202         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
25203         uint32_t ret_ref = 0;
25204         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25205         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25206         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25207         ret_ref = (uintptr_t)ret_var.inner;
25208         if (ret_var.is_owned) {
25209                 ret_ref |= 1;
25210         }
25211         return ret_ref;
25212 }
25213
25214 void  __attribute__((export_name("TS_ChannelDetails_set_counterparty"))) TS_ChannelDetails_set_counterparty(uint32_t this_ptr, uint32_t val) {
25215         LDKChannelDetails this_ptr_conv;
25216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25217         this_ptr_conv.is_owned = false;
25218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25219         LDKChannelCounterparty val_conv;
25220         val_conv.inner = (void*)(val & (~1));
25221         val_conv.is_owned = (val & 1) || (val == 0);
25222         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25223         val_conv = ChannelCounterparty_clone(&val_conv);
25224         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
25225 }
25226
25227 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_funding_txo"))) TS_ChannelDetails_get_funding_txo(uint32_t this_ptr) {
25228         LDKChannelDetails 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         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
25233         uint32_t ret_ref = 0;
25234         if ((uintptr_t)ret_var.inner > 4096) {
25235                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25236                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25237         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25238                 ret_ref = (uintptr_t)ret_var.inner;
25239                 if (ret_var.is_owned) {
25240                         ret_ref |= 1;
25241                 }
25242         }
25243         return ret_ref;
25244 }
25245
25246 void  __attribute__((export_name("TS_ChannelDetails_set_funding_txo"))) TS_ChannelDetails_set_funding_txo(uint32_t this_ptr, uint32_t val) {
25247         LDKChannelDetails this_ptr_conv;
25248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25249         this_ptr_conv.is_owned = false;
25250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25251         LDKOutPoint val_conv;
25252         val_conv.inner = (void*)(val & (~1));
25253         val_conv.is_owned = (val & 1) || (val == 0);
25254         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25255         val_conv = OutPoint_clone(&val_conv);
25256         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
25257 }
25258
25259 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_channel_type"))) TS_ChannelDetails_get_channel_type(uint32_t this_ptr) {
25260         LDKChannelDetails this_ptr_conv;
25261         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25262         this_ptr_conv.is_owned = false;
25263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25264         LDKChannelTypeFeatures ret_var = ChannelDetails_get_channel_type(&this_ptr_conv);
25265         uint32_t ret_ref = 0;
25266         if ((uintptr_t)ret_var.inner > 4096) {
25267                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25268                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25269         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25270                 ret_ref = (uintptr_t)ret_var.inner;
25271                 if (ret_var.is_owned) {
25272                         ret_ref |= 1;
25273                 }
25274         }
25275         return ret_ref;
25276 }
25277
25278 void  __attribute__((export_name("TS_ChannelDetails_set_channel_type"))) TS_ChannelDetails_set_channel_type(uint32_t this_ptr, uint32_t val) {
25279         LDKChannelDetails this_ptr_conv;
25280         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25281         this_ptr_conv.is_owned = false;
25282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25283         LDKChannelTypeFeatures val_conv;
25284         val_conv.inner = (void*)(val & (~1));
25285         val_conv.is_owned = (val & 1) || (val == 0);
25286         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25287         val_conv = ChannelTypeFeatures_clone(&val_conv);
25288         ChannelDetails_set_channel_type(&this_ptr_conv, val_conv);
25289 }
25290
25291 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_short_channel_id"))) TS_ChannelDetails_get_short_channel_id(uint32_t this_ptr) {
25292         LDKChannelDetails this_ptr_conv;
25293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25294         this_ptr_conv.is_owned = false;
25295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25296         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25297         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
25298         uint32_t ret_ref = (uintptr_t)ret_copy;
25299         return ret_ref;
25300 }
25301
25302 void  __attribute__((export_name("TS_ChannelDetails_set_short_channel_id"))) TS_ChannelDetails_set_short_channel_id(uint32_t this_ptr, uint32_t val) {
25303         LDKChannelDetails this_ptr_conv;
25304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25305         this_ptr_conv.is_owned = false;
25306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25307         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25308         CHECK_ACCESS(val_ptr);
25309         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
25310         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
25311         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
25312 }
25313
25314 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_outbound_scid_alias"))) TS_ChannelDetails_get_outbound_scid_alias(uint32_t this_ptr) {
25315         LDKChannelDetails this_ptr_conv;
25316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25317         this_ptr_conv.is_owned = false;
25318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25319         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25320         *ret_copy = ChannelDetails_get_outbound_scid_alias(&this_ptr_conv);
25321         uint32_t ret_ref = (uintptr_t)ret_copy;
25322         return ret_ref;
25323 }
25324
25325 void  __attribute__((export_name("TS_ChannelDetails_set_outbound_scid_alias"))) TS_ChannelDetails_set_outbound_scid_alias(uint32_t this_ptr, uint32_t val) {
25326         LDKChannelDetails this_ptr_conv;
25327         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25328         this_ptr_conv.is_owned = false;
25329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25330         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25331         CHECK_ACCESS(val_ptr);
25332         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
25333         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
25334         ChannelDetails_set_outbound_scid_alias(&this_ptr_conv, val_conv);
25335 }
25336
25337 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_scid_alias"))) TS_ChannelDetails_get_inbound_scid_alias(uint32_t this_ptr) {
25338         LDKChannelDetails this_ptr_conv;
25339         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25340         this_ptr_conv.is_owned = false;
25341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25342         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25343         *ret_copy = ChannelDetails_get_inbound_scid_alias(&this_ptr_conv);
25344         uint32_t ret_ref = (uintptr_t)ret_copy;
25345         return ret_ref;
25346 }
25347
25348 void  __attribute__((export_name("TS_ChannelDetails_set_inbound_scid_alias"))) TS_ChannelDetails_set_inbound_scid_alias(uint32_t this_ptr, uint32_t val) {
25349         LDKChannelDetails this_ptr_conv;
25350         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25351         this_ptr_conv.is_owned = false;
25352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25353         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25354         CHECK_ACCESS(val_ptr);
25355         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
25356         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
25357         ChannelDetails_set_inbound_scid_alias(&this_ptr_conv, val_conv);
25358 }
25359
25360 int64_t  __attribute__((export_name("TS_ChannelDetails_get_channel_value_satoshis"))) TS_ChannelDetails_get_channel_value_satoshis(uint32_t this_ptr) {
25361         LDKChannelDetails this_ptr_conv;
25362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25363         this_ptr_conv.is_owned = false;
25364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25365         int64_t ret_conv = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
25366         return ret_conv;
25367 }
25368
25369 void  __attribute__((export_name("TS_ChannelDetails_set_channel_value_satoshis"))) TS_ChannelDetails_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
25370         LDKChannelDetails this_ptr_conv;
25371         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25372         this_ptr_conv.is_owned = false;
25373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25374         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
25375 }
25376
25377 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_unspendable_punishment_reserve"))) TS_ChannelDetails_get_unspendable_punishment_reserve(uint32_t this_ptr) {
25378         LDKChannelDetails this_ptr_conv;
25379         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25380         this_ptr_conv.is_owned = false;
25381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25382         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25383         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
25384         uint32_t ret_ref = (uintptr_t)ret_copy;
25385         return ret_ref;
25386 }
25387
25388 void  __attribute__((export_name("TS_ChannelDetails_set_unspendable_punishment_reserve"))) TS_ChannelDetails_set_unspendable_punishment_reserve(uint32_t this_ptr, uint32_t val) {
25389         LDKChannelDetails this_ptr_conv;
25390         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25391         this_ptr_conv.is_owned = false;
25392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25393         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25394         CHECK_ACCESS(val_ptr);
25395         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
25396         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
25397         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
25398 }
25399
25400 int64_t  __attribute__((export_name("TS_ChannelDetails_get_user_channel_id"))) TS_ChannelDetails_get_user_channel_id(uint32_t this_ptr) {
25401         LDKChannelDetails this_ptr_conv;
25402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25403         this_ptr_conv.is_owned = false;
25404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25405         int64_t ret_conv = ChannelDetails_get_user_channel_id(&this_ptr_conv);
25406         return ret_conv;
25407 }
25408
25409 void  __attribute__((export_name("TS_ChannelDetails_set_user_channel_id"))) TS_ChannelDetails_set_user_channel_id(uint32_t this_ptr, int64_t val) {
25410         LDKChannelDetails this_ptr_conv;
25411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25412         this_ptr_conv.is_owned = false;
25413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25414         ChannelDetails_set_user_channel_id(&this_ptr_conv, val);
25415 }
25416
25417 int64_t  __attribute__((export_name("TS_ChannelDetails_get_balance_msat"))) TS_ChannelDetails_get_balance_msat(uint32_t this_ptr) {
25418         LDKChannelDetails this_ptr_conv;
25419         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25420         this_ptr_conv.is_owned = false;
25421         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25422         int64_t ret_conv = ChannelDetails_get_balance_msat(&this_ptr_conv);
25423         return ret_conv;
25424 }
25425
25426 void  __attribute__((export_name("TS_ChannelDetails_set_balance_msat"))) TS_ChannelDetails_set_balance_msat(uint32_t this_ptr, int64_t val) {
25427         LDKChannelDetails this_ptr_conv;
25428         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25429         this_ptr_conv.is_owned = false;
25430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25431         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
25432 }
25433
25434 int64_t  __attribute__((export_name("TS_ChannelDetails_get_outbound_capacity_msat"))) TS_ChannelDetails_get_outbound_capacity_msat(uint32_t this_ptr) {
25435         LDKChannelDetails this_ptr_conv;
25436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25437         this_ptr_conv.is_owned = false;
25438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25439         int64_t ret_conv = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
25440         return ret_conv;
25441 }
25442
25443 void  __attribute__((export_name("TS_ChannelDetails_set_outbound_capacity_msat"))) TS_ChannelDetails_set_outbound_capacity_msat(uint32_t this_ptr, int64_t val) {
25444         LDKChannelDetails this_ptr_conv;
25445         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25446         this_ptr_conv.is_owned = false;
25447         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25448         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
25449 }
25450
25451 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) {
25452         LDKChannelDetails this_ptr_conv;
25453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25454         this_ptr_conv.is_owned = false;
25455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25456         int64_t ret_conv = ChannelDetails_get_next_outbound_htlc_limit_msat(&this_ptr_conv);
25457         return ret_conv;
25458 }
25459
25460 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) {
25461         LDKChannelDetails this_ptr_conv;
25462         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25463         this_ptr_conv.is_owned = false;
25464         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25465         ChannelDetails_set_next_outbound_htlc_limit_msat(&this_ptr_conv, val);
25466 }
25467
25468 int64_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_capacity_msat"))) TS_ChannelDetails_get_inbound_capacity_msat(uint32_t this_ptr) {
25469         LDKChannelDetails this_ptr_conv;
25470         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25471         this_ptr_conv.is_owned = false;
25472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25473         int64_t ret_conv = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
25474         return ret_conv;
25475 }
25476
25477 void  __attribute__((export_name("TS_ChannelDetails_set_inbound_capacity_msat"))) TS_ChannelDetails_set_inbound_capacity_msat(uint32_t this_ptr, int64_t val) {
25478         LDKChannelDetails this_ptr_conv;
25479         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25480         this_ptr_conv.is_owned = false;
25481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25482         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
25483 }
25484
25485 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_confirmations_required"))) TS_ChannelDetails_get_confirmations_required(uint32_t this_ptr) {
25486         LDKChannelDetails this_ptr_conv;
25487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25488         this_ptr_conv.is_owned = false;
25489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25490         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
25491         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
25492         uint32_t ret_ref = (uintptr_t)ret_copy;
25493         return ret_ref;
25494 }
25495
25496 void  __attribute__((export_name("TS_ChannelDetails_set_confirmations_required"))) TS_ChannelDetails_set_confirmations_required(uint32_t this_ptr, uint32_t val) {
25497         LDKChannelDetails this_ptr_conv;
25498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25499         this_ptr_conv.is_owned = false;
25500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25501         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25502         CHECK_ACCESS(val_ptr);
25503         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
25504         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
25505         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
25506 }
25507
25508 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_force_close_spend_delay"))) TS_ChannelDetails_get_force_close_spend_delay(uint32_t this_ptr) {
25509         LDKChannelDetails this_ptr_conv;
25510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25511         this_ptr_conv.is_owned = false;
25512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25513         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
25514         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
25515         uint32_t ret_ref = (uintptr_t)ret_copy;
25516         return ret_ref;
25517 }
25518
25519 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) {
25520         LDKChannelDetails this_ptr_conv;
25521         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25522         this_ptr_conv.is_owned = false;
25523         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25524         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25525         CHECK_ACCESS(val_ptr);
25526         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
25527         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)val) & ~1));
25528         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
25529 }
25530
25531 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_outbound"))) TS_ChannelDetails_get_is_outbound(uint32_t this_ptr) {
25532         LDKChannelDetails this_ptr_conv;
25533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25534         this_ptr_conv.is_owned = false;
25535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25536         jboolean ret_conv = ChannelDetails_get_is_outbound(&this_ptr_conv);
25537         return ret_conv;
25538 }
25539
25540 void  __attribute__((export_name("TS_ChannelDetails_set_is_outbound"))) TS_ChannelDetails_set_is_outbound(uint32_t this_ptr, jboolean val) {
25541         LDKChannelDetails this_ptr_conv;
25542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25543         this_ptr_conv.is_owned = false;
25544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25545         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
25546 }
25547
25548 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_channel_ready"))) TS_ChannelDetails_get_is_channel_ready(uint32_t this_ptr) {
25549         LDKChannelDetails this_ptr_conv;
25550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25551         this_ptr_conv.is_owned = false;
25552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25553         jboolean ret_conv = ChannelDetails_get_is_channel_ready(&this_ptr_conv);
25554         return ret_conv;
25555 }
25556
25557 void  __attribute__((export_name("TS_ChannelDetails_set_is_channel_ready"))) TS_ChannelDetails_set_is_channel_ready(uint32_t this_ptr, jboolean val) {
25558         LDKChannelDetails this_ptr_conv;
25559         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25560         this_ptr_conv.is_owned = false;
25561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25562         ChannelDetails_set_is_channel_ready(&this_ptr_conv, val);
25563 }
25564
25565 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_usable"))) TS_ChannelDetails_get_is_usable(uint32_t this_ptr) {
25566         LDKChannelDetails this_ptr_conv;
25567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25568         this_ptr_conv.is_owned = false;
25569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25570         jboolean ret_conv = ChannelDetails_get_is_usable(&this_ptr_conv);
25571         return ret_conv;
25572 }
25573
25574 void  __attribute__((export_name("TS_ChannelDetails_set_is_usable"))) TS_ChannelDetails_set_is_usable(uint32_t this_ptr, jboolean val) {
25575         LDKChannelDetails this_ptr_conv;
25576         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25577         this_ptr_conv.is_owned = false;
25578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25579         ChannelDetails_set_is_usable(&this_ptr_conv, val);
25580 }
25581
25582 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_public"))) TS_ChannelDetails_get_is_public(uint32_t this_ptr) {
25583         LDKChannelDetails this_ptr_conv;
25584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25585         this_ptr_conv.is_owned = false;
25586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25587         jboolean ret_conv = ChannelDetails_get_is_public(&this_ptr_conv);
25588         return ret_conv;
25589 }
25590
25591 void  __attribute__((export_name("TS_ChannelDetails_set_is_public"))) TS_ChannelDetails_set_is_public(uint32_t this_ptr, jboolean val) {
25592         LDKChannelDetails this_ptr_conv;
25593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25594         this_ptr_conv.is_owned = false;
25595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25596         ChannelDetails_set_is_public(&this_ptr_conv, val);
25597 }
25598
25599 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_htlc_minimum_msat"))) TS_ChannelDetails_get_inbound_htlc_minimum_msat(uint32_t this_ptr) {
25600         LDKChannelDetails this_ptr_conv;
25601         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25602         this_ptr_conv.is_owned = false;
25603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25604         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25605         *ret_copy = ChannelDetails_get_inbound_htlc_minimum_msat(&this_ptr_conv);
25606         uint32_t ret_ref = (uintptr_t)ret_copy;
25607         return ret_ref;
25608 }
25609
25610 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) {
25611         LDKChannelDetails this_ptr_conv;
25612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25613         this_ptr_conv.is_owned = false;
25614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25615         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25616         CHECK_ACCESS(val_ptr);
25617         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
25618         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
25619         ChannelDetails_set_inbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
25620 }
25621
25622 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_htlc_maximum_msat"))) TS_ChannelDetails_get_inbound_htlc_maximum_msat(uint32_t this_ptr) {
25623         LDKChannelDetails this_ptr_conv;
25624         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25625         this_ptr_conv.is_owned = false;
25626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25627         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25628         *ret_copy = ChannelDetails_get_inbound_htlc_maximum_msat(&this_ptr_conv);
25629         uint32_t ret_ref = (uintptr_t)ret_copy;
25630         return ret_ref;
25631 }
25632
25633 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) {
25634         LDKChannelDetails this_ptr_conv;
25635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25636         this_ptr_conv.is_owned = false;
25637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25638         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25639         CHECK_ACCESS(val_ptr);
25640         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
25641         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
25642         ChannelDetails_set_inbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
25643 }
25644
25645 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) {
25646         LDKThirtyTwoBytes channel_id_arg_ref;
25647         CHECK(channel_id_arg->arr_len == 32);
25648         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
25649         LDKChannelCounterparty counterparty_arg_conv;
25650         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
25651         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
25652         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
25653         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
25654         LDKOutPoint funding_txo_arg_conv;
25655         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
25656         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
25657         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
25658         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
25659         LDKChannelTypeFeatures channel_type_arg_conv;
25660         channel_type_arg_conv.inner = (void*)(channel_type_arg & (~1));
25661         channel_type_arg_conv.is_owned = (channel_type_arg & 1) || (channel_type_arg == 0);
25662         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_arg_conv);
25663         channel_type_arg_conv = ChannelTypeFeatures_clone(&channel_type_arg_conv);
25664         void* short_channel_id_arg_ptr = (void*)(((uintptr_t)short_channel_id_arg) & ~1);
25665         CHECK_ACCESS(short_channel_id_arg_ptr);
25666         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
25667         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_arg) & ~1));
25668         void* outbound_scid_alias_arg_ptr = (void*)(((uintptr_t)outbound_scid_alias_arg) & ~1);
25669         CHECK_ACCESS(outbound_scid_alias_arg_ptr);
25670         LDKCOption_u64Z outbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(outbound_scid_alias_arg_ptr);
25671         outbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)outbound_scid_alias_arg) & ~1));
25672         void* inbound_scid_alias_arg_ptr = (void*)(((uintptr_t)inbound_scid_alias_arg) & ~1);
25673         CHECK_ACCESS(inbound_scid_alias_arg_ptr);
25674         LDKCOption_u64Z inbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(inbound_scid_alias_arg_ptr);
25675         inbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_scid_alias_arg) & ~1));
25676         void* unspendable_punishment_reserve_arg_ptr = (void*)(((uintptr_t)unspendable_punishment_reserve_arg) & ~1);
25677         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
25678         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
25679         void* confirmations_required_arg_ptr = (void*)(((uintptr_t)confirmations_required_arg) & ~1);
25680         CHECK_ACCESS(confirmations_required_arg_ptr);
25681         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
25682         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)confirmations_required_arg) & ~1));
25683         void* force_close_spend_delay_arg_ptr = (void*)(((uintptr_t)force_close_spend_delay_arg) & ~1);
25684         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
25685         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
25686         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)force_close_spend_delay_arg) & ~1));
25687         void* inbound_htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)inbound_htlc_minimum_msat_arg) & ~1);
25688         CHECK_ACCESS(inbound_htlc_minimum_msat_arg_ptr);
25689         LDKCOption_u64Z inbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_minimum_msat_arg_ptr);
25690         inbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_htlc_minimum_msat_arg) & ~1));
25691         void* inbound_htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)inbound_htlc_maximum_msat_arg) & ~1);
25692         CHECK_ACCESS(inbound_htlc_maximum_msat_arg_ptr);
25693         LDKCOption_u64Z inbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_maximum_msat_arg_ptr);
25694         inbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_htlc_maximum_msat_arg) & ~1));
25695         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);
25696         uint32_t ret_ref = 0;
25697         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25698         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25699         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25700         ret_ref = (uintptr_t)ret_var.inner;
25701         if (ret_var.is_owned) {
25702                 ret_ref |= 1;
25703         }
25704         return ret_ref;
25705 }
25706
25707 static inline uintptr_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
25708         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
25709 uint32_t ret_ref = 0;
25710 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25711 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25712 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25713 ret_ref = (uintptr_t)ret_var.inner;
25714 if (ret_var.is_owned) {
25715         ret_ref |= 1;
25716 }
25717         return ret_ref;
25718 }
25719 uint32_t  __attribute__((export_name("TS_ChannelDetails_clone_ptr"))) TS_ChannelDetails_clone_ptr(uint32_t arg) {
25720         LDKChannelDetails arg_conv;
25721         arg_conv.inner = (void*)(arg & (~1));
25722         arg_conv.is_owned = false;
25723         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25724         uint32_t ret_conv = ChannelDetails_clone_ptr(&arg_conv);
25725         return ret_conv;
25726 }
25727
25728 uint32_t  __attribute__((export_name("TS_ChannelDetails_clone"))) TS_ChannelDetails_clone(uint32_t orig) {
25729         LDKChannelDetails orig_conv;
25730         orig_conv.inner = (void*)(orig & (~1));
25731         orig_conv.is_owned = false;
25732         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25733         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
25734         uint32_t ret_ref = 0;
25735         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25736         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25737         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25738         ret_ref = (uintptr_t)ret_var.inner;
25739         if (ret_var.is_owned) {
25740                 ret_ref |= 1;
25741         }
25742         return ret_ref;
25743 }
25744
25745 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_payment_scid"))) TS_ChannelDetails_get_inbound_payment_scid(uint32_t this_arg) {
25746         LDKChannelDetails this_arg_conv;
25747         this_arg_conv.inner = (void*)(this_arg & (~1));
25748         this_arg_conv.is_owned = false;
25749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25750         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25751         *ret_copy = ChannelDetails_get_inbound_payment_scid(&this_arg_conv);
25752         uint32_t ret_ref = (uintptr_t)ret_copy;
25753         return ret_ref;
25754 }
25755
25756 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_outbound_payment_scid"))) TS_ChannelDetails_get_outbound_payment_scid(uint32_t this_arg) {
25757         LDKChannelDetails this_arg_conv;
25758         this_arg_conv.inner = (void*)(this_arg & (~1));
25759         this_arg_conv.is_owned = false;
25760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25761         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
25762         *ret_copy = ChannelDetails_get_outbound_payment_scid(&this_arg_conv);
25763         uint32_t ret_ref = (uintptr_t)ret_copy;
25764         return ret_ref;
25765 }
25766
25767 void  __attribute__((export_name("TS_PaymentSendFailure_free"))) TS_PaymentSendFailure_free(uint32_t this_ptr) {
25768         if ((this_ptr & 1) != 0) return;
25769         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
25770         CHECK_ACCESS(this_ptr_ptr);
25771         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
25772         FREE((void*)this_ptr);
25773         PaymentSendFailure_free(this_ptr_conv);
25774 }
25775
25776 static inline uintptr_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
25777         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
25778         *ret_copy = PaymentSendFailure_clone(arg);
25779 uint32_t ret_ref = (uintptr_t)ret_copy;
25780         return ret_ref;
25781 }
25782 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_clone_ptr"))) TS_PaymentSendFailure_clone_ptr(uint32_t arg) {
25783         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)arg;
25784         uint32_t ret_conv = PaymentSendFailure_clone_ptr(arg_conv);
25785         return ret_conv;
25786 }
25787
25788 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_clone"))) TS_PaymentSendFailure_clone(uint32_t orig) {
25789         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
25790         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
25791         *ret_copy = PaymentSendFailure_clone(orig_conv);
25792         uint32_t ret_ref = (uintptr_t)ret_copy;
25793         return ret_ref;
25794 }
25795
25796 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_parameter_error"))) TS_PaymentSendFailure_parameter_error(uint32_t a) {
25797         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
25798         CHECK_ACCESS(a_ptr);
25799         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
25800         a_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a) & ~1));
25801         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
25802         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
25803         uint32_t ret_ref = (uintptr_t)ret_copy;
25804         return ret_ref;
25805 }
25806
25807 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_path_parameter_error"))) TS_PaymentSendFailure_path_parameter_error(uint32_tArray a) {
25808         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
25809         a_constr.datalen = a->arr_len;
25810         if (a_constr.datalen > 0)
25811                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
25812         else
25813                 a_constr.data = NULL;
25814         uint32_t* a_vals = a->elems /* XXX a leaks */;
25815         for (size_t w = 0; w < a_constr.datalen; w++) {
25816                 uint32_t a_conv_22 = a_vals[w];
25817                 void* a_conv_22_ptr = (void*)(((uintptr_t)a_conv_22) & ~1);
25818                 CHECK_ACCESS(a_conv_22_ptr);
25819                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
25820                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uintptr_t)a_conv_22) & ~1));
25821                 a_constr.data[w] = a_conv_22_conv;
25822         }
25823         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
25824         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
25825         uint32_t ret_ref = (uintptr_t)ret_copy;
25826         return ret_ref;
25827 }
25828
25829 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_all_failed_retry_safe"))) TS_PaymentSendFailure_all_failed_retry_safe(uint32_tArray a) {
25830         LDKCVec_APIErrorZ a_constr;
25831         a_constr.datalen = a->arr_len;
25832         if (a_constr.datalen > 0)
25833                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
25834         else
25835                 a_constr.data = NULL;
25836         uint32_t* a_vals = a->elems /* XXX a leaks */;
25837         for (size_t k = 0; k < a_constr.datalen; k++) {
25838                 uint32_t a_conv_10 = a_vals[k];
25839                 void* a_conv_10_ptr = (void*)(((uintptr_t)a_conv_10) & ~1);
25840                 CHECK_ACCESS(a_conv_10_ptr);
25841                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
25842                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a_conv_10) & ~1));
25843                 a_constr.data[k] = a_conv_10_conv;
25844         }
25845         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
25846         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
25847         uint32_t ret_ref = (uintptr_t)ret_copy;
25848         return ret_ref;
25849 }
25850
25851 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) {
25852         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
25853         results_constr.datalen = results->arr_len;
25854         if (results_constr.datalen > 0)
25855                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
25856         else
25857                 results_constr.data = NULL;
25858         uint32_t* results_vals = results->elems /* XXX results leaks */;
25859         for (size_t w = 0; w < results_constr.datalen; w++) {
25860                 uint32_t results_conv_22 = results_vals[w];
25861                 void* results_conv_22_ptr = (void*)(((uintptr_t)results_conv_22) & ~1);
25862                 CHECK_ACCESS(results_conv_22_ptr);
25863                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
25864                 results_constr.data[w] = results_conv_22_conv;
25865         }
25866         LDKRouteParameters failed_paths_retry_conv;
25867         failed_paths_retry_conv.inner = (void*)(failed_paths_retry & (~1));
25868         failed_paths_retry_conv.is_owned = (failed_paths_retry & 1) || (failed_paths_retry == 0);
25869         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
25870         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
25871         LDKThirtyTwoBytes payment_id_ref;
25872         CHECK(payment_id->arr_len == 32);
25873         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
25874         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
25875         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
25876         uint32_t ret_ref = (uintptr_t)ret_copy;
25877         return ret_ref;
25878 }
25879
25880 void  __attribute__((export_name("TS_PhantomRouteHints_free"))) TS_PhantomRouteHints_free(uint32_t this_obj) {
25881         LDKPhantomRouteHints this_obj_conv;
25882         this_obj_conv.inner = (void*)(this_obj & (~1));
25883         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25885         PhantomRouteHints_free(this_obj_conv);
25886 }
25887
25888 uint32_tArray  __attribute__((export_name("TS_PhantomRouteHints_get_channels"))) TS_PhantomRouteHints_get_channels(uint32_t this_ptr) {
25889         LDKPhantomRouteHints this_ptr_conv;
25890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25891         this_ptr_conv.is_owned = false;
25892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25893         LDKCVec_ChannelDetailsZ ret_var = PhantomRouteHints_get_channels(&this_ptr_conv);
25894         uint32_tArray ret_arr = NULL;
25895         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
25896         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
25897         for (size_t q = 0; q < ret_var.datalen; q++) {
25898                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
25899                 uint32_t ret_conv_16_ref = 0;
25900                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25901                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25902                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
25903                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
25904                 if (ret_conv_16_var.is_owned) {
25905                         ret_conv_16_ref |= 1;
25906                 }
25907                 ret_arr_ptr[q] = ret_conv_16_ref;
25908         }
25909         
25910         FREE(ret_var.data);
25911         return ret_arr;
25912 }
25913
25914 void  __attribute__((export_name("TS_PhantomRouteHints_set_channels"))) TS_PhantomRouteHints_set_channels(uint32_t this_ptr, uint32_tArray val) {
25915         LDKPhantomRouteHints this_ptr_conv;
25916         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25917         this_ptr_conv.is_owned = false;
25918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25919         LDKCVec_ChannelDetailsZ val_constr;
25920         val_constr.datalen = val->arr_len;
25921         if (val_constr.datalen > 0)
25922                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
25923         else
25924                 val_constr.data = NULL;
25925         uint32_t* val_vals = val->elems /* XXX val leaks */;
25926         for (size_t q = 0; q < val_constr.datalen; q++) {
25927                 uint32_t val_conv_16 = val_vals[q];
25928                 LDKChannelDetails val_conv_16_conv;
25929                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
25930                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
25931                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
25932                 val_conv_16_conv = ChannelDetails_clone(&val_conv_16_conv);
25933                 val_constr.data[q] = val_conv_16_conv;
25934         }
25935         PhantomRouteHints_set_channels(&this_ptr_conv, val_constr);
25936 }
25937
25938 int64_t  __attribute__((export_name("TS_PhantomRouteHints_get_phantom_scid"))) TS_PhantomRouteHints_get_phantom_scid(uint32_t this_ptr) {
25939         LDKPhantomRouteHints this_ptr_conv;
25940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25941         this_ptr_conv.is_owned = false;
25942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25943         int64_t ret_conv = PhantomRouteHints_get_phantom_scid(&this_ptr_conv);
25944         return ret_conv;
25945 }
25946
25947 void  __attribute__((export_name("TS_PhantomRouteHints_set_phantom_scid"))) TS_PhantomRouteHints_set_phantom_scid(uint32_t this_ptr, int64_t val) {
25948         LDKPhantomRouteHints this_ptr_conv;
25949         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25950         this_ptr_conv.is_owned = false;
25951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25952         PhantomRouteHints_set_phantom_scid(&this_ptr_conv, val);
25953 }
25954
25955 int8_tArray  __attribute__((export_name("TS_PhantomRouteHints_get_real_node_pubkey"))) TS_PhantomRouteHints_get_real_node_pubkey(uint32_t this_ptr) {
25956         LDKPhantomRouteHints this_ptr_conv;
25957         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25958         this_ptr_conv.is_owned = false;
25959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25960         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
25961         memcpy(ret_arr->elems, PhantomRouteHints_get_real_node_pubkey(&this_ptr_conv).compressed_form, 33);
25962         return ret_arr;
25963 }
25964
25965 void  __attribute__((export_name("TS_PhantomRouteHints_set_real_node_pubkey"))) TS_PhantomRouteHints_set_real_node_pubkey(uint32_t this_ptr, int8_tArray val) {
25966         LDKPhantomRouteHints this_ptr_conv;
25967         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25968         this_ptr_conv.is_owned = false;
25969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25970         LDKPublicKey val_ref;
25971         CHECK(val->arr_len == 33);
25972         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
25973         PhantomRouteHints_set_real_node_pubkey(&this_ptr_conv, val_ref);
25974 }
25975
25976 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) {
25977         LDKCVec_ChannelDetailsZ channels_arg_constr;
25978         channels_arg_constr.datalen = channels_arg->arr_len;
25979         if (channels_arg_constr.datalen > 0)
25980                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
25981         else
25982                 channels_arg_constr.data = NULL;
25983         uint32_t* channels_arg_vals = channels_arg->elems /* XXX channels_arg leaks */;
25984         for (size_t q = 0; q < channels_arg_constr.datalen; q++) {
25985                 uint32_t channels_arg_conv_16 = channels_arg_vals[q];
25986                 LDKChannelDetails channels_arg_conv_16_conv;
25987                 channels_arg_conv_16_conv.inner = (void*)(channels_arg_conv_16 & (~1));
25988                 channels_arg_conv_16_conv.is_owned = (channels_arg_conv_16 & 1) || (channels_arg_conv_16 == 0);
25989                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channels_arg_conv_16_conv);
25990                 channels_arg_conv_16_conv = ChannelDetails_clone(&channels_arg_conv_16_conv);
25991                 channels_arg_constr.data[q] = channels_arg_conv_16_conv;
25992         }
25993         LDKPublicKey real_node_pubkey_arg_ref;
25994         CHECK(real_node_pubkey_arg->arr_len == 33);
25995         memcpy(real_node_pubkey_arg_ref.compressed_form, real_node_pubkey_arg->elems, 33); FREE(real_node_pubkey_arg);
25996         LDKPhantomRouteHints ret_var = PhantomRouteHints_new(channels_arg_constr, phantom_scid_arg, real_node_pubkey_arg_ref);
25997         uint32_t ret_ref = 0;
25998         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25999         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26000         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26001         ret_ref = (uintptr_t)ret_var.inner;
26002         if (ret_var.is_owned) {
26003                 ret_ref |= 1;
26004         }
26005         return ret_ref;
26006 }
26007
26008 static inline uintptr_t PhantomRouteHints_clone_ptr(LDKPhantomRouteHints *NONNULL_PTR arg) {
26009         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(arg);
26010 uint32_t ret_ref = 0;
26011 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26012 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26013 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26014 ret_ref = (uintptr_t)ret_var.inner;
26015 if (ret_var.is_owned) {
26016         ret_ref |= 1;
26017 }
26018         return ret_ref;
26019 }
26020 uint32_t  __attribute__((export_name("TS_PhantomRouteHints_clone_ptr"))) TS_PhantomRouteHints_clone_ptr(uint32_t arg) {
26021         LDKPhantomRouteHints arg_conv;
26022         arg_conv.inner = (void*)(arg & (~1));
26023         arg_conv.is_owned = false;
26024         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26025         uint32_t ret_conv = PhantomRouteHints_clone_ptr(&arg_conv);
26026         return ret_conv;
26027 }
26028
26029 uint32_t  __attribute__((export_name("TS_PhantomRouteHints_clone"))) TS_PhantomRouteHints_clone(uint32_t orig) {
26030         LDKPhantomRouteHints orig_conv;
26031         orig_conv.inner = (void*)(orig & (~1));
26032         orig_conv.is_owned = false;
26033         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26034         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(&orig_conv);
26035         uint32_t ret_ref = 0;
26036         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26037         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26038         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26039         ret_ref = (uintptr_t)ret_var.inner;
26040         if (ret_var.is_owned) {
26041                 ret_ref |= 1;
26042         }
26043         return ret_ref;
26044 }
26045
26046 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) {
26047         void* fee_est_ptr = (void*)(((uintptr_t)fee_est) & ~1);
26048         CHECK_ACCESS(fee_est_ptr);
26049         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
26050         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
26051                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26052                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
26053         }
26054         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
26055         CHECK_ACCESS(chain_monitor_ptr);
26056         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
26057         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
26058                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26059                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
26060         }
26061         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
26062         CHECK_ACCESS(tx_broadcaster_ptr);
26063         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
26064         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
26065                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26066                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
26067         }
26068         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
26069         CHECK_ACCESS(logger_ptr);
26070         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
26071         if (logger_conv.free == LDKLogger_JCalls_free) {
26072                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26073                 LDKLogger_JCalls_cloned(&logger_conv);
26074         }
26075         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
26076         CHECK_ACCESS(keys_manager_ptr);
26077         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
26078         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
26079                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26080                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
26081         }
26082         LDKUserConfig config_conv;
26083         config_conv.inner = (void*)(config & (~1));
26084         config_conv.is_owned = (config & 1) || (config == 0);
26085         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
26086         config_conv = UserConfig_clone(&config_conv);
26087         LDKChainParameters params_conv;
26088         params_conv.inner = (void*)(params & (~1));
26089         params_conv.is_owned = (params & 1) || (params == 0);
26090         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
26091         params_conv = ChainParameters_clone(&params_conv);
26092         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
26093         uint32_t ret_ref = 0;
26094         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26095         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26096         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26097         ret_ref = (uintptr_t)ret_var.inner;
26098         if (ret_var.is_owned) {
26099                 ret_ref |= 1;
26100         }
26101         return ret_ref;
26102 }
26103
26104 uint32_t  __attribute__((export_name("TS_ChannelManager_get_current_default_configuration"))) TS_ChannelManager_get_current_default_configuration(uint32_t this_arg) {
26105         LDKChannelManager this_arg_conv;
26106         this_arg_conv.inner = (void*)(this_arg & (~1));
26107         this_arg_conv.is_owned = false;
26108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26109         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
26110         uint32_t ret_ref = 0;
26111         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26112         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26113         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26114         ret_ref = (uintptr_t)ret_var.inner;
26115         if (ret_var.is_owned) {
26116                 ret_ref |= 1;
26117         }
26118         return ret_ref;
26119 }
26120
26121 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) {
26122         LDKChannelManager this_arg_conv;
26123         this_arg_conv.inner = (void*)(this_arg & (~1));
26124         this_arg_conv.is_owned = false;
26125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26126         LDKPublicKey their_network_key_ref;
26127         CHECK(their_network_key->arr_len == 33);
26128         memcpy(their_network_key_ref.compressed_form, their_network_key->elems, 33); FREE(their_network_key);
26129         LDKUserConfig override_config_conv;
26130         override_config_conv.inner = (void*)(override_config & (~1));
26131         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
26132         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
26133         override_config_conv = UserConfig_clone(&override_config_conv);
26134         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
26135         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id, override_config_conv);
26136         return (uint32_t)ret_conv;
26137 }
26138
26139 uint32_tArray  __attribute__((export_name("TS_ChannelManager_list_channels"))) TS_ChannelManager_list_channels(uint32_t this_arg) {
26140         LDKChannelManager this_arg_conv;
26141         this_arg_conv.inner = (void*)(this_arg & (~1));
26142         this_arg_conv.is_owned = false;
26143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26144         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
26145         uint32_tArray ret_arr = NULL;
26146         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
26147         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
26148         for (size_t q = 0; q < ret_var.datalen; q++) {
26149                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
26150                 uint32_t ret_conv_16_ref = 0;
26151                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26152                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26153                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
26154                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
26155                 if (ret_conv_16_var.is_owned) {
26156                         ret_conv_16_ref |= 1;
26157                 }
26158                 ret_arr_ptr[q] = ret_conv_16_ref;
26159         }
26160         
26161         FREE(ret_var.data);
26162         return ret_arr;
26163 }
26164
26165 uint32_tArray  __attribute__((export_name("TS_ChannelManager_list_usable_channels"))) TS_ChannelManager_list_usable_channels(uint32_t this_arg) {
26166         LDKChannelManager this_arg_conv;
26167         this_arg_conv.inner = (void*)(this_arg & (~1));
26168         this_arg_conv.is_owned = false;
26169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26170         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
26171         uint32_tArray ret_arr = NULL;
26172         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
26173         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
26174         for (size_t q = 0; q < ret_var.datalen; q++) {
26175                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
26176                 uint32_t ret_conv_16_ref = 0;
26177                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26178                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26179                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
26180                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
26181                 if (ret_conv_16_var.is_owned) {
26182                         ret_conv_16_ref |= 1;
26183                 }
26184                 ret_arr_ptr[q] = ret_conv_16_ref;
26185         }
26186         
26187         FREE(ret_var.data);
26188         return ret_arr;
26189 }
26190
26191 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) {
26192         LDKChannelManager this_arg_conv;
26193         this_arg_conv.inner = (void*)(this_arg & (~1));
26194         this_arg_conv.is_owned = false;
26195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26196         unsigned char channel_id_arr[32];
26197         CHECK(channel_id->arr_len == 32);
26198         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
26199         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
26200         LDKPublicKey counterparty_node_id_ref;
26201         CHECK(counterparty_node_id->arr_len == 33);
26202         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
26203         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
26204         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
26205         return (uint32_t)ret_conv;
26206 }
26207
26208 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) {
26209         LDKChannelManager this_arg_conv;
26210         this_arg_conv.inner = (void*)(this_arg & (~1));
26211         this_arg_conv.is_owned = false;
26212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26213         unsigned char channel_id_arr[32];
26214         CHECK(channel_id->arr_len == 32);
26215         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
26216         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
26217         LDKPublicKey counterparty_node_id_ref;
26218         CHECK(counterparty_node_id->arr_len == 33);
26219         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
26220         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
26221         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, counterparty_node_id_ref, target_feerate_sats_per_1000_weight);
26222         return (uint32_t)ret_conv;
26223 }
26224
26225 uint32_t  __attribute__((export_name("TS_ChannelManager_force_close_channel"))) TS_ChannelManager_force_close_channel(uint32_t this_arg, int8_tArray channel_id, int8_tArray counterparty_node_id) {
26226         LDKChannelManager this_arg_conv;
26227         this_arg_conv.inner = (void*)(this_arg & (~1));
26228         this_arg_conv.is_owned = false;
26229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26230         unsigned char channel_id_arr[32];
26231         CHECK(channel_id->arr_len == 32);
26232         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
26233         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
26234         LDKPublicKey counterparty_node_id_ref;
26235         CHECK(counterparty_node_id->arr_len == 33);
26236         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
26237         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
26238         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
26239         return (uint32_t)ret_conv;
26240 }
26241
26242 void  __attribute__((export_name("TS_ChannelManager_force_close_all_channels"))) TS_ChannelManager_force_close_all_channels(uint32_t this_arg) {
26243         LDKChannelManager this_arg_conv;
26244         this_arg_conv.inner = (void*)(this_arg & (~1));
26245         this_arg_conv.is_owned = false;
26246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26247         ChannelManager_force_close_all_channels(&this_arg_conv);
26248 }
26249
26250 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) {
26251         LDKChannelManager this_arg_conv;
26252         this_arg_conv.inner = (void*)(this_arg & (~1));
26253         this_arg_conv.is_owned = false;
26254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26255         LDKRoute route_conv;
26256         route_conv.inner = (void*)(route & (~1));
26257         route_conv.is_owned = false;
26258         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
26259         LDKThirtyTwoBytes payment_hash_ref;
26260         CHECK(payment_hash->arr_len == 32);
26261         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
26262         LDKThirtyTwoBytes payment_secret_ref;
26263         CHECK(payment_secret->arr_len == 32);
26264         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
26265         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
26266         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
26267         return (uint32_t)ret_conv;
26268 }
26269
26270 uint32_t  __attribute__((export_name("TS_ChannelManager_retry_payment"))) TS_ChannelManager_retry_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_id) {
26271         LDKChannelManager this_arg_conv;
26272         this_arg_conv.inner = (void*)(this_arg & (~1));
26273         this_arg_conv.is_owned = false;
26274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26275         LDKRoute route_conv;
26276         route_conv.inner = (void*)(route & (~1));
26277         route_conv.is_owned = false;
26278         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
26279         LDKThirtyTwoBytes payment_id_ref;
26280         CHECK(payment_id->arr_len == 32);
26281         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
26282         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
26283         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
26284         return (uint32_t)ret_conv;
26285 }
26286
26287 void  __attribute__((export_name("TS_ChannelManager_abandon_payment"))) TS_ChannelManager_abandon_payment(uint32_t this_arg, int8_tArray payment_id) {
26288         LDKChannelManager this_arg_conv;
26289         this_arg_conv.inner = (void*)(this_arg & (~1));
26290         this_arg_conv.is_owned = false;
26291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26292         LDKThirtyTwoBytes payment_id_ref;
26293         CHECK(payment_id->arr_len == 32);
26294         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
26295         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
26296 }
26297
26298 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) {
26299         LDKChannelManager this_arg_conv;
26300         this_arg_conv.inner = (void*)(this_arg & (~1));
26301         this_arg_conv.is_owned = false;
26302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26303         LDKRoute route_conv;
26304         route_conv.inner = (void*)(route & (~1));
26305         route_conv.is_owned = false;
26306         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
26307         LDKThirtyTwoBytes payment_preimage_ref;
26308         CHECK(payment_preimage->arr_len == 32);
26309         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
26310         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
26311         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
26312         return (uint32_t)ret_conv;
26313 }
26314
26315 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) {
26316         LDKChannelManager this_arg_conv;
26317         this_arg_conv.inner = (void*)(this_arg & (~1));
26318         this_arg_conv.is_owned = false;
26319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26320         unsigned char temporary_channel_id_arr[32];
26321         CHECK(temporary_channel_id->arr_len == 32);
26322         memcpy(temporary_channel_id_arr, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
26323         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
26324         LDKPublicKey counterparty_node_id_ref;
26325         CHECK(counterparty_node_id->arr_len == 33);
26326         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
26327         LDKTransaction funding_transaction_ref;
26328         funding_transaction_ref.datalen = funding_transaction->arr_len;
26329         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
26330         memcpy(funding_transaction_ref.data, funding_transaction->elems, funding_transaction_ref.datalen); FREE(funding_transaction);
26331         funding_transaction_ref.data_is_owned = true;
26332         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
26333         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, funding_transaction_ref);
26334         return (uint32_t)ret_conv;
26335 }
26336
26337 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) {
26338         LDKChannelManager this_arg_conv;
26339         this_arg_conv.inner = (void*)(this_arg & (~1));
26340         this_arg_conv.is_owned = false;
26341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26342         LDKThreeBytes rgb_ref;
26343         CHECK(rgb->arr_len == 3);
26344         memcpy(rgb_ref.data, rgb->elems, 3); FREE(rgb);
26345         LDKThirtyTwoBytes alias_ref;
26346         CHECK(alias->arr_len == 32);
26347         memcpy(alias_ref.data, alias->elems, 32); FREE(alias);
26348         LDKCVec_NetAddressZ addresses_constr;
26349         addresses_constr.datalen = addresses->arr_len;
26350         if (addresses_constr.datalen > 0)
26351                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
26352         else
26353                 addresses_constr.data = NULL;
26354         uint32_t* addresses_vals = addresses->elems /* XXX addresses leaks */;
26355         for (size_t m = 0; m < addresses_constr.datalen; m++) {
26356                 uint32_t addresses_conv_12 = addresses_vals[m];
26357                 void* addresses_conv_12_ptr = (void*)(((uintptr_t)addresses_conv_12) & ~1);
26358                 CHECK_ACCESS(addresses_conv_12_ptr);
26359                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
26360                 addresses_constr.data[m] = addresses_conv_12_conv;
26361         }
26362         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
26363 }
26364
26365 void  __attribute__((export_name("TS_ChannelManager_process_pending_htlc_forwards"))) TS_ChannelManager_process_pending_htlc_forwards(uint32_t this_arg) {
26366         LDKChannelManager this_arg_conv;
26367         this_arg_conv.inner = (void*)(this_arg & (~1));
26368         this_arg_conv.is_owned = false;
26369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26370         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
26371 }
26372
26373 void  __attribute__((export_name("TS_ChannelManager_timer_tick_occurred"))) TS_ChannelManager_timer_tick_occurred(uint32_t this_arg) {
26374         LDKChannelManager this_arg_conv;
26375         this_arg_conv.inner = (void*)(this_arg & (~1));
26376         this_arg_conv.is_owned = false;
26377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26378         ChannelManager_timer_tick_occurred(&this_arg_conv);
26379 }
26380
26381 void  __attribute__((export_name("TS_ChannelManager_fail_htlc_backwards"))) TS_ChannelManager_fail_htlc_backwards(uint32_t this_arg, int8_tArray payment_hash) {
26382         LDKChannelManager this_arg_conv;
26383         this_arg_conv.inner = (void*)(this_arg & (~1));
26384         this_arg_conv.is_owned = false;
26385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26386         unsigned char payment_hash_arr[32];
26387         CHECK(payment_hash->arr_len == 32);
26388         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
26389         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
26390         ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
26391 }
26392
26393 void  __attribute__((export_name("TS_ChannelManager_claim_funds"))) TS_ChannelManager_claim_funds(uint32_t this_arg, int8_tArray payment_preimage) {
26394         LDKChannelManager this_arg_conv;
26395         this_arg_conv.inner = (void*)(this_arg & (~1));
26396         this_arg_conv.is_owned = false;
26397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26398         LDKThirtyTwoBytes payment_preimage_ref;
26399         CHECK(payment_preimage->arr_len == 32);
26400         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
26401         ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
26402 }
26403
26404 int8_tArray  __attribute__((export_name("TS_ChannelManager_get_our_node_id"))) TS_ChannelManager_get_our_node_id(uint32_t this_arg) {
26405         LDKChannelManager this_arg_conv;
26406         this_arg_conv.inner = (void*)(this_arg & (~1));
26407         this_arg_conv.is_owned = false;
26408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26409         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26410         memcpy(ret_arr->elems, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form, 33);
26411         return ret_arr;
26412 }
26413
26414 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) {
26415         LDKChannelManager this_arg_conv;
26416         this_arg_conv.inner = (void*)(this_arg & (~1));
26417         this_arg_conv.is_owned = false;
26418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26419         unsigned char temporary_channel_id_arr[32];
26420         CHECK(temporary_channel_id->arr_len == 32);
26421         memcpy(temporary_channel_id_arr, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
26422         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
26423         LDKPublicKey counterparty_node_id_ref;
26424         CHECK(counterparty_node_id->arr_len == 33);
26425         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
26426         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
26427         *ret_conv = ChannelManager_accept_inbound_channel(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id);
26428         return (uint32_t)ret_conv;
26429 }
26430
26431 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) {
26432         LDKChannelManager this_arg_conv;
26433         this_arg_conv.inner = (void*)(this_arg & (~1));
26434         this_arg_conv.is_owned = false;
26435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26436         unsigned char temporary_channel_id_arr[32];
26437         CHECK(temporary_channel_id->arr_len == 32);
26438         memcpy(temporary_channel_id_arr, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
26439         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
26440         LDKPublicKey counterparty_node_id_ref;
26441         CHECK(counterparty_node_id->arr_len == 33);
26442         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
26443         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
26444         *ret_conv = ChannelManager_accept_inbound_channel_from_trusted_peer_0conf(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id);
26445         return (uint32_t)ret_conv;
26446 }
26447
26448 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) {
26449         LDKChannelManager this_arg_conv;
26450         this_arg_conv.inner = (void*)(this_arg & (~1));
26451         this_arg_conv.is_owned = false;
26452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26453         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
26454         CHECK_ACCESS(min_value_msat_ptr);
26455         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
26456         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
26457         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
26458         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
26459         return (uint32_t)ret_conv;
26460 }
26461
26462 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) {
26463         LDKChannelManager this_arg_conv;
26464         this_arg_conv.inner = (void*)(this_arg & (~1));
26465         this_arg_conv.is_owned = false;
26466         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26467         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
26468         CHECK_ACCESS(min_value_msat_ptr);
26469         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
26470         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
26471         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
26472         *ret_conv = ChannelManager_create_inbound_payment_legacy(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
26473         return (uint32_t)ret_conv;
26474 }
26475
26476 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) {
26477         LDKChannelManager this_arg_conv;
26478         this_arg_conv.inner = (void*)(this_arg & (~1));
26479         this_arg_conv.is_owned = false;
26480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26481         LDKThirtyTwoBytes payment_hash_ref;
26482         CHECK(payment_hash->arr_len == 32);
26483         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
26484         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
26485         CHECK_ACCESS(min_value_msat_ptr);
26486         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
26487         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
26488         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
26489         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
26490         return (uint32_t)ret_conv;
26491 }
26492
26493 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) {
26494         LDKChannelManager this_arg_conv;
26495         this_arg_conv.inner = (void*)(this_arg & (~1));
26496         this_arg_conv.is_owned = false;
26497         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26498         LDKThirtyTwoBytes payment_hash_ref;
26499         CHECK(payment_hash->arr_len == 32);
26500         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
26501         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
26502         CHECK_ACCESS(min_value_msat_ptr);
26503         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
26504         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
26505         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
26506         *ret_conv = ChannelManager_create_inbound_payment_for_hash_legacy(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
26507         return (uint32_t)ret_conv;
26508 }
26509
26510 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) {
26511         LDKChannelManager this_arg_conv;
26512         this_arg_conv.inner = (void*)(this_arg & (~1));
26513         this_arg_conv.is_owned = false;
26514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26515         LDKThirtyTwoBytes payment_hash_ref;
26516         CHECK(payment_hash->arr_len == 32);
26517         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
26518         LDKThirtyTwoBytes payment_secret_ref;
26519         CHECK(payment_secret->arr_len == 32);
26520         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
26521         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
26522         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
26523         return (uint32_t)ret_conv;
26524 }
26525
26526 int64_t  __attribute__((export_name("TS_ChannelManager_get_phantom_scid"))) TS_ChannelManager_get_phantom_scid(uint32_t this_arg) {
26527         LDKChannelManager this_arg_conv;
26528         this_arg_conv.inner = (void*)(this_arg & (~1));
26529         this_arg_conv.is_owned = false;
26530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26531         int64_t ret_conv = ChannelManager_get_phantom_scid(&this_arg_conv);
26532         return ret_conv;
26533 }
26534
26535 uint32_t  __attribute__((export_name("TS_ChannelManager_get_phantom_route_hints"))) TS_ChannelManager_get_phantom_route_hints(uint32_t this_arg) {
26536         LDKChannelManager this_arg_conv;
26537         this_arg_conv.inner = (void*)(this_arg & (~1));
26538         this_arg_conv.is_owned = false;
26539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26540         LDKPhantomRouteHints ret_var = ChannelManager_get_phantom_route_hints(&this_arg_conv);
26541         uint32_t ret_ref = 0;
26542         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26543         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26544         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26545         ret_ref = (uintptr_t)ret_var.inner;
26546         if (ret_var.is_owned) {
26547                 ret_ref |= 1;
26548         }
26549         return ret_ref;
26550 }
26551
26552 uint32_t  __attribute__((export_name("TS_ChannelManager_as_MessageSendEventsProvider"))) TS_ChannelManager_as_MessageSendEventsProvider(uint32_t this_arg) {
26553         LDKChannelManager this_arg_conv;
26554         this_arg_conv.inner = (void*)(this_arg & (~1));
26555         this_arg_conv.is_owned = false;
26556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26557         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
26558         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
26559         return (uint32_t)ret_ret;
26560 }
26561
26562 uint32_t  __attribute__((export_name("TS_ChannelManager_as_EventsProvider"))) TS_ChannelManager_as_EventsProvider(uint32_t this_arg) {
26563         LDKChannelManager this_arg_conv;
26564         this_arg_conv.inner = (void*)(this_arg & (~1));
26565         this_arg_conv.is_owned = false;
26566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26567         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
26568         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
26569         return (uint32_t)ret_ret;
26570 }
26571
26572 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Listen"))) TS_ChannelManager_as_Listen(uint32_t this_arg) {
26573         LDKChannelManager this_arg_conv;
26574         this_arg_conv.inner = (void*)(this_arg & (~1));
26575         this_arg_conv.is_owned = false;
26576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26577         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
26578         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
26579         return (uint32_t)ret_ret;
26580 }
26581
26582 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Confirm"))) TS_ChannelManager_as_Confirm(uint32_t this_arg) {
26583         LDKChannelManager this_arg_conv;
26584         this_arg_conv.inner = (void*)(this_arg & (~1));
26585         this_arg_conv.is_owned = false;
26586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26587         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
26588         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
26589         return (uint32_t)ret_ret;
26590 }
26591
26592 void  __attribute__((export_name("TS_ChannelManager_await_persistable_update"))) TS_ChannelManager_await_persistable_update(uint32_t this_arg) {
26593         LDKChannelManager this_arg_conv;
26594         this_arg_conv.inner = (void*)(this_arg & (~1));
26595         this_arg_conv.is_owned = false;
26596         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26597         ChannelManager_await_persistable_update(&this_arg_conv);
26598 }
26599
26600 uint32_t  __attribute__((export_name("TS_ChannelManager_current_best_block"))) TS_ChannelManager_current_best_block(uint32_t this_arg) {
26601         LDKChannelManager this_arg_conv;
26602         this_arg_conv.inner = (void*)(this_arg & (~1));
26603         this_arg_conv.is_owned = false;
26604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26605         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
26606         uint32_t ret_ref = 0;
26607         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26608         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26609         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26610         ret_ref = (uintptr_t)ret_var.inner;
26611         if (ret_var.is_owned) {
26612                 ret_ref |= 1;
26613         }
26614         return ret_ref;
26615 }
26616
26617 uint32_t  __attribute__((export_name("TS_ChannelManager_as_ChannelMessageHandler"))) TS_ChannelManager_as_ChannelMessageHandler(uint32_t this_arg) {
26618         LDKChannelManager this_arg_conv;
26619         this_arg_conv.inner = (void*)(this_arg & (~1));
26620         this_arg_conv.is_owned = false;
26621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26622         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
26623         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
26624         return (uint32_t)ret_ret;
26625 }
26626
26627 int8_tArray  __attribute__((export_name("TS_CounterpartyForwardingInfo_write"))) TS_CounterpartyForwardingInfo_write(uint32_t obj) {
26628         LDKCounterpartyForwardingInfo obj_conv;
26629         obj_conv.inner = (void*)(obj & (~1));
26630         obj_conv.is_owned = false;
26631         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
26632         LDKCVec_u8Z ret_var = CounterpartyForwardingInfo_write(&obj_conv);
26633         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
26634         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
26635         CVec_u8Z_free(ret_var);
26636         return ret_arr;
26637 }
26638
26639 uint32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_read"))) TS_CounterpartyForwardingInfo_read(int8_tArray ser) {
26640         LDKu8slice ser_ref;
26641         ser_ref.datalen = ser->arr_len;
26642         ser_ref.data = ser->elems /* XXX ser leaks */;
26643         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
26644         *ret_conv = CounterpartyForwardingInfo_read(ser_ref);
26645         return (uint32_t)ret_conv;
26646 }
26647
26648 int8_tArray  __attribute__((export_name("TS_ChannelCounterparty_write"))) TS_ChannelCounterparty_write(uint32_t obj) {
26649         LDKChannelCounterparty obj_conv;
26650         obj_conv.inner = (void*)(obj & (~1));
26651         obj_conv.is_owned = false;
26652         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
26653         LDKCVec_u8Z ret_var = ChannelCounterparty_write(&obj_conv);
26654         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
26655         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
26656         CVec_u8Z_free(ret_var);
26657         return ret_arr;
26658 }
26659
26660 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_read"))) TS_ChannelCounterparty_read(int8_tArray ser) {
26661         LDKu8slice ser_ref;
26662         ser_ref.datalen = ser->arr_len;
26663         ser_ref.data = ser->elems /* XXX ser leaks */;
26664         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
26665         *ret_conv = ChannelCounterparty_read(ser_ref);
26666         return (uint32_t)ret_conv;
26667 }
26668
26669 int8_tArray  __attribute__((export_name("TS_ChannelDetails_write"))) TS_ChannelDetails_write(uint32_t obj) {
26670         LDKChannelDetails obj_conv;
26671         obj_conv.inner = (void*)(obj & (~1));
26672         obj_conv.is_owned = false;
26673         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
26674         LDKCVec_u8Z ret_var = ChannelDetails_write(&obj_conv);
26675         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
26676         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
26677         CVec_u8Z_free(ret_var);
26678         return ret_arr;
26679 }
26680
26681 uint32_t  __attribute__((export_name("TS_ChannelDetails_read"))) TS_ChannelDetails_read(int8_tArray ser) {
26682         LDKu8slice ser_ref;
26683         ser_ref.datalen = ser->arr_len;
26684         ser_ref.data = ser->elems /* XXX ser leaks */;
26685         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
26686         *ret_conv = ChannelDetails_read(ser_ref);
26687         return (uint32_t)ret_conv;
26688 }
26689
26690 int8_tArray  __attribute__((export_name("TS_PhantomRouteHints_write"))) TS_PhantomRouteHints_write(uint32_t obj) {
26691         LDKPhantomRouteHints obj_conv;
26692         obj_conv.inner = (void*)(obj & (~1));
26693         obj_conv.is_owned = false;
26694         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
26695         LDKCVec_u8Z ret_var = PhantomRouteHints_write(&obj_conv);
26696         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
26697         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
26698         CVec_u8Z_free(ret_var);
26699         return ret_arr;
26700 }
26701
26702 uint32_t  __attribute__((export_name("TS_PhantomRouteHints_read"))) TS_PhantomRouteHints_read(int8_tArray ser) {
26703         LDKu8slice ser_ref;
26704         ser_ref.datalen = ser->arr_len;
26705         ser_ref.data = ser->elems /* XXX ser leaks */;
26706         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
26707         *ret_conv = PhantomRouteHints_read(ser_ref);
26708         return (uint32_t)ret_conv;
26709 }
26710
26711 int8_tArray  __attribute__((export_name("TS_ChannelManager_write"))) TS_ChannelManager_write(uint32_t obj) {
26712         LDKChannelManager obj_conv;
26713         obj_conv.inner = (void*)(obj & (~1));
26714         obj_conv.is_owned = false;
26715         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
26716         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
26717         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
26718         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
26719         CVec_u8Z_free(ret_var);
26720         return ret_arr;
26721 }
26722
26723 void  __attribute__((export_name("TS_ChannelManagerReadArgs_free"))) TS_ChannelManagerReadArgs_free(uint32_t this_obj) {
26724         LDKChannelManagerReadArgs this_obj_conv;
26725         this_obj_conv.inner = (void*)(this_obj & (~1));
26726         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26728         ChannelManagerReadArgs_free(this_obj_conv);
26729 }
26730
26731 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_keys_manager"))) TS_ChannelManagerReadArgs_get_keys_manager(uint32_t this_ptr) {
26732         LDKChannelManagerReadArgs this_ptr_conv;
26733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26734         this_ptr_conv.is_owned = false;
26735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26736         // WARNING: This object doesn't live past this scope, needs clone!
26737         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv)) | 1;
26738         return ret_ret;
26739 }
26740
26741 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_keys_manager"))) TS_ChannelManagerReadArgs_set_keys_manager(uint32_t this_ptr, uint32_t val) {
26742         LDKChannelManagerReadArgs this_ptr_conv;
26743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26744         this_ptr_conv.is_owned = false;
26745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26746         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26747         CHECK_ACCESS(val_ptr);
26748         LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
26749         if (val_conv.free == LDKKeysInterface_JCalls_free) {
26750                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26751                 LDKKeysInterface_JCalls_cloned(&val_conv);
26752         }
26753         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
26754 }
26755
26756 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_fee_estimator"))) TS_ChannelManagerReadArgs_get_fee_estimator(uint32_t this_ptr) {
26757         LDKChannelManagerReadArgs this_ptr_conv;
26758         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26759         this_ptr_conv.is_owned = false;
26760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26761         // WARNING: This object doesn't live past this scope, needs clone!
26762         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv)) | 1;
26763         return ret_ret;
26764 }
26765
26766 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_fee_estimator"))) TS_ChannelManagerReadArgs_set_fee_estimator(uint32_t this_ptr, uint32_t val) {
26767         LDKChannelManagerReadArgs this_ptr_conv;
26768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26769         this_ptr_conv.is_owned = false;
26770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26771         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26772         CHECK_ACCESS(val_ptr);
26773         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
26774         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
26775                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26776                 LDKFeeEstimator_JCalls_cloned(&val_conv);
26777         }
26778         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
26779 }
26780
26781 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_chain_monitor"))) TS_ChannelManagerReadArgs_get_chain_monitor(uint32_t this_ptr) {
26782         LDKChannelManagerReadArgs this_ptr_conv;
26783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26784         this_ptr_conv.is_owned = false;
26785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26786         // WARNING: This object doesn't live past this scope, needs clone!
26787         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv)) | 1;
26788         return ret_ret;
26789 }
26790
26791 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_chain_monitor"))) TS_ChannelManagerReadArgs_set_chain_monitor(uint32_t this_ptr, uint32_t val) {
26792         LDKChannelManagerReadArgs this_ptr_conv;
26793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26794         this_ptr_conv.is_owned = false;
26795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26796         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26797         CHECK_ACCESS(val_ptr);
26798         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
26799         if (val_conv.free == LDKWatch_JCalls_free) {
26800                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26801                 LDKWatch_JCalls_cloned(&val_conv);
26802         }
26803         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
26804 }
26805
26806 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_tx_broadcaster"))) TS_ChannelManagerReadArgs_get_tx_broadcaster(uint32_t this_ptr) {
26807         LDKChannelManagerReadArgs this_ptr_conv;
26808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26809         this_ptr_conv.is_owned = false;
26810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26811         // WARNING: This object doesn't live past this scope, needs clone!
26812         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv)) | 1;
26813         return ret_ret;
26814 }
26815
26816 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_tx_broadcaster"))) TS_ChannelManagerReadArgs_set_tx_broadcaster(uint32_t this_ptr, uint32_t val) {
26817         LDKChannelManagerReadArgs this_ptr_conv;
26818         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26819         this_ptr_conv.is_owned = false;
26820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26821         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26822         CHECK_ACCESS(val_ptr);
26823         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
26824         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
26825                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26826                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
26827         }
26828         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
26829 }
26830
26831 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_logger"))) TS_ChannelManagerReadArgs_get_logger(uint32_t this_ptr) {
26832         LDKChannelManagerReadArgs this_ptr_conv;
26833         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26834         this_ptr_conv.is_owned = false;
26835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26836         // WARNING: This object doesn't live past this scope, needs clone!
26837         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv)) | 1;
26838         return ret_ret;
26839 }
26840
26841 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_logger"))) TS_ChannelManagerReadArgs_set_logger(uint32_t this_ptr, uint32_t val) {
26842         LDKChannelManagerReadArgs this_ptr_conv;
26843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26844         this_ptr_conv.is_owned = false;
26845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26846         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26847         CHECK_ACCESS(val_ptr);
26848         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
26849         if (val_conv.free == LDKLogger_JCalls_free) {
26850                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26851                 LDKLogger_JCalls_cloned(&val_conv);
26852         }
26853         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
26854 }
26855
26856 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_default_config"))) TS_ChannelManagerReadArgs_get_default_config(uint32_t this_ptr) {
26857         LDKChannelManagerReadArgs this_ptr_conv;
26858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26859         this_ptr_conv.is_owned = false;
26860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26861         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
26862         uint32_t ret_ref = 0;
26863         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26864         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26865         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26866         ret_ref = (uintptr_t)ret_var.inner;
26867         if (ret_var.is_owned) {
26868                 ret_ref |= 1;
26869         }
26870         return ret_ref;
26871 }
26872
26873 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_default_config"))) TS_ChannelManagerReadArgs_set_default_config(uint32_t this_ptr, uint32_t val) {
26874         LDKChannelManagerReadArgs this_ptr_conv;
26875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26876         this_ptr_conv.is_owned = false;
26877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26878         LDKUserConfig val_conv;
26879         val_conv.inner = (void*)(val & (~1));
26880         val_conv.is_owned = (val & 1) || (val == 0);
26881         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26882         val_conv = UserConfig_clone(&val_conv);
26883         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
26884 }
26885
26886 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) {
26887         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
26888         CHECK_ACCESS(keys_manager_ptr);
26889         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
26890         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
26891                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26892                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
26893         }
26894         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
26895         CHECK_ACCESS(fee_estimator_ptr);
26896         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
26897         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
26898                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26899                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
26900         }
26901         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
26902         CHECK_ACCESS(chain_monitor_ptr);
26903         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
26904         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
26905                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26906                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
26907         }
26908         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
26909         CHECK_ACCESS(tx_broadcaster_ptr);
26910         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
26911         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
26912                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26913                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
26914         }
26915         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
26916         CHECK_ACCESS(logger_ptr);
26917         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
26918         if (logger_conv.free == LDKLogger_JCalls_free) {
26919                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26920                 LDKLogger_JCalls_cloned(&logger_conv);
26921         }
26922         LDKUserConfig default_config_conv;
26923         default_config_conv.inner = (void*)(default_config & (~1));
26924         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
26925         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
26926         default_config_conv = UserConfig_clone(&default_config_conv);
26927         LDKCVec_ChannelMonitorZ channel_monitors_constr;
26928         channel_monitors_constr.datalen = channel_monitors->arr_len;
26929         if (channel_monitors_constr.datalen > 0)
26930                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
26931         else
26932                 channel_monitors_constr.data = NULL;
26933         uint32_t* channel_monitors_vals = channel_monitors->elems /* XXX channel_monitors leaks */;
26934         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
26935                 uint32_t channel_monitors_conv_16 = channel_monitors_vals[q];
26936                 LDKChannelMonitor channel_monitors_conv_16_conv;
26937                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
26938                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
26939                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
26940                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
26941         }
26942         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);
26943         uint32_t ret_ref = 0;
26944         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26945         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26946         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26947         ret_ref = (uintptr_t)ret_var.inner;
26948         if (ret_var.is_owned) {
26949                 ret_ref |= 1;
26950         }
26951         return ret_ref;
26952 }
26953
26954 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_read"))) TS_C2Tuple_BlockHashChannelManagerZ_read(int8_tArray ser, uint32_t arg) {
26955         LDKu8slice ser_ref;
26956         ser_ref.datalen = ser->arr_len;
26957         ser_ref.data = ser->elems /* XXX ser leaks */;
26958         LDKChannelManagerReadArgs arg_conv;
26959         arg_conv.inner = (void*)(arg & (~1));
26960         arg_conv.is_owned = (arg & 1) || (arg == 0);
26961         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26962         // WARNING: we need a move here but no clone is available for LDKChannelManagerReadArgs
26963         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
26964         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
26965         return (uint32_t)ret_conv;
26966 }
26967
26968 void  __attribute__((export_name("TS_ExpandedKey_free"))) TS_ExpandedKey_free(uint32_t this_obj) {
26969         LDKExpandedKey this_obj_conv;
26970         this_obj_conv.inner = (void*)(this_obj & (~1));
26971         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26973         ExpandedKey_free(this_obj_conv);
26974 }
26975
26976 uint32_t  __attribute__((export_name("TS_ExpandedKey_new"))) TS_ExpandedKey_new(int8_tArray key_material) {
26977         unsigned char key_material_arr[32];
26978         CHECK(key_material->arr_len == 32);
26979         memcpy(key_material_arr, key_material->elems, 32); FREE(key_material);
26980         unsigned char (*key_material_ref)[32] = &key_material_arr;
26981         LDKExpandedKey ret_var = ExpandedKey_new(key_material_ref);
26982         uint32_t ret_ref = 0;
26983         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26984         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26985         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26986         ret_ref = (uintptr_t)ret_var.inner;
26987         if (ret_var.is_owned) {
26988                 ret_ref |= 1;
26989         }
26990         return ret_ref;
26991 }
26992
26993 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) {
26994         LDKExpandedKey keys_conv;
26995         keys_conv.inner = (void*)(keys & (~1));
26996         keys_conv.is_owned = false;
26997         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
26998         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
26999         CHECK_ACCESS(min_value_msat_ptr);
27000         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
27001         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
27002         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
27003         if (!(keys_manager & 1)) { CHECK_ACCESS(keys_manager_ptr); }
27004         LDKKeysInterface* keys_manager_conv = (LDKKeysInterface*)keys_manager_ptr;
27005         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
27006         *ret_conv = create(&keys_conv, min_value_msat_conv, invoice_expiry_delta_secs, keys_manager_conv, current_time);
27007         return (uint32_t)ret_conv;
27008 }
27009
27010 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) {
27011         LDKExpandedKey keys_conv;
27012         keys_conv.inner = (void*)(keys & (~1));
27013         keys_conv.is_owned = false;
27014         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
27015         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
27016         CHECK_ACCESS(min_value_msat_ptr);
27017         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
27018         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
27019         LDKThirtyTwoBytes payment_hash_ref;
27020         CHECK(payment_hash->arr_len == 32);
27021         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
27022         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
27023         *ret_conv = create_from_hash(&keys_conv, min_value_msat_conv, payment_hash_ref, invoice_expiry_delta_secs, current_time);
27024         return (uint32_t)ret_conv;
27025 }
27026
27027 void  __attribute__((export_name("TS_DecodeError_free"))) TS_DecodeError_free(uint32_t this_obj) {
27028         LDKDecodeError this_obj_conv;
27029         this_obj_conv.inner = (void*)(this_obj & (~1));
27030         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27032         DecodeError_free(this_obj_conv);
27033 }
27034
27035 static inline uintptr_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
27036         LDKDecodeError ret_var = DecodeError_clone(arg);
27037 uint32_t ret_ref = 0;
27038 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27039 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27040 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27041 ret_ref = (uintptr_t)ret_var.inner;
27042 if (ret_var.is_owned) {
27043         ret_ref |= 1;
27044 }
27045         return ret_ref;
27046 }
27047 uint32_t  __attribute__((export_name("TS_DecodeError_clone_ptr"))) TS_DecodeError_clone_ptr(uint32_t arg) {
27048         LDKDecodeError arg_conv;
27049         arg_conv.inner = (void*)(arg & (~1));
27050         arg_conv.is_owned = false;
27051         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27052         uint32_t ret_conv = DecodeError_clone_ptr(&arg_conv);
27053         return ret_conv;
27054 }
27055
27056 uint32_t  __attribute__((export_name("TS_DecodeError_clone"))) TS_DecodeError_clone(uint32_t orig) {
27057         LDKDecodeError orig_conv;
27058         orig_conv.inner = (void*)(orig & (~1));
27059         orig_conv.is_owned = false;
27060         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27061         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
27062         uint32_t ret_ref = 0;
27063         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27064         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27065         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27066         ret_ref = (uintptr_t)ret_var.inner;
27067         if (ret_var.is_owned) {
27068                 ret_ref |= 1;
27069         }
27070         return ret_ref;
27071 }
27072
27073 void  __attribute__((export_name("TS_Init_free"))) TS_Init_free(uint32_t this_obj) {
27074         LDKInit this_obj_conv;
27075         this_obj_conv.inner = (void*)(this_obj & (~1));
27076         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27078         Init_free(this_obj_conv);
27079 }
27080
27081 uint32_t  __attribute__((export_name("TS_Init_get_features"))) TS_Init_get_features(uint32_t this_ptr) {
27082         LDKInit this_ptr_conv;
27083         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27084         this_ptr_conv.is_owned = false;
27085         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27086         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
27087         uint32_t ret_ref = 0;
27088         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27089         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27090         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27091         ret_ref = (uintptr_t)ret_var.inner;
27092         if (ret_var.is_owned) {
27093                 ret_ref |= 1;
27094         }
27095         return ret_ref;
27096 }
27097
27098 void  __attribute__((export_name("TS_Init_set_features"))) TS_Init_set_features(uint32_t this_ptr, uint32_t val) {
27099         LDKInit this_ptr_conv;
27100         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27101         this_ptr_conv.is_owned = false;
27102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27103         LDKInitFeatures val_conv;
27104         val_conv.inner = (void*)(val & (~1));
27105         val_conv.is_owned = (val & 1) || (val == 0);
27106         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27107         val_conv = InitFeatures_clone(&val_conv);
27108         Init_set_features(&this_ptr_conv, val_conv);
27109 }
27110
27111 uint32_t  __attribute__((export_name("TS_Init_get_remote_network_address"))) TS_Init_get_remote_network_address(uint32_t this_ptr) {
27112         LDKInit this_ptr_conv;
27113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27114         this_ptr_conv.is_owned = false;
27115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27116         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
27117         *ret_copy = Init_get_remote_network_address(&this_ptr_conv);
27118         uint32_t ret_ref = (uintptr_t)ret_copy;
27119         return ret_ref;
27120 }
27121
27122 void  __attribute__((export_name("TS_Init_set_remote_network_address"))) TS_Init_set_remote_network_address(uint32_t this_ptr, uint32_t val) {
27123         LDKInit this_ptr_conv;
27124         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27125         this_ptr_conv.is_owned = false;
27126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27127         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27128         CHECK_ACCESS(val_ptr);
27129         LDKCOption_NetAddressZ val_conv = *(LDKCOption_NetAddressZ*)(val_ptr);
27130         val_conv = COption_NetAddressZ_clone((LDKCOption_NetAddressZ*)(((uintptr_t)val) & ~1));
27131         Init_set_remote_network_address(&this_ptr_conv, val_conv);
27132 }
27133
27134 uint32_t  __attribute__((export_name("TS_Init_new"))) TS_Init_new(uint32_t features_arg, uint32_t remote_network_address_arg) {
27135         LDKInitFeatures features_arg_conv;
27136         features_arg_conv.inner = (void*)(features_arg & (~1));
27137         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
27138         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
27139         features_arg_conv = InitFeatures_clone(&features_arg_conv);
27140         void* remote_network_address_arg_ptr = (void*)(((uintptr_t)remote_network_address_arg) & ~1);
27141         CHECK_ACCESS(remote_network_address_arg_ptr);
27142         LDKCOption_NetAddressZ remote_network_address_arg_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_arg_ptr);
27143         LDKInit ret_var = Init_new(features_arg_conv, remote_network_address_arg_conv);
27144         uint32_t ret_ref = 0;
27145         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27146         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27147         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27148         ret_ref = (uintptr_t)ret_var.inner;
27149         if (ret_var.is_owned) {
27150                 ret_ref |= 1;
27151         }
27152         return ret_ref;
27153 }
27154
27155 static inline uintptr_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
27156         LDKInit ret_var = Init_clone(arg);
27157 uint32_t ret_ref = 0;
27158 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27159 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27160 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27161 ret_ref = (uintptr_t)ret_var.inner;
27162 if (ret_var.is_owned) {
27163         ret_ref |= 1;
27164 }
27165         return ret_ref;
27166 }
27167 uint32_t  __attribute__((export_name("TS_Init_clone_ptr"))) TS_Init_clone_ptr(uint32_t arg) {
27168         LDKInit arg_conv;
27169         arg_conv.inner = (void*)(arg & (~1));
27170         arg_conv.is_owned = false;
27171         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27172         uint32_t ret_conv = Init_clone_ptr(&arg_conv);
27173         return ret_conv;
27174 }
27175
27176 uint32_t  __attribute__((export_name("TS_Init_clone"))) TS_Init_clone(uint32_t orig) {
27177         LDKInit orig_conv;
27178         orig_conv.inner = (void*)(orig & (~1));
27179         orig_conv.is_owned = false;
27180         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27181         LDKInit ret_var = Init_clone(&orig_conv);
27182         uint32_t ret_ref = 0;
27183         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27184         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27185         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27186         ret_ref = (uintptr_t)ret_var.inner;
27187         if (ret_var.is_owned) {
27188                 ret_ref |= 1;
27189         }
27190         return ret_ref;
27191 }
27192
27193 void  __attribute__((export_name("TS_ErrorMessage_free"))) TS_ErrorMessage_free(uint32_t this_obj) {
27194         LDKErrorMessage this_obj_conv;
27195         this_obj_conv.inner = (void*)(this_obj & (~1));
27196         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27198         ErrorMessage_free(this_obj_conv);
27199 }
27200
27201 int8_tArray  __attribute__((export_name("TS_ErrorMessage_get_channel_id"))) TS_ErrorMessage_get_channel_id(uint32_t this_ptr) {
27202         LDKErrorMessage this_ptr_conv;
27203         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27204         this_ptr_conv.is_owned = false;
27205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27206         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27207         memcpy(ret_arr->elems, *ErrorMessage_get_channel_id(&this_ptr_conv), 32);
27208         return ret_arr;
27209 }
27210
27211 void  __attribute__((export_name("TS_ErrorMessage_set_channel_id"))) TS_ErrorMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
27212         LDKErrorMessage this_ptr_conv;
27213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27214         this_ptr_conv.is_owned = false;
27215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27216         LDKThirtyTwoBytes val_ref;
27217         CHECK(val->arr_len == 32);
27218         memcpy(val_ref.data, val->elems, 32); FREE(val);
27219         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
27220 }
27221
27222 jstring  __attribute__((export_name("TS_ErrorMessage_get_data"))) TS_ErrorMessage_get_data(uint32_t this_ptr) {
27223         LDKErrorMessage this_ptr_conv;
27224         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27225         this_ptr_conv.is_owned = false;
27226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27227         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
27228         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
27229         Str_free(ret_str);
27230         return ret_conv;
27231 }
27232
27233 void  __attribute__((export_name("TS_ErrorMessage_set_data"))) TS_ErrorMessage_set_data(uint32_t this_ptr, jstring val) {
27234         LDKErrorMessage this_ptr_conv;
27235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27236         this_ptr_conv.is_owned = false;
27237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27238         LDKStr val_conv = str_ref_to_owned_c(val);
27239         ErrorMessage_set_data(&this_ptr_conv, val_conv);
27240 }
27241
27242 uint32_t  __attribute__((export_name("TS_ErrorMessage_new"))) TS_ErrorMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
27243         LDKThirtyTwoBytes channel_id_arg_ref;
27244         CHECK(channel_id_arg->arr_len == 32);
27245         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
27246         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
27247         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
27248         uint32_t ret_ref = 0;
27249         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27250         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27251         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27252         ret_ref = (uintptr_t)ret_var.inner;
27253         if (ret_var.is_owned) {
27254                 ret_ref |= 1;
27255         }
27256         return ret_ref;
27257 }
27258
27259 static inline uintptr_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
27260         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
27261 uint32_t ret_ref = 0;
27262 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27263 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27264 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27265 ret_ref = (uintptr_t)ret_var.inner;
27266 if (ret_var.is_owned) {
27267         ret_ref |= 1;
27268 }
27269         return ret_ref;
27270 }
27271 uint32_t  __attribute__((export_name("TS_ErrorMessage_clone_ptr"))) TS_ErrorMessage_clone_ptr(uint32_t arg) {
27272         LDKErrorMessage arg_conv;
27273         arg_conv.inner = (void*)(arg & (~1));
27274         arg_conv.is_owned = false;
27275         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27276         uint32_t ret_conv = ErrorMessage_clone_ptr(&arg_conv);
27277         return ret_conv;
27278 }
27279
27280 uint32_t  __attribute__((export_name("TS_ErrorMessage_clone"))) TS_ErrorMessage_clone(uint32_t orig) {
27281         LDKErrorMessage orig_conv;
27282         orig_conv.inner = (void*)(orig & (~1));
27283         orig_conv.is_owned = false;
27284         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27285         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
27286         uint32_t ret_ref = 0;
27287         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27288         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27289         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27290         ret_ref = (uintptr_t)ret_var.inner;
27291         if (ret_var.is_owned) {
27292                 ret_ref |= 1;
27293         }
27294         return ret_ref;
27295 }
27296
27297 void  __attribute__((export_name("TS_WarningMessage_free"))) TS_WarningMessage_free(uint32_t this_obj) {
27298         LDKWarningMessage this_obj_conv;
27299         this_obj_conv.inner = (void*)(this_obj & (~1));
27300         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27302         WarningMessage_free(this_obj_conv);
27303 }
27304
27305 int8_tArray  __attribute__((export_name("TS_WarningMessage_get_channel_id"))) TS_WarningMessage_get_channel_id(uint32_t this_ptr) {
27306         LDKWarningMessage this_ptr_conv;
27307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27308         this_ptr_conv.is_owned = false;
27309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27310         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27311         memcpy(ret_arr->elems, *WarningMessage_get_channel_id(&this_ptr_conv), 32);
27312         return ret_arr;
27313 }
27314
27315 void  __attribute__((export_name("TS_WarningMessage_set_channel_id"))) TS_WarningMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
27316         LDKWarningMessage this_ptr_conv;
27317         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27318         this_ptr_conv.is_owned = false;
27319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27320         LDKThirtyTwoBytes val_ref;
27321         CHECK(val->arr_len == 32);
27322         memcpy(val_ref.data, val->elems, 32); FREE(val);
27323         WarningMessage_set_channel_id(&this_ptr_conv, val_ref);
27324 }
27325
27326 jstring  __attribute__((export_name("TS_WarningMessage_get_data"))) TS_WarningMessage_get_data(uint32_t this_ptr) {
27327         LDKWarningMessage this_ptr_conv;
27328         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27329         this_ptr_conv.is_owned = false;
27330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27331         LDKStr ret_str = WarningMessage_get_data(&this_ptr_conv);
27332         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
27333         Str_free(ret_str);
27334         return ret_conv;
27335 }
27336
27337 void  __attribute__((export_name("TS_WarningMessage_set_data"))) TS_WarningMessage_set_data(uint32_t this_ptr, jstring val) {
27338         LDKWarningMessage this_ptr_conv;
27339         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27340         this_ptr_conv.is_owned = false;
27341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27342         LDKStr val_conv = str_ref_to_owned_c(val);
27343         WarningMessage_set_data(&this_ptr_conv, val_conv);
27344 }
27345
27346 uint32_t  __attribute__((export_name("TS_WarningMessage_new"))) TS_WarningMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
27347         LDKThirtyTwoBytes channel_id_arg_ref;
27348         CHECK(channel_id_arg->arr_len == 32);
27349         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
27350         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
27351         LDKWarningMessage ret_var = WarningMessage_new(channel_id_arg_ref, data_arg_conv);
27352         uint32_t ret_ref = 0;
27353         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27354         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27355         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27356         ret_ref = (uintptr_t)ret_var.inner;
27357         if (ret_var.is_owned) {
27358                 ret_ref |= 1;
27359         }
27360         return ret_ref;
27361 }
27362
27363 static inline uintptr_t WarningMessage_clone_ptr(LDKWarningMessage *NONNULL_PTR arg) {
27364         LDKWarningMessage ret_var = WarningMessage_clone(arg);
27365 uint32_t ret_ref = 0;
27366 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27367 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27368 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27369 ret_ref = (uintptr_t)ret_var.inner;
27370 if (ret_var.is_owned) {
27371         ret_ref |= 1;
27372 }
27373         return ret_ref;
27374 }
27375 uint32_t  __attribute__((export_name("TS_WarningMessage_clone_ptr"))) TS_WarningMessage_clone_ptr(uint32_t arg) {
27376         LDKWarningMessage arg_conv;
27377         arg_conv.inner = (void*)(arg & (~1));
27378         arg_conv.is_owned = false;
27379         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27380         uint32_t ret_conv = WarningMessage_clone_ptr(&arg_conv);
27381         return ret_conv;
27382 }
27383
27384 uint32_t  __attribute__((export_name("TS_WarningMessage_clone"))) TS_WarningMessage_clone(uint32_t orig) {
27385         LDKWarningMessage orig_conv;
27386         orig_conv.inner = (void*)(orig & (~1));
27387         orig_conv.is_owned = false;
27388         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27389         LDKWarningMessage ret_var = WarningMessage_clone(&orig_conv);
27390         uint32_t ret_ref = 0;
27391         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27392         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27393         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27394         ret_ref = (uintptr_t)ret_var.inner;
27395         if (ret_var.is_owned) {
27396                 ret_ref |= 1;
27397         }
27398         return ret_ref;
27399 }
27400
27401 void  __attribute__((export_name("TS_Ping_free"))) TS_Ping_free(uint32_t this_obj) {
27402         LDKPing this_obj_conv;
27403         this_obj_conv.inner = (void*)(this_obj & (~1));
27404         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27405         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27406         Ping_free(this_obj_conv);
27407 }
27408
27409 int16_t  __attribute__((export_name("TS_Ping_get_ponglen"))) TS_Ping_get_ponglen(uint32_t this_ptr) {
27410         LDKPing this_ptr_conv;
27411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27412         this_ptr_conv.is_owned = false;
27413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27414         int16_t ret_conv = Ping_get_ponglen(&this_ptr_conv);
27415         return ret_conv;
27416 }
27417
27418 void  __attribute__((export_name("TS_Ping_set_ponglen"))) TS_Ping_set_ponglen(uint32_t this_ptr, int16_t val) {
27419         LDKPing this_ptr_conv;
27420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27421         this_ptr_conv.is_owned = false;
27422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27423         Ping_set_ponglen(&this_ptr_conv, val);
27424 }
27425
27426 int16_t  __attribute__((export_name("TS_Ping_get_byteslen"))) TS_Ping_get_byteslen(uint32_t this_ptr) {
27427         LDKPing this_ptr_conv;
27428         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27429         this_ptr_conv.is_owned = false;
27430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27431         int16_t ret_conv = Ping_get_byteslen(&this_ptr_conv);
27432         return ret_conv;
27433 }
27434
27435 void  __attribute__((export_name("TS_Ping_set_byteslen"))) TS_Ping_set_byteslen(uint32_t this_ptr, int16_t val) {
27436         LDKPing this_ptr_conv;
27437         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27438         this_ptr_conv.is_owned = false;
27439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27440         Ping_set_byteslen(&this_ptr_conv, val);
27441 }
27442
27443 uint32_t  __attribute__((export_name("TS_Ping_new"))) TS_Ping_new(int16_t ponglen_arg, int16_t byteslen_arg) {
27444         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
27445         uint32_t ret_ref = 0;
27446         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27447         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27448         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27449         ret_ref = (uintptr_t)ret_var.inner;
27450         if (ret_var.is_owned) {
27451                 ret_ref |= 1;
27452         }
27453         return ret_ref;
27454 }
27455
27456 static inline uintptr_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
27457         LDKPing ret_var = Ping_clone(arg);
27458 uint32_t ret_ref = 0;
27459 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27460 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27461 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27462 ret_ref = (uintptr_t)ret_var.inner;
27463 if (ret_var.is_owned) {
27464         ret_ref |= 1;
27465 }
27466         return ret_ref;
27467 }
27468 uint32_t  __attribute__((export_name("TS_Ping_clone_ptr"))) TS_Ping_clone_ptr(uint32_t arg) {
27469         LDKPing arg_conv;
27470         arg_conv.inner = (void*)(arg & (~1));
27471         arg_conv.is_owned = false;
27472         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27473         uint32_t ret_conv = Ping_clone_ptr(&arg_conv);
27474         return ret_conv;
27475 }
27476
27477 uint32_t  __attribute__((export_name("TS_Ping_clone"))) TS_Ping_clone(uint32_t orig) {
27478         LDKPing orig_conv;
27479         orig_conv.inner = (void*)(orig & (~1));
27480         orig_conv.is_owned = false;
27481         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27482         LDKPing ret_var = Ping_clone(&orig_conv);
27483         uint32_t ret_ref = 0;
27484         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27485         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27486         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27487         ret_ref = (uintptr_t)ret_var.inner;
27488         if (ret_var.is_owned) {
27489                 ret_ref |= 1;
27490         }
27491         return ret_ref;
27492 }
27493
27494 void  __attribute__((export_name("TS_Pong_free"))) TS_Pong_free(uint32_t this_obj) {
27495         LDKPong this_obj_conv;
27496         this_obj_conv.inner = (void*)(this_obj & (~1));
27497         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27499         Pong_free(this_obj_conv);
27500 }
27501
27502 int16_t  __attribute__((export_name("TS_Pong_get_byteslen"))) TS_Pong_get_byteslen(uint32_t this_ptr) {
27503         LDKPong this_ptr_conv;
27504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27505         this_ptr_conv.is_owned = false;
27506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27507         int16_t ret_conv = Pong_get_byteslen(&this_ptr_conv);
27508         return ret_conv;
27509 }
27510
27511 void  __attribute__((export_name("TS_Pong_set_byteslen"))) TS_Pong_set_byteslen(uint32_t this_ptr, int16_t val) {
27512         LDKPong this_ptr_conv;
27513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27514         this_ptr_conv.is_owned = false;
27515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27516         Pong_set_byteslen(&this_ptr_conv, val);
27517 }
27518
27519 uint32_t  __attribute__((export_name("TS_Pong_new"))) TS_Pong_new(int16_t byteslen_arg) {
27520         LDKPong ret_var = Pong_new(byteslen_arg);
27521         uint32_t ret_ref = 0;
27522         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27523         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27524         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27525         ret_ref = (uintptr_t)ret_var.inner;
27526         if (ret_var.is_owned) {
27527                 ret_ref |= 1;
27528         }
27529         return ret_ref;
27530 }
27531
27532 static inline uintptr_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
27533         LDKPong ret_var = Pong_clone(arg);
27534 uint32_t ret_ref = 0;
27535 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27536 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27537 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27538 ret_ref = (uintptr_t)ret_var.inner;
27539 if (ret_var.is_owned) {
27540         ret_ref |= 1;
27541 }
27542         return ret_ref;
27543 }
27544 uint32_t  __attribute__((export_name("TS_Pong_clone_ptr"))) TS_Pong_clone_ptr(uint32_t arg) {
27545         LDKPong arg_conv;
27546         arg_conv.inner = (void*)(arg & (~1));
27547         arg_conv.is_owned = false;
27548         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27549         uint32_t ret_conv = Pong_clone_ptr(&arg_conv);
27550         return ret_conv;
27551 }
27552
27553 uint32_t  __attribute__((export_name("TS_Pong_clone"))) TS_Pong_clone(uint32_t orig) {
27554         LDKPong orig_conv;
27555         orig_conv.inner = (void*)(orig & (~1));
27556         orig_conv.is_owned = false;
27557         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27558         LDKPong ret_var = Pong_clone(&orig_conv);
27559         uint32_t ret_ref = 0;
27560         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27561         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27562         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27563         ret_ref = (uintptr_t)ret_var.inner;
27564         if (ret_var.is_owned) {
27565                 ret_ref |= 1;
27566         }
27567         return ret_ref;
27568 }
27569
27570 void  __attribute__((export_name("TS_OpenChannel_free"))) TS_OpenChannel_free(uint32_t this_obj) {
27571         LDKOpenChannel this_obj_conv;
27572         this_obj_conv.inner = (void*)(this_obj & (~1));
27573         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27575         OpenChannel_free(this_obj_conv);
27576 }
27577
27578 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_chain_hash"))) TS_OpenChannel_get_chain_hash(uint32_t this_ptr) {
27579         LDKOpenChannel this_ptr_conv;
27580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27581         this_ptr_conv.is_owned = false;
27582         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27583         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27584         memcpy(ret_arr->elems, *OpenChannel_get_chain_hash(&this_ptr_conv), 32);
27585         return ret_arr;
27586 }
27587
27588 void  __attribute__((export_name("TS_OpenChannel_set_chain_hash"))) TS_OpenChannel_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
27589         LDKOpenChannel this_ptr_conv;
27590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27591         this_ptr_conv.is_owned = false;
27592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27593         LDKThirtyTwoBytes val_ref;
27594         CHECK(val->arr_len == 32);
27595         memcpy(val_ref.data, val->elems, 32); FREE(val);
27596         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
27597 }
27598
27599 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_temporary_channel_id"))) TS_OpenChannel_get_temporary_channel_id(uint32_t this_ptr) {
27600         LDKOpenChannel this_ptr_conv;
27601         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27602         this_ptr_conv.is_owned = false;
27603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27604         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27605         memcpy(ret_arr->elems, *OpenChannel_get_temporary_channel_id(&this_ptr_conv), 32);
27606         return ret_arr;
27607 }
27608
27609 void  __attribute__((export_name("TS_OpenChannel_set_temporary_channel_id"))) TS_OpenChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
27610         LDKOpenChannel this_ptr_conv;
27611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27612         this_ptr_conv.is_owned = false;
27613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27614         LDKThirtyTwoBytes val_ref;
27615         CHECK(val->arr_len == 32);
27616         memcpy(val_ref.data, val->elems, 32); FREE(val);
27617         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
27618 }
27619
27620 int64_t  __attribute__((export_name("TS_OpenChannel_get_funding_satoshis"))) TS_OpenChannel_get_funding_satoshis(uint32_t this_ptr) {
27621         LDKOpenChannel this_ptr_conv;
27622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27623         this_ptr_conv.is_owned = false;
27624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27625         int64_t ret_conv = OpenChannel_get_funding_satoshis(&this_ptr_conv);
27626         return ret_conv;
27627 }
27628
27629 void  __attribute__((export_name("TS_OpenChannel_set_funding_satoshis"))) TS_OpenChannel_set_funding_satoshis(uint32_t this_ptr, int64_t val) {
27630         LDKOpenChannel this_ptr_conv;
27631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27632         this_ptr_conv.is_owned = false;
27633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27634         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
27635 }
27636
27637 int64_t  __attribute__((export_name("TS_OpenChannel_get_push_msat"))) TS_OpenChannel_get_push_msat(uint32_t this_ptr) {
27638         LDKOpenChannel this_ptr_conv;
27639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27640         this_ptr_conv.is_owned = false;
27641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27642         int64_t ret_conv = OpenChannel_get_push_msat(&this_ptr_conv);
27643         return ret_conv;
27644 }
27645
27646 void  __attribute__((export_name("TS_OpenChannel_set_push_msat"))) TS_OpenChannel_set_push_msat(uint32_t this_ptr, int64_t val) {
27647         LDKOpenChannel this_ptr_conv;
27648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27649         this_ptr_conv.is_owned = false;
27650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27651         OpenChannel_set_push_msat(&this_ptr_conv, val);
27652 }
27653
27654 int64_t  __attribute__((export_name("TS_OpenChannel_get_dust_limit_satoshis"))) TS_OpenChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
27655         LDKOpenChannel this_ptr_conv;
27656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27657         this_ptr_conv.is_owned = false;
27658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27659         int64_t ret_conv = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
27660         return ret_conv;
27661 }
27662
27663 void  __attribute__((export_name("TS_OpenChannel_set_dust_limit_satoshis"))) TS_OpenChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
27664         LDKOpenChannel this_ptr_conv;
27665         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27666         this_ptr_conv.is_owned = false;
27667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27668         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
27669 }
27670
27671 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) {
27672         LDKOpenChannel this_ptr_conv;
27673         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27674         this_ptr_conv.is_owned = false;
27675         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27676         int64_t ret_conv = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
27677         return ret_conv;
27678 }
27679
27680 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) {
27681         LDKOpenChannel this_ptr_conv;
27682         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27683         this_ptr_conv.is_owned = false;
27684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27685         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
27686 }
27687
27688 int64_t  __attribute__((export_name("TS_OpenChannel_get_channel_reserve_satoshis"))) TS_OpenChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
27689         LDKOpenChannel this_ptr_conv;
27690         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27691         this_ptr_conv.is_owned = false;
27692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27693         int64_t ret_conv = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
27694         return ret_conv;
27695 }
27696
27697 void  __attribute__((export_name("TS_OpenChannel_set_channel_reserve_satoshis"))) TS_OpenChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
27698         LDKOpenChannel this_ptr_conv;
27699         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27700         this_ptr_conv.is_owned = false;
27701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27702         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
27703 }
27704
27705 int64_t  __attribute__((export_name("TS_OpenChannel_get_htlc_minimum_msat"))) TS_OpenChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
27706         LDKOpenChannel this_ptr_conv;
27707         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27708         this_ptr_conv.is_owned = false;
27709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27710         int64_t ret_conv = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
27711         return ret_conv;
27712 }
27713
27714 void  __attribute__((export_name("TS_OpenChannel_set_htlc_minimum_msat"))) TS_OpenChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
27715         LDKOpenChannel this_ptr_conv;
27716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27717         this_ptr_conv.is_owned = false;
27718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27719         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
27720 }
27721
27722 int32_t  __attribute__((export_name("TS_OpenChannel_get_feerate_per_kw"))) TS_OpenChannel_get_feerate_per_kw(uint32_t this_ptr) {
27723         LDKOpenChannel this_ptr_conv;
27724         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27725         this_ptr_conv.is_owned = false;
27726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27727         int32_t ret_conv = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
27728         return ret_conv;
27729 }
27730
27731 void  __attribute__((export_name("TS_OpenChannel_set_feerate_per_kw"))) TS_OpenChannel_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
27732         LDKOpenChannel this_ptr_conv;
27733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27734         this_ptr_conv.is_owned = false;
27735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27736         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
27737 }
27738
27739 int16_t  __attribute__((export_name("TS_OpenChannel_get_to_self_delay"))) TS_OpenChannel_get_to_self_delay(uint32_t this_ptr) {
27740         LDKOpenChannel this_ptr_conv;
27741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27742         this_ptr_conv.is_owned = false;
27743         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27744         int16_t ret_conv = OpenChannel_get_to_self_delay(&this_ptr_conv);
27745         return ret_conv;
27746 }
27747
27748 void  __attribute__((export_name("TS_OpenChannel_set_to_self_delay"))) TS_OpenChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
27749         LDKOpenChannel this_ptr_conv;
27750         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27751         this_ptr_conv.is_owned = false;
27752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27753         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
27754 }
27755
27756 int16_t  __attribute__((export_name("TS_OpenChannel_get_max_accepted_htlcs"))) TS_OpenChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
27757         LDKOpenChannel this_ptr_conv;
27758         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27759         this_ptr_conv.is_owned = false;
27760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27761         int16_t ret_conv = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
27762         return ret_conv;
27763 }
27764
27765 void  __attribute__((export_name("TS_OpenChannel_set_max_accepted_htlcs"))) TS_OpenChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
27766         LDKOpenChannel this_ptr_conv;
27767         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27768         this_ptr_conv.is_owned = false;
27769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27770         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
27771 }
27772
27773 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_funding_pubkey"))) TS_OpenChannel_get_funding_pubkey(uint32_t this_ptr) {
27774         LDKOpenChannel this_ptr_conv;
27775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27776         this_ptr_conv.is_owned = false;
27777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27778         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
27779         memcpy(ret_arr->elems, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
27780         return ret_arr;
27781 }
27782
27783 void  __attribute__((export_name("TS_OpenChannel_set_funding_pubkey"))) TS_OpenChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
27784         LDKOpenChannel this_ptr_conv;
27785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27786         this_ptr_conv.is_owned = false;
27787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27788         LDKPublicKey val_ref;
27789         CHECK(val->arr_len == 33);
27790         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
27791         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
27792 }
27793
27794 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_revocation_basepoint"))) TS_OpenChannel_get_revocation_basepoint(uint32_t this_ptr) {
27795         LDKOpenChannel this_ptr_conv;
27796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27797         this_ptr_conv.is_owned = false;
27798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27799         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
27800         memcpy(ret_arr->elems, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
27801         return ret_arr;
27802 }
27803
27804 void  __attribute__((export_name("TS_OpenChannel_set_revocation_basepoint"))) TS_OpenChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
27805         LDKOpenChannel this_ptr_conv;
27806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27807         this_ptr_conv.is_owned = false;
27808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27809         LDKPublicKey val_ref;
27810         CHECK(val->arr_len == 33);
27811         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
27812         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
27813 }
27814
27815 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_payment_point"))) TS_OpenChannel_get_payment_point(uint32_t this_ptr) {
27816         LDKOpenChannel this_ptr_conv;
27817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27818         this_ptr_conv.is_owned = false;
27819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27820         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
27821         memcpy(ret_arr->elems, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
27822         return ret_arr;
27823 }
27824
27825 void  __attribute__((export_name("TS_OpenChannel_set_payment_point"))) TS_OpenChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
27826         LDKOpenChannel this_ptr_conv;
27827         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27828         this_ptr_conv.is_owned = false;
27829         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27830         LDKPublicKey val_ref;
27831         CHECK(val->arr_len == 33);
27832         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
27833         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
27834 }
27835
27836 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_delayed_payment_basepoint"))) TS_OpenChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
27837         LDKOpenChannel this_ptr_conv;
27838         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27839         this_ptr_conv.is_owned = false;
27840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27841         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
27842         memcpy(ret_arr->elems, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
27843         return ret_arr;
27844 }
27845
27846 void  __attribute__((export_name("TS_OpenChannel_set_delayed_payment_basepoint"))) TS_OpenChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
27847         LDKOpenChannel this_ptr_conv;
27848         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27849         this_ptr_conv.is_owned = false;
27850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27851         LDKPublicKey val_ref;
27852         CHECK(val->arr_len == 33);
27853         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
27854         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
27855 }
27856
27857 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_htlc_basepoint"))) TS_OpenChannel_get_htlc_basepoint(uint32_t this_ptr) {
27858         LDKOpenChannel this_ptr_conv;
27859         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27860         this_ptr_conv.is_owned = false;
27861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27862         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
27863         memcpy(ret_arr->elems, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
27864         return ret_arr;
27865 }
27866
27867 void  __attribute__((export_name("TS_OpenChannel_set_htlc_basepoint"))) TS_OpenChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
27868         LDKOpenChannel this_ptr_conv;
27869         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27870         this_ptr_conv.is_owned = false;
27871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27872         LDKPublicKey val_ref;
27873         CHECK(val->arr_len == 33);
27874         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
27875         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
27876 }
27877
27878 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_first_per_commitment_point"))) TS_OpenChannel_get_first_per_commitment_point(uint32_t this_ptr) {
27879         LDKOpenChannel this_ptr_conv;
27880         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27881         this_ptr_conv.is_owned = false;
27882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27883         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
27884         memcpy(ret_arr->elems, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
27885         return ret_arr;
27886 }
27887
27888 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) {
27889         LDKOpenChannel 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         LDKPublicKey val_ref;
27894         CHECK(val->arr_len == 33);
27895         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
27896         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
27897 }
27898
27899 int8_t  __attribute__((export_name("TS_OpenChannel_get_channel_flags"))) TS_OpenChannel_get_channel_flags(uint32_t this_ptr) {
27900         LDKOpenChannel this_ptr_conv;
27901         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27902         this_ptr_conv.is_owned = false;
27903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27904         int8_t ret_conv = OpenChannel_get_channel_flags(&this_ptr_conv);
27905         return ret_conv;
27906 }
27907
27908 void  __attribute__((export_name("TS_OpenChannel_set_channel_flags"))) TS_OpenChannel_set_channel_flags(uint32_t this_ptr, int8_t val) {
27909         LDKOpenChannel this_ptr_conv;
27910         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27911         this_ptr_conv.is_owned = false;
27912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27913         OpenChannel_set_channel_flags(&this_ptr_conv, val);
27914 }
27915
27916 uint32_t  __attribute__((export_name("TS_OpenChannel_get_channel_type"))) TS_OpenChannel_get_channel_type(uint32_t this_ptr) {
27917         LDKOpenChannel this_ptr_conv;
27918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27919         this_ptr_conv.is_owned = false;
27920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27921         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
27922         uint32_t ret_ref = 0;
27923         if ((uintptr_t)ret_var.inner > 4096) {
27924                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27925                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27926         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27927                 ret_ref = (uintptr_t)ret_var.inner;
27928                 if (ret_var.is_owned) {
27929                         ret_ref |= 1;
27930                 }
27931         }
27932         return ret_ref;
27933 }
27934
27935 void  __attribute__((export_name("TS_OpenChannel_set_channel_type"))) TS_OpenChannel_set_channel_type(uint32_t this_ptr, uint32_t val) {
27936         LDKOpenChannel this_ptr_conv;
27937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27938         this_ptr_conv.is_owned = false;
27939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27940         LDKChannelTypeFeatures val_conv;
27941         val_conv.inner = (void*)(val & (~1));
27942         val_conv.is_owned = (val & 1) || (val == 0);
27943         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27944         val_conv = ChannelTypeFeatures_clone(&val_conv);
27945         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
27946 }
27947
27948 static inline uintptr_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
27949         LDKOpenChannel ret_var = OpenChannel_clone(arg);
27950 uint32_t ret_ref = 0;
27951 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27952 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27953 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27954 ret_ref = (uintptr_t)ret_var.inner;
27955 if (ret_var.is_owned) {
27956         ret_ref |= 1;
27957 }
27958         return ret_ref;
27959 }
27960 uint32_t  __attribute__((export_name("TS_OpenChannel_clone_ptr"))) TS_OpenChannel_clone_ptr(uint32_t arg) {
27961         LDKOpenChannel arg_conv;
27962         arg_conv.inner = (void*)(arg & (~1));
27963         arg_conv.is_owned = false;
27964         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27965         uint32_t ret_conv = OpenChannel_clone_ptr(&arg_conv);
27966         return ret_conv;
27967 }
27968
27969 uint32_t  __attribute__((export_name("TS_OpenChannel_clone"))) TS_OpenChannel_clone(uint32_t orig) {
27970         LDKOpenChannel orig_conv;
27971         orig_conv.inner = (void*)(orig & (~1));
27972         orig_conv.is_owned = false;
27973         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27974         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
27975         uint32_t ret_ref = 0;
27976         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27977         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27978         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27979         ret_ref = (uintptr_t)ret_var.inner;
27980         if (ret_var.is_owned) {
27981                 ret_ref |= 1;
27982         }
27983         return ret_ref;
27984 }
27985
27986 void  __attribute__((export_name("TS_AcceptChannel_free"))) TS_AcceptChannel_free(uint32_t this_obj) {
27987         LDKAcceptChannel this_obj_conv;
27988         this_obj_conv.inner = (void*)(this_obj & (~1));
27989         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27991         AcceptChannel_free(this_obj_conv);
27992 }
27993
27994 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_temporary_channel_id"))) TS_AcceptChannel_get_temporary_channel_id(uint32_t this_ptr) {
27995         LDKAcceptChannel this_ptr_conv;
27996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27997         this_ptr_conv.is_owned = false;
27998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27999         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28000         memcpy(ret_arr->elems, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv), 32);
28001         return ret_arr;
28002 }
28003
28004 void  __attribute__((export_name("TS_AcceptChannel_set_temporary_channel_id"))) TS_AcceptChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
28005         LDKAcceptChannel this_ptr_conv;
28006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28007         this_ptr_conv.is_owned = false;
28008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28009         LDKThirtyTwoBytes val_ref;
28010         CHECK(val->arr_len == 32);
28011         memcpy(val_ref.data, val->elems, 32); FREE(val);
28012         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
28013 }
28014
28015 int64_t  __attribute__((export_name("TS_AcceptChannel_get_dust_limit_satoshis"))) TS_AcceptChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
28016         LDKAcceptChannel this_ptr_conv;
28017         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28018         this_ptr_conv.is_owned = false;
28019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28020         int64_t ret_conv = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
28021         return ret_conv;
28022 }
28023
28024 void  __attribute__((export_name("TS_AcceptChannel_set_dust_limit_satoshis"))) TS_AcceptChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
28025         LDKAcceptChannel this_ptr_conv;
28026         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28027         this_ptr_conv.is_owned = false;
28028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28029         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
28030 }
28031
28032 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) {
28033         LDKAcceptChannel this_ptr_conv;
28034         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28035         this_ptr_conv.is_owned = false;
28036         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28037         int64_t ret_conv = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
28038         return ret_conv;
28039 }
28040
28041 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) {
28042         LDKAcceptChannel this_ptr_conv;
28043         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28044         this_ptr_conv.is_owned = false;
28045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28046         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
28047 }
28048
28049 int64_t  __attribute__((export_name("TS_AcceptChannel_get_channel_reserve_satoshis"))) TS_AcceptChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
28050         LDKAcceptChannel this_ptr_conv;
28051         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28052         this_ptr_conv.is_owned = false;
28053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28054         int64_t ret_conv = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
28055         return ret_conv;
28056 }
28057
28058 void  __attribute__((export_name("TS_AcceptChannel_set_channel_reserve_satoshis"))) TS_AcceptChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
28059         LDKAcceptChannel this_ptr_conv;
28060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28061         this_ptr_conv.is_owned = false;
28062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28063         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
28064 }
28065
28066 int64_t  __attribute__((export_name("TS_AcceptChannel_get_htlc_minimum_msat"))) TS_AcceptChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
28067         LDKAcceptChannel this_ptr_conv;
28068         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28069         this_ptr_conv.is_owned = false;
28070         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28071         int64_t ret_conv = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
28072         return ret_conv;
28073 }
28074
28075 void  __attribute__((export_name("TS_AcceptChannel_set_htlc_minimum_msat"))) TS_AcceptChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
28076         LDKAcceptChannel this_ptr_conv;
28077         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28078         this_ptr_conv.is_owned = false;
28079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28080         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
28081 }
28082
28083 int32_t  __attribute__((export_name("TS_AcceptChannel_get_minimum_depth"))) TS_AcceptChannel_get_minimum_depth(uint32_t this_ptr) {
28084         LDKAcceptChannel this_ptr_conv;
28085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28086         this_ptr_conv.is_owned = false;
28087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28088         int32_t ret_conv = AcceptChannel_get_minimum_depth(&this_ptr_conv);
28089         return ret_conv;
28090 }
28091
28092 void  __attribute__((export_name("TS_AcceptChannel_set_minimum_depth"))) TS_AcceptChannel_set_minimum_depth(uint32_t this_ptr, int32_t val) {
28093         LDKAcceptChannel this_ptr_conv;
28094         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28095         this_ptr_conv.is_owned = false;
28096         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28097         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
28098 }
28099
28100 int16_t  __attribute__((export_name("TS_AcceptChannel_get_to_self_delay"))) TS_AcceptChannel_get_to_self_delay(uint32_t this_ptr) {
28101         LDKAcceptChannel this_ptr_conv;
28102         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28103         this_ptr_conv.is_owned = false;
28104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28105         int16_t ret_conv = AcceptChannel_get_to_self_delay(&this_ptr_conv);
28106         return ret_conv;
28107 }
28108
28109 void  __attribute__((export_name("TS_AcceptChannel_set_to_self_delay"))) TS_AcceptChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
28110         LDKAcceptChannel this_ptr_conv;
28111         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28112         this_ptr_conv.is_owned = false;
28113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28114         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
28115 }
28116
28117 int16_t  __attribute__((export_name("TS_AcceptChannel_get_max_accepted_htlcs"))) TS_AcceptChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
28118         LDKAcceptChannel this_ptr_conv;
28119         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28120         this_ptr_conv.is_owned = false;
28121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28122         int16_t ret_conv = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
28123         return ret_conv;
28124 }
28125
28126 void  __attribute__((export_name("TS_AcceptChannel_set_max_accepted_htlcs"))) TS_AcceptChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
28127         LDKAcceptChannel this_ptr_conv;
28128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28129         this_ptr_conv.is_owned = false;
28130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28131         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
28132 }
28133
28134 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_funding_pubkey"))) TS_AcceptChannel_get_funding_pubkey(uint32_t this_ptr) {
28135         LDKAcceptChannel this_ptr_conv;
28136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28137         this_ptr_conv.is_owned = false;
28138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28139         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28140         memcpy(ret_arr->elems, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
28141         return ret_arr;
28142 }
28143
28144 void  __attribute__((export_name("TS_AcceptChannel_set_funding_pubkey"))) TS_AcceptChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
28145         LDKAcceptChannel this_ptr_conv;
28146         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28147         this_ptr_conv.is_owned = false;
28148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28149         LDKPublicKey val_ref;
28150         CHECK(val->arr_len == 33);
28151         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28152         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
28153 }
28154
28155 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_revocation_basepoint"))) TS_AcceptChannel_get_revocation_basepoint(uint32_t this_ptr) {
28156         LDKAcceptChannel this_ptr_conv;
28157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28158         this_ptr_conv.is_owned = false;
28159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28160         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28161         memcpy(ret_arr->elems, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
28162         return ret_arr;
28163 }
28164
28165 void  __attribute__((export_name("TS_AcceptChannel_set_revocation_basepoint"))) TS_AcceptChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
28166         LDKAcceptChannel this_ptr_conv;
28167         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28168         this_ptr_conv.is_owned = false;
28169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28170         LDKPublicKey val_ref;
28171         CHECK(val->arr_len == 33);
28172         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28173         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
28174 }
28175
28176 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_payment_point"))) TS_AcceptChannel_get_payment_point(uint32_t this_ptr) {
28177         LDKAcceptChannel this_ptr_conv;
28178         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28179         this_ptr_conv.is_owned = false;
28180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28181         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28182         memcpy(ret_arr->elems, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
28183         return ret_arr;
28184 }
28185
28186 void  __attribute__((export_name("TS_AcceptChannel_set_payment_point"))) TS_AcceptChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
28187         LDKAcceptChannel this_ptr_conv;
28188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28189         this_ptr_conv.is_owned = false;
28190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28191         LDKPublicKey val_ref;
28192         CHECK(val->arr_len == 33);
28193         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28194         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
28195 }
28196
28197 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_delayed_payment_basepoint"))) TS_AcceptChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
28198         LDKAcceptChannel this_ptr_conv;
28199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28200         this_ptr_conv.is_owned = false;
28201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28202         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28203         memcpy(ret_arr->elems, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
28204         return ret_arr;
28205 }
28206
28207 void  __attribute__((export_name("TS_AcceptChannel_set_delayed_payment_basepoint"))) TS_AcceptChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
28208         LDKAcceptChannel this_ptr_conv;
28209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28210         this_ptr_conv.is_owned = false;
28211         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28212         LDKPublicKey val_ref;
28213         CHECK(val->arr_len == 33);
28214         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28215         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
28216 }
28217
28218 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_htlc_basepoint"))) TS_AcceptChannel_get_htlc_basepoint(uint32_t this_ptr) {
28219         LDKAcceptChannel this_ptr_conv;
28220         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28221         this_ptr_conv.is_owned = false;
28222         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28223         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28224         memcpy(ret_arr->elems, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
28225         return ret_arr;
28226 }
28227
28228 void  __attribute__((export_name("TS_AcceptChannel_set_htlc_basepoint"))) TS_AcceptChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
28229         LDKAcceptChannel this_ptr_conv;
28230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28231         this_ptr_conv.is_owned = false;
28232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28233         LDKPublicKey val_ref;
28234         CHECK(val->arr_len == 33);
28235         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28236         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
28237 }
28238
28239 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_first_per_commitment_point"))) TS_AcceptChannel_get_first_per_commitment_point(uint32_t this_ptr) {
28240         LDKAcceptChannel this_ptr_conv;
28241         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28242         this_ptr_conv.is_owned = false;
28243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28244         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28245         memcpy(ret_arr->elems, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
28246         return ret_arr;
28247 }
28248
28249 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) {
28250         LDKAcceptChannel this_ptr_conv;
28251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28252         this_ptr_conv.is_owned = false;
28253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28254         LDKPublicKey val_ref;
28255         CHECK(val->arr_len == 33);
28256         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28257         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
28258 }
28259
28260 uint32_t  __attribute__((export_name("TS_AcceptChannel_get_channel_type"))) TS_AcceptChannel_get_channel_type(uint32_t this_ptr) {
28261         LDKAcceptChannel this_ptr_conv;
28262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28263         this_ptr_conv.is_owned = false;
28264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28265         LDKChannelTypeFeatures ret_var = AcceptChannel_get_channel_type(&this_ptr_conv);
28266         uint32_t ret_ref = 0;
28267         if ((uintptr_t)ret_var.inner > 4096) {
28268                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28269                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28270         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28271                 ret_ref = (uintptr_t)ret_var.inner;
28272                 if (ret_var.is_owned) {
28273                         ret_ref |= 1;
28274                 }
28275         }
28276         return ret_ref;
28277 }
28278
28279 void  __attribute__((export_name("TS_AcceptChannel_set_channel_type"))) TS_AcceptChannel_set_channel_type(uint32_t this_ptr, uint32_t val) {
28280         LDKAcceptChannel this_ptr_conv;
28281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28282         this_ptr_conv.is_owned = false;
28283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28284         LDKChannelTypeFeatures val_conv;
28285         val_conv.inner = (void*)(val & (~1));
28286         val_conv.is_owned = (val & 1) || (val == 0);
28287         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28288         val_conv = ChannelTypeFeatures_clone(&val_conv);
28289         AcceptChannel_set_channel_type(&this_ptr_conv, val_conv);
28290 }
28291
28292 static inline uintptr_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
28293         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
28294 uint32_t ret_ref = 0;
28295 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28296 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28297 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28298 ret_ref = (uintptr_t)ret_var.inner;
28299 if (ret_var.is_owned) {
28300         ret_ref |= 1;
28301 }
28302         return ret_ref;
28303 }
28304 uint32_t  __attribute__((export_name("TS_AcceptChannel_clone_ptr"))) TS_AcceptChannel_clone_ptr(uint32_t arg) {
28305         LDKAcceptChannel arg_conv;
28306         arg_conv.inner = (void*)(arg & (~1));
28307         arg_conv.is_owned = false;
28308         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28309         uint32_t ret_conv = AcceptChannel_clone_ptr(&arg_conv);
28310         return ret_conv;
28311 }
28312
28313 uint32_t  __attribute__((export_name("TS_AcceptChannel_clone"))) TS_AcceptChannel_clone(uint32_t orig) {
28314         LDKAcceptChannel orig_conv;
28315         orig_conv.inner = (void*)(orig & (~1));
28316         orig_conv.is_owned = false;
28317         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28318         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
28319         uint32_t ret_ref = 0;
28320         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28321         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28322         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28323         ret_ref = (uintptr_t)ret_var.inner;
28324         if (ret_var.is_owned) {
28325                 ret_ref |= 1;
28326         }
28327         return ret_ref;
28328 }
28329
28330 void  __attribute__((export_name("TS_FundingCreated_free"))) TS_FundingCreated_free(uint32_t this_obj) {
28331         LDKFundingCreated this_obj_conv;
28332         this_obj_conv.inner = (void*)(this_obj & (~1));
28333         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28335         FundingCreated_free(this_obj_conv);
28336 }
28337
28338 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_temporary_channel_id"))) TS_FundingCreated_get_temporary_channel_id(uint32_t this_ptr) {
28339         LDKFundingCreated this_ptr_conv;
28340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28341         this_ptr_conv.is_owned = false;
28342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28343         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28344         memcpy(ret_arr->elems, *FundingCreated_get_temporary_channel_id(&this_ptr_conv), 32);
28345         return ret_arr;
28346 }
28347
28348 void  __attribute__((export_name("TS_FundingCreated_set_temporary_channel_id"))) TS_FundingCreated_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
28349         LDKFundingCreated this_ptr_conv;
28350         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28351         this_ptr_conv.is_owned = false;
28352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28353         LDKThirtyTwoBytes val_ref;
28354         CHECK(val->arr_len == 32);
28355         memcpy(val_ref.data, val->elems, 32); FREE(val);
28356         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
28357 }
28358
28359 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_funding_txid"))) TS_FundingCreated_get_funding_txid(uint32_t this_ptr) {
28360         LDKFundingCreated this_ptr_conv;
28361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28362         this_ptr_conv.is_owned = false;
28363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28364         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28365         memcpy(ret_arr->elems, *FundingCreated_get_funding_txid(&this_ptr_conv), 32);
28366         return ret_arr;
28367 }
28368
28369 void  __attribute__((export_name("TS_FundingCreated_set_funding_txid"))) TS_FundingCreated_set_funding_txid(uint32_t this_ptr, int8_tArray val) {
28370         LDKFundingCreated this_ptr_conv;
28371         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28372         this_ptr_conv.is_owned = false;
28373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28374         LDKThirtyTwoBytes val_ref;
28375         CHECK(val->arr_len == 32);
28376         memcpy(val_ref.data, val->elems, 32); FREE(val);
28377         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
28378 }
28379
28380 int16_t  __attribute__((export_name("TS_FundingCreated_get_funding_output_index"))) TS_FundingCreated_get_funding_output_index(uint32_t this_ptr) {
28381         LDKFundingCreated this_ptr_conv;
28382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28383         this_ptr_conv.is_owned = false;
28384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28385         int16_t ret_conv = FundingCreated_get_funding_output_index(&this_ptr_conv);
28386         return ret_conv;
28387 }
28388
28389 void  __attribute__((export_name("TS_FundingCreated_set_funding_output_index"))) TS_FundingCreated_set_funding_output_index(uint32_t this_ptr, int16_t val) {
28390         LDKFundingCreated this_ptr_conv;
28391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28392         this_ptr_conv.is_owned = false;
28393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28394         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
28395 }
28396
28397 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_signature"))) TS_FundingCreated_get_signature(uint32_t this_ptr) {
28398         LDKFundingCreated this_ptr_conv;
28399         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28400         this_ptr_conv.is_owned = false;
28401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28402         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
28403         memcpy(ret_arr->elems, FundingCreated_get_signature(&this_ptr_conv).compact_form, 64);
28404         return ret_arr;
28405 }
28406
28407 void  __attribute__((export_name("TS_FundingCreated_set_signature"))) TS_FundingCreated_set_signature(uint32_t this_ptr, int8_tArray val) {
28408         LDKFundingCreated this_ptr_conv;
28409         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28410         this_ptr_conv.is_owned = false;
28411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28412         LDKSignature val_ref;
28413         CHECK(val->arr_len == 64);
28414         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
28415         FundingCreated_set_signature(&this_ptr_conv, val_ref);
28416 }
28417
28418 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) {
28419         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
28420         CHECK(temporary_channel_id_arg->arr_len == 32);
28421         memcpy(temporary_channel_id_arg_ref.data, temporary_channel_id_arg->elems, 32); FREE(temporary_channel_id_arg);
28422         LDKThirtyTwoBytes funding_txid_arg_ref;
28423         CHECK(funding_txid_arg->arr_len == 32);
28424         memcpy(funding_txid_arg_ref.data, funding_txid_arg->elems, 32); FREE(funding_txid_arg);
28425         LDKSignature signature_arg_ref;
28426         CHECK(signature_arg->arr_len == 64);
28427         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
28428         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
28429         uint32_t ret_ref = 0;
28430         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28431         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28432         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28433         ret_ref = (uintptr_t)ret_var.inner;
28434         if (ret_var.is_owned) {
28435                 ret_ref |= 1;
28436         }
28437         return ret_ref;
28438 }
28439
28440 static inline uintptr_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
28441         LDKFundingCreated ret_var = FundingCreated_clone(arg);
28442 uint32_t ret_ref = 0;
28443 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28444 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28445 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28446 ret_ref = (uintptr_t)ret_var.inner;
28447 if (ret_var.is_owned) {
28448         ret_ref |= 1;
28449 }
28450         return ret_ref;
28451 }
28452 uint32_t  __attribute__((export_name("TS_FundingCreated_clone_ptr"))) TS_FundingCreated_clone_ptr(uint32_t arg) {
28453         LDKFundingCreated arg_conv;
28454         arg_conv.inner = (void*)(arg & (~1));
28455         arg_conv.is_owned = false;
28456         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28457         uint32_t ret_conv = FundingCreated_clone_ptr(&arg_conv);
28458         return ret_conv;
28459 }
28460
28461 uint32_t  __attribute__((export_name("TS_FundingCreated_clone"))) TS_FundingCreated_clone(uint32_t orig) {
28462         LDKFundingCreated orig_conv;
28463         orig_conv.inner = (void*)(orig & (~1));
28464         orig_conv.is_owned = false;
28465         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28466         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
28467         uint32_t ret_ref = 0;
28468         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28469         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28470         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28471         ret_ref = (uintptr_t)ret_var.inner;
28472         if (ret_var.is_owned) {
28473                 ret_ref |= 1;
28474         }
28475         return ret_ref;
28476 }
28477
28478 void  __attribute__((export_name("TS_FundingSigned_free"))) TS_FundingSigned_free(uint32_t this_obj) {
28479         LDKFundingSigned this_obj_conv;
28480         this_obj_conv.inner = (void*)(this_obj & (~1));
28481         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28483         FundingSigned_free(this_obj_conv);
28484 }
28485
28486 int8_tArray  __attribute__((export_name("TS_FundingSigned_get_channel_id"))) TS_FundingSigned_get_channel_id(uint32_t this_ptr) {
28487         LDKFundingSigned this_ptr_conv;
28488         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28489         this_ptr_conv.is_owned = false;
28490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28491         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28492         memcpy(ret_arr->elems, *FundingSigned_get_channel_id(&this_ptr_conv), 32);
28493         return ret_arr;
28494 }
28495
28496 void  __attribute__((export_name("TS_FundingSigned_set_channel_id"))) TS_FundingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28497         LDKFundingSigned this_ptr_conv;
28498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28499         this_ptr_conv.is_owned = false;
28500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28501         LDKThirtyTwoBytes val_ref;
28502         CHECK(val->arr_len == 32);
28503         memcpy(val_ref.data, val->elems, 32); FREE(val);
28504         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
28505 }
28506
28507 int8_tArray  __attribute__((export_name("TS_FundingSigned_get_signature"))) TS_FundingSigned_get_signature(uint32_t this_ptr) {
28508         LDKFundingSigned this_ptr_conv;
28509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28510         this_ptr_conv.is_owned = false;
28511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28512         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
28513         memcpy(ret_arr->elems, FundingSigned_get_signature(&this_ptr_conv).compact_form, 64);
28514         return ret_arr;
28515 }
28516
28517 void  __attribute__((export_name("TS_FundingSigned_set_signature"))) TS_FundingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
28518         LDKFundingSigned this_ptr_conv;
28519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28520         this_ptr_conv.is_owned = false;
28521         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28522         LDKSignature val_ref;
28523         CHECK(val->arr_len == 64);
28524         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
28525         FundingSigned_set_signature(&this_ptr_conv, val_ref);
28526 }
28527
28528 uint32_t  __attribute__((export_name("TS_FundingSigned_new"))) TS_FundingSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg) {
28529         LDKThirtyTwoBytes channel_id_arg_ref;
28530         CHECK(channel_id_arg->arr_len == 32);
28531         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28532         LDKSignature signature_arg_ref;
28533         CHECK(signature_arg->arr_len == 64);
28534         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
28535         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
28536         uint32_t ret_ref = 0;
28537         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28538         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28539         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28540         ret_ref = (uintptr_t)ret_var.inner;
28541         if (ret_var.is_owned) {
28542                 ret_ref |= 1;
28543         }
28544         return ret_ref;
28545 }
28546
28547 static inline uintptr_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
28548         LDKFundingSigned ret_var = FundingSigned_clone(arg);
28549 uint32_t ret_ref = 0;
28550 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28551 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28552 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28553 ret_ref = (uintptr_t)ret_var.inner;
28554 if (ret_var.is_owned) {
28555         ret_ref |= 1;
28556 }
28557         return ret_ref;
28558 }
28559 uint32_t  __attribute__((export_name("TS_FundingSigned_clone_ptr"))) TS_FundingSigned_clone_ptr(uint32_t arg) {
28560         LDKFundingSigned arg_conv;
28561         arg_conv.inner = (void*)(arg & (~1));
28562         arg_conv.is_owned = false;
28563         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28564         uint32_t ret_conv = FundingSigned_clone_ptr(&arg_conv);
28565         return ret_conv;
28566 }
28567
28568 uint32_t  __attribute__((export_name("TS_FundingSigned_clone"))) TS_FundingSigned_clone(uint32_t orig) {
28569         LDKFundingSigned orig_conv;
28570         orig_conv.inner = (void*)(orig & (~1));
28571         orig_conv.is_owned = false;
28572         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28573         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
28574         uint32_t ret_ref = 0;
28575         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28576         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28577         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28578         ret_ref = (uintptr_t)ret_var.inner;
28579         if (ret_var.is_owned) {
28580                 ret_ref |= 1;
28581         }
28582         return ret_ref;
28583 }
28584
28585 void  __attribute__((export_name("TS_ChannelReady_free"))) TS_ChannelReady_free(uint32_t this_obj) {
28586         LDKChannelReady this_obj_conv;
28587         this_obj_conv.inner = (void*)(this_obj & (~1));
28588         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28590         ChannelReady_free(this_obj_conv);
28591 }
28592
28593 int8_tArray  __attribute__((export_name("TS_ChannelReady_get_channel_id"))) TS_ChannelReady_get_channel_id(uint32_t this_ptr) {
28594         LDKChannelReady this_ptr_conv;
28595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28596         this_ptr_conv.is_owned = false;
28597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28598         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28599         memcpy(ret_arr->elems, *ChannelReady_get_channel_id(&this_ptr_conv), 32);
28600         return ret_arr;
28601 }
28602
28603 void  __attribute__((export_name("TS_ChannelReady_set_channel_id"))) TS_ChannelReady_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28604         LDKChannelReady this_ptr_conv;
28605         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28606         this_ptr_conv.is_owned = false;
28607         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28608         LDKThirtyTwoBytes val_ref;
28609         CHECK(val->arr_len == 32);
28610         memcpy(val_ref.data, val->elems, 32); FREE(val);
28611         ChannelReady_set_channel_id(&this_ptr_conv, val_ref);
28612 }
28613
28614 int8_tArray  __attribute__((export_name("TS_ChannelReady_get_next_per_commitment_point"))) TS_ChannelReady_get_next_per_commitment_point(uint32_t this_ptr) {
28615         LDKChannelReady this_ptr_conv;
28616         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28617         this_ptr_conv.is_owned = false;
28618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28619         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28620         memcpy(ret_arr->elems, ChannelReady_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
28621         return ret_arr;
28622 }
28623
28624 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) {
28625         LDKChannelReady this_ptr_conv;
28626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28627         this_ptr_conv.is_owned = false;
28628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28629         LDKPublicKey val_ref;
28630         CHECK(val->arr_len == 33);
28631         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28632         ChannelReady_set_next_per_commitment_point(&this_ptr_conv, val_ref);
28633 }
28634
28635 uint32_t  __attribute__((export_name("TS_ChannelReady_get_short_channel_id_alias"))) TS_ChannelReady_get_short_channel_id_alias(uint32_t this_ptr) {
28636         LDKChannelReady this_ptr_conv;
28637         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28638         this_ptr_conv.is_owned = false;
28639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28640         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
28641         *ret_copy = ChannelReady_get_short_channel_id_alias(&this_ptr_conv);
28642         uint32_t ret_ref = (uintptr_t)ret_copy;
28643         return ret_ref;
28644 }
28645
28646 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) {
28647         LDKChannelReady this_ptr_conv;
28648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28649         this_ptr_conv.is_owned = false;
28650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28651         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
28652         CHECK_ACCESS(val_ptr);
28653         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
28654         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
28655         ChannelReady_set_short_channel_id_alias(&this_ptr_conv, val_conv);
28656 }
28657
28658 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) {
28659         LDKThirtyTwoBytes channel_id_arg_ref;
28660         CHECK(channel_id_arg->arr_len == 32);
28661         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28662         LDKPublicKey next_per_commitment_point_arg_ref;
28663         CHECK(next_per_commitment_point_arg->arr_len == 33);
28664         memcpy(next_per_commitment_point_arg_ref.compressed_form, next_per_commitment_point_arg->elems, 33); FREE(next_per_commitment_point_arg);
28665         void* short_channel_id_alias_arg_ptr = (void*)(((uintptr_t)short_channel_id_alias_arg) & ~1);
28666         CHECK_ACCESS(short_channel_id_alias_arg_ptr);
28667         LDKCOption_u64Z short_channel_id_alias_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_alias_arg_ptr);
28668         short_channel_id_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_alias_arg) & ~1));
28669         LDKChannelReady ret_var = ChannelReady_new(channel_id_arg_ref, next_per_commitment_point_arg_ref, short_channel_id_alias_arg_conv);
28670         uint32_t ret_ref = 0;
28671         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28672         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28673         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28674         ret_ref = (uintptr_t)ret_var.inner;
28675         if (ret_var.is_owned) {
28676                 ret_ref |= 1;
28677         }
28678         return ret_ref;
28679 }
28680
28681 static inline uintptr_t ChannelReady_clone_ptr(LDKChannelReady *NONNULL_PTR arg) {
28682         LDKChannelReady ret_var = ChannelReady_clone(arg);
28683 uint32_t ret_ref = 0;
28684 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28685 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28686 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28687 ret_ref = (uintptr_t)ret_var.inner;
28688 if (ret_var.is_owned) {
28689         ret_ref |= 1;
28690 }
28691         return ret_ref;
28692 }
28693 uint32_t  __attribute__((export_name("TS_ChannelReady_clone_ptr"))) TS_ChannelReady_clone_ptr(uint32_t arg) {
28694         LDKChannelReady arg_conv;
28695         arg_conv.inner = (void*)(arg & (~1));
28696         arg_conv.is_owned = false;
28697         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28698         uint32_t ret_conv = ChannelReady_clone_ptr(&arg_conv);
28699         return ret_conv;
28700 }
28701
28702 uint32_t  __attribute__((export_name("TS_ChannelReady_clone"))) TS_ChannelReady_clone(uint32_t orig) {
28703         LDKChannelReady orig_conv;
28704         orig_conv.inner = (void*)(orig & (~1));
28705         orig_conv.is_owned = false;
28706         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28707         LDKChannelReady ret_var = ChannelReady_clone(&orig_conv);
28708         uint32_t ret_ref = 0;
28709         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28710         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28711         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28712         ret_ref = (uintptr_t)ret_var.inner;
28713         if (ret_var.is_owned) {
28714                 ret_ref |= 1;
28715         }
28716         return ret_ref;
28717 }
28718
28719 void  __attribute__((export_name("TS_Shutdown_free"))) TS_Shutdown_free(uint32_t this_obj) {
28720         LDKShutdown this_obj_conv;
28721         this_obj_conv.inner = (void*)(this_obj & (~1));
28722         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28724         Shutdown_free(this_obj_conv);
28725 }
28726
28727 int8_tArray  __attribute__((export_name("TS_Shutdown_get_channel_id"))) TS_Shutdown_get_channel_id(uint32_t this_ptr) {
28728         LDKShutdown this_ptr_conv;
28729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28730         this_ptr_conv.is_owned = false;
28731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28732         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28733         memcpy(ret_arr->elems, *Shutdown_get_channel_id(&this_ptr_conv), 32);
28734         return ret_arr;
28735 }
28736
28737 void  __attribute__((export_name("TS_Shutdown_set_channel_id"))) TS_Shutdown_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28738         LDKShutdown this_ptr_conv;
28739         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28740         this_ptr_conv.is_owned = false;
28741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28742         LDKThirtyTwoBytes val_ref;
28743         CHECK(val->arr_len == 32);
28744         memcpy(val_ref.data, val->elems, 32); FREE(val);
28745         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
28746 }
28747
28748 int8_tArray  __attribute__((export_name("TS_Shutdown_get_scriptpubkey"))) TS_Shutdown_get_scriptpubkey(uint32_t this_ptr) {
28749         LDKShutdown this_ptr_conv;
28750         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28751         this_ptr_conv.is_owned = false;
28752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28753         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
28754         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
28755         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
28756         return ret_arr;
28757 }
28758
28759 void  __attribute__((export_name("TS_Shutdown_set_scriptpubkey"))) TS_Shutdown_set_scriptpubkey(uint32_t this_ptr, int8_tArray val) {
28760         LDKShutdown this_ptr_conv;
28761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28762         this_ptr_conv.is_owned = false;
28763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28764         LDKCVec_u8Z val_ref;
28765         val_ref.datalen = val->arr_len;
28766         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
28767         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
28768         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
28769 }
28770
28771 uint32_t  __attribute__((export_name("TS_Shutdown_new"))) TS_Shutdown_new(int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
28772         LDKThirtyTwoBytes channel_id_arg_ref;
28773         CHECK(channel_id_arg->arr_len == 32);
28774         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28775         LDKCVec_u8Z scriptpubkey_arg_ref;
28776         scriptpubkey_arg_ref.datalen = scriptpubkey_arg->arr_len;
28777         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
28778         memcpy(scriptpubkey_arg_ref.data, scriptpubkey_arg->elems, scriptpubkey_arg_ref.datalen); FREE(scriptpubkey_arg);
28779         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
28780         uint32_t ret_ref = 0;
28781         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28782         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28783         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28784         ret_ref = (uintptr_t)ret_var.inner;
28785         if (ret_var.is_owned) {
28786                 ret_ref |= 1;
28787         }
28788         return ret_ref;
28789 }
28790
28791 static inline uintptr_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
28792         LDKShutdown ret_var = Shutdown_clone(arg);
28793 uint32_t ret_ref = 0;
28794 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28795 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28796 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28797 ret_ref = (uintptr_t)ret_var.inner;
28798 if (ret_var.is_owned) {
28799         ret_ref |= 1;
28800 }
28801         return ret_ref;
28802 }
28803 uint32_t  __attribute__((export_name("TS_Shutdown_clone_ptr"))) TS_Shutdown_clone_ptr(uint32_t arg) {
28804         LDKShutdown arg_conv;
28805         arg_conv.inner = (void*)(arg & (~1));
28806         arg_conv.is_owned = false;
28807         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28808         uint32_t ret_conv = Shutdown_clone_ptr(&arg_conv);
28809         return ret_conv;
28810 }
28811
28812 uint32_t  __attribute__((export_name("TS_Shutdown_clone"))) TS_Shutdown_clone(uint32_t orig) {
28813         LDKShutdown orig_conv;
28814         orig_conv.inner = (void*)(orig & (~1));
28815         orig_conv.is_owned = false;
28816         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28817         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
28818         uint32_t ret_ref = 0;
28819         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28820         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28821         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28822         ret_ref = (uintptr_t)ret_var.inner;
28823         if (ret_var.is_owned) {
28824                 ret_ref |= 1;
28825         }
28826         return ret_ref;
28827 }
28828
28829 void  __attribute__((export_name("TS_ClosingSignedFeeRange_free"))) TS_ClosingSignedFeeRange_free(uint32_t this_obj) {
28830         LDKClosingSignedFeeRange this_obj_conv;
28831         this_obj_conv.inner = (void*)(this_obj & (~1));
28832         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28834         ClosingSignedFeeRange_free(this_obj_conv);
28835 }
28836
28837 int64_t  __attribute__((export_name("TS_ClosingSignedFeeRange_get_min_fee_satoshis"))) TS_ClosingSignedFeeRange_get_min_fee_satoshis(uint32_t this_ptr) {
28838         LDKClosingSignedFeeRange this_ptr_conv;
28839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28840         this_ptr_conv.is_owned = false;
28841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28842         int64_t ret_conv = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
28843         return ret_conv;
28844 }
28845
28846 void  __attribute__((export_name("TS_ClosingSignedFeeRange_set_min_fee_satoshis"))) TS_ClosingSignedFeeRange_set_min_fee_satoshis(uint32_t this_ptr, int64_t val) {
28847         LDKClosingSignedFeeRange this_ptr_conv;
28848         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28849         this_ptr_conv.is_owned = false;
28850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28851         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
28852 }
28853
28854 int64_t  __attribute__((export_name("TS_ClosingSignedFeeRange_get_max_fee_satoshis"))) TS_ClosingSignedFeeRange_get_max_fee_satoshis(uint32_t this_ptr) {
28855         LDKClosingSignedFeeRange this_ptr_conv;
28856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28857         this_ptr_conv.is_owned = false;
28858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28859         int64_t ret_conv = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
28860         return ret_conv;
28861 }
28862
28863 void  __attribute__((export_name("TS_ClosingSignedFeeRange_set_max_fee_satoshis"))) TS_ClosingSignedFeeRange_set_max_fee_satoshis(uint32_t this_ptr, int64_t val) {
28864         LDKClosingSignedFeeRange this_ptr_conv;
28865         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28866         this_ptr_conv.is_owned = false;
28867         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28868         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
28869 }
28870
28871 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_new"))) TS_ClosingSignedFeeRange_new(int64_t min_fee_satoshis_arg, int64_t max_fee_satoshis_arg) {
28872         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
28873         uint32_t ret_ref = 0;
28874         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28875         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28876         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28877         ret_ref = (uintptr_t)ret_var.inner;
28878         if (ret_var.is_owned) {
28879                 ret_ref |= 1;
28880         }
28881         return ret_ref;
28882 }
28883
28884 static inline uintptr_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
28885         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
28886 uint32_t ret_ref = 0;
28887 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28888 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28889 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28890 ret_ref = (uintptr_t)ret_var.inner;
28891 if (ret_var.is_owned) {
28892         ret_ref |= 1;
28893 }
28894         return ret_ref;
28895 }
28896 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_clone_ptr"))) TS_ClosingSignedFeeRange_clone_ptr(uint32_t arg) {
28897         LDKClosingSignedFeeRange arg_conv;
28898         arg_conv.inner = (void*)(arg & (~1));
28899         arg_conv.is_owned = false;
28900         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28901         uint32_t ret_conv = ClosingSignedFeeRange_clone_ptr(&arg_conv);
28902         return ret_conv;
28903 }
28904
28905 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_clone"))) TS_ClosingSignedFeeRange_clone(uint32_t orig) {
28906         LDKClosingSignedFeeRange orig_conv;
28907         orig_conv.inner = (void*)(orig & (~1));
28908         orig_conv.is_owned = false;
28909         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28910         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
28911         uint32_t ret_ref = 0;
28912         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28913         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28914         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28915         ret_ref = (uintptr_t)ret_var.inner;
28916         if (ret_var.is_owned) {
28917                 ret_ref |= 1;
28918         }
28919         return ret_ref;
28920 }
28921
28922 void  __attribute__((export_name("TS_ClosingSigned_free"))) TS_ClosingSigned_free(uint32_t this_obj) {
28923         LDKClosingSigned this_obj_conv;
28924         this_obj_conv.inner = (void*)(this_obj & (~1));
28925         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28927         ClosingSigned_free(this_obj_conv);
28928 }
28929
28930 int8_tArray  __attribute__((export_name("TS_ClosingSigned_get_channel_id"))) TS_ClosingSigned_get_channel_id(uint32_t this_ptr) {
28931         LDKClosingSigned this_ptr_conv;
28932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28933         this_ptr_conv.is_owned = false;
28934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28935         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28936         memcpy(ret_arr->elems, *ClosingSigned_get_channel_id(&this_ptr_conv), 32);
28937         return ret_arr;
28938 }
28939
28940 void  __attribute__((export_name("TS_ClosingSigned_set_channel_id"))) TS_ClosingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28941         LDKClosingSigned this_ptr_conv;
28942         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28943         this_ptr_conv.is_owned = false;
28944         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28945         LDKThirtyTwoBytes val_ref;
28946         CHECK(val->arr_len == 32);
28947         memcpy(val_ref.data, val->elems, 32); FREE(val);
28948         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
28949 }
28950
28951 int64_t  __attribute__((export_name("TS_ClosingSigned_get_fee_satoshis"))) TS_ClosingSigned_get_fee_satoshis(uint32_t this_ptr) {
28952         LDKClosingSigned this_ptr_conv;
28953         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28954         this_ptr_conv.is_owned = false;
28955         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28956         int64_t ret_conv = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
28957         return ret_conv;
28958 }
28959
28960 void  __attribute__((export_name("TS_ClosingSigned_set_fee_satoshis"))) TS_ClosingSigned_set_fee_satoshis(uint32_t this_ptr, int64_t val) {
28961         LDKClosingSigned this_ptr_conv;
28962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28963         this_ptr_conv.is_owned = false;
28964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28965         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
28966 }
28967
28968 int8_tArray  __attribute__((export_name("TS_ClosingSigned_get_signature"))) TS_ClosingSigned_get_signature(uint32_t this_ptr) {
28969         LDKClosingSigned this_ptr_conv;
28970         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28971         this_ptr_conv.is_owned = false;
28972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28973         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
28974         memcpy(ret_arr->elems, ClosingSigned_get_signature(&this_ptr_conv).compact_form, 64);
28975         return ret_arr;
28976 }
28977
28978 void  __attribute__((export_name("TS_ClosingSigned_set_signature"))) TS_ClosingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
28979         LDKClosingSigned this_ptr_conv;
28980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28981         this_ptr_conv.is_owned = false;
28982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28983         LDKSignature val_ref;
28984         CHECK(val->arr_len == 64);
28985         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
28986         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
28987 }
28988
28989 uint32_t  __attribute__((export_name("TS_ClosingSigned_get_fee_range"))) TS_ClosingSigned_get_fee_range(uint32_t this_ptr) {
28990         LDKClosingSigned this_ptr_conv;
28991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28992         this_ptr_conv.is_owned = false;
28993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28994         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
28995         uint32_t ret_ref = 0;
28996         if ((uintptr_t)ret_var.inner > 4096) {
28997                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28998                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28999         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29000                 ret_ref = (uintptr_t)ret_var.inner;
29001                 if (ret_var.is_owned) {
29002                         ret_ref |= 1;
29003                 }
29004         }
29005         return ret_ref;
29006 }
29007
29008 void  __attribute__((export_name("TS_ClosingSigned_set_fee_range"))) TS_ClosingSigned_set_fee_range(uint32_t this_ptr, uint32_t val) {
29009         LDKClosingSigned this_ptr_conv;
29010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29011         this_ptr_conv.is_owned = false;
29012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29013         LDKClosingSignedFeeRange val_conv;
29014         val_conv.inner = (void*)(val & (~1));
29015         val_conv.is_owned = (val & 1) || (val == 0);
29016         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29017         val_conv = ClosingSignedFeeRange_clone(&val_conv);
29018         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
29019 }
29020
29021 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) {
29022         LDKThirtyTwoBytes channel_id_arg_ref;
29023         CHECK(channel_id_arg->arr_len == 32);
29024         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
29025         LDKSignature signature_arg_ref;
29026         CHECK(signature_arg->arr_len == 64);
29027         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
29028         LDKClosingSignedFeeRange fee_range_arg_conv;
29029         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
29030         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
29031         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
29032         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
29033         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
29034         uint32_t ret_ref = 0;
29035         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29036         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29037         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29038         ret_ref = (uintptr_t)ret_var.inner;
29039         if (ret_var.is_owned) {
29040                 ret_ref |= 1;
29041         }
29042         return ret_ref;
29043 }
29044
29045 static inline uintptr_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
29046         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
29047 uint32_t ret_ref = 0;
29048 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29049 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29050 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29051 ret_ref = (uintptr_t)ret_var.inner;
29052 if (ret_var.is_owned) {
29053         ret_ref |= 1;
29054 }
29055         return ret_ref;
29056 }
29057 uint32_t  __attribute__((export_name("TS_ClosingSigned_clone_ptr"))) TS_ClosingSigned_clone_ptr(uint32_t arg) {
29058         LDKClosingSigned arg_conv;
29059         arg_conv.inner = (void*)(arg & (~1));
29060         arg_conv.is_owned = false;
29061         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29062         uint32_t ret_conv = ClosingSigned_clone_ptr(&arg_conv);
29063         return ret_conv;
29064 }
29065
29066 uint32_t  __attribute__((export_name("TS_ClosingSigned_clone"))) TS_ClosingSigned_clone(uint32_t orig) {
29067         LDKClosingSigned orig_conv;
29068         orig_conv.inner = (void*)(orig & (~1));
29069         orig_conv.is_owned = false;
29070         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29071         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
29072         uint32_t ret_ref = 0;
29073         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29074         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29075         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29076         ret_ref = (uintptr_t)ret_var.inner;
29077         if (ret_var.is_owned) {
29078                 ret_ref |= 1;
29079         }
29080         return ret_ref;
29081 }
29082
29083 void  __attribute__((export_name("TS_UpdateAddHTLC_free"))) TS_UpdateAddHTLC_free(uint32_t this_obj) {
29084         LDKUpdateAddHTLC this_obj_conv;
29085         this_obj_conv.inner = (void*)(this_obj & (~1));
29086         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29088         UpdateAddHTLC_free(this_obj_conv);
29089 }
29090
29091 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_get_channel_id"))) TS_UpdateAddHTLC_get_channel_id(uint32_t this_ptr) {
29092         LDKUpdateAddHTLC this_ptr_conv;
29093         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29094         this_ptr_conv.is_owned = false;
29095         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29096         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29097         memcpy(ret_arr->elems, *UpdateAddHTLC_get_channel_id(&this_ptr_conv), 32);
29098         return ret_arr;
29099 }
29100
29101 void  __attribute__((export_name("TS_UpdateAddHTLC_set_channel_id"))) TS_UpdateAddHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
29102         LDKUpdateAddHTLC this_ptr_conv;
29103         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29104         this_ptr_conv.is_owned = false;
29105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29106         LDKThirtyTwoBytes val_ref;
29107         CHECK(val->arr_len == 32);
29108         memcpy(val_ref.data, val->elems, 32); FREE(val);
29109         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
29110 }
29111
29112 int64_t  __attribute__((export_name("TS_UpdateAddHTLC_get_htlc_id"))) TS_UpdateAddHTLC_get_htlc_id(uint32_t this_ptr) {
29113         LDKUpdateAddHTLC this_ptr_conv;
29114         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29115         this_ptr_conv.is_owned = false;
29116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29117         int64_t ret_conv = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
29118         return ret_conv;
29119 }
29120
29121 void  __attribute__((export_name("TS_UpdateAddHTLC_set_htlc_id"))) TS_UpdateAddHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
29122         LDKUpdateAddHTLC this_ptr_conv;
29123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29124         this_ptr_conv.is_owned = false;
29125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29126         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
29127 }
29128
29129 int64_t  __attribute__((export_name("TS_UpdateAddHTLC_get_amount_msat"))) TS_UpdateAddHTLC_get_amount_msat(uint32_t this_ptr) {
29130         LDKUpdateAddHTLC this_ptr_conv;
29131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29132         this_ptr_conv.is_owned = false;
29133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29134         int64_t ret_conv = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
29135         return ret_conv;
29136 }
29137
29138 void  __attribute__((export_name("TS_UpdateAddHTLC_set_amount_msat"))) TS_UpdateAddHTLC_set_amount_msat(uint32_t this_ptr, int64_t val) {
29139         LDKUpdateAddHTLC 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         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
29144 }
29145
29146 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_get_payment_hash"))) TS_UpdateAddHTLC_get_payment_hash(uint32_t this_ptr) {
29147         LDKUpdateAddHTLC this_ptr_conv;
29148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29149         this_ptr_conv.is_owned = false;
29150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29151         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29152         memcpy(ret_arr->elems, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv), 32);
29153         return ret_arr;
29154 }
29155
29156 void  __attribute__((export_name("TS_UpdateAddHTLC_set_payment_hash"))) TS_UpdateAddHTLC_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
29157         LDKUpdateAddHTLC this_ptr_conv;
29158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29159         this_ptr_conv.is_owned = false;
29160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29161         LDKThirtyTwoBytes val_ref;
29162         CHECK(val->arr_len == 32);
29163         memcpy(val_ref.data, val->elems, 32); FREE(val);
29164         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
29165 }
29166
29167 int32_t  __attribute__((export_name("TS_UpdateAddHTLC_get_cltv_expiry"))) TS_UpdateAddHTLC_get_cltv_expiry(uint32_t this_ptr) {
29168         LDKUpdateAddHTLC this_ptr_conv;
29169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29170         this_ptr_conv.is_owned = false;
29171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29172         int32_t ret_conv = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
29173         return ret_conv;
29174 }
29175
29176 void  __attribute__((export_name("TS_UpdateAddHTLC_set_cltv_expiry"))) TS_UpdateAddHTLC_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
29177         LDKUpdateAddHTLC this_ptr_conv;
29178         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29179         this_ptr_conv.is_owned = false;
29180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29181         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
29182 }
29183
29184 static inline uintptr_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
29185         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
29186 uint32_t ret_ref = 0;
29187 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29188 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29189 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29190 ret_ref = (uintptr_t)ret_var.inner;
29191 if (ret_var.is_owned) {
29192         ret_ref |= 1;
29193 }
29194         return ret_ref;
29195 }
29196 uint32_t  __attribute__((export_name("TS_UpdateAddHTLC_clone_ptr"))) TS_UpdateAddHTLC_clone_ptr(uint32_t arg) {
29197         LDKUpdateAddHTLC arg_conv;
29198         arg_conv.inner = (void*)(arg & (~1));
29199         arg_conv.is_owned = false;
29200         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29201         uint32_t ret_conv = UpdateAddHTLC_clone_ptr(&arg_conv);
29202         return ret_conv;
29203 }
29204
29205 uint32_t  __attribute__((export_name("TS_UpdateAddHTLC_clone"))) TS_UpdateAddHTLC_clone(uint32_t orig) {
29206         LDKUpdateAddHTLC orig_conv;
29207         orig_conv.inner = (void*)(orig & (~1));
29208         orig_conv.is_owned = false;
29209         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29210         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
29211         uint32_t ret_ref = 0;
29212         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29213         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29214         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29215         ret_ref = (uintptr_t)ret_var.inner;
29216         if (ret_var.is_owned) {
29217                 ret_ref |= 1;
29218         }
29219         return ret_ref;
29220 }
29221
29222 void  __attribute__((export_name("TS_UpdateFulfillHTLC_free"))) TS_UpdateFulfillHTLC_free(uint32_t this_obj) {
29223         LDKUpdateFulfillHTLC this_obj_conv;
29224         this_obj_conv.inner = (void*)(this_obj & (~1));
29225         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29227         UpdateFulfillHTLC_free(this_obj_conv);
29228 }
29229
29230 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_get_channel_id"))) TS_UpdateFulfillHTLC_get_channel_id(uint32_t this_ptr) {
29231         LDKUpdateFulfillHTLC this_ptr_conv;
29232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29233         this_ptr_conv.is_owned = false;
29234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29235         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29236         memcpy(ret_arr->elems, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv), 32);
29237         return ret_arr;
29238 }
29239
29240 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_channel_id"))) TS_UpdateFulfillHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
29241         LDKUpdateFulfillHTLC this_ptr_conv;
29242         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29243         this_ptr_conv.is_owned = false;
29244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29245         LDKThirtyTwoBytes val_ref;
29246         CHECK(val->arr_len == 32);
29247         memcpy(val_ref.data, val->elems, 32); FREE(val);
29248         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
29249 }
29250
29251 int64_t  __attribute__((export_name("TS_UpdateFulfillHTLC_get_htlc_id"))) TS_UpdateFulfillHTLC_get_htlc_id(uint32_t this_ptr) {
29252         LDKUpdateFulfillHTLC 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         int64_t ret_conv = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
29257         return ret_conv;
29258 }
29259
29260 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_htlc_id"))) TS_UpdateFulfillHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
29261         LDKUpdateFulfillHTLC 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         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
29266 }
29267
29268 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_get_payment_preimage"))) TS_UpdateFulfillHTLC_get_payment_preimage(uint32_t this_ptr) {
29269         LDKUpdateFulfillHTLC 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(32, __LINE__);
29274         memcpy(ret_arr->elems, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv), 32);
29275         return ret_arr;
29276 }
29277
29278 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_payment_preimage"))) TS_UpdateFulfillHTLC_set_payment_preimage(uint32_t this_ptr, int8_tArray val) {
29279         LDKUpdateFulfillHTLC 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         LDKThirtyTwoBytes val_ref;
29284         CHECK(val->arr_len == 32);
29285         memcpy(val_ref.data, val->elems, 32); FREE(val);
29286         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
29287 }
29288
29289 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) {
29290         LDKThirtyTwoBytes channel_id_arg_ref;
29291         CHECK(channel_id_arg->arr_len == 32);
29292         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
29293         LDKThirtyTwoBytes payment_preimage_arg_ref;
29294         CHECK(payment_preimage_arg->arr_len == 32);
29295         memcpy(payment_preimage_arg_ref.data, payment_preimage_arg->elems, 32); FREE(payment_preimage_arg);
29296         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
29297         uint32_t ret_ref = 0;
29298         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29299         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29300         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29301         ret_ref = (uintptr_t)ret_var.inner;
29302         if (ret_var.is_owned) {
29303                 ret_ref |= 1;
29304         }
29305         return ret_ref;
29306 }
29307
29308 static inline uintptr_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
29309         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
29310 uint32_t ret_ref = 0;
29311 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29312 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29313 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29314 ret_ref = (uintptr_t)ret_var.inner;
29315 if (ret_var.is_owned) {
29316         ret_ref |= 1;
29317 }
29318         return ret_ref;
29319 }
29320 uint32_t  __attribute__((export_name("TS_UpdateFulfillHTLC_clone_ptr"))) TS_UpdateFulfillHTLC_clone_ptr(uint32_t arg) {
29321         LDKUpdateFulfillHTLC arg_conv;
29322         arg_conv.inner = (void*)(arg & (~1));
29323         arg_conv.is_owned = false;
29324         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29325         uint32_t ret_conv = UpdateFulfillHTLC_clone_ptr(&arg_conv);
29326         return ret_conv;
29327 }
29328
29329 uint32_t  __attribute__((export_name("TS_UpdateFulfillHTLC_clone"))) TS_UpdateFulfillHTLC_clone(uint32_t orig) {
29330         LDKUpdateFulfillHTLC orig_conv;
29331         orig_conv.inner = (void*)(orig & (~1));
29332         orig_conv.is_owned = false;
29333         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29334         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
29335         uint32_t ret_ref = 0;
29336         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29337         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29338         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29339         ret_ref = (uintptr_t)ret_var.inner;
29340         if (ret_var.is_owned) {
29341                 ret_ref |= 1;
29342         }
29343         return ret_ref;
29344 }
29345
29346 void  __attribute__((export_name("TS_UpdateFailHTLC_free"))) TS_UpdateFailHTLC_free(uint32_t this_obj) {
29347         LDKUpdateFailHTLC this_obj_conv;
29348         this_obj_conv.inner = (void*)(this_obj & (~1));
29349         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29351         UpdateFailHTLC_free(this_obj_conv);
29352 }
29353
29354 int8_tArray  __attribute__((export_name("TS_UpdateFailHTLC_get_channel_id"))) TS_UpdateFailHTLC_get_channel_id(uint32_t this_ptr) {
29355         LDKUpdateFailHTLC this_ptr_conv;
29356         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29357         this_ptr_conv.is_owned = false;
29358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29359         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29360         memcpy(ret_arr->elems, *UpdateFailHTLC_get_channel_id(&this_ptr_conv), 32);
29361         return ret_arr;
29362 }
29363
29364 void  __attribute__((export_name("TS_UpdateFailHTLC_set_channel_id"))) TS_UpdateFailHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
29365         LDKUpdateFailHTLC this_ptr_conv;
29366         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29367         this_ptr_conv.is_owned = false;
29368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29369         LDKThirtyTwoBytes val_ref;
29370         CHECK(val->arr_len == 32);
29371         memcpy(val_ref.data, val->elems, 32); FREE(val);
29372         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
29373 }
29374
29375 int64_t  __attribute__((export_name("TS_UpdateFailHTLC_get_htlc_id"))) TS_UpdateFailHTLC_get_htlc_id(uint32_t this_ptr) {
29376         LDKUpdateFailHTLC this_ptr_conv;
29377         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29378         this_ptr_conv.is_owned = false;
29379         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29380         int64_t ret_conv = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
29381         return ret_conv;
29382 }
29383
29384 void  __attribute__((export_name("TS_UpdateFailHTLC_set_htlc_id"))) TS_UpdateFailHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
29385         LDKUpdateFailHTLC this_ptr_conv;
29386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29387         this_ptr_conv.is_owned = false;
29388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29389         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
29390 }
29391
29392 static inline uintptr_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
29393         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
29394 uint32_t ret_ref = 0;
29395 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29396 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29397 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29398 ret_ref = (uintptr_t)ret_var.inner;
29399 if (ret_var.is_owned) {
29400         ret_ref |= 1;
29401 }
29402         return ret_ref;
29403 }
29404 uint32_t  __attribute__((export_name("TS_UpdateFailHTLC_clone_ptr"))) TS_UpdateFailHTLC_clone_ptr(uint32_t arg) {
29405         LDKUpdateFailHTLC arg_conv;
29406         arg_conv.inner = (void*)(arg & (~1));
29407         arg_conv.is_owned = false;
29408         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29409         uint32_t ret_conv = UpdateFailHTLC_clone_ptr(&arg_conv);
29410         return ret_conv;
29411 }
29412
29413 uint32_t  __attribute__((export_name("TS_UpdateFailHTLC_clone"))) TS_UpdateFailHTLC_clone(uint32_t orig) {
29414         LDKUpdateFailHTLC orig_conv;
29415         orig_conv.inner = (void*)(orig & (~1));
29416         orig_conv.is_owned = false;
29417         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29418         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
29419         uint32_t ret_ref = 0;
29420         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29421         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29422         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29423         ret_ref = (uintptr_t)ret_var.inner;
29424         if (ret_var.is_owned) {
29425                 ret_ref |= 1;
29426         }
29427         return ret_ref;
29428 }
29429
29430 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_free"))) TS_UpdateFailMalformedHTLC_free(uint32_t this_obj) {
29431         LDKUpdateFailMalformedHTLC this_obj_conv;
29432         this_obj_conv.inner = (void*)(this_obj & (~1));
29433         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29435         UpdateFailMalformedHTLC_free(this_obj_conv);
29436 }
29437
29438 int8_tArray  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_channel_id"))) TS_UpdateFailMalformedHTLC_get_channel_id(uint32_t this_ptr) {
29439         LDKUpdateFailMalformedHTLC this_ptr_conv;
29440         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29441         this_ptr_conv.is_owned = false;
29442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29443         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29444         memcpy(ret_arr->elems, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv), 32);
29445         return ret_arr;
29446 }
29447
29448 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_channel_id"))) TS_UpdateFailMalformedHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
29449         LDKUpdateFailMalformedHTLC this_ptr_conv;
29450         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29451         this_ptr_conv.is_owned = false;
29452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29453         LDKThirtyTwoBytes val_ref;
29454         CHECK(val->arr_len == 32);
29455         memcpy(val_ref.data, val->elems, 32); FREE(val);
29456         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
29457 }
29458
29459 int64_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_htlc_id"))) TS_UpdateFailMalformedHTLC_get_htlc_id(uint32_t this_ptr) {
29460         LDKUpdateFailMalformedHTLC this_ptr_conv;
29461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29462         this_ptr_conv.is_owned = false;
29463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29464         int64_t ret_conv = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
29465         return ret_conv;
29466 }
29467
29468 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_htlc_id"))) TS_UpdateFailMalformedHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
29469         LDKUpdateFailMalformedHTLC this_ptr_conv;
29470         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29471         this_ptr_conv.is_owned = false;
29472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29473         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
29474 }
29475
29476 int16_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_failure_code"))) TS_UpdateFailMalformedHTLC_get_failure_code(uint32_t this_ptr) {
29477         LDKUpdateFailMalformedHTLC this_ptr_conv;
29478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29479         this_ptr_conv.is_owned = false;
29480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29481         int16_t ret_conv = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
29482         return ret_conv;
29483 }
29484
29485 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_failure_code"))) TS_UpdateFailMalformedHTLC_set_failure_code(uint32_t this_ptr, int16_t val) {
29486         LDKUpdateFailMalformedHTLC this_ptr_conv;
29487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29488         this_ptr_conv.is_owned = false;
29489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29490         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
29491 }
29492
29493 static inline uintptr_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
29494         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
29495 uint32_t ret_ref = 0;
29496 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29497 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29498 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29499 ret_ref = (uintptr_t)ret_var.inner;
29500 if (ret_var.is_owned) {
29501         ret_ref |= 1;
29502 }
29503         return ret_ref;
29504 }
29505 uint32_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_clone_ptr"))) TS_UpdateFailMalformedHTLC_clone_ptr(uint32_t arg) {
29506         LDKUpdateFailMalformedHTLC arg_conv;
29507         arg_conv.inner = (void*)(arg & (~1));
29508         arg_conv.is_owned = false;
29509         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29510         uint32_t ret_conv = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
29511         return ret_conv;
29512 }
29513
29514 uint32_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_clone"))) TS_UpdateFailMalformedHTLC_clone(uint32_t orig) {
29515         LDKUpdateFailMalformedHTLC orig_conv;
29516         orig_conv.inner = (void*)(orig & (~1));
29517         orig_conv.is_owned = false;
29518         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29519         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
29520         uint32_t ret_ref = 0;
29521         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29522         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29523         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29524         ret_ref = (uintptr_t)ret_var.inner;
29525         if (ret_var.is_owned) {
29526                 ret_ref |= 1;
29527         }
29528         return ret_ref;
29529 }
29530
29531 void  __attribute__((export_name("TS_CommitmentSigned_free"))) TS_CommitmentSigned_free(uint32_t this_obj) {
29532         LDKCommitmentSigned this_obj_conv;
29533         this_obj_conv.inner = (void*)(this_obj & (~1));
29534         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29536         CommitmentSigned_free(this_obj_conv);
29537 }
29538
29539 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_get_channel_id"))) TS_CommitmentSigned_get_channel_id(uint32_t this_ptr) {
29540         LDKCommitmentSigned this_ptr_conv;
29541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29542         this_ptr_conv.is_owned = false;
29543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29544         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29545         memcpy(ret_arr->elems, *CommitmentSigned_get_channel_id(&this_ptr_conv), 32);
29546         return ret_arr;
29547 }
29548
29549 void  __attribute__((export_name("TS_CommitmentSigned_set_channel_id"))) TS_CommitmentSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
29550         LDKCommitmentSigned this_ptr_conv;
29551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29552         this_ptr_conv.is_owned = false;
29553         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29554         LDKThirtyTwoBytes val_ref;
29555         CHECK(val->arr_len == 32);
29556         memcpy(val_ref.data, val->elems, 32); FREE(val);
29557         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
29558 }
29559
29560 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_get_signature"))) TS_CommitmentSigned_get_signature(uint32_t this_ptr) {
29561         LDKCommitmentSigned this_ptr_conv;
29562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29563         this_ptr_conv.is_owned = false;
29564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29565         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29566         memcpy(ret_arr->elems, CommitmentSigned_get_signature(&this_ptr_conv).compact_form, 64);
29567         return ret_arr;
29568 }
29569
29570 void  __attribute__((export_name("TS_CommitmentSigned_set_signature"))) TS_CommitmentSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
29571         LDKCommitmentSigned this_ptr_conv;
29572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29573         this_ptr_conv.is_owned = false;
29574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29575         LDKSignature val_ref;
29576         CHECK(val->arr_len == 64);
29577         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29578         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
29579 }
29580
29581 void  __attribute__((export_name("TS_CommitmentSigned_set_htlc_signatures"))) TS_CommitmentSigned_set_htlc_signatures(uint32_t this_ptr, ptrArray val) {
29582         LDKCommitmentSigned this_ptr_conv;
29583         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29584         this_ptr_conv.is_owned = false;
29585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29586         LDKCVec_SignatureZ val_constr;
29587         val_constr.datalen = val->arr_len;
29588         if (val_constr.datalen > 0)
29589                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
29590         else
29591                 val_constr.data = NULL;
29592         int8_tArray* val_vals = (void*) val->elems /* XXX val leaks */;
29593         for (size_t m = 0; m < val_constr.datalen; m++) {
29594                 int8_tArray val_conv_12 = val_vals[m];
29595                 LDKSignature val_conv_12_ref;
29596                 CHECK(val_conv_12->arr_len == 64);
29597                 memcpy(val_conv_12_ref.compact_form, val_conv_12->elems, 64); FREE(val_conv_12);
29598                 val_constr.data[m] = val_conv_12_ref;
29599         }
29600         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
29601 }
29602
29603 uint32_t  __attribute__((export_name("TS_CommitmentSigned_new"))) TS_CommitmentSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg, ptrArray htlc_signatures_arg) {
29604         LDKThirtyTwoBytes channel_id_arg_ref;
29605         CHECK(channel_id_arg->arr_len == 32);
29606         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
29607         LDKSignature signature_arg_ref;
29608         CHECK(signature_arg->arr_len == 64);
29609         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
29610         LDKCVec_SignatureZ htlc_signatures_arg_constr;
29611         htlc_signatures_arg_constr.datalen = htlc_signatures_arg->arr_len;
29612         if (htlc_signatures_arg_constr.datalen > 0)
29613                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
29614         else
29615                 htlc_signatures_arg_constr.data = NULL;
29616         int8_tArray* htlc_signatures_arg_vals = (void*) htlc_signatures_arg->elems /* XXX htlc_signatures_arg leaks */;
29617         for (size_t m = 0; m < htlc_signatures_arg_constr.datalen; m++) {
29618                 int8_tArray htlc_signatures_arg_conv_12 = htlc_signatures_arg_vals[m];
29619                 LDKSignature htlc_signatures_arg_conv_12_ref;
29620                 CHECK(htlc_signatures_arg_conv_12->arr_len == 64);
29621                 memcpy(htlc_signatures_arg_conv_12_ref.compact_form, htlc_signatures_arg_conv_12->elems, 64); FREE(htlc_signatures_arg_conv_12);
29622                 htlc_signatures_arg_constr.data[m] = htlc_signatures_arg_conv_12_ref;
29623         }
29624         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
29625         uint32_t ret_ref = 0;
29626         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29627         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29628         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29629         ret_ref = (uintptr_t)ret_var.inner;
29630         if (ret_var.is_owned) {
29631                 ret_ref |= 1;
29632         }
29633         return ret_ref;
29634 }
29635
29636 static inline uintptr_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
29637         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
29638 uint32_t ret_ref = 0;
29639 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29640 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29641 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29642 ret_ref = (uintptr_t)ret_var.inner;
29643 if (ret_var.is_owned) {
29644         ret_ref |= 1;
29645 }
29646         return ret_ref;
29647 }
29648 uint32_t  __attribute__((export_name("TS_CommitmentSigned_clone_ptr"))) TS_CommitmentSigned_clone_ptr(uint32_t arg) {
29649         LDKCommitmentSigned arg_conv;
29650         arg_conv.inner = (void*)(arg & (~1));
29651         arg_conv.is_owned = false;
29652         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29653         uint32_t ret_conv = CommitmentSigned_clone_ptr(&arg_conv);
29654         return ret_conv;
29655 }
29656
29657 uint32_t  __attribute__((export_name("TS_CommitmentSigned_clone"))) TS_CommitmentSigned_clone(uint32_t orig) {
29658         LDKCommitmentSigned orig_conv;
29659         orig_conv.inner = (void*)(orig & (~1));
29660         orig_conv.is_owned = false;
29661         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29662         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
29663         uint32_t ret_ref = 0;
29664         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29665         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29666         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29667         ret_ref = (uintptr_t)ret_var.inner;
29668         if (ret_var.is_owned) {
29669                 ret_ref |= 1;
29670         }
29671         return ret_ref;
29672 }
29673
29674 void  __attribute__((export_name("TS_RevokeAndACK_free"))) TS_RevokeAndACK_free(uint32_t this_obj) {
29675         LDKRevokeAndACK this_obj_conv;
29676         this_obj_conv.inner = (void*)(this_obj & (~1));
29677         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29679         RevokeAndACK_free(this_obj_conv);
29680 }
29681
29682 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_channel_id"))) TS_RevokeAndACK_get_channel_id(uint32_t this_ptr) {
29683         LDKRevokeAndACK this_ptr_conv;
29684         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29685         this_ptr_conv.is_owned = false;
29686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29687         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29688         memcpy(ret_arr->elems, *RevokeAndACK_get_channel_id(&this_ptr_conv), 32);
29689         return ret_arr;
29690 }
29691
29692 void  __attribute__((export_name("TS_RevokeAndACK_set_channel_id"))) TS_RevokeAndACK_set_channel_id(uint32_t this_ptr, int8_tArray val) {
29693         LDKRevokeAndACK this_ptr_conv;
29694         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29695         this_ptr_conv.is_owned = false;
29696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29697         LDKThirtyTwoBytes val_ref;
29698         CHECK(val->arr_len == 32);
29699         memcpy(val_ref.data, val->elems, 32); FREE(val);
29700         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
29701 }
29702
29703 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_per_commitment_secret"))) TS_RevokeAndACK_get_per_commitment_secret(uint32_t this_ptr) {
29704         LDKRevokeAndACK this_ptr_conv;
29705         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29706         this_ptr_conv.is_owned = false;
29707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29708         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29709         memcpy(ret_arr->elems, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv), 32);
29710         return ret_arr;
29711 }
29712
29713 void  __attribute__((export_name("TS_RevokeAndACK_set_per_commitment_secret"))) TS_RevokeAndACK_set_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
29714         LDKRevokeAndACK this_ptr_conv;
29715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29716         this_ptr_conv.is_owned = false;
29717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29718         LDKThirtyTwoBytes val_ref;
29719         CHECK(val->arr_len == 32);
29720         memcpy(val_ref.data, val->elems, 32); FREE(val);
29721         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
29722 }
29723
29724 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_next_per_commitment_point"))) TS_RevokeAndACK_get_next_per_commitment_point(uint32_t this_ptr) {
29725         LDKRevokeAndACK this_ptr_conv;
29726         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29727         this_ptr_conv.is_owned = false;
29728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29729         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29730         memcpy(ret_arr->elems, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
29731         return ret_arr;
29732 }
29733
29734 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) {
29735         LDKRevokeAndACK this_ptr_conv;
29736         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29737         this_ptr_conv.is_owned = false;
29738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29739         LDKPublicKey val_ref;
29740         CHECK(val->arr_len == 33);
29741         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29742         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
29743 }
29744
29745 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) {
29746         LDKThirtyTwoBytes channel_id_arg_ref;
29747         CHECK(channel_id_arg->arr_len == 32);
29748         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
29749         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
29750         CHECK(per_commitment_secret_arg->arr_len == 32);
29751         memcpy(per_commitment_secret_arg_ref.data, per_commitment_secret_arg->elems, 32); FREE(per_commitment_secret_arg);
29752         LDKPublicKey next_per_commitment_point_arg_ref;
29753         CHECK(next_per_commitment_point_arg->arr_len == 33);
29754         memcpy(next_per_commitment_point_arg_ref.compressed_form, next_per_commitment_point_arg->elems, 33); FREE(next_per_commitment_point_arg);
29755         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
29756         uint32_t ret_ref = 0;
29757         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29758         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29759         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29760         ret_ref = (uintptr_t)ret_var.inner;
29761         if (ret_var.is_owned) {
29762                 ret_ref |= 1;
29763         }
29764         return ret_ref;
29765 }
29766
29767 static inline uintptr_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
29768         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
29769 uint32_t ret_ref = 0;
29770 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29771 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29772 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29773 ret_ref = (uintptr_t)ret_var.inner;
29774 if (ret_var.is_owned) {
29775         ret_ref |= 1;
29776 }
29777         return ret_ref;
29778 }
29779 uint32_t  __attribute__((export_name("TS_RevokeAndACK_clone_ptr"))) TS_RevokeAndACK_clone_ptr(uint32_t arg) {
29780         LDKRevokeAndACK arg_conv;
29781         arg_conv.inner = (void*)(arg & (~1));
29782         arg_conv.is_owned = false;
29783         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29784         uint32_t ret_conv = RevokeAndACK_clone_ptr(&arg_conv);
29785         return ret_conv;
29786 }
29787
29788 uint32_t  __attribute__((export_name("TS_RevokeAndACK_clone"))) TS_RevokeAndACK_clone(uint32_t orig) {
29789         LDKRevokeAndACK orig_conv;
29790         orig_conv.inner = (void*)(orig & (~1));
29791         orig_conv.is_owned = false;
29792         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29793         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
29794         uint32_t ret_ref = 0;
29795         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29796         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29797         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29798         ret_ref = (uintptr_t)ret_var.inner;
29799         if (ret_var.is_owned) {
29800                 ret_ref |= 1;
29801         }
29802         return ret_ref;
29803 }
29804
29805 void  __attribute__((export_name("TS_UpdateFee_free"))) TS_UpdateFee_free(uint32_t this_obj) {
29806         LDKUpdateFee this_obj_conv;
29807         this_obj_conv.inner = (void*)(this_obj & (~1));
29808         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29810         UpdateFee_free(this_obj_conv);
29811 }
29812
29813 int8_tArray  __attribute__((export_name("TS_UpdateFee_get_channel_id"))) TS_UpdateFee_get_channel_id(uint32_t this_ptr) {
29814         LDKUpdateFee this_ptr_conv;
29815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29816         this_ptr_conv.is_owned = false;
29817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29818         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29819         memcpy(ret_arr->elems, *UpdateFee_get_channel_id(&this_ptr_conv), 32);
29820         return ret_arr;
29821 }
29822
29823 void  __attribute__((export_name("TS_UpdateFee_set_channel_id"))) TS_UpdateFee_set_channel_id(uint32_t this_ptr, int8_tArray val) {
29824         LDKUpdateFee this_ptr_conv;
29825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29826         this_ptr_conv.is_owned = false;
29827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29828         LDKThirtyTwoBytes val_ref;
29829         CHECK(val->arr_len == 32);
29830         memcpy(val_ref.data, val->elems, 32); FREE(val);
29831         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
29832 }
29833
29834 int32_t  __attribute__((export_name("TS_UpdateFee_get_feerate_per_kw"))) TS_UpdateFee_get_feerate_per_kw(uint32_t this_ptr) {
29835         LDKUpdateFee this_ptr_conv;
29836         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29837         this_ptr_conv.is_owned = false;
29838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29839         int32_t ret_conv = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
29840         return ret_conv;
29841 }
29842
29843 void  __attribute__((export_name("TS_UpdateFee_set_feerate_per_kw"))) TS_UpdateFee_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
29844         LDKUpdateFee this_ptr_conv;
29845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29846         this_ptr_conv.is_owned = false;
29847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29848         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
29849 }
29850
29851 uint32_t  __attribute__((export_name("TS_UpdateFee_new"))) TS_UpdateFee_new(int8_tArray channel_id_arg, int32_t feerate_per_kw_arg) {
29852         LDKThirtyTwoBytes channel_id_arg_ref;
29853         CHECK(channel_id_arg->arr_len == 32);
29854         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
29855         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
29856         uint32_t ret_ref = 0;
29857         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29858         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29859         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29860         ret_ref = (uintptr_t)ret_var.inner;
29861         if (ret_var.is_owned) {
29862                 ret_ref |= 1;
29863         }
29864         return ret_ref;
29865 }
29866
29867 static inline uintptr_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
29868         LDKUpdateFee ret_var = UpdateFee_clone(arg);
29869 uint32_t ret_ref = 0;
29870 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29871 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29872 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29873 ret_ref = (uintptr_t)ret_var.inner;
29874 if (ret_var.is_owned) {
29875         ret_ref |= 1;
29876 }
29877         return ret_ref;
29878 }
29879 uint32_t  __attribute__((export_name("TS_UpdateFee_clone_ptr"))) TS_UpdateFee_clone_ptr(uint32_t arg) {
29880         LDKUpdateFee arg_conv;
29881         arg_conv.inner = (void*)(arg & (~1));
29882         arg_conv.is_owned = false;
29883         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29884         uint32_t ret_conv = UpdateFee_clone_ptr(&arg_conv);
29885         return ret_conv;
29886 }
29887
29888 uint32_t  __attribute__((export_name("TS_UpdateFee_clone"))) TS_UpdateFee_clone(uint32_t orig) {
29889         LDKUpdateFee orig_conv;
29890         orig_conv.inner = (void*)(orig & (~1));
29891         orig_conv.is_owned = false;
29892         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29893         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
29894         uint32_t ret_ref = 0;
29895         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29896         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29897         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29898         ret_ref = (uintptr_t)ret_var.inner;
29899         if (ret_var.is_owned) {
29900                 ret_ref |= 1;
29901         }
29902         return ret_ref;
29903 }
29904
29905 void  __attribute__((export_name("TS_DataLossProtect_free"))) TS_DataLossProtect_free(uint32_t this_obj) {
29906         LDKDataLossProtect this_obj_conv;
29907         this_obj_conv.inner = (void*)(this_obj & (~1));
29908         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29910         DataLossProtect_free(this_obj_conv);
29911 }
29912
29913 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) {
29914         LDKDataLossProtect this_ptr_conv;
29915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29916         this_ptr_conv.is_owned = false;
29917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29918         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29919         memcpy(ret_arr->elems, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv), 32);
29920         return ret_arr;
29921 }
29922
29923 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) {
29924         LDKDataLossProtect this_ptr_conv;
29925         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29926         this_ptr_conv.is_owned = false;
29927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29928         LDKThirtyTwoBytes val_ref;
29929         CHECK(val->arr_len == 32);
29930         memcpy(val_ref.data, val->elems, 32); FREE(val);
29931         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
29932 }
29933
29934 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) {
29935         LDKDataLossProtect this_ptr_conv;
29936         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29937         this_ptr_conv.is_owned = false;
29938         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29939         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29940         memcpy(ret_arr->elems, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form, 33);
29941         return ret_arr;
29942 }
29943
29944 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) {
29945         LDKDataLossProtect this_ptr_conv;
29946         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29947         this_ptr_conv.is_owned = false;
29948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29949         LDKPublicKey val_ref;
29950         CHECK(val->arr_len == 33);
29951         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29952         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
29953 }
29954
29955 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) {
29956         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
29957         CHECK(your_last_per_commitment_secret_arg->arr_len == 32);
29958         memcpy(your_last_per_commitment_secret_arg_ref.data, your_last_per_commitment_secret_arg->elems, 32); FREE(your_last_per_commitment_secret_arg);
29959         LDKPublicKey my_current_per_commitment_point_arg_ref;
29960         CHECK(my_current_per_commitment_point_arg->arr_len == 33);
29961         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);
29962         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
29963         uint32_t ret_ref = 0;
29964         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29965         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29966         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29967         ret_ref = (uintptr_t)ret_var.inner;
29968         if (ret_var.is_owned) {
29969                 ret_ref |= 1;
29970         }
29971         return ret_ref;
29972 }
29973
29974 static inline uintptr_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
29975         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
29976 uint32_t ret_ref = 0;
29977 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29978 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29979 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29980 ret_ref = (uintptr_t)ret_var.inner;
29981 if (ret_var.is_owned) {
29982         ret_ref |= 1;
29983 }
29984         return ret_ref;
29985 }
29986 uint32_t  __attribute__((export_name("TS_DataLossProtect_clone_ptr"))) TS_DataLossProtect_clone_ptr(uint32_t arg) {
29987         LDKDataLossProtect arg_conv;
29988         arg_conv.inner = (void*)(arg & (~1));
29989         arg_conv.is_owned = false;
29990         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29991         uint32_t ret_conv = DataLossProtect_clone_ptr(&arg_conv);
29992         return ret_conv;
29993 }
29994
29995 uint32_t  __attribute__((export_name("TS_DataLossProtect_clone"))) TS_DataLossProtect_clone(uint32_t orig) {
29996         LDKDataLossProtect orig_conv;
29997         orig_conv.inner = (void*)(orig & (~1));
29998         orig_conv.is_owned = false;
29999         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30000         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
30001         uint32_t ret_ref = 0;
30002         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30003         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30004         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30005         ret_ref = (uintptr_t)ret_var.inner;
30006         if (ret_var.is_owned) {
30007                 ret_ref |= 1;
30008         }
30009         return ret_ref;
30010 }
30011
30012 void  __attribute__((export_name("TS_ChannelReestablish_free"))) TS_ChannelReestablish_free(uint32_t this_obj) {
30013         LDKChannelReestablish this_obj_conv;
30014         this_obj_conv.inner = (void*)(this_obj & (~1));
30015         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30017         ChannelReestablish_free(this_obj_conv);
30018 }
30019
30020 int8_tArray  __attribute__((export_name("TS_ChannelReestablish_get_channel_id"))) TS_ChannelReestablish_get_channel_id(uint32_t this_ptr) {
30021         LDKChannelReestablish this_ptr_conv;
30022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30023         this_ptr_conv.is_owned = false;
30024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30025         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30026         memcpy(ret_arr->elems, *ChannelReestablish_get_channel_id(&this_ptr_conv), 32);
30027         return ret_arr;
30028 }
30029
30030 void  __attribute__((export_name("TS_ChannelReestablish_set_channel_id"))) TS_ChannelReestablish_set_channel_id(uint32_t this_ptr, int8_tArray val) {
30031         LDKChannelReestablish this_ptr_conv;
30032         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30033         this_ptr_conv.is_owned = false;
30034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30035         LDKThirtyTwoBytes val_ref;
30036         CHECK(val->arr_len == 32);
30037         memcpy(val_ref.data, val->elems, 32); FREE(val);
30038         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
30039 }
30040
30041 int64_t  __attribute__((export_name("TS_ChannelReestablish_get_next_local_commitment_number"))) TS_ChannelReestablish_get_next_local_commitment_number(uint32_t this_ptr) {
30042         LDKChannelReestablish this_ptr_conv;
30043         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30044         this_ptr_conv.is_owned = false;
30045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30046         int64_t ret_conv = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
30047         return ret_conv;
30048 }
30049
30050 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) {
30051         LDKChannelReestablish this_ptr_conv;
30052         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30053         this_ptr_conv.is_owned = false;
30054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30055         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
30056 }
30057
30058 int64_t  __attribute__((export_name("TS_ChannelReestablish_get_next_remote_commitment_number"))) TS_ChannelReestablish_get_next_remote_commitment_number(uint32_t this_ptr) {
30059         LDKChannelReestablish this_ptr_conv;
30060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30061         this_ptr_conv.is_owned = false;
30062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30063         int64_t ret_conv = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
30064         return ret_conv;
30065 }
30066
30067 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) {
30068         LDKChannelReestablish this_ptr_conv;
30069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30070         this_ptr_conv.is_owned = false;
30071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30072         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
30073 }
30074
30075 static inline uintptr_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
30076         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
30077 uint32_t ret_ref = 0;
30078 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30079 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30080 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30081 ret_ref = (uintptr_t)ret_var.inner;
30082 if (ret_var.is_owned) {
30083         ret_ref |= 1;
30084 }
30085         return ret_ref;
30086 }
30087 uint32_t  __attribute__((export_name("TS_ChannelReestablish_clone_ptr"))) TS_ChannelReestablish_clone_ptr(uint32_t arg) {
30088         LDKChannelReestablish arg_conv;
30089         arg_conv.inner = (void*)(arg & (~1));
30090         arg_conv.is_owned = false;
30091         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30092         uint32_t ret_conv = ChannelReestablish_clone_ptr(&arg_conv);
30093         return ret_conv;
30094 }
30095
30096 uint32_t  __attribute__((export_name("TS_ChannelReestablish_clone"))) TS_ChannelReestablish_clone(uint32_t orig) {
30097         LDKChannelReestablish orig_conv;
30098         orig_conv.inner = (void*)(orig & (~1));
30099         orig_conv.is_owned = false;
30100         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30101         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
30102         uint32_t ret_ref = 0;
30103         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30104         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30105         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30106         ret_ref = (uintptr_t)ret_var.inner;
30107         if (ret_var.is_owned) {
30108                 ret_ref |= 1;
30109         }
30110         return ret_ref;
30111 }
30112
30113 void  __attribute__((export_name("TS_AnnouncementSignatures_free"))) TS_AnnouncementSignatures_free(uint32_t this_obj) {
30114         LDKAnnouncementSignatures this_obj_conv;
30115         this_obj_conv.inner = (void*)(this_obj & (~1));
30116         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30118         AnnouncementSignatures_free(this_obj_conv);
30119 }
30120
30121 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_channel_id"))) TS_AnnouncementSignatures_get_channel_id(uint32_t this_ptr) {
30122         LDKAnnouncementSignatures this_ptr_conv;
30123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30124         this_ptr_conv.is_owned = false;
30125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30126         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30127         memcpy(ret_arr->elems, *AnnouncementSignatures_get_channel_id(&this_ptr_conv), 32);
30128         return ret_arr;
30129 }
30130
30131 void  __attribute__((export_name("TS_AnnouncementSignatures_set_channel_id"))) TS_AnnouncementSignatures_set_channel_id(uint32_t this_ptr, int8_tArray val) {
30132         LDKAnnouncementSignatures this_ptr_conv;
30133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30134         this_ptr_conv.is_owned = false;
30135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30136         LDKThirtyTwoBytes val_ref;
30137         CHECK(val->arr_len == 32);
30138         memcpy(val_ref.data, val->elems, 32); FREE(val);
30139         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
30140 }
30141
30142 int64_t  __attribute__((export_name("TS_AnnouncementSignatures_get_short_channel_id"))) TS_AnnouncementSignatures_get_short_channel_id(uint32_t this_ptr) {
30143         LDKAnnouncementSignatures 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         int64_t ret_conv = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
30148         return ret_conv;
30149 }
30150
30151 void  __attribute__((export_name("TS_AnnouncementSignatures_set_short_channel_id"))) TS_AnnouncementSignatures_set_short_channel_id(uint32_t this_ptr, int64_t val) {
30152         LDKAnnouncementSignatures this_ptr_conv;
30153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30154         this_ptr_conv.is_owned = false;
30155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30156         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
30157 }
30158
30159 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_node_signature"))) TS_AnnouncementSignatures_get_node_signature(uint32_t this_ptr) {
30160         LDKAnnouncementSignatures this_ptr_conv;
30161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30162         this_ptr_conv.is_owned = false;
30163         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30164         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
30165         memcpy(ret_arr->elems, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form, 64);
30166         return ret_arr;
30167 }
30168
30169 void  __attribute__((export_name("TS_AnnouncementSignatures_set_node_signature"))) TS_AnnouncementSignatures_set_node_signature(uint32_t this_ptr, int8_tArray val) {
30170         LDKAnnouncementSignatures this_ptr_conv;
30171         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30172         this_ptr_conv.is_owned = false;
30173         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30174         LDKSignature val_ref;
30175         CHECK(val->arr_len == 64);
30176         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
30177         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
30178 }
30179
30180 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_bitcoin_signature"))) TS_AnnouncementSignatures_get_bitcoin_signature(uint32_t this_ptr) {
30181         LDKAnnouncementSignatures this_ptr_conv;
30182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30183         this_ptr_conv.is_owned = false;
30184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30185         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
30186         memcpy(ret_arr->elems, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form, 64);
30187         return ret_arr;
30188 }
30189
30190 void  __attribute__((export_name("TS_AnnouncementSignatures_set_bitcoin_signature"))) TS_AnnouncementSignatures_set_bitcoin_signature(uint32_t this_ptr, int8_tArray val) {
30191         LDKAnnouncementSignatures this_ptr_conv;
30192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30193         this_ptr_conv.is_owned = false;
30194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30195         LDKSignature val_ref;
30196         CHECK(val->arr_len == 64);
30197         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
30198         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
30199 }
30200
30201 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) {
30202         LDKThirtyTwoBytes channel_id_arg_ref;
30203         CHECK(channel_id_arg->arr_len == 32);
30204         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
30205         LDKSignature node_signature_arg_ref;
30206         CHECK(node_signature_arg->arr_len == 64);
30207         memcpy(node_signature_arg_ref.compact_form, node_signature_arg->elems, 64); FREE(node_signature_arg);
30208         LDKSignature bitcoin_signature_arg_ref;
30209         CHECK(bitcoin_signature_arg->arr_len == 64);
30210         memcpy(bitcoin_signature_arg_ref.compact_form, bitcoin_signature_arg->elems, 64); FREE(bitcoin_signature_arg);
30211         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
30212         uint32_t ret_ref = 0;
30213         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30214         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30215         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30216         ret_ref = (uintptr_t)ret_var.inner;
30217         if (ret_var.is_owned) {
30218                 ret_ref |= 1;
30219         }
30220         return ret_ref;
30221 }
30222
30223 static inline uintptr_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
30224         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
30225 uint32_t ret_ref = 0;
30226 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30227 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30228 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30229 ret_ref = (uintptr_t)ret_var.inner;
30230 if (ret_var.is_owned) {
30231         ret_ref |= 1;
30232 }
30233         return ret_ref;
30234 }
30235 uint32_t  __attribute__((export_name("TS_AnnouncementSignatures_clone_ptr"))) TS_AnnouncementSignatures_clone_ptr(uint32_t arg) {
30236         LDKAnnouncementSignatures arg_conv;
30237         arg_conv.inner = (void*)(arg & (~1));
30238         arg_conv.is_owned = false;
30239         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30240         uint32_t ret_conv = AnnouncementSignatures_clone_ptr(&arg_conv);
30241         return ret_conv;
30242 }
30243
30244 uint32_t  __attribute__((export_name("TS_AnnouncementSignatures_clone"))) TS_AnnouncementSignatures_clone(uint32_t orig) {
30245         LDKAnnouncementSignatures orig_conv;
30246         orig_conv.inner = (void*)(orig & (~1));
30247         orig_conv.is_owned = false;
30248         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30249         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
30250         uint32_t ret_ref = 0;
30251         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30252         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30253         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30254         ret_ref = (uintptr_t)ret_var.inner;
30255         if (ret_var.is_owned) {
30256                 ret_ref |= 1;
30257         }
30258         return ret_ref;
30259 }
30260
30261 void  __attribute__((export_name("TS_NetAddress_free"))) TS_NetAddress_free(uint32_t this_ptr) {
30262         if ((this_ptr & 1) != 0) return;
30263         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
30264         CHECK_ACCESS(this_ptr_ptr);
30265         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
30266         FREE((void*)this_ptr);
30267         NetAddress_free(this_ptr_conv);
30268 }
30269
30270 static inline uintptr_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
30271         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
30272         *ret_copy = NetAddress_clone(arg);
30273 uint32_t ret_ref = (uintptr_t)ret_copy;
30274         return ret_ref;
30275 }
30276 uint32_t  __attribute__((export_name("TS_NetAddress_clone_ptr"))) TS_NetAddress_clone_ptr(uint32_t arg) {
30277         LDKNetAddress* arg_conv = (LDKNetAddress*)arg;
30278         uint32_t ret_conv = NetAddress_clone_ptr(arg_conv);
30279         return ret_conv;
30280 }
30281
30282 uint32_t  __attribute__((export_name("TS_NetAddress_clone"))) TS_NetAddress_clone(uint32_t orig) {
30283         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
30284         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
30285         *ret_copy = NetAddress_clone(orig_conv);
30286         uint32_t ret_ref = (uintptr_t)ret_copy;
30287         return ret_ref;
30288 }
30289
30290 uint32_t  __attribute__((export_name("TS_NetAddress_ipv4"))) TS_NetAddress_ipv4(int8_tArray addr, int16_t port) {
30291         LDKFourBytes addr_ref;
30292         CHECK(addr->arr_len == 4);
30293         memcpy(addr_ref.data, addr->elems, 4); FREE(addr);
30294         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
30295         *ret_copy = NetAddress_ipv4(addr_ref, port);
30296         uint32_t ret_ref = (uintptr_t)ret_copy;
30297         return ret_ref;
30298 }
30299
30300 uint32_t  __attribute__((export_name("TS_NetAddress_ipv6"))) TS_NetAddress_ipv6(int8_tArray addr, int16_t port) {
30301         LDKSixteenBytes addr_ref;
30302         CHECK(addr->arr_len == 16);
30303         memcpy(addr_ref.data, addr->elems, 16); FREE(addr);
30304         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
30305         *ret_copy = NetAddress_ipv6(addr_ref, port);
30306         uint32_t ret_ref = (uintptr_t)ret_copy;
30307         return ret_ref;
30308 }
30309
30310 uint32_t  __attribute__((export_name("TS_NetAddress_onion_v2"))) TS_NetAddress_onion_v2(int8_tArray a) {
30311         LDKTwelveBytes a_ref;
30312         CHECK(a->arr_len == 12);
30313         memcpy(a_ref.data, a->elems, 12); FREE(a);
30314         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
30315         *ret_copy = NetAddress_onion_v2(a_ref);
30316         uint32_t ret_ref = (uintptr_t)ret_copy;
30317         return ret_ref;
30318 }
30319
30320 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) {
30321         LDKThirtyTwoBytes ed25519_pubkey_ref;
30322         CHECK(ed25519_pubkey->arr_len == 32);
30323         memcpy(ed25519_pubkey_ref.data, ed25519_pubkey->elems, 32); FREE(ed25519_pubkey);
30324         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
30325         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
30326         uint32_t ret_ref = (uintptr_t)ret_copy;
30327         return ret_ref;
30328 }
30329
30330 int8_tArray  __attribute__((export_name("TS_NetAddress_write"))) TS_NetAddress_write(uint32_t obj) {
30331         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
30332         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
30333         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
30334         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
30335         CVec_u8Z_free(ret_var);
30336         return ret_arr;
30337 }
30338
30339 uint32_t  __attribute__((export_name("TS_NetAddress_read"))) TS_NetAddress_read(int8_tArray ser) {
30340         LDKu8slice ser_ref;
30341         ser_ref.datalen = ser->arr_len;
30342         ser_ref.data = ser->elems /* XXX ser leaks */;
30343         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
30344         *ret_conv = NetAddress_read(ser_ref);
30345         return (uint32_t)ret_conv;
30346 }
30347
30348 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_free"))) TS_UnsignedNodeAnnouncement_free(uint32_t this_obj) {
30349         LDKUnsignedNodeAnnouncement this_obj_conv;
30350         this_obj_conv.inner = (void*)(this_obj & (~1));
30351         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30353         UnsignedNodeAnnouncement_free(this_obj_conv);
30354 }
30355
30356 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_features"))) TS_UnsignedNodeAnnouncement_get_features(uint32_t this_ptr) {
30357         LDKUnsignedNodeAnnouncement this_ptr_conv;
30358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30359         this_ptr_conv.is_owned = false;
30360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30361         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
30362         uint32_t ret_ref = 0;
30363         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30364         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30365         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30366         ret_ref = (uintptr_t)ret_var.inner;
30367         if (ret_var.is_owned) {
30368                 ret_ref |= 1;
30369         }
30370         return ret_ref;
30371 }
30372
30373 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_features"))) TS_UnsignedNodeAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
30374         LDKUnsignedNodeAnnouncement this_ptr_conv;
30375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30376         this_ptr_conv.is_owned = false;
30377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30378         LDKNodeFeatures val_conv;
30379         val_conv.inner = (void*)(val & (~1));
30380         val_conv.is_owned = (val & 1) || (val == 0);
30381         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30382         val_conv = NodeFeatures_clone(&val_conv);
30383         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
30384 }
30385
30386 int32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_timestamp"))) TS_UnsignedNodeAnnouncement_get_timestamp(uint32_t this_ptr) {
30387         LDKUnsignedNodeAnnouncement this_ptr_conv;
30388         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30389         this_ptr_conv.is_owned = false;
30390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30391         int32_t ret_conv = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
30392         return ret_conv;
30393 }
30394
30395 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_timestamp"))) TS_UnsignedNodeAnnouncement_set_timestamp(uint32_t this_ptr, int32_t val) {
30396         LDKUnsignedNodeAnnouncement this_ptr_conv;
30397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30398         this_ptr_conv.is_owned = false;
30399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30400         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
30401 }
30402
30403 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_node_id"))) TS_UnsignedNodeAnnouncement_get_node_id(uint32_t this_ptr) {
30404         LDKUnsignedNodeAnnouncement this_ptr_conv;
30405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30406         this_ptr_conv.is_owned = false;
30407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30408         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
30409         memcpy(ret_arr->elems, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form, 33);
30410         return ret_arr;
30411 }
30412
30413 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_node_id"))) TS_UnsignedNodeAnnouncement_set_node_id(uint32_t this_ptr, int8_tArray val) {
30414         LDKUnsignedNodeAnnouncement this_ptr_conv;
30415         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30416         this_ptr_conv.is_owned = false;
30417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30418         LDKPublicKey val_ref;
30419         CHECK(val->arr_len == 33);
30420         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
30421         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
30422 }
30423
30424 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_rgb"))) TS_UnsignedNodeAnnouncement_get_rgb(uint32_t this_ptr) {
30425         LDKUnsignedNodeAnnouncement this_ptr_conv;
30426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30427         this_ptr_conv.is_owned = false;
30428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30429         int8_tArray ret_arr = init_int8_tArray(3, __LINE__);
30430         memcpy(ret_arr->elems, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv), 3);
30431         return ret_arr;
30432 }
30433
30434 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_rgb"))) TS_UnsignedNodeAnnouncement_set_rgb(uint32_t this_ptr, int8_tArray val) {
30435         LDKUnsignedNodeAnnouncement this_ptr_conv;
30436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30437         this_ptr_conv.is_owned = false;
30438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30439         LDKThreeBytes val_ref;
30440         CHECK(val->arr_len == 3);
30441         memcpy(val_ref.data, val->elems, 3); FREE(val);
30442         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
30443 }
30444
30445 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_alias"))) TS_UnsignedNodeAnnouncement_get_alias(uint32_t this_ptr) {
30446         LDKUnsignedNodeAnnouncement this_ptr_conv;
30447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30448         this_ptr_conv.is_owned = false;
30449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30450         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30451         memcpy(ret_arr->elems, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv), 32);
30452         return ret_arr;
30453 }
30454
30455 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_alias"))) TS_UnsignedNodeAnnouncement_set_alias(uint32_t this_ptr, int8_tArray val) {
30456         LDKUnsignedNodeAnnouncement this_ptr_conv;
30457         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30458         this_ptr_conv.is_owned = false;
30459         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30460         LDKThirtyTwoBytes val_ref;
30461         CHECK(val->arr_len == 32);
30462         memcpy(val_ref.data, val->elems, 32); FREE(val);
30463         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
30464 }
30465
30466 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_addresses"))) TS_UnsignedNodeAnnouncement_set_addresses(uint32_t this_ptr, uint32_tArray val) {
30467         LDKUnsignedNodeAnnouncement this_ptr_conv;
30468         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30469         this_ptr_conv.is_owned = false;
30470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30471         LDKCVec_NetAddressZ val_constr;
30472         val_constr.datalen = val->arr_len;
30473         if (val_constr.datalen > 0)
30474                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
30475         else
30476                 val_constr.data = NULL;
30477         uint32_t* val_vals = val->elems /* XXX val leaks */;
30478         for (size_t m = 0; m < val_constr.datalen; m++) {
30479                 uint32_t val_conv_12 = val_vals[m];
30480                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
30481                 CHECK_ACCESS(val_conv_12_ptr);
30482                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
30483                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
30484                 val_constr.data[m] = val_conv_12_conv;
30485         }
30486         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
30487 }
30488
30489 static inline uintptr_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
30490         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
30491 uint32_t ret_ref = 0;
30492 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30493 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30494 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30495 ret_ref = (uintptr_t)ret_var.inner;
30496 if (ret_var.is_owned) {
30497         ret_ref |= 1;
30498 }
30499         return ret_ref;
30500 }
30501 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_clone_ptr"))) TS_UnsignedNodeAnnouncement_clone_ptr(uint32_t arg) {
30502         LDKUnsignedNodeAnnouncement arg_conv;
30503         arg_conv.inner = (void*)(arg & (~1));
30504         arg_conv.is_owned = false;
30505         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30506         uint32_t ret_conv = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
30507         return ret_conv;
30508 }
30509
30510 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_clone"))) TS_UnsignedNodeAnnouncement_clone(uint32_t orig) {
30511         LDKUnsignedNodeAnnouncement orig_conv;
30512         orig_conv.inner = (void*)(orig & (~1));
30513         orig_conv.is_owned = false;
30514         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30515         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
30516         uint32_t ret_ref = 0;
30517         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30518         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30519         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30520         ret_ref = (uintptr_t)ret_var.inner;
30521         if (ret_var.is_owned) {
30522                 ret_ref |= 1;
30523         }
30524         return ret_ref;
30525 }
30526
30527 void  __attribute__((export_name("TS_NodeAnnouncement_free"))) TS_NodeAnnouncement_free(uint32_t this_obj) {
30528         LDKNodeAnnouncement this_obj_conv;
30529         this_obj_conv.inner = (void*)(this_obj & (~1));
30530         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30531         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30532         NodeAnnouncement_free(this_obj_conv);
30533 }
30534
30535 int8_tArray  __attribute__((export_name("TS_NodeAnnouncement_get_signature"))) TS_NodeAnnouncement_get_signature(uint32_t this_ptr) {
30536         LDKNodeAnnouncement this_ptr_conv;
30537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30538         this_ptr_conv.is_owned = false;
30539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30540         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
30541         memcpy(ret_arr->elems, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form, 64);
30542         return ret_arr;
30543 }
30544
30545 void  __attribute__((export_name("TS_NodeAnnouncement_set_signature"))) TS_NodeAnnouncement_set_signature(uint32_t this_ptr, int8_tArray val) {
30546         LDKNodeAnnouncement this_ptr_conv;
30547         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30548         this_ptr_conv.is_owned = false;
30549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30550         LDKSignature val_ref;
30551         CHECK(val->arr_len == 64);
30552         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
30553         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
30554 }
30555
30556 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_get_contents"))) TS_NodeAnnouncement_get_contents(uint32_t this_ptr) {
30557         LDKNodeAnnouncement this_ptr_conv;
30558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30559         this_ptr_conv.is_owned = false;
30560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30561         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
30562         uint32_t ret_ref = 0;
30563         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30564         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30565         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30566         ret_ref = (uintptr_t)ret_var.inner;
30567         if (ret_var.is_owned) {
30568                 ret_ref |= 1;
30569         }
30570         return ret_ref;
30571 }
30572
30573 void  __attribute__((export_name("TS_NodeAnnouncement_set_contents"))) TS_NodeAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
30574         LDKNodeAnnouncement this_ptr_conv;
30575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30576         this_ptr_conv.is_owned = false;
30577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30578         LDKUnsignedNodeAnnouncement val_conv;
30579         val_conv.inner = (void*)(val & (~1));
30580         val_conv.is_owned = (val & 1) || (val == 0);
30581         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30582         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
30583         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
30584 }
30585
30586 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_new"))) TS_NodeAnnouncement_new(int8_tArray signature_arg, uint32_t contents_arg) {
30587         LDKSignature signature_arg_ref;
30588         CHECK(signature_arg->arr_len == 64);
30589         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
30590         LDKUnsignedNodeAnnouncement contents_arg_conv;
30591         contents_arg_conv.inner = (void*)(contents_arg & (~1));
30592         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
30593         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
30594         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
30595         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
30596         uint32_t ret_ref = 0;
30597         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30598         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30599         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30600         ret_ref = (uintptr_t)ret_var.inner;
30601         if (ret_var.is_owned) {
30602                 ret_ref |= 1;
30603         }
30604         return ret_ref;
30605 }
30606
30607 static inline uintptr_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
30608         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
30609 uint32_t ret_ref = 0;
30610 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30611 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30612 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30613 ret_ref = (uintptr_t)ret_var.inner;
30614 if (ret_var.is_owned) {
30615         ret_ref |= 1;
30616 }
30617         return ret_ref;
30618 }
30619 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_clone_ptr"))) TS_NodeAnnouncement_clone_ptr(uint32_t arg) {
30620         LDKNodeAnnouncement arg_conv;
30621         arg_conv.inner = (void*)(arg & (~1));
30622         arg_conv.is_owned = false;
30623         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30624         uint32_t ret_conv = NodeAnnouncement_clone_ptr(&arg_conv);
30625         return ret_conv;
30626 }
30627
30628 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_clone"))) TS_NodeAnnouncement_clone(uint32_t orig) {
30629         LDKNodeAnnouncement orig_conv;
30630         orig_conv.inner = (void*)(orig & (~1));
30631         orig_conv.is_owned = false;
30632         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30633         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
30634         uint32_t ret_ref = 0;
30635         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30636         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30637         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30638         ret_ref = (uintptr_t)ret_var.inner;
30639         if (ret_var.is_owned) {
30640                 ret_ref |= 1;
30641         }
30642         return ret_ref;
30643 }
30644
30645 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_free"))) TS_UnsignedChannelAnnouncement_free(uint32_t this_obj) {
30646         LDKUnsignedChannelAnnouncement this_obj_conv;
30647         this_obj_conv.inner = (void*)(this_obj & (~1));
30648         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30649         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30650         UnsignedChannelAnnouncement_free(this_obj_conv);
30651 }
30652
30653 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_features"))) TS_UnsignedChannelAnnouncement_get_features(uint32_t this_ptr) {
30654         LDKUnsignedChannelAnnouncement this_ptr_conv;
30655         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30656         this_ptr_conv.is_owned = false;
30657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30658         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
30659         uint32_t ret_ref = 0;
30660         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30661         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30662         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30663         ret_ref = (uintptr_t)ret_var.inner;
30664         if (ret_var.is_owned) {
30665                 ret_ref |= 1;
30666         }
30667         return ret_ref;
30668 }
30669
30670 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_features"))) TS_UnsignedChannelAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
30671         LDKUnsignedChannelAnnouncement this_ptr_conv;
30672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30673         this_ptr_conv.is_owned = false;
30674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30675         LDKChannelFeatures val_conv;
30676         val_conv.inner = (void*)(val & (~1));
30677         val_conv.is_owned = (val & 1) || (val == 0);
30678         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30679         val_conv = ChannelFeatures_clone(&val_conv);
30680         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
30681 }
30682
30683 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_chain_hash"))) TS_UnsignedChannelAnnouncement_get_chain_hash(uint32_t this_ptr) {
30684         LDKUnsignedChannelAnnouncement 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         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30689         memcpy(ret_arr->elems, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv), 32);
30690         return ret_arr;
30691 }
30692
30693 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_chain_hash"))) TS_UnsignedChannelAnnouncement_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
30694         LDKUnsignedChannelAnnouncement this_ptr_conv;
30695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30696         this_ptr_conv.is_owned = false;
30697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30698         LDKThirtyTwoBytes val_ref;
30699         CHECK(val->arr_len == 32);
30700         memcpy(val_ref.data, val->elems, 32); FREE(val);
30701         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
30702 }
30703
30704 int64_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_short_channel_id"))) TS_UnsignedChannelAnnouncement_get_short_channel_id(uint32_t this_ptr) {
30705         LDKUnsignedChannelAnnouncement 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         int64_t ret_conv = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
30710         return ret_conv;
30711 }
30712
30713 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_short_channel_id"))) TS_UnsignedChannelAnnouncement_set_short_channel_id(uint32_t this_ptr, int64_t val) {
30714         LDKUnsignedChannelAnnouncement this_ptr_conv;
30715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30716         this_ptr_conv.is_owned = false;
30717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30718         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
30719 }
30720
30721 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_node_id_1"))) TS_UnsignedChannelAnnouncement_get_node_id_1(uint32_t this_ptr) {
30722         LDKUnsignedChannelAnnouncement this_ptr_conv;
30723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30724         this_ptr_conv.is_owned = false;
30725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30726         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
30727         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form, 33);
30728         return ret_arr;
30729 }
30730
30731 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_node_id_1"))) TS_UnsignedChannelAnnouncement_set_node_id_1(uint32_t this_ptr, int8_tArray val) {
30732         LDKUnsignedChannelAnnouncement this_ptr_conv;
30733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30734         this_ptr_conv.is_owned = false;
30735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30736         LDKPublicKey val_ref;
30737         CHECK(val->arr_len == 33);
30738         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
30739         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
30740 }
30741
30742 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_node_id_2"))) TS_UnsignedChannelAnnouncement_get_node_id_2(uint32_t this_ptr) {
30743         LDKUnsignedChannelAnnouncement this_ptr_conv;
30744         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30745         this_ptr_conv.is_owned = false;
30746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30747         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
30748         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form, 33);
30749         return ret_arr;
30750 }
30751
30752 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_node_id_2"))) TS_UnsignedChannelAnnouncement_set_node_id_2(uint32_t this_ptr, int8_tArray val) {
30753         LDKUnsignedChannelAnnouncement this_ptr_conv;
30754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30755         this_ptr_conv.is_owned = false;
30756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30757         LDKPublicKey val_ref;
30758         CHECK(val->arr_len == 33);
30759         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
30760         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
30761 }
30762
30763 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_bitcoin_key_1"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_1(uint32_t this_ptr) {
30764         LDKUnsignedChannelAnnouncement this_ptr_conv;
30765         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30766         this_ptr_conv.is_owned = false;
30767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30768         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
30769         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form, 33);
30770         return ret_arr;
30771 }
30772
30773 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_bitcoin_key_1"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_1(uint32_t this_ptr, int8_tArray val) {
30774         LDKUnsignedChannelAnnouncement this_ptr_conv;
30775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30776         this_ptr_conv.is_owned = false;
30777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30778         LDKPublicKey val_ref;
30779         CHECK(val->arr_len == 33);
30780         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
30781         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
30782 }
30783
30784 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_bitcoin_key_2"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_2(uint32_t this_ptr) {
30785         LDKUnsignedChannelAnnouncement this_ptr_conv;
30786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30787         this_ptr_conv.is_owned = false;
30788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30789         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
30790         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form, 33);
30791         return ret_arr;
30792 }
30793
30794 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_bitcoin_key_2"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_2(uint32_t this_ptr, int8_tArray val) {
30795         LDKUnsignedChannelAnnouncement this_ptr_conv;
30796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30797         this_ptr_conv.is_owned = false;
30798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30799         LDKPublicKey val_ref;
30800         CHECK(val->arr_len == 33);
30801         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
30802         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
30803 }
30804
30805 static inline uintptr_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
30806         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
30807 uint32_t ret_ref = 0;
30808 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30809 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30810 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30811 ret_ref = (uintptr_t)ret_var.inner;
30812 if (ret_var.is_owned) {
30813         ret_ref |= 1;
30814 }
30815         return ret_ref;
30816 }
30817 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_clone_ptr"))) TS_UnsignedChannelAnnouncement_clone_ptr(uint32_t arg) {
30818         LDKUnsignedChannelAnnouncement arg_conv;
30819         arg_conv.inner = (void*)(arg & (~1));
30820         arg_conv.is_owned = false;
30821         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30822         uint32_t ret_conv = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
30823         return ret_conv;
30824 }
30825
30826 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_clone"))) TS_UnsignedChannelAnnouncement_clone(uint32_t orig) {
30827         LDKUnsignedChannelAnnouncement orig_conv;
30828         orig_conv.inner = (void*)(orig & (~1));
30829         orig_conv.is_owned = false;
30830         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30831         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
30832         uint32_t ret_ref = 0;
30833         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30834         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30835         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30836         ret_ref = (uintptr_t)ret_var.inner;
30837         if (ret_var.is_owned) {
30838                 ret_ref |= 1;
30839         }
30840         return ret_ref;
30841 }
30842
30843 void  __attribute__((export_name("TS_ChannelAnnouncement_free"))) TS_ChannelAnnouncement_free(uint32_t this_obj) {
30844         LDKChannelAnnouncement this_obj_conv;
30845         this_obj_conv.inner = (void*)(this_obj & (~1));
30846         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30848         ChannelAnnouncement_free(this_obj_conv);
30849 }
30850
30851 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_node_signature_1"))) TS_ChannelAnnouncement_get_node_signature_1(uint32_t this_ptr) {
30852         LDKChannelAnnouncement this_ptr_conv;
30853         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30854         this_ptr_conv.is_owned = false;
30855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30856         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
30857         memcpy(ret_arr->elems, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form, 64);
30858         return ret_arr;
30859 }
30860
30861 void  __attribute__((export_name("TS_ChannelAnnouncement_set_node_signature_1"))) TS_ChannelAnnouncement_set_node_signature_1(uint32_t this_ptr, int8_tArray val) {
30862         LDKChannelAnnouncement this_ptr_conv;
30863         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30864         this_ptr_conv.is_owned = false;
30865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30866         LDKSignature val_ref;
30867         CHECK(val->arr_len == 64);
30868         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
30869         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
30870 }
30871
30872 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_node_signature_2"))) TS_ChannelAnnouncement_get_node_signature_2(uint32_t this_ptr) {
30873         LDKChannelAnnouncement this_ptr_conv;
30874         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30875         this_ptr_conv.is_owned = false;
30876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30877         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
30878         memcpy(ret_arr->elems, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form, 64);
30879         return ret_arr;
30880 }
30881
30882 void  __attribute__((export_name("TS_ChannelAnnouncement_set_node_signature_2"))) TS_ChannelAnnouncement_set_node_signature_2(uint32_t this_ptr, int8_tArray val) {
30883         LDKChannelAnnouncement this_ptr_conv;
30884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30885         this_ptr_conv.is_owned = false;
30886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30887         LDKSignature val_ref;
30888         CHECK(val->arr_len == 64);
30889         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
30890         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
30891 }
30892
30893 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_bitcoin_signature_1"))) TS_ChannelAnnouncement_get_bitcoin_signature_1(uint32_t this_ptr) {
30894         LDKChannelAnnouncement this_ptr_conv;
30895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30896         this_ptr_conv.is_owned = false;
30897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30898         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
30899         memcpy(ret_arr->elems, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form, 64);
30900         return ret_arr;
30901 }
30902
30903 void  __attribute__((export_name("TS_ChannelAnnouncement_set_bitcoin_signature_1"))) TS_ChannelAnnouncement_set_bitcoin_signature_1(uint32_t this_ptr, int8_tArray val) {
30904         LDKChannelAnnouncement this_ptr_conv;
30905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30906         this_ptr_conv.is_owned = false;
30907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30908         LDKSignature val_ref;
30909         CHECK(val->arr_len == 64);
30910         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
30911         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
30912 }
30913
30914 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_bitcoin_signature_2"))) TS_ChannelAnnouncement_get_bitcoin_signature_2(uint32_t this_ptr) {
30915         LDKChannelAnnouncement this_ptr_conv;
30916         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30917         this_ptr_conv.is_owned = false;
30918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30919         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
30920         memcpy(ret_arr->elems, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form, 64);
30921         return ret_arr;
30922 }
30923
30924 void  __attribute__((export_name("TS_ChannelAnnouncement_set_bitcoin_signature_2"))) TS_ChannelAnnouncement_set_bitcoin_signature_2(uint32_t this_ptr, int8_tArray val) {
30925         LDKChannelAnnouncement this_ptr_conv;
30926         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30927         this_ptr_conv.is_owned = false;
30928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30929         LDKSignature val_ref;
30930         CHECK(val->arr_len == 64);
30931         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
30932         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
30933 }
30934
30935 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_get_contents"))) TS_ChannelAnnouncement_get_contents(uint32_t this_ptr) {
30936         LDKChannelAnnouncement this_ptr_conv;
30937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30938         this_ptr_conv.is_owned = false;
30939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30940         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
30941         uint32_t ret_ref = 0;
30942         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30943         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30944         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30945         ret_ref = (uintptr_t)ret_var.inner;
30946         if (ret_var.is_owned) {
30947                 ret_ref |= 1;
30948         }
30949         return ret_ref;
30950 }
30951
30952 void  __attribute__((export_name("TS_ChannelAnnouncement_set_contents"))) TS_ChannelAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
30953         LDKChannelAnnouncement this_ptr_conv;
30954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30955         this_ptr_conv.is_owned = false;
30956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30957         LDKUnsignedChannelAnnouncement val_conv;
30958         val_conv.inner = (void*)(val & (~1));
30959         val_conv.is_owned = (val & 1) || (val == 0);
30960         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30961         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
30962         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
30963 }
30964
30965 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) {
30966         LDKSignature node_signature_1_arg_ref;
30967         CHECK(node_signature_1_arg->arr_len == 64);
30968         memcpy(node_signature_1_arg_ref.compact_form, node_signature_1_arg->elems, 64); FREE(node_signature_1_arg);
30969         LDKSignature node_signature_2_arg_ref;
30970         CHECK(node_signature_2_arg->arr_len == 64);
30971         memcpy(node_signature_2_arg_ref.compact_form, node_signature_2_arg->elems, 64); FREE(node_signature_2_arg);
30972         LDKSignature bitcoin_signature_1_arg_ref;
30973         CHECK(bitcoin_signature_1_arg->arr_len == 64);
30974         memcpy(bitcoin_signature_1_arg_ref.compact_form, bitcoin_signature_1_arg->elems, 64); FREE(bitcoin_signature_1_arg);
30975         LDKSignature bitcoin_signature_2_arg_ref;
30976         CHECK(bitcoin_signature_2_arg->arr_len == 64);
30977         memcpy(bitcoin_signature_2_arg_ref.compact_form, bitcoin_signature_2_arg->elems, 64); FREE(bitcoin_signature_2_arg);
30978         LDKUnsignedChannelAnnouncement contents_arg_conv;
30979         contents_arg_conv.inner = (void*)(contents_arg & (~1));
30980         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
30981         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
30982         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
30983         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);
30984         uint32_t ret_ref = 0;
30985         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30986         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30987         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30988         ret_ref = (uintptr_t)ret_var.inner;
30989         if (ret_var.is_owned) {
30990                 ret_ref |= 1;
30991         }
30992         return ret_ref;
30993 }
30994
30995 static inline uintptr_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
30996         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
30997 uint32_t ret_ref = 0;
30998 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30999 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31000 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31001 ret_ref = (uintptr_t)ret_var.inner;
31002 if (ret_var.is_owned) {
31003         ret_ref |= 1;
31004 }
31005         return ret_ref;
31006 }
31007 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_clone_ptr"))) TS_ChannelAnnouncement_clone_ptr(uint32_t arg) {
31008         LDKChannelAnnouncement arg_conv;
31009         arg_conv.inner = (void*)(arg & (~1));
31010         arg_conv.is_owned = false;
31011         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31012         uint32_t ret_conv = ChannelAnnouncement_clone_ptr(&arg_conv);
31013         return ret_conv;
31014 }
31015
31016 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_clone"))) TS_ChannelAnnouncement_clone(uint32_t orig) {
31017         LDKChannelAnnouncement orig_conv;
31018         orig_conv.inner = (void*)(orig & (~1));
31019         orig_conv.is_owned = false;
31020         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31021         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
31022         uint32_t ret_ref = 0;
31023         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31024         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31025         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31026         ret_ref = (uintptr_t)ret_var.inner;
31027         if (ret_var.is_owned) {
31028                 ret_ref |= 1;
31029         }
31030         return ret_ref;
31031 }
31032
31033 void  __attribute__((export_name("TS_UnsignedChannelUpdate_free"))) TS_UnsignedChannelUpdate_free(uint32_t this_obj) {
31034         LDKUnsignedChannelUpdate this_obj_conv;
31035         this_obj_conv.inner = (void*)(this_obj & (~1));
31036         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31038         UnsignedChannelUpdate_free(this_obj_conv);
31039 }
31040
31041 int8_tArray  __attribute__((export_name("TS_UnsignedChannelUpdate_get_chain_hash"))) TS_UnsignedChannelUpdate_get_chain_hash(uint32_t this_ptr) {
31042         LDKUnsignedChannelUpdate this_ptr_conv;
31043         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31044         this_ptr_conv.is_owned = false;
31045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31046         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
31047         memcpy(ret_arr->elems, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv), 32);
31048         return ret_arr;
31049 }
31050
31051 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_chain_hash"))) TS_UnsignedChannelUpdate_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
31052         LDKUnsignedChannelUpdate this_ptr_conv;
31053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31054         this_ptr_conv.is_owned = false;
31055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31056         LDKThirtyTwoBytes val_ref;
31057         CHECK(val->arr_len == 32);
31058         memcpy(val_ref.data, val->elems, 32); FREE(val);
31059         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
31060 }
31061
31062 int64_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_short_channel_id"))) TS_UnsignedChannelUpdate_get_short_channel_id(uint32_t this_ptr) {
31063         LDKUnsignedChannelUpdate this_ptr_conv;
31064         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31065         this_ptr_conv.is_owned = false;
31066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31067         int64_t ret_conv = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
31068         return ret_conv;
31069 }
31070
31071 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_short_channel_id"))) TS_UnsignedChannelUpdate_set_short_channel_id(uint32_t this_ptr, int64_t val) {
31072         LDKUnsignedChannelUpdate this_ptr_conv;
31073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31074         this_ptr_conv.is_owned = false;
31075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31076         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
31077 }
31078
31079 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_timestamp"))) TS_UnsignedChannelUpdate_get_timestamp(uint32_t this_ptr) {
31080         LDKUnsignedChannelUpdate this_ptr_conv;
31081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31082         this_ptr_conv.is_owned = false;
31083         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31084         int32_t ret_conv = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
31085         return ret_conv;
31086 }
31087
31088 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_timestamp"))) TS_UnsignedChannelUpdate_set_timestamp(uint32_t this_ptr, int32_t val) {
31089         LDKUnsignedChannelUpdate this_ptr_conv;
31090         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31091         this_ptr_conv.is_owned = false;
31092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31093         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
31094 }
31095
31096 int8_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_flags"))) TS_UnsignedChannelUpdate_get_flags(uint32_t this_ptr) {
31097         LDKUnsignedChannelUpdate this_ptr_conv;
31098         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31099         this_ptr_conv.is_owned = false;
31100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31101         int8_t ret_conv = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
31102         return ret_conv;
31103 }
31104
31105 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_flags"))) TS_UnsignedChannelUpdate_set_flags(uint32_t this_ptr, int8_t val) {
31106         LDKUnsignedChannelUpdate this_ptr_conv;
31107         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31108         this_ptr_conv.is_owned = false;
31109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31110         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
31111 }
31112
31113 int16_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_cltv_expiry_delta"))) TS_UnsignedChannelUpdate_get_cltv_expiry_delta(uint32_t this_ptr) {
31114         LDKUnsignedChannelUpdate this_ptr_conv;
31115         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31116         this_ptr_conv.is_owned = false;
31117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31118         int16_t ret_conv = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
31119         return ret_conv;
31120 }
31121
31122 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_cltv_expiry_delta"))) TS_UnsignedChannelUpdate_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
31123         LDKUnsignedChannelUpdate this_ptr_conv;
31124         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31125         this_ptr_conv.is_owned = false;
31126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31127         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
31128 }
31129
31130 int64_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_htlc_minimum_msat"))) TS_UnsignedChannelUpdate_get_htlc_minimum_msat(uint32_t this_ptr) {
31131         LDKUnsignedChannelUpdate this_ptr_conv;
31132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31133         this_ptr_conv.is_owned = false;
31134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31135         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
31136         return ret_conv;
31137 }
31138
31139 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_htlc_minimum_msat"))) TS_UnsignedChannelUpdate_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
31140         LDKUnsignedChannelUpdate this_ptr_conv;
31141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31142         this_ptr_conv.is_owned = false;
31143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31144         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
31145 }
31146
31147 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_fee_base_msat"))) TS_UnsignedChannelUpdate_get_fee_base_msat(uint32_t this_ptr) {
31148         LDKUnsignedChannelUpdate this_ptr_conv;
31149         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31150         this_ptr_conv.is_owned = false;
31151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31152         int32_t ret_conv = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
31153         return ret_conv;
31154 }
31155
31156 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_fee_base_msat"))) TS_UnsignedChannelUpdate_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
31157         LDKUnsignedChannelUpdate this_ptr_conv;
31158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31159         this_ptr_conv.is_owned = false;
31160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31161         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
31162 }
31163
31164 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_fee_proportional_millionths"))) TS_UnsignedChannelUpdate_get_fee_proportional_millionths(uint32_t this_ptr) {
31165         LDKUnsignedChannelUpdate this_ptr_conv;
31166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31167         this_ptr_conv.is_owned = false;
31168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31169         int32_t ret_conv = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
31170         return ret_conv;
31171 }
31172
31173 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_fee_proportional_millionths"))) TS_UnsignedChannelUpdate_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
31174         LDKUnsignedChannelUpdate this_ptr_conv;
31175         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31176         this_ptr_conv.is_owned = false;
31177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31178         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
31179 }
31180
31181 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_excess_data"))) TS_UnsignedChannelUpdate_set_excess_data(uint32_t this_ptr, int8_tArray val) {
31182         LDKUnsignedChannelUpdate this_ptr_conv;
31183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31184         this_ptr_conv.is_owned = false;
31185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31186         LDKCVec_u8Z val_ref;
31187         val_ref.datalen = val->arr_len;
31188         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
31189         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
31190         UnsignedChannelUpdate_set_excess_data(&this_ptr_conv, val_ref);
31191 }
31192
31193 static inline uintptr_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
31194         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
31195 uint32_t ret_ref = 0;
31196 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31197 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31198 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31199 ret_ref = (uintptr_t)ret_var.inner;
31200 if (ret_var.is_owned) {
31201         ret_ref |= 1;
31202 }
31203         return ret_ref;
31204 }
31205 uint32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_clone_ptr"))) TS_UnsignedChannelUpdate_clone_ptr(uint32_t arg) {
31206         LDKUnsignedChannelUpdate arg_conv;
31207         arg_conv.inner = (void*)(arg & (~1));
31208         arg_conv.is_owned = false;
31209         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31210         uint32_t ret_conv = UnsignedChannelUpdate_clone_ptr(&arg_conv);
31211         return ret_conv;
31212 }
31213
31214 uint32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_clone"))) TS_UnsignedChannelUpdate_clone(uint32_t orig) {
31215         LDKUnsignedChannelUpdate orig_conv;
31216         orig_conv.inner = (void*)(orig & (~1));
31217         orig_conv.is_owned = false;
31218         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31219         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
31220         uint32_t ret_ref = 0;
31221         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31222         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31223         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31224         ret_ref = (uintptr_t)ret_var.inner;
31225         if (ret_var.is_owned) {
31226                 ret_ref |= 1;
31227         }
31228         return ret_ref;
31229 }
31230
31231 void  __attribute__((export_name("TS_ChannelUpdate_free"))) TS_ChannelUpdate_free(uint32_t this_obj) {
31232         LDKChannelUpdate this_obj_conv;
31233         this_obj_conv.inner = (void*)(this_obj & (~1));
31234         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31236         ChannelUpdate_free(this_obj_conv);
31237 }
31238
31239 int8_tArray  __attribute__((export_name("TS_ChannelUpdate_get_signature"))) TS_ChannelUpdate_get_signature(uint32_t this_ptr) {
31240         LDKChannelUpdate this_ptr_conv;
31241         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31242         this_ptr_conv.is_owned = false;
31243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31244         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
31245         memcpy(ret_arr->elems, ChannelUpdate_get_signature(&this_ptr_conv).compact_form, 64);
31246         return ret_arr;
31247 }
31248
31249 void  __attribute__((export_name("TS_ChannelUpdate_set_signature"))) TS_ChannelUpdate_set_signature(uint32_t this_ptr, int8_tArray val) {
31250         LDKChannelUpdate this_ptr_conv;
31251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31252         this_ptr_conv.is_owned = false;
31253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31254         LDKSignature val_ref;
31255         CHECK(val->arr_len == 64);
31256         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
31257         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
31258 }
31259
31260 uint32_t  __attribute__((export_name("TS_ChannelUpdate_get_contents"))) TS_ChannelUpdate_get_contents(uint32_t this_ptr) {
31261         LDKChannelUpdate this_ptr_conv;
31262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31263         this_ptr_conv.is_owned = false;
31264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31265         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
31266         uint32_t ret_ref = 0;
31267         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31268         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31269         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31270         ret_ref = (uintptr_t)ret_var.inner;
31271         if (ret_var.is_owned) {
31272                 ret_ref |= 1;
31273         }
31274         return ret_ref;
31275 }
31276
31277 void  __attribute__((export_name("TS_ChannelUpdate_set_contents"))) TS_ChannelUpdate_set_contents(uint32_t this_ptr, uint32_t val) {
31278         LDKChannelUpdate this_ptr_conv;
31279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31280         this_ptr_conv.is_owned = false;
31281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31282         LDKUnsignedChannelUpdate val_conv;
31283         val_conv.inner = (void*)(val & (~1));
31284         val_conv.is_owned = (val & 1) || (val == 0);
31285         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31286         val_conv = UnsignedChannelUpdate_clone(&val_conv);
31287         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
31288 }
31289
31290 uint32_t  __attribute__((export_name("TS_ChannelUpdate_new"))) TS_ChannelUpdate_new(int8_tArray signature_arg, uint32_t contents_arg) {
31291         LDKSignature signature_arg_ref;
31292         CHECK(signature_arg->arr_len == 64);
31293         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
31294         LDKUnsignedChannelUpdate contents_arg_conv;
31295         contents_arg_conv.inner = (void*)(contents_arg & (~1));
31296         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
31297         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
31298         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
31299         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
31300         uint32_t ret_ref = 0;
31301         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31302         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31303         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31304         ret_ref = (uintptr_t)ret_var.inner;
31305         if (ret_var.is_owned) {
31306                 ret_ref |= 1;
31307         }
31308         return ret_ref;
31309 }
31310
31311 static inline uintptr_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
31312         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
31313 uint32_t ret_ref = 0;
31314 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31315 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31316 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31317 ret_ref = (uintptr_t)ret_var.inner;
31318 if (ret_var.is_owned) {
31319         ret_ref |= 1;
31320 }
31321         return ret_ref;
31322 }
31323 uint32_t  __attribute__((export_name("TS_ChannelUpdate_clone_ptr"))) TS_ChannelUpdate_clone_ptr(uint32_t arg) {
31324         LDKChannelUpdate arg_conv;
31325         arg_conv.inner = (void*)(arg & (~1));
31326         arg_conv.is_owned = false;
31327         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31328         uint32_t ret_conv = ChannelUpdate_clone_ptr(&arg_conv);
31329         return ret_conv;
31330 }
31331
31332 uint32_t  __attribute__((export_name("TS_ChannelUpdate_clone"))) TS_ChannelUpdate_clone(uint32_t orig) {
31333         LDKChannelUpdate orig_conv;
31334         orig_conv.inner = (void*)(orig & (~1));
31335         orig_conv.is_owned = false;
31336         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31337         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
31338         uint32_t ret_ref = 0;
31339         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31340         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31341         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31342         ret_ref = (uintptr_t)ret_var.inner;
31343         if (ret_var.is_owned) {
31344                 ret_ref |= 1;
31345         }
31346         return ret_ref;
31347 }
31348
31349 void  __attribute__((export_name("TS_QueryChannelRange_free"))) TS_QueryChannelRange_free(uint32_t this_obj) {
31350         LDKQueryChannelRange this_obj_conv;
31351         this_obj_conv.inner = (void*)(this_obj & (~1));
31352         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31354         QueryChannelRange_free(this_obj_conv);
31355 }
31356
31357 int8_tArray  __attribute__((export_name("TS_QueryChannelRange_get_chain_hash"))) TS_QueryChannelRange_get_chain_hash(uint32_t this_ptr) {
31358         LDKQueryChannelRange this_ptr_conv;
31359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31360         this_ptr_conv.is_owned = false;
31361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31362         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
31363         memcpy(ret_arr->elems, *QueryChannelRange_get_chain_hash(&this_ptr_conv), 32);
31364         return ret_arr;
31365 }
31366
31367 void  __attribute__((export_name("TS_QueryChannelRange_set_chain_hash"))) TS_QueryChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
31368         LDKQueryChannelRange this_ptr_conv;
31369         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31370         this_ptr_conv.is_owned = false;
31371         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31372         LDKThirtyTwoBytes val_ref;
31373         CHECK(val->arr_len == 32);
31374         memcpy(val_ref.data, val->elems, 32); FREE(val);
31375         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
31376 }
31377
31378 int32_t  __attribute__((export_name("TS_QueryChannelRange_get_first_blocknum"))) TS_QueryChannelRange_get_first_blocknum(uint32_t this_ptr) {
31379         LDKQueryChannelRange this_ptr_conv;
31380         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31381         this_ptr_conv.is_owned = false;
31382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31383         int32_t ret_conv = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
31384         return ret_conv;
31385 }
31386
31387 void  __attribute__((export_name("TS_QueryChannelRange_set_first_blocknum"))) TS_QueryChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
31388         LDKQueryChannelRange this_ptr_conv;
31389         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31390         this_ptr_conv.is_owned = false;
31391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31392         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
31393 }
31394
31395 int32_t  __attribute__((export_name("TS_QueryChannelRange_get_number_of_blocks"))) TS_QueryChannelRange_get_number_of_blocks(uint32_t this_ptr) {
31396         LDKQueryChannelRange this_ptr_conv;
31397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31398         this_ptr_conv.is_owned = false;
31399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31400         int32_t ret_conv = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
31401         return ret_conv;
31402 }
31403
31404 void  __attribute__((export_name("TS_QueryChannelRange_set_number_of_blocks"))) TS_QueryChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
31405         LDKQueryChannelRange this_ptr_conv;
31406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31407         this_ptr_conv.is_owned = false;
31408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31409         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
31410 }
31411
31412 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) {
31413         LDKThirtyTwoBytes chain_hash_arg_ref;
31414         CHECK(chain_hash_arg->arr_len == 32);
31415         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
31416         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
31417         uint32_t ret_ref = 0;
31418         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31419         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31420         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31421         ret_ref = (uintptr_t)ret_var.inner;
31422         if (ret_var.is_owned) {
31423                 ret_ref |= 1;
31424         }
31425         return ret_ref;
31426 }
31427
31428 static inline uintptr_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
31429         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
31430 uint32_t ret_ref = 0;
31431 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31432 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31433 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31434 ret_ref = (uintptr_t)ret_var.inner;
31435 if (ret_var.is_owned) {
31436         ret_ref |= 1;
31437 }
31438         return ret_ref;
31439 }
31440 uint32_t  __attribute__((export_name("TS_QueryChannelRange_clone_ptr"))) TS_QueryChannelRange_clone_ptr(uint32_t arg) {
31441         LDKQueryChannelRange arg_conv;
31442         arg_conv.inner = (void*)(arg & (~1));
31443         arg_conv.is_owned = false;
31444         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31445         uint32_t ret_conv = QueryChannelRange_clone_ptr(&arg_conv);
31446         return ret_conv;
31447 }
31448
31449 uint32_t  __attribute__((export_name("TS_QueryChannelRange_clone"))) TS_QueryChannelRange_clone(uint32_t orig) {
31450         LDKQueryChannelRange orig_conv;
31451         orig_conv.inner = (void*)(orig & (~1));
31452         orig_conv.is_owned = false;
31453         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31454         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
31455         uint32_t ret_ref = 0;
31456         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31457         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31458         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31459         ret_ref = (uintptr_t)ret_var.inner;
31460         if (ret_var.is_owned) {
31461                 ret_ref |= 1;
31462         }
31463         return ret_ref;
31464 }
31465
31466 void  __attribute__((export_name("TS_ReplyChannelRange_free"))) TS_ReplyChannelRange_free(uint32_t this_obj) {
31467         LDKReplyChannelRange this_obj_conv;
31468         this_obj_conv.inner = (void*)(this_obj & (~1));
31469         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31471         ReplyChannelRange_free(this_obj_conv);
31472 }
31473
31474 int8_tArray  __attribute__((export_name("TS_ReplyChannelRange_get_chain_hash"))) TS_ReplyChannelRange_get_chain_hash(uint32_t this_ptr) {
31475         LDKReplyChannelRange this_ptr_conv;
31476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31477         this_ptr_conv.is_owned = false;
31478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31479         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
31480         memcpy(ret_arr->elems, *ReplyChannelRange_get_chain_hash(&this_ptr_conv), 32);
31481         return ret_arr;
31482 }
31483
31484 void  __attribute__((export_name("TS_ReplyChannelRange_set_chain_hash"))) TS_ReplyChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
31485         LDKReplyChannelRange this_ptr_conv;
31486         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31487         this_ptr_conv.is_owned = false;
31488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31489         LDKThirtyTwoBytes val_ref;
31490         CHECK(val->arr_len == 32);
31491         memcpy(val_ref.data, val->elems, 32); FREE(val);
31492         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
31493 }
31494
31495 int32_t  __attribute__((export_name("TS_ReplyChannelRange_get_first_blocknum"))) TS_ReplyChannelRange_get_first_blocknum(uint32_t this_ptr) {
31496         LDKReplyChannelRange this_ptr_conv;
31497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31498         this_ptr_conv.is_owned = false;
31499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31500         int32_t ret_conv = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
31501         return ret_conv;
31502 }
31503
31504 void  __attribute__((export_name("TS_ReplyChannelRange_set_first_blocknum"))) TS_ReplyChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
31505         LDKReplyChannelRange this_ptr_conv;
31506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31507         this_ptr_conv.is_owned = false;
31508         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31509         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
31510 }
31511
31512 int32_t  __attribute__((export_name("TS_ReplyChannelRange_get_number_of_blocks"))) TS_ReplyChannelRange_get_number_of_blocks(uint32_t this_ptr) {
31513         LDKReplyChannelRange this_ptr_conv;
31514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31515         this_ptr_conv.is_owned = false;
31516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31517         int32_t ret_conv = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
31518         return ret_conv;
31519 }
31520
31521 void  __attribute__((export_name("TS_ReplyChannelRange_set_number_of_blocks"))) TS_ReplyChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
31522         LDKReplyChannelRange this_ptr_conv;
31523         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31524         this_ptr_conv.is_owned = false;
31525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31526         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
31527 }
31528
31529 jboolean  __attribute__((export_name("TS_ReplyChannelRange_get_sync_complete"))) TS_ReplyChannelRange_get_sync_complete(uint32_t this_ptr) {
31530         LDKReplyChannelRange this_ptr_conv;
31531         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31532         this_ptr_conv.is_owned = false;
31533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31534         jboolean ret_conv = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
31535         return ret_conv;
31536 }
31537
31538 void  __attribute__((export_name("TS_ReplyChannelRange_set_sync_complete"))) TS_ReplyChannelRange_set_sync_complete(uint32_t this_ptr, jboolean val) {
31539         LDKReplyChannelRange this_ptr_conv;
31540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31541         this_ptr_conv.is_owned = false;
31542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31543         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
31544 }
31545
31546 void  __attribute__((export_name("TS_ReplyChannelRange_set_short_channel_ids"))) TS_ReplyChannelRange_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
31547         LDKReplyChannelRange this_ptr_conv;
31548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31549         this_ptr_conv.is_owned = false;
31550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31551         LDKCVec_u64Z val_constr;
31552         val_constr.datalen = val->arr_len;
31553         if (val_constr.datalen > 0)
31554                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
31555         else
31556                 val_constr.data = NULL;
31557         int64_t* val_vals = val->elems /* XXX val leaks */;
31558         for (size_t i = 0; i < val_constr.datalen; i++) {
31559                 int64_t val_conv_8 = val_vals[i];
31560                 val_constr.data[i] = val_conv_8;
31561         }
31562         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
31563 }
31564
31565 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) {
31566         LDKThirtyTwoBytes chain_hash_arg_ref;
31567         CHECK(chain_hash_arg->arr_len == 32);
31568         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
31569         LDKCVec_u64Z short_channel_ids_arg_constr;
31570         short_channel_ids_arg_constr.datalen = short_channel_ids_arg->arr_len;
31571         if (short_channel_ids_arg_constr.datalen > 0)
31572                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
31573         else
31574                 short_channel_ids_arg_constr.data = NULL;
31575         int64_t* short_channel_ids_arg_vals = short_channel_ids_arg->elems /* XXX short_channel_ids_arg leaks */;
31576         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
31577                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
31578                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
31579         }
31580         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
31581         uint32_t ret_ref = 0;
31582         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31583         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31584         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31585         ret_ref = (uintptr_t)ret_var.inner;
31586         if (ret_var.is_owned) {
31587                 ret_ref |= 1;
31588         }
31589         return ret_ref;
31590 }
31591
31592 static inline uintptr_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
31593         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
31594 uint32_t ret_ref = 0;
31595 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31596 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31597 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31598 ret_ref = (uintptr_t)ret_var.inner;
31599 if (ret_var.is_owned) {
31600         ret_ref |= 1;
31601 }
31602         return ret_ref;
31603 }
31604 uint32_t  __attribute__((export_name("TS_ReplyChannelRange_clone_ptr"))) TS_ReplyChannelRange_clone_ptr(uint32_t arg) {
31605         LDKReplyChannelRange arg_conv;
31606         arg_conv.inner = (void*)(arg & (~1));
31607         arg_conv.is_owned = false;
31608         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31609         uint32_t ret_conv = ReplyChannelRange_clone_ptr(&arg_conv);
31610         return ret_conv;
31611 }
31612
31613 uint32_t  __attribute__((export_name("TS_ReplyChannelRange_clone"))) TS_ReplyChannelRange_clone(uint32_t orig) {
31614         LDKReplyChannelRange orig_conv;
31615         orig_conv.inner = (void*)(orig & (~1));
31616         orig_conv.is_owned = false;
31617         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31618         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
31619         uint32_t ret_ref = 0;
31620         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31621         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31622         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31623         ret_ref = (uintptr_t)ret_var.inner;
31624         if (ret_var.is_owned) {
31625                 ret_ref |= 1;
31626         }
31627         return ret_ref;
31628 }
31629
31630 void  __attribute__((export_name("TS_QueryShortChannelIds_free"))) TS_QueryShortChannelIds_free(uint32_t this_obj) {
31631         LDKQueryShortChannelIds this_obj_conv;
31632         this_obj_conv.inner = (void*)(this_obj & (~1));
31633         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31635         QueryShortChannelIds_free(this_obj_conv);
31636 }
31637
31638 int8_tArray  __attribute__((export_name("TS_QueryShortChannelIds_get_chain_hash"))) TS_QueryShortChannelIds_get_chain_hash(uint32_t this_ptr) {
31639         LDKQueryShortChannelIds this_ptr_conv;
31640         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31641         this_ptr_conv.is_owned = false;
31642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31643         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
31644         memcpy(ret_arr->elems, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv), 32);
31645         return ret_arr;
31646 }
31647
31648 void  __attribute__((export_name("TS_QueryShortChannelIds_set_chain_hash"))) TS_QueryShortChannelIds_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
31649         LDKQueryShortChannelIds this_ptr_conv;
31650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31651         this_ptr_conv.is_owned = false;
31652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31653         LDKThirtyTwoBytes val_ref;
31654         CHECK(val->arr_len == 32);
31655         memcpy(val_ref.data, val->elems, 32); FREE(val);
31656         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
31657 }
31658
31659 void  __attribute__((export_name("TS_QueryShortChannelIds_set_short_channel_ids"))) TS_QueryShortChannelIds_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
31660         LDKQueryShortChannelIds this_ptr_conv;
31661         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31662         this_ptr_conv.is_owned = false;
31663         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31664         LDKCVec_u64Z val_constr;
31665         val_constr.datalen = val->arr_len;
31666         if (val_constr.datalen > 0)
31667                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
31668         else
31669                 val_constr.data = NULL;
31670         int64_t* val_vals = val->elems /* XXX val leaks */;
31671         for (size_t i = 0; i < val_constr.datalen; i++) {
31672                 int64_t val_conv_8 = val_vals[i];
31673                 val_constr.data[i] = val_conv_8;
31674         }
31675         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
31676 }
31677
31678 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_new"))) TS_QueryShortChannelIds_new(int8_tArray chain_hash_arg, int64_tArray short_channel_ids_arg) {
31679         LDKThirtyTwoBytes chain_hash_arg_ref;
31680         CHECK(chain_hash_arg->arr_len == 32);
31681         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
31682         LDKCVec_u64Z short_channel_ids_arg_constr;
31683         short_channel_ids_arg_constr.datalen = short_channel_ids_arg->arr_len;
31684         if (short_channel_ids_arg_constr.datalen > 0)
31685                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
31686         else
31687                 short_channel_ids_arg_constr.data = NULL;
31688         int64_t* short_channel_ids_arg_vals = short_channel_ids_arg->elems /* XXX short_channel_ids_arg leaks */;
31689         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
31690                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
31691                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
31692         }
31693         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
31694         uint32_t ret_ref = 0;
31695         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31696         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31697         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31698         ret_ref = (uintptr_t)ret_var.inner;
31699         if (ret_var.is_owned) {
31700                 ret_ref |= 1;
31701         }
31702         return ret_ref;
31703 }
31704
31705 static inline uintptr_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
31706         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
31707 uint32_t ret_ref = 0;
31708 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31709 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31710 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31711 ret_ref = (uintptr_t)ret_var.inner;
31712 if (ret_var.is_owned) {
31713         ret_ref |= 1;
31714 }
31715         return ret_ref;
31716 }
31717 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_clone_ptr"))) TS_QueryShortChannelIds_clone_ptr(uint32_t arg) {
31718         LDKQueryShortChannelIds arg_conv;
31719         arg_conv.inner = (void*)(arg & (~1));
31720         arg_conv.is_owned = false;
31721         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31722         uint32_t ret_conv = QueryShortChannelIds_clone_ptr(&arg_conv);
31723         return ret_conv;
31724 }
31725
31726 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_clone"))) TS_QueryShortChannelIds_clone(uint32_t orig) {
31727         LDKQueryShortChannelIds orig_conv;
31728         orig_conv.inner = (void*)(orig & (~1));
31729         orig_conv.is_owned = false;
31730         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31731         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
31732         uint32_t ret_ref = 0;
31733         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31734         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31735         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31736         ret_ref = (uintptr_t)ret_var.inner;
31737         if (ret_var.is_owned) {
31738                 ret_ref |= 1;
31739         }
31740         return ret_ref;
31741 }
31742
31743 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_free"))) TS_ReplyShortChannelIdsEnd_free(uint32_t this_obj) {
31744         LDKReplyShortChannelIdsEnd this_obj_conv;
31745         this_obj_conv.inner = (void*)(this_obj & (~1));
31746         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31748         ReplyShortChannelIdsEnd_free(this_obj_conv);
31749 }
31750
31751 int8_tArray  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_get_chain_hash"))) TS_ReplyShortChannelIdsEnd_get_chain_hash(uint32_t this_ptr) {
31752         LDKReplyShortChannelIdsEnd this_ptr_conv;
31753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31754         this_ptr_conv.is_owned = false;
31755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31756         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
31757         memcpy(ret_arr->elems, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv), 32);
31758         return ret_arr;
31759 }
31760
31761 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_set_chain_hash"))) TS_ReplyShortChannelIdsEnd_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
31762         LDKReplyShortChannelIdsEnd this_ptr_conv;
31763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31764         this_ptr_conv.is_owned = false;
31765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31766         LDKThirtyTwoBytes val_ref;
31767         CHECK(val->arr_len == 32);
31768         memcpy(val_ref.data, val->elems, 32); FREE(val);
31769         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
31770 }
31771
31772 jboolean  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_get_full_information"))) TS_ReplyShortChannelIdsEnd_get_full_information(uint32_t this_ptr) {
31773         LDKReplyShortChannelIdsEnd this_ptr_conv;
31774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31775         this_ptr_conv.is_owned = false;
31776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31777         jboolean ret_conv = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
31778         return ret_conv;
31779 }
31780
31781 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_set_full_information"))) TS_ReplyShortChannelIdsEnd_set_full_information(uint32_t this_ptr, jboolean val) {
31782         LDKReplyShortChannelIdsEnd this_ptr_conv;
31783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31784         this_ptr_conv.is_owned = false;
31785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31786         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
31787 }
31788
31789 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_new"))) TS_ReplyShortChannelIdsEnd_new(int8_tArray chain_hash_arg, jboolean full_information_arg) {
31790         LDKThirtyTwoBytes chain_hash_arg_ref;
31791         CHECK(chain_hash_arg->arr_len == 32);
31792         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
31793         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
31794         uint32_t ret_ref = 0;
31795         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31796         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31797         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31798         ret_ref = (uintptr_t)ret_var.inner;
31799         if (ret_var.is_owned) {
31800                 ret_ref |= 1;
31801         }
31802         return ret_ref;
31803 }
31804
31805 static inline uintptr_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
31806         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
31807 uint32_t ret_ref = 0;
31808 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31809 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31810 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31811 ret_ref = (uintptr_t)ret_var.inner;
31812 if (ret_var.is_owned) {
31813         ret_ref |= 1;
31814 }
31815         return ret_ref;
31816 }
31817 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_clone_ptr"))) TS_ReplyShortChannelIdsEnd_clone_ptr(uint32_t arg) {
31818         LDKReplyShortChannelIdsEnd arg_conv;
31819         arg_conv.inner = (void*)(arg & (~1));
31820         arg_conv.is_owned = false;
31821         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31822         uint32_t ret_conv = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
31823         return ret_conv;
31824 }
31825
31826 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_clone"))) TS_ReplyShortChannelIdsEnd_clone(uint32_t orig) {
31827         LDKReplyShortChannelIdsEnd orig_conv;
31828         orig_conv.inner = (void*)(orig & (~1));
31829         orig_conv.is_owned = false;
31830         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31831         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
31832         uint32_t ret_ref = 0;
31833         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31834         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31835         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31836         ret_ref = (uintptr_t)ret_var.inner;
31837         if (ret_var.is_owned) {
31838                 ret_ref |= 1;
31839         }
31840         return ret_ref;
31841 }
31842
31843 void  __attribute__((export_name("TS_GossipTimestampFilter_free"))) TS_GossipTimestampFilter_free(uint32_t this_obj) {
31844         LDKGossipTimestampFilter this_obj_conv;
31845         this_obj_conv.inner = (void*)(this_obj & (~1));
31846         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31848         GossipTimestampFilter_free(this_obj_conv);
31849 }
31850
31851 int8_tArray  __attribute__((export_name("TS_GossipTimestampFilter_get_chain_hash"))) TS_GossipTimestampFilter_get_chain_hash(uint32_t this_ptr) {
31852         LDKGossipTimestampFilter this_ptr_conv;
31853         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31854         this_ptr_conv.is_owned = false;
31855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31856         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
31857         memcpy(ret_arr->elems, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv), 32);
31858         return ret_arr;
31859 }
31860
31861 void  __attribute__((export_name("TS_GossipTimestampFilter_set_chain_hash"))) TS_GossipTimestampFilter_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
31862         LDKGossipTimestampFilter this_ptr_conv;
31863         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31864         this_ptr_conv.is_owned = false;
31865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31866         LDKThirtyTwoBytes val_ref;
31867         CHECK(val->arr_len == 32);
31868         memcpy(val_ref.data, val->elems, 32); FREE(val);
31869         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
31870 }
31871
31872 int32_t  __attribute__((export_name("TS_GossipTimestampFilter_get_first_timestamp"))) TS_GossipTimestampFilter_get_first_timestamp(uint32_t this_ptr) {
31873         LDKGossipTimestampFilter 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         int32_t ret_conv = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
31878         return ret_conv;
31879 }
31880
31881 void  __attribute__((export_name("TS_GossipTimestampFilter_set_first_timestamp"))) TS_GossipTimestampFilter_set_first_timestamp(uint32_t this_ptr, int32_t val) {
31882         LDKGossipTimestampFilter this_ptr_conv;
31883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31884         this_ptr_conv.is_owned = false;
31885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31886         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
31887 }
31888
31889 int32_t  __attribute__((export_name("TS_GossipTimestampFilter_get_timestamp_range"))) TS_GossipTimestampFilter_get_timestamp_range(uint32_t this_ptr) {
31890         LDKGossipTimestampFilter this_ptr_conv;
31891         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31892         this_ptr_conv.is_owned = false;
31893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31894         int32_t ret_conv = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
31895         return ret_conv;
31896 }
31897
31898 void  __attribute__((export_name("TS_GossipTimestampFilter_set_timestamp_range"))) TS_GossipTimestampFilter_set_timestamp_range(uint32_t this_ptr, int32_t val) {
31899         LDKGossipTimestampFilter this_ptr_conv;
31900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31901         this_ptr_conv.is_owned = false;
31902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31903         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
31904 }
31905
31906 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) {
31907         LDKThirtyTwoBytes chain_hash_arg_ref;
31908         CHECK(chain_hash_arg->arr_len == 32);
31909         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
31910         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
31911         uint32_t ret_ref = 0;
31912         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31913         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31914         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31915         ret_ref = (uintptr_t)ret_var.inner;
31916         if (ret_var.is_owned) {
31917                 ret_ref |= 1;
31918         }
31919         return ret_ref;
31920 }
31921
31922 static inline uintptr_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
31923         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
31924 uint32_t ret_ref = 0;
31925 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31926 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31927 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31928 ret_ref = (uintptr_t)ret_var.inner;
31929 if (ret_var.is_owned) {
31930         ret_ref |= 1;
31931 }
31932         return ret_ref;
31933 }
31934 uint32_t  __attribute__((export_name("TS_GossipTimestampFilter_clone_ptr"))) TS_GossipTimestampFilter_clone_ptr(uint32_t arg) {
31935         LDKGossipTimestampFilter arg_conv;
31936         arg_conv.inner = (void*)(arg & (~1));
31937         arg_conv.is_owned = false;
31938         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31939         uint32_t ret_conv = GossipTimestampFilter_clone_ptr(&arg_conv);
31940         return ret_conv;
31941 }
31942
31943 uint32_t  __attribute__((export_name("TS_GossipTimestampFilter_clone"))) TS_GossipTimestampFilter_clone(uint32_t orig) {
31944         LDKGossipTimestampFilter orig_conv;
31945         orig_conv.inner = (void*)(orig & (~1));
31946         orig_conv.is_owned = false;
31947         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31948         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
31949         uint32_t ret_ref = 0;
31950         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31951         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31952         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31953         ret_ref = (uintptr_t)ret_var.inner;
31954         if (ret_var.is_owned) {
31955                 ret_ref |= 1;
31956         }
31957         return ret_ref;
31958 }
31959
31960 void  __attribute__((export_name("TS_ErrorAction_free"))) TS_ErrorAction_free(uint32_t this_ptr) {
31961         if ((this_ptr & 1) != 0) return;
31962         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
31963         CHECK_ACCESS(this_ptr_ptr);
31964         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
31965         FREE((void*)this_ptr);
31966         ErrorAction_free(this_ptr_conv);
31967 }
31968
31969 static inline uintptr_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
31970         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
31971         *ret_copy = ErrorAction_clone(arg);
31972 uint32_t ret_ref = (uintptr_t)ret_copy;
31973         return ret_ref;
31974 }
31975 uint32_t  __attribute__((export_name("TS_ErrorAction_clone_ptr"))) TS_ErrorAction_clone_ptr(uint32_t arg) {
31976         LDKErrorAction* arg_conv = (LDKErrorAction*)arg;
31977         uint32_t ret_conv = ErrorAction_clone_ptr(arg_conv);
31978         return ret_conv;
31979 }
31980
31981 uint32_t  __attribute__((export_name("TS_ErrorAction_clone"))) TS_ErrorAction_clone(uint32_t orig) {
31982         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
31983         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
31984         *ret_copy = ErrorAction_clone(orig_conv);
31985         uint32_t ret_ref = (uintptr_t)ret_copy;
31986         return ret_ref;
31987 }
31988
31989 uint32_t  __attribute__((export_name("TS_ErrorAction_disconnect_peer"))) TS_ErrorAction_disconnect_peer(uint32_t msg) {
31990         LDKErrorMessage msg_conv;
31991         msg_conv.inner = (void*)(msg & (~1));
31992         msg_conv.is_owned = (msg & 1) || (msg == 0);
31993         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
31994         msg_conv = ErrorMessage_clone(&msg_conv);
31995         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
31996         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
31997         uint32_t ret_ref = (uintptr_t)ret_copy;
31998         return ret_ref;
31999 }
32000
32001 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_error"))) TS_ErrorAction_ignore_error() {
32002         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
32003         *ret_copy = ErrorAction_ignore_error();
32004         uint32_t ret_ref = (uintptr_t)ret_copy;
32005         return ret_ref;
32006 }
32007
32008 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_and_log"))) TS_ErrorAction_ignore_and_log(uint32_t a) {
32009         LDKLevel a_conv = LDKLevel_from_js(a);
32010         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
32011         *ret_copy = ErrorAction_ignore_and_log(a_conv);
32012         uint32_t ret_ref = (uintptr_t)ret_copy;
32013         return ret_ref;
32014 }
32015
32016 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_duplicate_gossip"))) TS_ErrorAction_ignore_duplicate_gossip() {
32017         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
32018         *ret_copy = ErrorAction_ignore_duplicate_gossip();
32019         uint32_t ret_ref = (uintptr_t)ret_copy;
32020         return ret_ref;
32021 }
32022
32023 uint32_t  __attribute__((export_name("TS_ErrorAction_send_error_message"))) TS_ErrorAction_send_error_message(uint32_t msg) {
32024         LDKErrorMessage msg_conv;
32025         msg_conv.inner = (void*)(msg & (~1));
32026         msg_conv.is_owned = (msg & 1) || (msg == 0);
32027         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
32028         msg_conv = ErrorMessage_clone(&msg_conv);
32029         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
32030         *ret_copy = ErrorAction_send_error_message(msg_conv);
32031         uint32_t ret_ref = (uintptr_t)ret_copy;
32032         return ret_ref;
32033 }
32034
32035 uint32_t  __attribute__((export_name("TS_ErrorAction_send_warning_message"))) TS_ErrorAction_send_warning_message(uint32_t msg, uint32_t log_level) {
32036         LDKWarningMessage msg_conv;
32037         msg_conv.inner = (void*)(msg & (~1));
32038         msg_conv.is_owned = (msg & 1) || (msg == 0);
32039         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
32040         msg_conv = WarningMessage_clone(&msg_conv);
32041         LDKLevel log_level_conv = LDKLevel_from_js(log_level);
32042         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
32043         *ret_copy = ErrorAction_send_warning_message(msg_conv, log_level_conv);
32044         uint32_t ret_ref = (uintptr_t)ret_copy;
32045         return ret_ref;
32046 }
32047
32048 void  __attribute__((export_name("TS_LightningError_free"))) TS_LightningError_free(uint32_t this_obj) {
32049         LDKLightningError this_obj_conv;
32050         this_obj_conv.inner = (void*)(this_obj & (~1));
32051         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32053         LightningError_free(this_obj_conv);
32054 }
32055
32056 jstring  __attribute__((export_name("TS_LightningError_get_err"))) TS_LightningError_get_err(uint32_t this_ptr) {
32057         LDKLightningError this_ptr_conv;
32058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32059         this_ptr_conv.is_owned = false;
32060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32061         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
32062         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
32063         Str_free(ret_str);
32064         return ret_conv;
32065 }
32066
32067 void  __attribute__((export_name("TS_LightningError_set_err"))) TS_LightningError_set_err(uint32_t this_ptr, jstring val) {
32068         LDKLightningError this_ptr_conv;
32069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32070         this_ptr_conv.is_owned = false;
32071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32072         LDKStr val_conv = str_ref_to_owned_c(val);
32073         LightningError_set_err(&this_ptr_conv, val_conv);
32074 }
32075
32076 uint32_t  __attribute__((export_name("TS_LightningError_get_action"))) TS_LightningError_get_action(uint32_t this_ptr) {
32077         LDKLightningError this_ptr_conv;
32078         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32079         this_ptr_conv.is_owned = false;
32080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32081         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
32082         *ret_copy = LightningError_get_action(&this_ptr_conv);
32083         uint32_t ret_ref = (uintptr_t)ret_copy;
32084         return ret_ref;
32085 }
32086
32087 void  __attribute__((export_name("TS_LightningError_set_action"))) TS_LightningError_set_action(uint32_t this_ptr, uint32_t val) {
32088         LDKLightningError this_ptr_conv;
32089         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32090         this_ptr_conv.is_owned = false;
32091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32092         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
32093         CHECK_ACCESS(val_ptr);
32094         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
32095         val_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)val) & ~1));
32096         LightningError_set_action(&this_ptr_conv, val_conv);
32097 }
32098
32099 uint32_t  __attribute__((export_name("TS_LightningError_new"))) TS_LightningError_new(jstring err_arg, uint32_t action_arg) {
32100         LDKStr err_arg_conv = str_ref_to_owned_c(err_arg);
32101         void* action_arg_ptr = (void*)(((uintptr_t)action_arg) & ~1);
32102         CHECK_ACCESS(action_arg_ptr);
32103         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
32104         action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action_arg) & ~1));
32105         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
32106         uint32_t ret_ref = 0;
32107         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32108         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32109         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32110         ret_ref = (uintptr_t)ret_var.inner;
32111         if (ret_var.is_owned) {
32112                 ret_ref |= 1;
32113         }
32114         return ret_ref;
32115 }
32116
32117 static inline uintptr_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
32118         LDKLightningError ret_var = LightningError_clone(arg);
32119 uint32_t ret_ref = 0;
32120 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32121 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32122 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32123 ret_ref = (uintptr_t)ret_var.inner;
32124 if (ret_var.is_owned) {
32125         ret_ref |= 1;
32126 }
32127         return ret_ref;
32128 }
32129 uint32_t  __attribute__((export_name("TS_LightningError_clone_ptr"))) TS_LightningError_clone_ptr(uint32_t arg) {
32130         LDKLightningError arg_conv;
32131         arg_conv.inner = (void*)(arg & (~1));
32132         arg_conv.is_owned = false;
32133         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32134         uint32_t ret_conv = LightningError_clone_ptr(&arg_conv);
32135         return ret_conv;
32136 }
32137
32138 uint32_t  __attribute__((export_name("TS_LightningError_clone"))) TS_LightningError_clone(uint32_t orig) {
32139         LDKLightningError orig_conv;
32140         orig_conv.inner = (void*)(orig & (~1));
32141         orig_conv.is_owned = false;
32142         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32143         LDKLightningError ret_var = LightningError_clone(&orig_conv);
32144         uint32_t ret_ref = 0;
32145         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32146         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32147         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32148         ret_ref = (uintptr_t)ret_var.inner;
32149         if (ret_var.is_owned) {
32150                 ret_ref |= 1;
32151         }
32152         return ret_ref;
32153 }
32154
32155 void  __attribute__((export_name("TS_CommitmentUpdate_free"))) TS_CommitmentUpdate_free(uint32_t this_obj) {
32156         LDKCommitmentUpdate this_obj_conv;
32157         this_obj_conv.inner = (void*)(this_obj & (~1));
32158         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32160         CommitmentUpdate_free(this_obj_conv);
32161 }
32162
32163 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_add_htlcs"))) TS_CommitmentUpdate_get_update_add_htlcs(uint32_t this_ptr) {
32164         LDKCommitmentUpdate this_ptr_conv;
32165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32166         this_ptr_conv.is_owned = false;
32167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32168         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
32169         uint32_tArray ret_arr = NULL;
32170         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
32171         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
32172         for (size_t p = 0; p < ret_var.datalen; p++) {
32173                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
32174                 uint32_t ret_conv_15_ref = 0;
32175                 CHECK((((uintptr_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32176                 CHECK((((uintptr_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32177                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
32178                 ret_conv_15_ref = (uintptr_t)ret_conv_15_var.inner;
32179                 if (ret_conv_15_var.is_owned) {
32180                         ret_conv_15_ref |= 1;
32181                 }
32182                 ret_arr_ptr[p] = ret_conv_15_ref;
32183         }
32184         
32185         FREE(ret_var.data);
32186         return ret_arr;
32187 }
32188
32189 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_add_htlcs"))) TS_CommitmentUpdate_set_update_add_htlcs(uint32_t this_ptr, uint32_tArray val) {
32190         LDKCommitmentUpdate this_ptr_conv;
32191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32192         this_ptr_conv.is_owned = false;
32193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32194         LDKCVec_UpdateAddHTLCZ val_constr;
32195         val_constr.datalen = val->arr_len;
32196         if (val_constr.datalen > 0)
32197                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
32198         else
32199                 val_constr.data = NULL;
32200         uint32_t* val_vals = val->elems /* XXX val leaks */;
32201         for (size_t p = 0; p < val_constr.datalen; p++) {
32202                 uint32_t val_conv_15 = val_vals[p];
32203                 LDKUpdateAddHTLC val_conv_15_conv;
32204                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
32205                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
32206                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
32207                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
32208                 val_constr.data[p] = val_conv_15_conv;
32209         }
32210         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
32211 }
32212
32213 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fulfill_htlcs"))) TS_CommitmentUpdate_get_update_fulfill_htlcs(uint32_t this_ptr) {
32214         LDKCommitmentUpdate this_ptr_conv;
32215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32216         this_ptr_conv.is_owned = false;
32217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32218         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
32219         uint32_tArray ret_arr = NULL;
32220         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
32221         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
32222         for (size_t t = 0; t < ret_var.datalen; t++) {
32223                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
32224                 uint32_t ret_conv_19_ref = 0;
32225                 CHECK((((uintptr_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32226                 CHECK((((uintptr_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32227                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
32228                 ret_conv_19_ref = (uintptr_t)ret_conv_19_var.inner;
32229                 if (ret_conv_19_var.is_owned) {
32230                         ret_conv_19_ref |= 1;
32231                 }
32232                 ret_arr_ptr[t] = ret_conv_19_ref;
32233         }
32234         
32235         FREE(ret_var.data);
32236         return ret_arr;
32237 }
32238
32239 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fulfill_htlcs"))) TS_CommitmentUpdate_set_update_fulfill_htlcs(uint32_t this_ptr, uint32_tArray val) {
32240         LDKCommitmentUpdate this_ptr_conv;
32241         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32242         this_ptr_conv.is_owned = false;
32243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32244         LDKCVec_UpdateFulfillHTLCZ val_constr;
32245         val_constr.datalen = val->arr_len;
32246         if (val_constr.datalen > 0)
32247                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
32248         else
32249                 val_constr.data = NULL;
32250         uint32_t* val_vals = val->elems /* XXX val leaks */;
32251         for (size_t t = 0; t < val_constr.datalen; t++) {
32252                 uint32_t val_conv_19 = val_vals[t];
32253                 LDKUpdateFulfillHTLC val_conv_19_conv;
32254                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
32255                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
32256                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
32257                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
32258                 val_constr.data[t] = val_conv_19_conv;
32259         }
32260         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
32261 }
32262
32263 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fail_htlcs"))) TS_CommitmentUpdate_get_update_fail_htlcs(uint32_t this_ptr) {
32264         LDKCommitmentUpdate this_ptr_conv;
32265         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32266         this_ptr_conv.is_owned = false;
32267         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32268         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
32269         uint32_tArray ret_arr = NULL;
32270         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
32271         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
32272         for (size_t q = 0; q < ret_var.datalen; q++) {
32273                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
32274                 uint32_t ret_conv_16_ref = 0;
32275                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32276                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32277                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
32278                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
32279                 if (ret_conv_16_var.is_owned) {
32280                         ret_conv_16_ref |= 1;
32281                 }
32282                 ret_arr_ptr[q] = ret_conv_16_ref;
32283         }
32284         
32285         FREE(ret_var.data);
32286         return ret_arr;
32287 }
32288
32289 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fail_htlcs"))) TS_CommitmentUpdate_set_update_fail_htlcs(uint32_t this_ptr, uint32_tArray val) {
32290         LDKCommitmentUpdate this_ptr_conv;
32291         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32292         this_ptr_conv.is_owned = false;
32293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32294         LDKCVec_UpdateFailHTLCZ val_constr;
32295         val_constr.datalen = val->arr_len;
32296         if (val_constr.datalen > 0)
32297                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
32298         else
32299                 val_constr.data = NULL;
32300         uint32_t* val_vals = val->elems /* XXX val leaks */;
32301         for (size_t q = 0; q < val_constr.datalen; q++) {
32302                 uint32_t val_conv_16 = val_vals[q];
32303                 LDKUpdateFailHTLC val_conv_16_conv;
32304                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
32305                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
32306                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
32307                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
32308                 val_constr.data[q] = val_conv_16_conv;
32309         }
32310         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
32311 }
32312
32313 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fail_malformed_htlcs"))) TS_CommitmentUpdate_get_update_fail_malformed_htlcs(uint32_t this_ptr) {
32314         LDKCommitmentUpdate this_ptr_conv;
32315         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32316         this_ptr_conv.is_owned = false;
32317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32318         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
32319         uint32_tArray ret_arr = NULL;
32320         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
32321         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
32322         for (size_t z = 0; z < ret_var.datalen; z++) {
32323                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
32324                 uint32_t ret_conv_25_ref = 0;
32325                 CHECK((((uintptr_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32326                 CHECK((((uintptr_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32327                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
32328                 ret_conv_25_ref = (uintptr_t)ret_conv_25_var.inner;
32329                 if (ret_conv_25_var.is_owned) {
32330                         ret_conv_25_ref |= 1;
32331                 }
32332                 ret_arr_ptr[z] = ret_conv_25_ref;
32333         }
32334         
32335         FREE(ret_var.data);
32336         return ret_arr;
32337 }
32338
32339 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) {
32340         LDKCommitmentUpdate this_ptr_conv;
32341         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32342         this_ptr_conv.is_owned = false;
32343         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32344         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
32345         val_constr.datalen = val->arr_len;
32346         if (val_constr.datalen > 0)
32347                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
32348         else
32349                 val_constr.data = NULL;
32350         uint32_t* val_vals = val->elems /* XXX val leaks */;
32351         for (size_t z = 0; z < val_constr.datalen; z++) {
32352                 uint32_t val_conv_25 = val_vals[z];
32353                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
32354                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
32355                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
32356                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
32357                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
32358                 val_constr.data[z] = val_conv_25_conv;
32359         }
32360         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
32361 }
32362
32363 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_get_update_fee"))) TS_CommitmentUpdate_get_update_fee(uint32_t this_ptr) {
32364         LDKCommitmentUpdate this_ptr_conv;
32365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32366         this_ptr_conv.is_owned = false;
32367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32368         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
32369         uint32_t ret_ref = 0;
32370         if ((uintptr_t)ret_var.inner > 4096) {
32371                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32372                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32373         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32374                 ret_ref = (uintptr_t)ret_var.inner;
32375                 if (ret_var.is_owned) {
32376                         ret_ref |= 1;
32377                 }
32378         }
32379         return ret_ref;
32380 }
32381
32382 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fee"))) TS_CommitmentUpdate_set_update_fee(uint32_t this_ptr, uint32_t val) {
32383         LDKCommitmentUpdate this_ptr_conv;
32384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32385         this_ptr_conv.is_owned = false;
32386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32387         LDKUpdateFee val_conv;
32388         val_conv.inner = (void*)(val & (~1));
32389         val_conv.is_owned = (val & 1) || (val == 0);
32390         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32391         val_conv = UpdateFee_clone(&val_conv);
32392         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
32393 }
32394
32395 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_get_commitment_signed"))) TS_CommitmentUpdate_get_commitment_signed(uint32_t this_ptr) {
32396         LDKCommitmentUpdate this_ptr_conv;
32397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32398         this_ptr_conv.is_owned = false;
32399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32400         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
32401         uint32_t ret_ref = 0;
32402         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32403         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32404         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32405         ret_ref = (uintptr_t)ret_var.inner;
32406         if (ret_var.is_owned) {
32407                 ret_ref |= 1;
32408         }
32409         return ret_ref;
32410 }
32411
32412 void  __attribute__((export_name("TS_CommitmentUpdate_set_commitment_signed"))) TS_CommitmentUpdate_set_commitment_signed(uint32_t this_ptr, uint32_t val) {
32413         LDKCommitmentUpdate this_ptr_conv;
32414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32415         this_ptr_conv.is_owned = false;
32416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32417         LDKCommitmentSigned val_conv;
32418         val_conv.inner = (void*)(val & (~1));
32419         val_conv.is_owned = (val & 1) || (val == 0);
32420         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32421         val_conv = CommitmentSigned_clone(&val_conv);
32422         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
32423 }
32424
32425 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) {
32426         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
32427         update_add_htlcs_arg_constr.datalen = update_add_htlcs_arg->arr_len;
32428         if (update_add_htlcs_arg_constr.datalen > 0)
32429                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
32430         else
32431                 update_add_htlcs_arg_constr.data = NULL;
32432         uint32_t* update_add_htlcs_arg_vals = update_add_htlcs_arg->elems /* XXX update_add_htlcs_arg leaks */;
32433         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
32434                 uint32_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
32435                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
32436                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
32437                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
32438                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
32439                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
32440                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
32441         }
32442         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
32443         update_fulfill_htlcs_arg_constr.datalen = update_fulfill_htlcs_arg->arr_len;
32444         if (update_fulfill_htlcs_arg_constr.datalen > 0)
32445                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
32446         else
32447                 update_fulfill_htlcs_arg_constr.data = NULL;
32448         uint32_t* update_fulfill_htlcs_arg_vals = update_fulfill_htlcs_arg->elems /* XXX update_fulfill_htlcs_arg leaks */;
32449         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
32450                 uint32_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
32451                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
32452                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
32453                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
32454                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
32455                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
32456                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
32457         }
32458         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
32459         update_fail_htlcs_arg_constr.datalen = update_fail_htlcs_arg->arr_len;
32460         if (update_fail_htlcs_arg_constr.datalen > 0)
32461                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
32462         else
32463                 update_fail_htlcs_arg_constr.data = NULL;
32464         uint32_t* update_fail_htlcs_arg_vals = update_fail_htlcs_arg->elems /* XXX update_fail_htlcs_arg leaks */;
32465         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
32466                 uint32_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
32467                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
32468                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
32469                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
32470                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
32471                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
32472                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
32473         }
32474         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
32475         update_fail_malformed_htlcs_arg_constr.datalen = update_fail_malformed_htlcs_arg->arr_len;
32476         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
32477                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
32478         else
32479                 update_fail_malformed_htlcs_arg_constr.data = NULL;
32480         uint32_t* update_fail_malformed_htlcs_arg_vals = update_fail_malformed_htlcs_arg->elems /* XXX update_fail_malformed_htlcs_arg leaks */;
32481         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
32482                 uint32_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
32483                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
32484                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
32485                 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);
32486                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
32487                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
32488                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
32489         }
32490         LDKUpdateFee update_fee_arg_conv;
32491         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
32492         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
32493         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
32494         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
32495         LDKCommitmentSigned commitment_signed_arg_conv;
32496         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
32497         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
32498         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
32499         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
32500         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);
32501         uint32_t ret_ref = 0;
32502         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32503         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32504         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32505         ret_ref = (uintptr_t)ret_var.inner;
32506         if (ret_var.is_owned) {
32507                 ret_ref |= 1;
32508         }
32509         return ret_ref;
32510 }
32511
32512 static inline uintptr_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
32513         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
32514 uint32_t ret_ref = 0;
32515 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32516 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32517 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32518 ret_ref = (uintptr_t)ret_var.inner;
32519 if (ret_var.is_owned) {
32520         ret_ref |= 1;
32521 }
32522         return ret_ref;
32523 }
32524 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_clone_ptr"))) TS_CommitmentUpdate_clone_ptr(uint32_t arg) {
32525         LDKCommitmentUpdate arg_conv;
32526         arg_conv.inner = (void*)(arg & (~1));
32527         arg_conv.is_owned = false;
32528         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32529         uint32_t ret_conv = CommitmentUpdate_clone_ptr(&arg_conv);
32530         return ret_conv;
32531 }
32532
32533 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_clone"))) TS_CommitmentUpdate_clone(uint32_t orig) {
32534         LDKCommitmentUpdate orig_conv;
32535         orig_conv.inner = (void*)(orig & (~1));
32536         orig_conv.is_owned = false;
32537         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32538         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
32539         uint32_t ret_ref = 0;
32540         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32541         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32542         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32543         ret_ref = (uintptr_t)ret_var.inner;
32544         if (ret_var.is_owned) {
32545                 ret_ref |= 1;
32546         }
32547         return ret_ref;
32548 }
32549
32550 void  __attribute__((export_name("TS_ChannelMessageHandler_free"))) TS_ChannelMessageHandler_free(uint32_t this_ptr) {
32551         if ((this_ptr & 1) != 0) return;
32552         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
32553         CHECK_ACCESS(this_ptr_ptr);
32554         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
32555         FREE((void*)this_ptr);
32556         ChannelMessageHandler_free(this_ptr_conv);
32557 }
32558
32559 void  __attribute__((export_name("TS_RoutingMessageHandler_free"))) TS_RoutingMessageHandler_free(uint32_t this_ptr) {
32560         if ((this_ptr & 1) != 0) return;
32561         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
32562         CHECK_ACCESS(this_ptr_ptr);
32563         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
32564         FREE((void*)this_ptr);
32565         RoutingMessageHandler_free(this_ptr_conv);
32566 }
32567
32568 int8_tArray  __attribute__((export_name("TS_AcceptChannel_write"))) TS_AcceptChannel_write(uint32_t obj) {
32569         LDKAcceptChannel obj_conv;
32570         obj_conv.inner = (void*)(obj & (~1));
32571         obj_conv.is_owned = false;
32572         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32573         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
32574         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32575         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32576         CVec_u8Z_free(ret_var);
32577         return ret_arr;
32578 }
32579
32580 uint32_t  __attribute__((export_name("TS_AcceptChannel_read"))) TS_AcceptChannel_read(int8_tArray ser) {
32581         LDKu8slice ser_ref;
32582         ser_ref.datalen = ser->arr_len;
32583         ser_ref.data = ser->elems /* XXX ser leaks */;
32584         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
32585         *ret_conv = AcceptChannel_read(ser_ref);
32586         return (uint32_t)ret_conv;
32587 }
32588
32589 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_write"))) TS_AnnouncementSignatures_write(uint32_t obj) {
32590         LDKAnnouncementSignatures obj_conv;
32591         obj_conv.inner = (void*)(obj & (~1));
32592         obj_conv.is_owned = false;
32593         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32594         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
32595         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32596         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32597         CVec_u8Z_free(ret_var);
32598         return ret_arr;
32599 }
32600
32601 uint32_t  __attribute__((export_name("TS_AnnouncementSignatures_read"))) TS_AnnouncementSignatures_read(int8_tArray ser) {
32602         LDKu8slice ser_ref;
32603         ser_ref.datalen = ser->arr_len;
32604         ser_ref.data = ser->elems /* XXX ser leaks */;
32605         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
32606         *ret_conv = AnnouncementSignatures_read(ser_ref);
32607         return (uint32_t)ret_conv;
32608 }
32609
32610 int8_tArray  __attribute__((export_name("TS_ChannelReestablish_write"))) TS_ChannelReestablish_write(uint32_t obj) {
32611         LDKChannelReestablish obj_conv;
32612         obj_conv.inner = (void*)(obj & (~1));
32613         obj_conv.is_owned = false;
32614         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32615         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
32616         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32617         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32618         CVec_u8Z_free(ret_var);
32619         return ret_arr;
32620 }
32621
32622 uint32_t  __attribute__((export_name("TS_ChannelReestablish_read"))) TS_ChannelReestablish_read(int8_tArray ser) {
32623         LDKu8slice ser_ref;
32624         ser_ref.datalen = ser->arr_len;
32625         ser_ref.data = ser->elems /* XXX ser leaks */;
32626         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
32627         *ret_conv = ChannelReestablish_read(ser_ref);
32628         return (uint32_t)ret_conv;
32629 }
32630
32631 int8_tArray  __attribute__((export_name("TS_ClosingSigned_write"))) TS_ClosingSigned_write(uint32_t obj) {
32632         LDKClosingSigned obj_conv;
32633         obj_conv.inner = (void*)(obj & (~1));
32634         obj_conv.is_owned = false;
32635         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32636         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
32637         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32638         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32639         CVec_u8Z_free(ret_var);
32640         return ret_arr;
32641 }
32642
32643 uint32_t  __attribute__((export_name("TS_ClosingSigned_read"))) TS_ClosingSigned_read(int8_tArray ser) {
32644         LDKu8slice ser_ref;
32645         ser_ref.datalen = ser->arr_len;
32646         ser_ref.data = ser->elems /* XXX ser leaks */;
32647         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
32648         *ret_conv = ClosingSigned_read(ser_ref);
32649         return (uint32_t)ret_conv;
32650 }
32651
32652 int8_tArray  __attribute__((export_name("TS_ClosingSignedFeeRange_write"))) TS_ClosingSignedFeeRange_write(uint32_t obj) {
32653         LDKClosingSignedFeeRange obj_conv;
32654         obj_conv.inner = (void*)(obj & (~1));
32655         obj_conv.is_owned = false;
32656         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32657         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
32658         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32659         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32660         CVec_u8Z_free(ret_var);
32661         return ret_arr;
32662 }
32663
32664 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_read"))) TS_ClosingSignedFeeRange_read(int8_tArray ser) {
32665         LDKu8slice ser_ref;
32666         ser_ref.datalen = ser->arr_len;
32667         ser_ref.data = ser->elems /* XXX ser leaks */;
32668         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
32669         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
32670         return (uint32_t)ret_conv;
32671 }
32672
32673 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_write"))) TS_CommitmentSigned_write(uint32_t obj) {
32674         LDKCommitmentSigned obj_conv;
32675         obj_conv.inner = (void*)(obj & (~1));
32676         obj_conv.is_owned = false;
32677         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32678         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
32679         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32680         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32681         CVec_u8Z_free(ret_var);
32682         return ret_arr;
32683 }
32684
32685 uint32_t  __attribute__((export_name("TS_CommitmentSigned_read"))) TS_CommitmentSigned_read(int8_tArray ser) {
32686         LDKu8slice ser_ref;
32687         ser_ref.datalen = ser->arr_len;
32688         ser_ref.data = ser->elems /* XXX ser leaks */;
32689         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
32690         *ret_conv = CommitmentSigned_read(ser_ref);
32691         return (uint32_t)ret_conv;
32692 }
32693
32694 int8_tArray  __attribute__((export_name("TS_FundingCreated_write"))) TS_FundingCreated_write(uint32_t obj) {
32695         LDKFundingCreated obj_conv;
32696         obj_conv.inner = (void*)(obj & (~1));
32697         obj_conv.is_owned = false;
32698         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32699         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
32700         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32701         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32702         CVec_u8Z_free(ret_var);
32703         return ret_arr;
32704 }
32705
32706 uint32_t  __attribute__((export_name("TS_FundingCreated_read"))) TS_FundingCreated_read(int8_tArray ser) {
32707         LDKu8slice ser_ref;
32708         ser_ref.datalen = ser->arr_len;
32709         ser_ref.data = ser->elems /* XXX ser leaks */;
32710         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
32711         *ret_conv = FundingCreated_read(ser_ref);
32712         return (uint32_t)ret_conv;
32713 }
32714
32715 int8_tArray  __attribute__((export_name("TS_FundingSigned_write"))) TS_FundingSigned_write(uint32_t obj) {
32716         LDKFundingSigned obj_conv;
32717         obj_conv.inner = (void*)(obj & (~1));
32718         obj_conv.is_owned = false;
32719         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32720         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
32721         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32722         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32723         CVec_u8Z_free(ret_var);
32724         return ret_arr;
32725 }
32726
32727 uint32_t  __attribute__((export_name("TS_FundingSigned_read"))) TS_FundingSigned_read(int8_tArray ser) {
32728         LDKu8slice ser_ref;
32729         ser_ref.datalen = ser->arr_len;
32730         ser_ref.data = ser->elems /* XXX ser leaks */;
32731         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
32732         *ret_conv = FundingSigned_read(ser_ref);
32733         return (uint32_t)ret_conv;
32734 }
32735
32736 int8_tArray  __attribute__((export_name("TS_ChannelReady_write"))) TS_ChannelReady_write(uint32_t obj) {
32737         LDKChannelReady obj_conv;
32738         obj_conv.inner = (void*)(obj & (~1));
32739         obj_conv.is_owned = false;
32740         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32741         LDKCVec_u8Z ret_var = ChannelReady_write(&obj_conv);
32742         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32743         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32744         CVec_u8Z_free(ret_var);
32745         return ret_arr;
32746 }
32747
32748 uint32_t  __attribute__((export_name("TS_ChannelReady_read"))) TS_ChannelReady_read(int8_tArray ser) {
32749         LDKu8slice ser_ref;
32750         ser_ref.datalen = ser->arr_len;
32751         ser_ref.data = ser->elems /* XXX ser leaks */;
32752         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
32753         *ret_conv = ChannelReady_read(ser_ref);
32754         return (uint32_t)ret_conv;
32755 }
32756
32757 int8_tArray  __attribute__((export_name("TS_Init_write"))) TS_Init_write(uint32_t obj) {
32758         LDKInit obj_conv;
32759         obj_conv.inner = (void*)(obj & (~1));
32760         obj_conv.is_owned = false;
32761         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32762         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
32763         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32764         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32765         CVec_u8Z_free(ret_var);
32766         return ret_arr;
32767 }
32768
32769 uint32_t  __attribute__((export_name("TS_Init_read"))) TS_Init_read(int8_tArray ser) {
32770         LDKu8slice ser_ref;
32771         ser_ref.datalen = ser->arr_len;
32772         ser_ref.data = ser->elems /* XXX ser leaks */;
32773         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
32774         *ret_conv = Init_read(ser_ref);
32775         return (uint32_t)ret_conv;
32776 }
32777
32778 int8_tArray  __attribute__((export_name("TS_OpenChannel_write"))) TS_OpenChannel_write(uint32_t obj) {
32779         LDKOpenChannel obj_conv;
32780         obj_conv.inner = (void*)(obj & (~1));
32781         obj_conv.is_owned = false;
32782         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32783         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
32784         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32785         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32786         CVec_u8Z_free(ret_var);
32787         return ret_arr;
32788 }
32789
32790 uint32_t  __attribute__((export_name("TS_OpenChannel_read"))) TS_OpenChannel_read(int8_tArray ser) {
32791         LDKu8slice ser_ref;
32792         ser_ref.datalen = ser->arr_len;
32793         ser_ref.data = ser->elems /* XXX ser leaks */;
32794         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
32795         *ret_conv = OpenChannel_read(ser_ref);
32796         return (uint32_t)ret_conv;
32797 }
32798
32799 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_write"))) TS_RevokeAndACK_write(uint32_t obj) {
32800         LDKRevokeAndACK obj_conv;
32801         obj_conv.inner = (void*)(obj & (~1));
32802         obj_conv.is_owned = false;
32803         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32804         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
32805         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32806         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32807         CVec_u8Z_free(ret_var);
32808         return ret_arr;
32809 }
32810
32811 uint32_t  __attribute__((export_name("TS_RevokeAndACK_read"))) TS_RevokeAndACK_read(int8_tArray ser) {
32812         LDKu8slice ser_ref;
32813         ser_ref.datalen = ser->arr_len;
32814         ser_ref.data = ser->elems /* XXX ser leaks */;
32815         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
32816         *ret_conv = RevokeAndACK_read(ser_ref);
32817         return (uint32_t)ret_conv;
32818 }
32819
32820 int8_tArray  __attribute__((export_name("TS_Shutdown_write"))) TS_Shutdown_write(uint32_t obj) {
32821         LDKShutdown obj_conv;
32822         obj_conv.inner = (void*)(obj & (~1));
32823         obj_conv.is_owned = false;
32824         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32825         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
32826         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32827         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32828         CVec_u8Z_free(ret_var);
32829         return ret_arr;
32830 }
32831
32832 uint32_t  __attribute__((export_name("TS_Shutdown_read"))) TS_Shutdown_read(int8_tArray ser) {
32833         LDKu8slice ser_ref;
32834         ser_ref.datalen = ser->arr_len;
32835         ser_ref.data = ser->elems /* XXX ser leaks */;
32836         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
32837         *ret_conv = Shutdown_read(ser_ref);
32838         return (uint32_t)ret_conv;
32839 }
32840
32841 int8_tArray  __attribute__((export_name("TS_UpdateFailHTLC_write"))) TS_UpdateFailHTLC_write(uint32_t obj) {
32842         LDKUpdateFailHTLC obj_conv;
32843         obj_conv.inner = (void*)(obj & (~1));
32844         obj_conv.is_owned = false;
32845         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32846         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
32847         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32848         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32849         CVec_u8Z_free(ret_var);
32850         return ret_arr;
32851 }
32852
32853 uint32_t  __attribute__((export_name("TS_UpdateFailHTLC_read"))) TS_UpdateFailHTLC_read(int8_tArray ser) {
32854         LDKu8slice ser_ref;
32855         ser_ref.datalen = ser->arr_len;
32856         ser_ref.data = ser->elems /* XXX ser leaks */;
32857         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
32858         *ret_conv = UpdateFailHTLC_read(ser_ref);
32859         return (uint32_t)ret_conv;
32860 }
32861
32862 int8_tArray  __attribute__((export_name("TS_UpdateFailMalformedHTLC_write"))) TS_UpdateFailMalformedHTLC_write(uint32_t obj) {
32863         LDKUpdateFailMalformedHTLC obj_conv;
32864         obj_conv.inner = (void*)(obj & (~1));
32865         obj_conv.is_owned = false;
32866         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32867         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
32868         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32869         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32870         CVec_u8Z_free(ret_var);
32871         return ret_arr;
32872 }
32873
32874 uint32_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_read"))) TS_UpdateFailMalformedHTLC_read(int8_tArray ser) {
32875         LDKu8slice ser_ref;
32876         ser_ref.datalen = ser->arr_len;
32877         ser_ref.data = ser->elems /* XXX ser leaks */;
32878         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
32879         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
32880         return (uint32_t)ret_conv;
32881 }
32882
32883 int8_tArray  __attribute__((export_name("TS_UpdateFee_write"))) TS_UpdateFee_write(uint32_t obj) {
32884         LDKUpdateFee obj_conv;
32885         obj_conv.inner = (void*)(obj & (~1));
32886         obj_conv.is_owned = false;
32887         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32888         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
32889         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32890         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32891         CVec_u8Z_free(ret_var);
32892         return ret_arr;
32893 }
32894
32895 uint32_t  __attribute__((export_name("TS_UpdateFee_read"))) TS_UpdateFee_read(int8_tArray ser) {
32896         LDKu8slice ser_ref;
32897         ser_ref.datalen = ser->arr_len;
32898         ser_ref.data = ser->elems /* XXX ser leaks */;
32899         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
32900         *ret_conv = UpdateFee_read(ser_ref);
32901         return (uint32_t)ret_conv;
32902 }
32903
32904 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_write"))) TS_UpdateFulfillHTLC_write(uint32_t obj) {
32905         LDKUpdateFulfillHTLC obj_conv;
32906         obj_conv.inner = (void*)(obj & (~1));
32907         obj_conv.is_owned = false;
32908         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32909         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
32910         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32911         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32912         CVec_u8Z_free(ret_var);
32913         return ret_arr;
32914 }
32915
32916 uint32_t  __attribute__((export_name("TS_UpdateFulfillHTLC_read"))) TS_UpdateFulfillHTLC_read(int8_tArray ser) {
32917         LDKu8slice ser_ref;
32918         ser_ref.datalen = ser->arr_len;
32919         ser_ref.data = ser->elems /* XXX ser leaks */;
32920         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
32921         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
32922         return (uint32_t)ret_conv;
32923 }
32924
32925 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_write"))) TS_UpdateAddHTLC_write(uint32_t obj) {
32926         LDKUpdateAddHTLC obj_conv;
32927         obj_conv.inner = (void*)(obj & (~1));
32928         obj_conv.is_owned = false;
32929         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32930         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
32931         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32932         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32933         CVec_u8Z_free(ret_var);
32934         return ret_arr;
32935 }
32936
32937 uint32_t  __attribute__((export_name("TS_UpdateAddHTLC_read"))) TS_UpdateAddHTLC_read(int8_tArray ser) {
32938         LDKu8slice ser_ref;
32939         ser_ref.datalen = ser->arr_len;
32940         ser_ref.data = ser->elems /* XXX ser leaks */;
32941         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
32942         *ret_conv = UpdateAddHTLC_read(ser_ref);
32943         return (uint32_t)ret_conv;
32944 }
32945
32946 int8_tArray  __attribute__((export_name("TS_Ping_write"))) TS_Ping_write(uint32_t obj) {
32947         LDKPing obj_conv;
32948         obj_conv.inner = (void*)(obj & (~1));
32949         obj_conv.is_owned = false;
32950         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32951         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
32952         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32953         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32954         CVec_u8Z_free(ret_var);
32955         return ret_arr;
32956 }
32957
32958 uint32_t  __attribute__((export_name("TS_Ping_read"))) TS_Ping_read(int8_tArray ser) {
32959         LDKu8slice ser_ref;
32960         ser_ref.datalen = ser->arr_len;
32961         ser_ref.data = ser->elems /* XXX ser leaks */;
32962         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
32963         *ret_conv = Ping_read(ser_ref);
32964         return (uint32_t)ret_conv;
32965 }
32966
32967 int8_tArray  __attribute__((export_name("TS_Pong_write"))) TS_Pong_write(uint32_t obj) {
32968         LDKPong obj_conv;
32969         obj_conv.inner = (void*)(obj & (~1));
32970         obj_conv.is_owned = false;
32971         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32972         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
32973         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32974         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32975         CVec_u8Z_free(ret_var);
32976         return ret_arr;
32977 }
32978
32979 uint32_t  __attribute__((export_name("TS_Pong_read"))) TS_Pong_read(int8_tArray ser) {
32980         LDKu8slice ser_ref;
32981         ser_ref.datalen = ser->arr_len;
32982         ser_ref.data = ser->elems /* XXX ser leaks */;
32983         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
32984         *ret_conv = Pong_read(ser_ref);
32985         return (uint32_t)ret_conv;
32986 }
32987
32988 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_write"))) TS_UnsignedChannelAnnouncement_write(uint32_t obj) {
32989         LDKUnsignedChannelAnnouncement obj_conv;
32990         obj_conv.inner = (void*)(obj & (~1));
32991         obj_conv.is_owned = false;
32992         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32993         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
32994         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32995         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32996         CVec_u8Z_free(ret_var);
32997         return ret_arr;
32998 }
32999
33000 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_read"))) TS_UnsignedChannelAnnouncement_read(int8_tArray ser) {
33001         LDKu8slice ser_ref;
33002         ser_ref.datalen = ser->arr_len;
33003         ser_ref.data = ser->elems /* XXX ser leaks */;
33004         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
33005         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
33006         return (uint32_t)ret_conv;
33007 }
33008
33009 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_write"))) TS_ChannelAnnouncement_write(uint32_t obj) {
33010         LDKChannelAnnouncement obj_conv;
33011         obj_conv.inner = (void*)(obj & (~1));
33012         obj_conv.is_owned = false;
33013         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33014         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
33015         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33016         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33017         CVec_u8Z_free(ret_var);
33018         return ret_arr;
33019 }
33020
33021 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_read"))) TS_ChannelAnnouncement_read(int8_tArray ser) {
33022         LDKu8slice ser_ref;
33023         ser_ref.datalen = ser->arr_len;
33024         ser_ref.data = ser->elems /* XXX ser leaks */;
33025         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
33026         *ret_conv = ChannelAnnouncement_read(ser_ref);
33027         return (uint32_t)ret_conv;
33028 }
33029
33030 int8_tArray  __attribute__((export_name("TS_UnsignedChannelUpdate_write"))) TS_UnsignedChannelUpdate_write(uint32_t obj) {
33031         LDKUnsignedChannelUpdate obj_conv;
33032         obj_conv.inner = (void*)(obj & (~1));
33033         obj_conv.is_owned = false;
33034         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33035         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
33036         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33037         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33038         CVec_u8Z_free(ret_var);
33039         return ret_arr;
33040 }
33041
33042 uint32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_read"))) TS_UnsignedChannelUpdate_read(int8_tArray ser) {
33043         LDKu8slice ser_ref;
33044         ser_ref.datalen = ser->arr_len;
33045         ser_ref.data = ser->elems /* XXX ser leaks */;
33046         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
33047         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
33048         return (uint32_t)ret_conv;
33049 }
33050
33051 int8_tArray  __attribute__((export_name("TS_ChannelUpdate_write"))) TS_ChannelUpdate_write(uint32_t obj) {
33052         LDKChannelUpdate obj_conv;
33053         obj_conv.inner = (void*)(obj & (~1));
33054         obj_conv.is_owned = false;
33055         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33056         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
33057         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33058         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33059         CVec_u8Z_free(ret_var);
33060         return ret_arr;
33061 }
33062
33063 uint32_t  __attribute__((export_name("TS_ChannelUpdate_read"))) TS_ChannelUpdate_read(int8_tArray ser) {
33064         LDKu8slice ser_ref;
33065         ser_ref.datalen = ser->arr_len;
33066         ser_ref.data = ser->elems /* XXX ser leaks */;
33067         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
33068         *ret_conv = ChannelUpdate_read(ser_ref);
33069         return (uint32_t)ret_conv;
33070 }
33071
33072 int8_tArray  __attribute__((export_name("TS_ErrorMessage_write"))) TS_ErrorMessage_write(uint32_t obj) {
33073         LDKErrorMessage obj_conv;
33074         obj_conv.inner = (void*)(obj & (~1));
33075         obj_conv.is_owned = false;
33076         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33077         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
33078         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33079         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33080         CVec_u8Z_free(ret_var);
33081         return ret_arr;
33082 }
33083
33084 uint32_t  __attribute__((export_name("TS_ErrorMessage_read"))) TS_ErrorMessage_read(int8_tArray ser) {
33085         LDKu8slice ser_ref;
33086         ser_ref.datalen = ser->arr_len;
33087         ser_ref.data = ser->elems /* XXX ser leaks */;
33088         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
33089         *ret_conv = ErrorMessage_read(ser_ref);
33090         return (uint32_t)ret_conv;
33091 }
33092
33093 int8_tArray  __attribute__((export_name("TS_WarningMessage_write"))) TS_WarningMessage_write(uint32_t obj) {
33094         LDKWarningMessage obj_conv;
33095         obj_conv.inner = (void*)(obj & (~1));
33096         obj_conv.is_owned = false;
33097         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33098         LDKCVec_u8Z ret_var = WarningMessage_write(&obj_conv);
33099         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33100         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33101         CVec_u8Z_free(ret_var);
33102         return ret_arr;
33103 }
33104
33105 uint32_t  __attribute__((export_name("TS_WarningMessage_read"))) TS_WarningMessage_read(int8_tArray ser) {
33106         LDKu8slice ser_ref;
33107         ser_ref.datalen = ser->arr_len;
33108         ser_ref.data = ser->elems /* XXX ser leaks */;
33109         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
33110         *ret_conv = WarningMessage_read(ser_ref);
33111         return (uint32_t)ret_conv;
33112 }
33113
33114 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_write"))) TS_UnsignedNodeAnnouncement_write(uint32_t obj) {
33115         LDKUnsignedNodeAnnouncement obj_conv;
33116         obj_conv.inner = (void*)(obj & (~1));
33117         obj_conv.is_owned = false;
33118         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33119         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
33120         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33121         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33122         CVec_u8Z_free(ret_var);
33123         return ret_arr;
33124 }
33125
33126 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_read"))) TS_UnsignedNodeAnnouncement_read(int8_tArray ser) {
33127         LDKu8slice ser_ref;
33128         ser_ref.datalen = ser->arr_len;
33129         ser_ref.data = ser->elems /* XXX ser leaks */;
33130         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
33131         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
33132         return (uint32_t)ret_conv;
33133 }
33134
33135 int8_tArray  __attribute__((export_name("TS_NodeAnnouncement_write"))) TS_NodeAnnouncement_write(uint32_t obj) {
33136         LDKNodeAnnouncement obj_conv;
33137         obj_conv.inner = (void*)(obj & (~1));
33138         obj_conv.is_owned = false;
33139         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33140         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
33141         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33142         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33143         CVec_u8Z_free(ret_var);
33144         return ret_arr;
33145 }
33146
33147 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_read"))) TS_NodeAnnouncement_read(int8_tArray ser) {
33148         LDKu8slice ser_ref;
33149         ser_ref.datalen = ser->arr_len;
33150         ser_ref.data = ser->elems /* XXX ser leaks */;
33151         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
33152         *ret_conv = NodeAnnouncement_read(ser_ref);
33153         return (uint32_t)ret_conv;
33154 }
33155
33156 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_read"))) TS_QueryShortChannelIds_read(int8_tArray ser) {
33157         LDKu8slice ser_ref;
33158         ser_ref.datalen = ser->arr_len;
33159         ser_ref.data = ser->elems /* XXX ser leaks */;
33160         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
33161         *ret_conv = QueryShortChannelIds_read(ser_ref);
33162         return (uint32_t)ret_conv;
33163 }
33164
33165 int8_tArray  __attribute__((export_name("TS_QueryShortChannelIds_write"))) TS_QueryShortChannelIds_write(uint32_t obj) {
33166         LDKQueryShortChannelIds obj_conv;
33167         obj_conv.inner = (void*)(obj & (~1));
33168         obj_conv.is_owned = false;
33169         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33170         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
33171         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33172         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33173         CVec_u8Z_free(ret_var);
33174         return ret_arr;
33175 }
33176
33177 int8_tArray  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_write"))) TS_ReplyShortChannelIdsEnd_write(uint32_t obj) {
33178         LDKReplyShortChannelIdsEnd obj_conv;
33179         obj_conv.inner = (void*)(obj & (~1));
33180         obj_conv.is_owned = false;
33181         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33182         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
33183         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33184         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33185         CVec_u8Z_free(ret_var);
33186         return ret_arr;
33187 }
33188
33189 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_read"))) TS_ReplyShortChannelIdsEnd_read(int8_tArray ser) {
33190         LDKu8slice ser_ref;
33191         ser_ref.datalen = ser->arr_len;
33192         ser_ref.data = ser->elems /* XXX ser leaks */;
33193         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
33194         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
33195         return (uint32_t)ret_conv;
33196 }
33197
33198 int32_t  __attribute__((export_name("TS_QueryChannelRange_end_blocknum"))) TS_QueryChannelRange_end_blocknum(uint32_t this_arg) {
33199         LDKQueryChannelRange this_arg_conv;
33200         this_arg_conv.inner = (void*)(this_arg & (~1));
33201         this_arg_conv.is_owned = false;
33202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33203         int32_t ret_conv = QueryChannelRange_end_blocknum(&this_arg_conv);
33204         return ret_conv;
33205 }
33206
33207 int8_tArray  __attribute__((export_name("TS_QueryChannelRange_write"))) TS_QueryChannelRange_write(uint32_t obj) {
33208         LDKQueryChannelRange obj_conv;
33209         obj_conv.inner = (void*)(obj & (~1));
33210         obj_conv.is_owned = false;
33211         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33212         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
33213         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33214         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33215         CVec_u8Z_free(ret_var);
33216         return ret_arr;
33217 }
33218
33219 uint32_t  __attribute__((export_name("TS_QueryChannelRange_read"))) TS_QueryChannelRange_read(int8_tArray ser) {
33220         LDKu8slice ser_ref;
33221         ser_ref.datalen = ser->arr_len;
33222         ser_ref.data = ser->elems /* XXX ser leaks */;
33223         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
33224         *ret_conv = QueryChannelRange_read(ser_ref);
33225         return (uint32_t)ret_conv;
33226 }
33227
33228 uint32_t  __attribute__((export_name("TS_ReplyChannelRange_read"))) TS_ReplyChannelRange_read(int8_tArray ser) {
33229         LDKu8slice ser_ref;
33230         ser_ref.datalen = ser->arr_len;
33231         ser_ref.data = ser->elems /* XXX ser leaks */;
33232         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
33233         *ret_conv = ReplyChannelRange_read(ser_ref);
33234         return (uint32_t)ret_conv;
33235 }
33236
33237 int8_tArray  __attribute__((export_name("TS_ReplyChannelRange_write"))) TS_ReplyChannelRange_write(uint32_t obj) {
33238         LDKReplyChannelRange obj_conv;
33239         obj_conv.inner = (void*)(obj & (~1));
33240         obj_conv.is_owned = false;
33241         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33242         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
33243         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33244         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33245         CVec_u8Z_free(ret_var);
33246         return ret_arr;
33247 }
33248
33249 int8_tArray  __attribute__((export_name("TS_GossipTimestampFilter_write"))) TS_GossipTimestampFilter_write(uint32_t obj) {
33250         LDKGossipTimestampFilter obj_conv;
33251         obj_conv.inner = (void*)(obj & (~1));
33252         obj_conv.is_owned = false;
33253         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33254         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
33255         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33256         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33257         CVec_u8Z_free(ret_var);
33258         return ret_arr;
33259 }
33260
33261 uint32_t  __attribute__((export_name("TS_GossipTimestampFilter_read"))) TS_GossipTimestampFilter_read(int8_tArray ser) {
33262         LDKu8slice ser_ref;
33263         ser_ref.datalen = ser->arr_len;
33264         ser_ref.data = ser->elems /* XXX ser leaks */;
33265         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
33266         *ret_conv = GossipTimestampFilter_read(ser_ref);
33267         return (uint32_t)ret_conv;
33268 }
33269
33270 void  __attribute__((export_name("TS_CustomMessageHandler_free"))) TS_CustomMessageHandler_free(uint32_t this_ptr) {
33271         if ((this_ptr & 1) != 0) return;
33272         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
33273         CHECK_ACCESS(this_ptr_ptr);
33274         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
33275         FREE((void*)this_ptr);
33276         CustomMessageHandler_free(this_ptr_conv);
33277 }
33278
33279 void  __attribute__((export_name("TS_IgnoringMessageHandler_free"))) TS_IgnoringMessageHandler_free(uint32_t this_obj) {
33280         LDKIgnoringMessageHandler this_obj_conv;
33281         this_obj_conv.inner = (void*)(this_obj & (~1));
33282         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33284         IgnoringMessageHandler_free(this_obj_conv);
33285 }
33286
33287 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_new"))) TS_IgnoringMessageHandler_new() {
33288         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
33289         uint32_t ret_ref = 0;
33290         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33291         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33292         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33293         ret_ref = (uintptr_t)ret_var.inner;
33294         if (ret_var.is_owned) {
33295                 ret_ref |= 1;
33296         }
33297         return ret_ref;
33298 }
33299
33300 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_MessageSendEventsProvider"))) TS_IgnoringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
33301         LDKIgnoringMessageHandler this_arg_conv;
33302         this_arg_conv.inner = (void*)(this_arg & (~1));
33303         this_arg_conv.is_owned = false;
33304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33305         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
33306         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
33307         return (uint32_t)ret_ret;
33308 }
33309
33310 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_RoutingMessageHandler"))) TS_IgnoringMessageHandler_as_RoutingMessageHandler(uint32_t this_arg) {
33311         LDKIgnoringMessageHandler this_arg_conv;
33312         this_arg_conv.inner = (void*)(this_arg & (~1));
33313         this_arg_conv.is_owned = false;
33314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33315         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
33316         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
33317         return (uint32_t)ret_ret;
33318 }
33319
33320 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_CustomMessageReader"))) TS_IgnoringMessageHandler_as_CustomMessageReader(uint32_t this_arg) {
33321         LDKIgnoringMessageHandler this_arg_conv;
33322         this_arg_conv.inner = (void*)(this_arg & (~1));
33323         this_arg_conv.is_owned = false;
33324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33325         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
33326         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
33327         return (uint32_t)ret_ret;
33328 }
33329
33330 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_CustomMessageHandler"))) TS_IgnoringMessageHandler_as_CustomMessageHandler(uint32_t this_arg) {
33331         LDKIgnoringMessageHandler this_arg_conv;
33332         this_arg_conv.inner = (void*)(this_arg & (~1));
33333         this_arg_conv.is_owned = false;
33334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33335         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
33336         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
33337         return (uint32_t)ret_ret;
33338 }
33339
33340 void  __attribute__((export_name("TS_ErroringMessageHandler_free"))) TS_ErroringMessageHandler_free(uint32_t this_obj) {
33341         LDKErroringMessageHandler this_obj_conv;
33342         this_obj_conv.inner = (void*)(this_obj & (~1));
33343         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33345         ErroringMessageHandler_free(this_obj_conv);
33346 }
33347
33348 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_new"))) TS_ErroringMessageHandler_new() {
33349         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
33350         uint32_t ret_ref = 0;
33351         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33352         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33353         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33354         ret_ref = (uintptr_t)ret_var.inner;
33355         if (ret_var.is_owned) {
33356                 ret_ref |= 1;
33357         }
33358         return ret_ref;
33359 }
33360
33361 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_as_MessageSendEventsProvider"))) TS_ErroringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
33362         LDKErroringMessageHandler this_arg_conv;
33363         this_arg_conv.inner = (void*)(this_arg & (~1));
33364         this_arg_conv.is_owned = false;
33365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33366         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
33367         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
33368         return (uint32_t)ret_ret;
33369 }
33370
33371 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_as_ChannelMessageHandler"))) TS_ErroringMessageHandler_as_ChannelMessageHandler(uint32_t this_arg) {
33372         LDKErroringMessageHandler this_arg_conv;
33373         this_arg_conv.inner = (void*)(this_arg & (~1));
33374         this_arg_conv.is_owned = false;
33375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33376         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
33377         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
33378         return (uint32_t)ret_ret;
33379 }
33380
33381 void  __attribute__((export_name("TS_MessageHandler_free"))) TS_MessageHandler_free(uint32_t this_obj) {
33382         LDKMessageHandler this_obj_conv;
33383         this_obj_conv.inner = (void*)(this_obj & (~1));
33384         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33386         MessageHandler_free(this_obj_conv);
33387 }
33388
33389 uint32_t  __attribute__((export_name("TS_MessageHandler_get_chan_handler"))) TS_MessageHandler_get_chan_handler(uint32_t this_ptr) {
33390         LDKMessageHandler this_ptr_conv;
33391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33392         this_ptr_conv.is_owned = false;
33393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33394         // WARNING: This object doesn't live past this scope, needs clone!
33395         uint32_t ret_ret = ((uintptr_t)MessageHandler_get_chan_handler(&this_ptr_conv)) | 1;
33396         return ret_ret;
33397 }
33398
33399 void  __attribute__((export_name("TS_MessageHandler_set_chan_handler"))) TS_MessageHandler_set_chan_handler(uint32_t this_ptr, uint32_t val) {
33400         LDKMessageHandler this_ptr_conv;
33401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33402         this_ptr_conv.is_owned = false;
33403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33404         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
33405         CHECK_ACCESS(val_ptr);
33406         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
33407         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
33408                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33409                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
33410         }
33411         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
33412 }
33413
33414 uint32_t  __attribute__((export_name("TS_MessageHandler_get_route_handler"))) TS_MessageHandler_get_route_handler(uint32_t this_ptr) {
33415         LDKMessageHandler this_ptr_conv;
33416         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33417         this_ptr_conv.is_owned = false;
33418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33419         // WARNING: This object doesn't live past this scope, needs clone!
33420         uint32_t ret_ret = ((uintptr_t)MessageHandler_get_route_handler(&this_ptr_conv)) | 1;
33421         return ret_ret;
33422 }
33423
33424 void  __attribute__((export_name("TS_MessageHandler_set_route_handler"))) TS_MessageHandler_set_route_handler(uint32_t this_ptr, uint32_t val) {
33425         LDKMessageHandler this_ptr_conv;
33426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33427         this_ptr_conv.is_owned = false;
33428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33429         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
33430         CHECK_ACCESS(val_ptr);
33431         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
33432         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
33433                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33434                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
33435         }
33436         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
33437 }
33438
33439 uint32_t  __attribute__((export_name("TS_MessageHandler_new"))) TS_MessageHandler_new(uint32_t chan_handler_arg, uint32_t route_handler_arg) {
33440         void* chan_handler_arg_ptr = (void*)(((uintptr_t)chan_handler_arg) & ~1);
33441         CHECK_ACCESS(chan_handler_arg_ptr);
33442         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
33443         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
33444                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33445                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
33446         }
33447         void* route_handler_arg_ptr = (void*)(((uintptr_t)route_handler_arg) & ~1);
33448         CHECK_ACCESS(route_handler_arg_ptr);
33449         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
33450         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
33451                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33452                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
33453         }
33454         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
33455         uint32_t ret_ref = 0;
33456         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33457         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33458         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33459         ret_ref = (uintptr_t)ret_var.inner;
33460         if (ret_var.is_owned) {
33461                 ret_ref |= 1;
33462         }
33463         return ret_ref;
33464 }
33465
33466 static inline uintptr_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
33467         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
33468         *ret_ret = SocketDescriptor_clone(arg);
33469         return (uint32_t)ret_ret;
33470 }
33471 uint32_t  __attribute__((export_name("TS_SocketDescriptor_clone_ptr"))) TS_SocketDescriptor_clone_ptr(uint32_t arg) {
33472         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
33473         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
33474         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
33475         uint32_t ret_conv = SocketDescriptor_clone_ptr(arg_conv);
33476         return ret_conv;
33477 }
33478
33479 uint32_t  __attribute__((export_name("TS_SocketDescriptor_clone"))) TS_SocketDescriptor_clone(uint32_t orig) {
33480         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
33481         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
33482         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
33483         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
33484         *ret_ret = SocketDescriptor_clone(orig_conv);
33485         return (uint32_t)ret_ret;
33486 }
33487
33488 void  __attribute__((export_name("TS_SocketDescriptor_free"))) TS_SocketDescriptor_free(uint32_t this_ptr) {
33489         if ((this_ptr & 1) != 0) return;
33490         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
33491         CHECK_ACCESS(this_ptr_ptr);
33492         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
33493         FREE((void*)this_ptr);
33494         SocketDescriptor_free(this_ptr_conv);
33495 }
33496
33497 void  __attribute__((export_name("TS_PeerHandleError_free"))) TS_PeerHandleError_free(uint32_t this_obj) {
33498         LDKPeerHandleError this_obj_conv;
33499         this_obj_conv.inner = (void*)(this_obj & (~1));
33500         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33502         PeerHandleError_free(this_obj_conv);
33503 }
33504
33505 jboolean  __attribute__((export_name("TS_PeerHandleError_get_no_connection_possible"))) TS_PeerHandleError_get_no_connection_possible(uint32_t this_ptr) {
33506         LDKPeerHandleError this_ptr_conv;
33507         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33508         this_ptr_conv.is_owned = false;
33509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33510         jboolean ret_conv = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
33511         return ret_conv;
33512 }
33513
33514 void  __attribute__((export_name("TS_PeerHandleError_set_no_connection_possible"))) TS_PeerHandleError_set_no_connection_possible(uint32_t this_ptr, jboolean val) {
33515         LDKPeerHandleError this_ptr_conv;
33516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33517         this_ptr_conv.is_owned = false;
33518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33519         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
33520 }
33521
33522 uint32_t  __attribute__((export_name("TS_PeerHandleError_new"))) TS_PeerHandleError_new(jboolean no_connection_possible_arg) {
33523         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
33524         uint32_t ret_ref = 0;
33525         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33526         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33527         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33528         ret_ref = (uintptr_t)ret_var.inner;
33529         if (ret_var.is_owned) {
33530                 ret_ref |= 1;
33531         }
33532         return ret_ref;
33533 }
33534
33535 static inline uintptr_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
33536         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
33537 uint32_t ret_ref = 0;
33538 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33539 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33540 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33541 ret_ref = (uintptr_t)ret_var.inner;
33542 if (ret_var.is_owned) {
33543         ret_ref |= 1;
33544 }
33545         return ret_ref;
33546 }
33547 uint32_t  __attribute__((export_name("TS_PeerHandleError_clone_ptr"))) TS_PeerHandleError_clone_ptr(uint32_t arg) {
33548         LDKPeerHandleError arg_conv;
33549         arg_conv.inner = (void*)(arg & (~1));
33550         arg_conv.is_owned = false;
33551         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33552         uint32_t ret_conv = PeerHandleError_clone_ptr(&arg_conv);
33553         return ret_conv;
33554 }
33555
33556 uint32_t  __attribute__((export_name("TS_PeerHandleError_clone"))) TS_PeerHandleError_clone(uint32_t orig) {
33557         LDKPeerHandleError orig_conv;
33558         orig_conv.inner = (void*)(orig & (~1));
33559         orig_conv.is_owned = false;
33560         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33561         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
33562         uint32_t ret_ref = 0;
33563         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33564         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33565         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33566         ret_ref = (uintptr_t)ret_var.inner;
33567         if (ret_var.is_owned) {
33568                 ret_ref |= 1;
33569         }
33570         return ret_ref;
33571 }
33572
33573 void  __attribute__((export_name("TS_PeerManager_free"))) TS_PeerManager_free(uint32_t this_obj) {
33574         LDKPeerManager this_obj_conv;
33575         this_obj_conv.inner = (void*)(this_obj & (~1));
33576         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33578         PeerManager_free(this_obj_conv);
33579 }
33580
33581 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) {
33582         LDKMessageHandler message_handler_conv;
33583         message_handler_conv.inner = (void*)(message_handler & (~1));
33584         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
33585         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
33586         // WARNING: we need a move here but no clone is available for LDKMessageHandler
33587         LDKSecretKey our_node_secret_ref;
33588         CHECK(our_node_secret->arr_len == 32);
33589         memcpy(our_node_secret_ref.bytes, our_node_secret->elems, 32); FREE(our_node_secret);
33590         unsigned char ephemeral_random_data_arr[32];
33591         CHECK(ephemeral_random_data->arr_len == 32);
33592         memcpy(ephemeral_random_data_arr, ephemeral_random_data->elems, 32); FREE(ephemeral_random_data);
33593         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
33594         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
33595         CHECK_ACCESS(logger_ptr);
33596         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
33597         if (logger_conv.free == LDKLogger_JCalls_free) {
33598                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33599                 LDKLogger_JCalls_cloned(&logger_conv);
33600         }
33601         void* custom_message_handler_ptr = (void*)(((uintptr_t)custom_message_handler) & ~1);
33602         CHECK_ACCESS(custom_message_handler_ptr);
33603         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
33604         if (custom_message_handler_conv.free == LDKCustomMessageHandler_JCalls_free) {
33605                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33606                 LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_conv);
33607         }
33608         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
33609         uint32_t ret_ref = 0;
33610         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33611         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33612         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33613         ret_ref = (uintptr_t)ret_var.inner;
33614         if (ret_var.is_owned) {
33615                 ret_ref |= 1;
33616         }
33617         return ret_ref;
33618 }
33619
33620 ptrArray  __attribute__((export_name("TS_PeerManager_get_peer_node_ids"))) TS_PeerManager_get_peer_node_ids(uint32_t this_arg) {
33621         LDKPeerManager this_arg_conv;
33622         this_arg_conv.inner = (void*)(this_arg & (~1));
33623         this_arg_conv.is_owned = false;
33624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33625         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
33626         ptrArray ret_arr = NULL;
33627         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
33628         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
33629         for (size_t m = 0; m < ret_var.datalen; m++) {
33630                 int8_tArray ret_conv_12_arr = init_int8_tArray(33, __LINE__);
33631                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compressed_form, 33);
33632                 ret_arr_ptr[m] = ret_conv_12_arr;
33633         }
33634         
33635         FREE(ret_var.data);
33636         return ret_arr;
33637 }
33638
33639 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) {
33640         LDKPeerManager this_arg_conv;
33641         this_arg_conv.inner = (void*)(this_arg & (~1));
33642         this_arg_conv.is_owned = false;
33643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33644         LDKPublicKey their_node_id_ref;
33645         CHECK(their_node_id->arr_len == 33);
33646         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
33647         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
33648         CHECK_ACCESS(descriptor_ptr);
33649         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
33650         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
33651                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33652                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
33653         }
33654         void* remote_network_address_ptr = (void*)(((uintptr_t)remote_network_address) & ~1);
33655         CHECK_ACCESS(remote_network_address_ptr);
33656         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
33657         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
33658         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv, remote_network_address_conv);
33659         return (uint32_t)ret_conv;
33660 }
33661
33662 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) {
33663         LDKPeerManager this_arg_conv;
33664         this_arg_conv.inner = (void*)(this_arg & (~1));
33665         this_arg_conv.is_owned = false;
33666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33667         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
33668         CHECK_ACCESS(descriptor_ptr);
33669         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
33670         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
33671                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33672                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
33673         }
33674         void* remote_network_address_ptr = (void*)(((uintptr_t)remote_network_address) & ~1);
33675         CHECK_ACCESS(remote_network_address_ptr);
33676         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
33677         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
33678         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv, remote_network_address_conv);
33679         return (uint32_t)ret_conv;
33680 }
33681
33682 uint32_t  __attribute__((export_name("TS_PeerManager_write_buffer_space_avail"))) TS_PeerManager_write_buffer_space_avail(uint32_t this_arg, uint32_t descriptor) {
33683         LDKPeerManager this_arg_conv;
33684         this_arg_conv.inner = (void*)(this_arg & (~1));
33685         this_arg_conv.is_owned = false;
33686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33687         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
33688         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
33689         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
33690         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
33691         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
33692         return (uint32_t)ret_conv;
33693 }
33694
33695 uint32_t  __attribute__((export_name("TS_PeerManager_read_event"))) TS_PeerManager_read_event(uint32_t this_arg, uint32_t peer_descriptor, int8_tArray data) {
33696         LDKPeerManager this_arg_conv;
33697         this_arg_conv.inner = (void*)(this_arg & (~1));
33698         this_arg_conv.is_owned = false;
33699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33700         void* peer_descriptor_ptr = (void*)(((uintptr_t)peer_descriptor) & ~1);
33701         if (!(peer_descriptor & 1)) { CHECK_ACCESS(peer_descriptor_ptr); }
33702         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
33703         LDKu8slice data_ref;
33704         data_ref.datalen = data->arr_len;
33705         data_ref.data = data->elems /* XXX data leaks */;
33706         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
33707         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
33708         return (uint32_t)ret_conv;
33709 }
33710
33711 void  __attribute__((export_name("TS_PeerManager_process_events"))) TS_PeerManager_process_events(uint32_t this_arg) {
33712         LDKPeerManager this_arg_conv;
33713         this_arg_conv.inner = (void*)(this_arg & (~1));
33714         this_arg_conv.is_owned = false;
33715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33716         PeerManager_process_events(&this_arg_conv);
33717 }
33718
33719 void  __attribute__((export_name("TS_PeerManager_socket_disconnected"))) TS_PeerManager_socket_disconnected(uint32_t this_arg, uint32_t descriptor) {
33720         LDKPeerManager this_arg_conv;
33721         this_arg_conv.inner = (void*)(this_arg & (~1));
33722         this_arg_conv.is_owned = false;
33723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33724         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
33725         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
33726         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
33727         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
33728 }
33729
33730 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) {
33731         LDKPeerManager this_arg_conv;
33732         this_arg_conv.inner = (void*)(this_arg & (~1));
33733         this_arg_conv.is_owned = false;
33734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33735         LDKPublicKey node_id_ref;
33736         CHECK(node_id->arr_len == 33);
33737         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
33738         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
33739 }
33740
33741 void  __attribute__((export_name("TS_PeerManager_disconnect_all_peers"))) TS_PeerManager_disconnect_all_peers(uint32_t this_arg) {
33742         LDKPeerManager this_arg_conv;
33743         this_arg_conv.inner = (void*)(this_arg & (~1));
33744         this_arg_conv.is_owned = false;
33745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33746         PeerManager_disconnect_all_peers(&this_arg_conv);
33747 }
33748
33749 void  __attribute__((export_name("TS_PeerManager_timer_tick_occurred"))) TS_PeerManager_timer_tick_occurred(uint32_t this_arg) {
33750         LDKPeerManager this_arg_conv;
33751         this_arg_conv.inner = (void*)(this_arg & (~1));
33752         this_arg_conv.is_owned = false;
33753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33754         PeerManager_timer_tick_occurred(&this_arg_conv);
33755 }
33756
33757 int64_t  __attribute__((export_name("TS_htlc_success_tx_weight"))) TS_htlc_success_tx_weight(jboolean opt_anchors) {
33758         int64_t ret_conv = htlc_success_tx_weight(opt_anchors);
33759         return ret_conv;
33760 }
33761
33762 int64_t  __attribute__((export_name("TS_htlc_timeout_tx_weight"))) TS_htlc_timeout_tx_weight(jboolean opt_anchors) {
33763         int64_t ret_conv = htlc_timeout_tx_weight(opt_anchors);
33764         return ret_conv;
33765 }
33766
33767 int8_tArray  __attribute__((export_name("TS_build_commitment_secret"))) TS_build_commitment_secret(int8_tArray commitment_seed, int64_t idx) {
33768         unsigned char commitment_seed_arr[32];
33769         CHECK(commitment_seed->arr_len == 32);
33770         memcpy(commitment_seed_arr, commitment_seed->elems, 32); FREE(commitment_seed);
33771         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
33772         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
33773         memcpy(ret_arr->elems, build_commitment_secret(commitment_seed_ref, idx).data, 32);
33774         return ret_arr;
33775 }
33776
33777 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) {
33778         LDKCVec_u8Z to_holder_script_ref;
33779         to_holder_script_ref.datalen = to_holder_script->arr_len;
33780         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
33781         memcpy(to_holder_script_ref.data, to_holder_script->elems, to_holder_script_ref.datalen); FREE(to_holder_script);
33782         LDKCVec_u8Z to_counterparty_script_ref;
33783         to_counterparty_script_ref.datalen = to_counterparty_script->arr_len;
33784         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
33785         memcpy(to_counterparty_script_ref.data, to_counterparty_script->elems, to_counterparty_script_ref.datalen); FREE(to_counterparty_script);
33786         LDKOutPoint funding_outpoint_conv;
33787         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
33788         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
33789         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
33790         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
33791         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);
33792         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33793         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33794         Transaction_free(ret_var);
33795         return ret_arr;
33796 }
33797
33798 void  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_free"))) TS_CounterpartyCommitmentSecrets_free(uint32_t this_obj) {
33799         LDKCounterpartyCommitmentSecrets this_obj_conv;
33800         this_obj_conv.inner = (void*)(this_obj & (~1));
33801         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33803         CounterpartyCommitmentSecrets_free(this_obj_conv);
33804 }
33805
33806 static inline uintptr_t CounterpartyCommitmentSecrets_clone_ptr(LDKCounterpartyCommitmentSecrets *NONNULL_PTR arg) {
33807         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(arg);
33808 uint32_t ret_ref = 0;
33809 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33810 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33811 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33812 ret_ref = (uintptr_t)ret_var.inner;
33813 if (ret_var.is_owned) {
33814         ret_ref |= 1;
33815 }
33816         return ret_ref;
33817 }
33818 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_clone_ptr"))) TS_CounterpartyCommitmentSecrets_clone_ptr(uint32_t arg) {
33819         LDKCounterpartyCommitmentSecrets arg_conv;
33820         arg_conv.inner = (void*)(arg & (~1));
33821         arg_conv.is_owned = false;
33822         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33823         uint32_t ret_conv = CounterpartyCommitmentSecrets_clone_ptr(&arg_conv);
33824         return ret_conv;
33825 }
33826
33827 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_clone"))) TS_CounterpartyCommitmentSecrets_clone(uint32_t orig) {
33828         LDKCounterpartyCommitmentSecrets orig_conv;
33829         orig_conv.inner = (void*)(orig & (~1));
33830         orig_conv.is_owned = false;
33831         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33832         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(&orig_conv);
33833         uint32_t ret_ref = 0;
33834         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33835         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33836         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33837         ret_ref = (uintptr_t)ret_var.inner;
33838         if (ret_var.is_owned) {
33839                 ret_ref |= 1;
33840         }
33841         return ret_ref;
33842 }
33843
33844 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_new"))) TS_CounterpartyCommitmentSecrets_new() {
33845         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_new();
33846         uint32_t ret_ref = 0;
33847         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33848         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33849         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33850         ret_ref = (uintptr_t)ret_var.inner;
33851         if (ret_var.is_owned) {
33852                 ret_ref |= 1;
33853         }
33854         return ret_ref;
33855 }
33856
33857 int64_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_get_min_seen_secret"))) TS_CounterpartyCommitmentSecrets_get_min_seen_secret(uint32_t this_arg) {
33858         LDKCounterpartyCommitmentSecrets this_arg_conv;
33859         this_arg_conv.inner = (void*)(this_arg & (~1));
33860         this_arg_conv.is_owned = false;
33861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33862         int64_t ret_conv = CounterpartyCommitmentSecrets_get_min_seen_secret(&this_arg_conv);
33863         return ret_conv;
33864 }
33865
33866 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_provide_secret"))) TS_CounterpartyCommitmentSecrets_provide_secret(uint32_t this_arg, int64_t idx, int8_tArray secret) {
33867         LDKCounterpartyCommitmentSecrets this_arg_conv;
33868         this_arg_conv.inner = (void*)(this_arg & (~1));
33869         this_arg_conv.is_owned = false;
33870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33871         LDKThirtyTwoBytes secret_ref;
33872         CHECK(secret->arr_len == 32);
33873         memcpy(secret_ref.data, secret->elems, 32); FREE(secret);
33874         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
33875         *ret_conv = CounterpartyCommitmentSecrets_provide_secret(&this_arg_conv, idx, secret_ref);
33876         return (uint32_t)ret_conv;
33877 }
33878
33879 int8_tArray  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_get_secret"))) TS_CounterpartyCommitmentSecrets_get_secret(uint32_t this_arg, int64_t idx) {
33880         LDKCounterpartyCommitmentSecrets this_arg_conv;
33881         this_arg_conv.inner = (void*)(this_arg & (~1));
33882         this_arg_conv.is_owned = false;
33883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33884         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
33885         memcpy(ret_arr->elems, CounterpartyCommitmentSecrets_get_secret(&this_arg_conv, idx).data, 32);
33886         return ret_arr;
33887 }
33888
33889 int8_tArray  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_write"))) TS_CounterpartyCommitmentSecrets_write(uint32_t obj) {
33890         LDKCounterpartyCommitmentSecrets obj_conv;
33891         obj_conv.inner = (void*)(obj & (~1));
33892         obj_conv.is_owned = false;
33893         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33894         LDKCVec_u8Z ret_var = CounterpartyCommitmentSecrets_write(&obj_conv);
33895         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33896         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33897         CVec_u8Z_free(ret_var);
33898         return ret_arr;
33899 }
33900
33901 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_read"))) TS_CounterpartyCommitmentSecrets_read(int8_tArray ser) {
33902         LDKu8slice ser_ref;
33903         ser_ref.datalen = ser->arr_len;
33904         ser_ref.data = ser->elems /* XXX ser leaks */;
33905         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
33906         *ret_conv = CounterpartyCommitmentSecrets_read(ser_ref);
33907         return (uint32_t)ret_conv;
33908 }
33909
33910 uint32_t  __attribute__((export_name("TS_derive_private_key"))) TS_derive_private_key(int8_tArray per_commitment_point, int8_tArray base_secret) {
33911         LDKPublicKey per_commitment_point_ref;
33912         CHECK(per_commitment_point->arr_len == 33);
33913         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
33914         unsigned char base_secret_arr[32];
33915         CHECK(base_secret->arr_len == 32);
33916         memcpy(base_secret_arr, base_secret->elems, 32); FREE(base_secret);
33917         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
33918         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
33919         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
33920         return (uint32_t)ret_conv;
33921 }
33922
33923 uint32_t  __attribute__((export_name("TS_derive_public_key"))) TS_derive_public_key(int8_tArray per_commitment_point, int8_tArray base_point) {
33924         LDKPublicKey per_commitment_point_ref;
33925         CHECK(per_commitment_point->arr_len == 33);
33926         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
33927         LDKPublicKey base_point_ref;
33928         CHECK(base_point->arr_len == 33);
33929         memcpy(base_point_ref.compressed_form, base_point->elems, 33); FREE(base_point);
33930         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
33931         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
33932         return (uint32_t)ret_conv;
33933 }
33934
33935 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) {
33936         unsigned char per_commitment_secret_arr[32];
33937         CHECK(per_commitment_secret->arr_len == 32);
33938         memcpy(per_commitment_secret_arr, per_commitment_secret->elems, 32); FREE(per_commitment_secret);
33939         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
33940         unsigned char countersignatory_revocation_base_secret_arr[32];
33941         CHECK(countersignatory_revocation_base_secret->arr_len == 32);
33942         memcpy(countersignatory_revocation_base_secret_arr, countersignatory_revocation_base_secret->elems, 32); FREE(countersignatory_revocation_base_secret);
33943         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
33944         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
33945         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
33946         return (uint32_t)ret_conv;
33947 }
33948
33949 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) {
33950         LDKPublicKey per_commitment_point_ref;
33951         CHECK(per_commitment_point->arr_len == 33);
33952         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
33953         LDKPublicKey countersignatory_revocation_base_point_ref;
33954         CHECK(countersignatory_revocation_base_point->arr_len == 33);
33955         memcpy(countersignatory_revocation_base_point_ref.compressed_form, countersignatory_revocation_base_point->elems, 33); FREE(countersignatory_revocation_base_point);
33956         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
33957         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
33958         return (uint32_t)ret_conv;
33959 }
33960
33961 void  __attribute__((export_name("TS_TxCreationKeys_free"))) TS_TxCreationKeys_free(uint32_t this_obj) {
33962         LDKTxCreationKeys this_obj_conv;
33963         this_obj_conv.inner = (void*)(this_obj & (~1));
33964         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33966         TxCreationKeys_free(this_obj_conv);
33967 }
33968
33969 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_per_commitment_point"))) TS_TxCreationKeys_get_per_commitment_point(uint32_t this_ptr) {
33970         LDKTxCreationKeys this_ptr_conv;
33971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33972         this_ptr_conv.is_owned = false;
33973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33974         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
33975         memcpy(ret_arr->elems, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
33976         return ret_arr;
33977 }
33978
33979 void  __attribute__((export_name("TS_TxCreationKeys_set_per_commitment_point"))) TS_TxCreationKeys_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
33980         LDKTxCreationKeys this_ptr_conv;
33981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33982         this_ptr_conv.is_owned = false;
33983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33984         LDKPublicKey val_ref;
33985         CHECK(val->arr_len == 33);
33986         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
33987         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
33988 }
33989
33990 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_revocation_key"))) TS_TxCreationKeys_get_revocation_key(uint32_t this_ptr) {
33991         LDKTxCreationKeys this_ptr_conv;
33992         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33993         this_ptr_conv.is_owned = false;
33994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33995         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
33996         memcpy(ret_arr->elems, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form, 33);
33997         return ret_arr;
33998 }
33999
34000 void  __attribute__((export_name("TS_TxCreationKeys_set_revocation_key"))) TS_TxCreationKeys_set_revocation_key(uint32_t this_ptr, int8_tArray val) {
34001         LDKTxCreationKeys this_ptr_conv;
34002         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34003         this_ptr_conv.is_owned = false;
34004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34005         LDKPublicKey val_ref;
34006         CHECK(val->arr_len == 33);
34007         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
34008         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
34009 }
34010
34011 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_broadcaster_htlc_key"))) TS_TxCreationKeys_get_broadcaster_htlc_key(uint32_t this_ptr) {
34012         LDKTxCreationKeys this_ptr_conv;
34013         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34014         this_ptr_conv.is_owned = false;
34015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34016         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
34017         memcpy(ret_arr->elems, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form, 33);
34018         return ret_arr;
34019 }
34020
34021 void  __attribute__((export_name("TS_TxCreationKeys_set_broadcaster_htlc_key"))) TS_TxCreationKeys_set_broadcaster_htlc_key(uint32_t this_ptr, int8_tArray val) {
34022         LDKTxCreationKeys this_ptr_conv;
34023         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34024         this_ptr_conv.is_owned = false;
34025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34026         LDKPublicKey val_ref;
34027         CHECK(val->arr_len == 33);
34028         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
34029         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
34030 }
34031
34032 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_countersignatory_htlc_key"))) TS_TxCreationKeys_get_countersignatory_htlc_key(uint32_t this_ptr) {
34033         LDKTxCreationKeys this_ptr_conv;
34034         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34035         this_ptr_conv.is_owned = false;
34036         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34037         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
34038         memcpy(ret_arr->elems, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form, 33);
34039         return ret_arr;
34040 }
34041
34042 void  __attribute__((export_name("TS_TxCreationKeys_set_countersignatory_htlc_key"))) TS_TxCreationKeys_set_countersignatory_htlc_key(uint32_t this_ptr, int8_tArray val) {
34043         LDKTxCreationKeys this_ptr_conv;
34044         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34045         this_ptr_conv.is_owned = false;
34046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34047         LDKPublicKey val_ref;
34048         CHECK(val->arr_len == 33);
34049         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
34050         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
34051 }
34052
34053 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_broadcaster_delayed_payment_key"))) TS_TxCreationKeys_get_broadcaster_delayed_payment_key(uint32_t this_ptr) {
34054         LDKTxCreationKeys this_ptr_conv;
34055         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34056         this_ptr_conv.is_owned = false;
34057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34058         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
34059         memcpy(ret_arr->elems, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form, 33);
34060         return ret_arr;
34061 }
34062
34063 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) {
34064         LDKTxCreationKeys this_ptr_conv;
34065         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34066         this_ptr_conv.is_owned = false;
34067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34068         LDKPublicKey val_ref;
34069         CHECK(val->arr_len == 33);
34070         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
34071         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
34072 }
34073
34074 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) {
34075         LDKPublicKey per_commitment_point_arg_ref;
34076         CHECK(per_commitment_point_arg->arr_len == 33);
34077         memcpy(per_commitment_point_arg_ref.compressed_form, per_commitment_point_arg->elems, 33); FREE(per_commitment_point_arg);
34078         LDKPublicKey revocation_key_arg_ref;
34079         CHECK(revocation_key_arg->arr_len == 33);
34080         memcpy(revocation_key_arg_ref.compressed_form, revocation_key_arg->elems, 33); FREE(revocation_key_arg);
34081         LDKPublicKey broadcaster_htlc_key_arg_ref;
34082         CHECK(broadcaster_htlc_key_arg->arr_len == 33);
34083         memcpy(broadcaster_htlc_key_arg_ref.compressed_form, broadcaster_htlc_key_arg->elems, 33); FREE(broadcaster_htlc_key_arg);
34084         LDKPublicKey countersignatory_htlc_key_arg_ref;
34085         CHECK(countersignatory_htlc_key_arg->arr_len == 33);
34086         memcpy(countersignatory_htlc_key_arg_ref.compressed_form, countersignatory_htlc_key_arg->elems, 33); FREE(countersignatory_htlc_key_arg);
34087         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
34088         CHECK(broadcaster_delayed_payment_key_arg->arr_len == 33);
34089         memcpy(broadcaster_delayed_payment_key_arg_ref.compressed_form, broadcaster_delayed_payment_key_arg->elems, 33); FREE(broadcaster_delayed_payment_key_arg);
34090         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);
34091         uint32_t ret_ref = 0;
34092         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34093         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34094         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34095         ret_ref = (uintptr_t)ret_var.inner;
34096         if (ret_var.is_owned) {
34097                 ret_ref |= 1;
34098         }
34099         return ret_ref;
34100 }
34101
34102 static inline uintptr_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
34103         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
34104 uint32_t ret_ref = 0;
34105 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34106 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34107 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34108 ret_ref = (uintptr_t)ret_var.inner;
34109 if (ret_var.is_owned) {
34110         ret_ref |= 1;
34111 }
34112         return ret_ref;
34113 }
34114 uint32_t  __attribute__((export_name("TS_TxCreationKeys_clone_ptr"))) TS_TxCreationKeys_clone_ptr(uint32_t arg) {
34115         LDKTxCreationKeys arg_conv;
34116         arg_conv.inner = (void*)(arg & (~1));
34117         arg_conv.is_owned = false;
34118         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34119         uint32_t ret_conv = TxCreationKeys_clone_ptr(&arg_conv);
34120         return ret_conv;
34121 }
34122
34123 uint32_t  __attribute__((export_name("TS_TxCreationKeys_clone"))) TS_TxCreationKeys_clone(uint32_t orig) {
34124         LDKTxCreationKeys orig_conv;
34125         orig_conv.inner = (void*)(orig & (~1));
34126         orig_conv.is_owned = false;
34127         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34128         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
34129         uint32_t ret_ref = 0;
34130         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34131         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34132         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34133         ret_ref = (uintptr_t)ret_var.inner;
34134         if (ret_var.is_owned) {
34135                 ret_ref |= 1;
34136         }
34137         return ret_ref;
34138 }
34139
34140 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_write"))) TS_TxCreationKeys_write(uint32_t obj) {
34141         LDKTxCreationKeys 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 = TxCreationKeys_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_TxCreationKeys_read"))) TS_TxCreationKeys_read(int8_tArray ser) {
34153         LDKu8slice ser_ref;
34154         ser_ref.datalen = ser->arr_len;
34155         ser_ref.data = ser->elems /* XXX ser leaks */;
34156         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
34157         *ret_conv = TxCreationKeys_read(ser_ref);
34158         return (uint32_t)ret_conv;
34159 }
34160
34161 void  __attribute__((export_name("TS_ChannelPublicKeys_free"))) TS_ChannelPublicKeys_free(uint32_t this_obj) {
34162         LDKChannelPublicKeys this_obj_conv;
34163         this_obj_conv.inner = (void*)(this_obj & (~1));
34164         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34166         ChannelPublicKeys_free(this_obj_conv);
34167 }
34168
34169 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_funding_pubkey"))) TS_ChannelPublicKeys_get_funding_pubkey(uint32_t this_ptr) {
34170         LDKChannelPublicKeys this_ptr_conv;
34171         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34172         this_ptr_conv.is_owned = false;
34173         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34174         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
34175         memcpy(ret_arr->elems, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
34176         return ret_arr;
34177 }
34178
34179 void  __attribute__((export_name("TS_ChannelPublicKeys_set_funding_pubkey"))) TS_ChannelPublicKeys_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
34180         LDKChannelPublicKeys this_ptr_conv;
34181         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34182         this_ptr_conv.is_owned = false;
34183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34184         LDKPublicKey val_ref;
34185         CHECK(val->arr_len == 33);
34186         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
34187         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
34188 }
34189
34190 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_revocation_basepoint"))) TS_ChannelPublicKeys_get_revocation_basepoint(uint32_t this_ptr) {
34191         LDKChannelPublicKeys this_ptr_conv;
34192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34193         this_ptr_conv.is_owned = false;
34194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34195         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
34196         memcpy(ret_arr->elems, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
34197         return ret_arr;
34198 }
34199
34200 void  __attribute__((export_name("TS_ChannelPublicKeys_set_revocation_basepoint"))) TS_ChannelPublicKeys_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
34201         LDKChannelPublicKeys this_ptr_conv;
34202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34203         this_ptr_conv.is_owned = false;
34204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34205         LDKPublicKey val_ref;
34206         CHECK(val->arr_len == 33);
34207         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
34208         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
34209 }
34210
34211 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_payment_point"))) TS_ChannelPublicKeys_get_payment_point(uint32_t this_ptr) {
34212         LDKChannelPublicKeys this_ptr_conv;
34213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34214         this_ptr_conv.is_owned = false;
34215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34216         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
34217         memcpy(ret_arr->elems, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form, 33);
34218         return ret_arr;
34219 }
34220
34221 void  __attribute__((export_name("TS_ChannelPublicKeys_set_payment_point"))) TS_ChannelPublicKeys_set_payment_point(uint32_t this_ptr, int8_tArray val) {
34222         LDKChannelPublicKeys this_ptr_conv;
34223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34224         this_ptr_conv.is_owned = false;
34225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34226         LDKPublicKey val_ref;
34227         CHECK(val->arr_len == 33);
34228         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
34229         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
34230 }
34231
34232 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_delayed_payment_basepoint"))) TS_ChannelPublicKeys_get_delayed_payment_basepoint(uint32_t this_ptr) {
34233         LDKChannelPublicKeys this_ptr_conv;
34234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34235         this_ptr_conv.is_owned = false;
34236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34237         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
34238         memcpy(ret_arr->elems, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
34239         return ret_arr;
34240 }
34241
34242 void  __attribute__((export_name("TS_ChannelPublicKeys_set_delayed_payment_basepoint"))) TS_ChannelPublicKeys_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
34243         LDKChannelPublicKeys this_ptr_conv;
34244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34245         this_ptr_conv.is_owned = false;
34246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34247         LDKPublicKey val_ref;
34248         CHECK(val->arr_len == 33);
34249         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
34250         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
34251 }
34252
34253 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_htlc_basepoint"))) TS_ChannelPublicKeys_get_htlc_basepoint(uint32_t this_ptr) {
34254         LDKChannelPublicKeys this_ptr_conv;
34255         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34256         this_ptr_conv.is_owned = false;
34257         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34258         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
34259         memcpy(ret_arr->elems, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
34260         return ret_arr;
34261 }
34262
34263 void  __attribute__((export_name("TS_ChannelPublicKeys_set_htlc_basepoint"))) TS_ChannelPublicKeys_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
34264         LDKChannelPublicKeys this_ptr_conv;
34265         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34266         this_ptr_conv.is_owned = false;
34267         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34268         LDKPublicKey val_ref;
34269         CHECK(val->arr_len == 33);
34270         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
34271         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
34272 }
34273
34274 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) {
34275         LDKPublicKey funding_pubkey_arg_ref;
34276         CHECK(funding_pubkey_arg->arr_len == 33);
34277         memcpy(funding_pubkey_arg_ref.compressed_form, funding_pubkey_arg->elems, 33); FREE(funding_pubkey_arg);
34278         LDKPublicKey revocation_basepoint_arg_ref;
34279         CHECK(revocation_basepoint_arg->arr_len == 33);
34280         memcpy(revocation_basepoint_arg_ref.compressed_form, revocation_basepoint_arg->elems, 33); FREE(revocation_basepoint_arg);
34281         LDKPublicKey payment_point_arg_ref;
34282         CHECK(payment_point_arg->arr_len == 33);
34283         memcpy(payment_point_arg_ref.compressed_form, payment_point_arg->elems, 33); FREE(payment_point_arg);
34284         LDKPublicKey delayed_payment_basepoint_arg_ref;
34285         CHECK(delayed_payment_basepoint_arg->arr_len == 33);
34286         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, delayed_payment_basepoint_arg->elems, 33); FREE(delayed_payment_basepoint_arg);
34287         LDKPublicKey htlc_basepoint_arg_ref;
34288         CHECK(htlc_basepoint_arg->arr_len == 33);
34289         memcpy(htlc_basepoint_arg_ref.compressed_form, htlc_basepoint_arg->elems, 33); FREE(htlc_basepoint_arg);
34290         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);
34291         uint32_t ret_ref = 0;
34292         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34293         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34294         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34295         ret_ref = (uintptr_t)ret_var.inner;
34296         if (ret_var.is_owned) {
34297                 ret_ref |= 1;
34298         }
34299         return ret_ref;
34300 }
34301
34302 static inline uintptr_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
34303         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
34304 uint32_t ret_ref = 0;
34305 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34306 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34307 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34308 ret_ref = (uintptr_t)ret_var.inner;
34309 if (ret_var.is_owned) {
34310         ret_ref |= 1;
34311 }
34312         return ret_ref;
34313 }
34314 uint32_t  __attribute__((export_name("TS_ChannelPublicKeys_clone_ptr"))) TS_ChannelPublicKeys_clone_ptr(uint32_t arg) {
34315         LDKChannelPublicKeys arg_conv;
34316         arg_conv.inner = (void*)(arg & (~1));
34317         arg_conv.is_owned = false;
34318         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34319         uint32_t ret_conv = ChannelPublicKeys_clone_ptr(&arg_conv);
34320         return ret_conv;
34321 }
34322
34323 uint32_t  __attribute__((export_name("TS_ChannelPublicKeys_clone"))) TS_ChannelPublicKeys_clone(uint32_t orig) {
34324         LDKChannelPublicKeys orig_conv;
34325         orig_conv.inner = (void*)(orig & (~1));
34326         orig_conv.is_owned = false;
34327         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34328         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
34329         uint32_t ret_ref = 0;
34330         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34331         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34332         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34333         ret_ref = (uintptr_t)ret_var.inner;
34334         if (ret_var.is_owned) {
34335                 ret_ref |= 1;
34336         }
34337         return ret_ref;
34338 }
34339
34340 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_write"))) TS_ChannelPublicKeys_write(uint32_t obj) {
34341         LDKChannelPublicKeys obj_conv;
34342         obj_conv.inner = (void*)(obj & (~1));
34343         obj_conv.is_owned = false;
34344         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34345         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
34346         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34347         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34348         CVec_u8Z_free(ret_var);
34349         return ret_arr;
34350 }
34351
34352 uint32_t  __attribute__((export_name("TS_ChannelPublicKeys_read"))) TS_ChannelPublicKeys_read(int8_tArray ser) {
34353         LDKu8slice ser_ref;
34354         ser_ref.datalen = ser->arr_len;
34355         ser_ref.data = ser->elems /* XXX ser leaks */;
34356         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
34357         *ret_conv = ChannelPublicKeys_read(ser_ref);
34358         return (uint32_t)ret_conv;
34359 }
34360
34361 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) {
34362         LDKPublicKey per_commitment_point_ref;
34363         CHECK(per_commitment_point->arr_len == 33);
34364         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
34365         LDKPublicKey broadcaster_delayed_payment_base_ref;
34366         CHECK(broadcaster_delayed_payment_base->arr_len == 33);
34367         memcpy(broadcaster_delayed_payment_base_ref.compressed_form, broadcaster_delayed_payment_base->elems, 33); FREE(broadcaster_delayed_payment_base);
34368         LDKPublicKey broadcaster_htlc_base_ref;
34369         CHECK(broadcaster_htlc_base->arr_len == 33);
34370         memcpy(broadcaster_htlc_base_ref.compressed_form, broadcaster_htlc_base->elems, 33); FREE(broadcaster_htlc_base);
34371         LDKPublicKey countersignatory_revocation_base_ref;
34372         CHECK(countersignatory_revocation_base->arr_len == 33);
34373         memcpy(countersignatory_revocation_base_ref.compressed_form, countersignatory_revocation_base->elems, 33); FREE(countersignatory_revocation_base);
34374         LDKPublicKey countersignatory_htlc_base_ref;
34375         CHECK(countersignatory_htlc_base->arr_len == 33);
34376         memcpy(countersignatory_htlc_base_ref.compressed_form, countersignatory_htlc_base->elems, 33); FREE(countersignatory_htlc_base);
34377         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
34378         *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);
34379         return (uint32_t)ret_conv;
34380 }
34381
34382 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) {
34383         LDKPublicKey per_commitment_point_ref;
34384         CHECK(per_commitment_point->arr_len == 33);
34385         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
34386         LDKChannelPublicKeys broadcaster_keys_conv;
34387         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
34388         broadcaster_keys_conv.is_owned = false;
34389         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
34390         LDKChannelPublicKeys countersignatory_keys_conv;
34391         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
34392         countersignatory_keys_conv.is_owned = false;
34393         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
34394         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
34395         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
34396         return (uint32_t)ret_conv;
34397 }
34398
34399 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) {
34400         LDKPublicKey revocation_key_ref;
34401         CHECK(revocation_key->arr_len == 33);
34402         memcpy(revocation_key_ref.compressed_form, revocation_key->elems, 33); FREE(revocation_key);
34403         LDKPublicKey broadcaster_delayed_payment_key_ref;
34404         CHECK(broadcaster_delayed_payment_key->arr_len == 33);
34405         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, broadcaster_delayed_payment_key->elems, 33); FREE(broadcaster_delayed_payment_key);
34406         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
34407         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34408         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34409         CVec_u8Z_free(ret_var);
34410         return ret_arr;
34411 }
34412
34413 void  __attribute__((export_name("TS_HTLCOutputInCommitment_free"))) TS_HTLCOutputInCommitment_free(uint32_t this_obj) {
34414         LDKHTLCOutputInCommitment this_obj_conv;
34415         this_obj_conv.inner = (void*)(this_obj & (~1));
34416         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34418         HTLCOutputInCommitment_free(this_obj_conv);
34419 }
34420
34421 jboolean  __attribute__((export_name("TS_HTLCOutputInCommitment_get_offered"))) TS_HTLCOutputInCommitment_get_offered(uint32_t this_ptr) {
34422         LDKHTLCOutputInCommitment this_ptr_conv;
34423         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34424         this_ptr_conv.is_owned = false;
34425         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34426         jboolean ret_conv = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
34427         return ret_conv;
34428 }
34429
34430 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_offered"))) TS_HTLCOutputInCommitment_set_offered(uint32_t this_ptr, jboolean val) {
34431         LDKHTLCOutputInCommitment this_ptr_conv;
34432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34433         this_ptr_conv.is_owned = false;
34434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34435         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
34436 }
34437
34438 int64_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_amount_msat"))) TS_HTLCOutputInCommitment_get_amount_msat(uint32_t this_ptr) {
34439         LDKHTLCOutputInCommitment this_ptr_conv;
34440         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34441         this_ptr_conv.is_owned = false;
34442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34443         int64_t ret_conv = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
34444         return ret_conv;
34445 }
34446
34447 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_amount_msat"))) TS_HTLCOutputInCommitment_set_amount_msat(uint32_t this_ptr, int64_t val) {
34448         LDKHTLCOutputInCommitment this_ptr_conv;
34449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34450         this_ptr_conv.is_owned = false;
34451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34452         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
34453 }
34454
34455 int32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_cltv_expiry"))) TS_HTLCOutputInCommitment_get_cltv_expiry(uint32_t this_ptr) {
34456         LDKHTLCOutputInCommitment this_ptr_conv;
34457         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34458         this_ptr_conv.is_owned = false;
34459         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34460         int32_t ret_conv = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
34461         return ret_conv;
34462 }
34463
34464 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_cltv_expiry"))) TS_HTLCOutputInCommitment_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
34465         LDKHTLCOutputInCommitment this_ptr_conv;
34466         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34467         this_ptr_conv.is_owned = false;
34468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34469         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
34470 }
34471
34472 int8_tArray  __attribute__((export_name("TS_HTLCOutputInCommitment_get_payment_hash"))) TS_HTLCOutputInCommitment_get_payment_hash(uint32_t this_ptr) {
34473         LDKHTLCOutputInCommitment this_ptr_conv;
34474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34475         this_ptr_conv.is_owned = false;
34476         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34477         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
34478         memcpy(ret_arr->elems, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv), 32);
34479         return ret_arr;
34480 }
34481
34482 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_payment_hash"))) TS_HTLCOutputInCommitment_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
34483         LDKHTLCOutputInCommitment this_ptr_conv;
34484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34485         this_ptr_conv.is_owned = false;
34486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34487         LDKThirtyTwoBytes val_ref;
34488         CHECK(val->arr_len == 32);
34489         memcpy(val_ref.data, val->elems, 32); FREE(val);
34490         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
34491 }
34492
34493 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_transaction_output_index"))) TS_HTLCOutputInCommitment_get_transaction_output_index(uint32_t this_ptr) {
34494         LDKHTLCOutputInCommitment this_ptr_conv;
34495         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34496         this_ptr_conv.is_owned = false;
34497         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34498         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
34499         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
34500         uint32_t ret_ref = (uintptr_t)ret_copy;
34501         return ret_ref;
34502 }
34503
34504 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_transaction_output_index"))) TS_HTLCOutputInCommitment_set_transaction_output_index(uint32_t this_ptr, uint32_t val) {
34505         LDKHTLCOutputInCommitment this_ptr_conv;
34506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34507         this_ptr_conv.is_owned = false;
34508         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34509         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
34510         CHECK_ACCESS(val_ptr);
34511         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
34512         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
34513         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
34514 }
34515
34516 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) {
34517         LDKThirtyTwoBytes payment_hash_arg_ref;
34518         CHECK(payment_hash_arg->arr_len == 32);
34519         memcpy(payment_hash_arg_ref.data, payment_hash_arg->elems, 32); FREE(payment_hash_arg);
34520         void* transaction_output_index_arg_ptr = (void*)(((uintptr_t)transaction_output_index_arg) & ~1);
34521         CHECK_ACCESS(transaction_output_index_arg_ptr);
34522         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
34523         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)transaction_output_index_arg) & ~1));
34524         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
34525         uint32_t ret_ref = 0;
34526         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34527         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34528         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34529         ret_ref = (uintptr_t)ret_var.inner;
34530         if (ret_var.is_owned) {
34531                 ret_ref |= 1;
34532         }
34533         return ret_ref;
34534 }
34535
34536 static inline uintptr_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
34537         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
34538 uint32_t ret_ref = 0;
34539 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34540 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34541 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34542 ret_ref = (uintptr_t)ret_var.inner;
34543 if (ret_var.is_owned) {
34544         ret_ref |= 1;
34545 }
34546         return ret_ref;
34547 }
34548 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_clone_ptr"))) TS_HTLCOutputInCommitment_clone_ptr(uint32_t arg) {
34549         LDKHTLCOutputInCommitment arg_conv;
34550         arg_conv.inner = (void*)(arg & (~1));
34551         arg_conv.is_owned = false;
34552         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34553         uint32_t ret_conv = HTLCOutputInCommitment_clone_ptr(&arg_conv);
34554         return ret_conv;
34555 }
34556
34557 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_clone"))) TS_HTLCOutputInCommitment_clone(uint32_t orig) {
34558         LDKHTLCOutputInCommitment orig_conv;
34559         orig_conv.inner = (void*)(orig & (~1));
34560         orig_conv.is_owned = false;
34561         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34562         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
34563         uint32_t ret_ref = 0;
34564         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34565         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34566         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34567         ret_ref = (uintptr_t)ret_var.inner;
34568         if (ret_var.is_owned) {
34569                 ret_ref |= 1;
34570         }
34571         return ret_ref;
34572 }
34573
34574 int8_tArray  __attribute__((export_name("TS_HTLCOutputInCommitment_write"))) TS_HTLCOutputInCommitment_write(uint32_t obj) {
34575         LDKHTLCOutputInCommitment obj_conv;
34576         obj_conv.inner = (void*)(obj & (~1));
34577         obj_conv.is_owned = false;
34578         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34579         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
34580         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34581         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34582         CVec_u8Z_free(ret_var);
34583         return ret_arr;
34584 }
34585
34586 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_read"))) TS_HTLCOutputInCommitment_read(int8_tArray ser) {
34587         LDKu8slice ser_ref;
34588         ser_ref.datalen = ser->arr_len;
34589         ser_ref.data = ser->elems /* XXX ser leaks */;
34590         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
34591         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
34592         return (uint32_t)ret_conv;
34593 }
34594
34595 int8_tArray  __attribute__((export_name("TS_get_htlc_redeemscript"))) TS_get_htlc_redeemscript(uint32_t htlc, jboolean opt_anchors, uint32_t keys) {
34596         LDKHTLCOutputInCommitment htlc_conv;
34597         htlc_conv.inner = (void*)(htlc & (~1));
34598         htlc_conv.is_owned = false;
34599         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
34600         LDKTxCreationKeys keys_conv;
34601         keys_conv.inner = (void*)(keys & (~1));
34602         keys_conv.is_owned = false;
34603         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
34604         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, opt_anchors, &keys_conv);
34605         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34606         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34607         CVec_u8Z_free(ret_var);
34608         return ret_arr;
34609 }
34610
34611 int8_tArray  __attribute__((export_name("TS_make_funding_redeemscript"))) TS_make_funding_redeemscript(int8_tArray broadcaster, int8_tArray countersignatory) {
34612         LDKPublicKey broadcaster_ref;
34613         CHECK(broadcaster->arr_len == 33);
34614         memcpy(broadcaster_ref.compressed_form, broadcaster->elems, 33); FREE(broadcaster);
34615         LDKPublicKey countersignatory_ref;
34616         CHECK(countersignatory->arr_len == 33);
34617         memcpy(countersignatory_ref.compressed_form, countersignatory->elems, 33); FREE(countersignatory);
34618         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
34619         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34620         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34621         CVec_u8Z_free(ret_var);
34622         return ret_arr;
34623 }
34624
34625 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) {
34626         unsigned char commitment_txid_arr[32];
34627         CHECK(commitment_txid->arr_len == 32);
34628         memcpy(commitment_txid_arr, commitment_txid->elems, 32); FREE(commitment_txid);
34629         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
34630         LDKHTLCOutputInCommitment htlc_conv;
34631         htlc_conv.inner = (void*)(htlc & (~1));
34632         htlc_conv.is_owned = false;
34633         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
34634         LDKPublicKey broadcaster_delayed_payment_key_ref;
34635         CHECK(broadcaster_delayed_payment_key->arr_len == 33);
34636         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, broadcaster_delayed_payment_key->elems, 33); FREE(broadcaster_delayed_payment_key);
34637         LDKPublicKey revocation_key_ref;
34638         CHECK(revocation_key->arr_len == 33);
34639         memcpy(revocation_key_ref.compressed_form, revocation_key->elems, 33); FREE(revocation_key);
34640         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);
34641         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34642         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34643         Transaction_free(ret_var);
34644         return ret_arr;
34645 }
34646
34647 int8_tArray  __attribute__((export_name("TS_get_anchor_redeemscript"))) TS_get_anchor_redeemscript(int8_tArray funding_pubkey) {
34648         LDKPublicKey funding_pubkey_ref;
34649         CHECK(funding_pubkey->arr_len == 33);
34650         memcpy(funding_pubkey_ref.compressed_form, funding_pubkey->elems, 33); FREE(funding_pubkey);
34651         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
34652         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34653         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34654         CVec_u8Z_free(ret_var);
34655         return ret_arr;
34656 }
34657
34658 void  __attribute__((export_name("TS_ChannelTransactionParameters_free"))) TS_ChannelTransactionParameters_free(uint32_t this_obj) {
34659         LDKChannelTransactionParameters this_obj_conv;
34660         this_obj_conv.inner = (void*)(this_obj & (~1));
34661         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34663         ChannelTransactionParameters_free(this_obj_conv);
34664 }
34665
34666 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_holder_pubkeys"))) TS_ChannelTransactionParameters_get_holder_pubkeys(uint32_t this_ptr) {
34667         LDKChannelTransactionParameters this_ptr_conv;
34668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34669         this_ptr_conv.is_owned = false;
34670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34671         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
34672         uint32_t ret_ref = 0;
34673         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34674         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34675         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34676         ret_ref = (uintptr_t)ret_var.inner;
34677         if (ret_var.is_owned) {
34678                 ret_ref |= 1;
34679         }
34680         return ret_ref;
34681 }
34682
34683 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_holder_pubkeys"))) TS_ChannelTransactionParameters_set_holder_pubkeys(uint32_t this_ptr, uint32_t val) {
34684         LDKChannelTransactionParameters this_ptr_conv;
34685         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34686         this_ptr_conv.is_owned = false;
34687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34688         LDKChannelPublicKeys val_conv;
34689         val_conv.inner = (void*)(val & (~1));
34690         val_conv.is_owned = (val & 1) || (val == 0);
34691         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34692         val_conv = ChannelPublicKeys_clone(&val_conv);
34693         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
34694 }
34695
34696 int16_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_holder_selected_contest_delay"))) TS_ChannelTransactionParameters_get_holder_selected_contest_delay(uint32_t this_ptr) {
34697         LDKChannelTransactionParameters this_ptr_conv;
34698         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34699         this_ptr_conv.is_owned = false;
34700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34701         int16_t ret_conv = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
34702         return ret_conv;
34703 }
34704
34705 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) {
34706         LDKChannelTransactionParameters this_ptr_conv;
34707         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34708         this_ptr_conv.is_owned = false;
34709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34710         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
34711 }
34712
34713 jboolean  __attribute__((export_name("TS_ChannelTransactionParameters_get_is_outbound_from_holder"))) TS_ChannelTransactionParameters_get_is_outbound_from_holder(uint32_t this_ptr) {
34714         LDKChannelTransactionParameters this_ptr_conv;
34715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34716         this_ptr_conv.is_owned = false;
34717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34718         jboolean ret_conv = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
34719         return ret_conv;
34720 }
34721
34722 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_is_outbound_from_holder"))) TS_ChannelTransactionParameters_set_is_outbound_from_holder(uint32_t this_ptr, jboolean val) {
34723         LDKChannelTransactionParameters this_ptr_conv;
34724         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34725         this_ptr_conv.is_owned = false;
34726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34727         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
34728 }
34729
34730 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_counterparty_parameters"))) TS_ChannelTransactionParameters_get_counterparty_parameters(uint32_t this_ptr) {
34731         LDKChannelTransactionParameters this_ptr_conv;
34732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34733         this_ptr_conv.is_owned = false;
34734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34735         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
34736         uint32_t ret_ref = 0;
34737         if ((uintptr_t)ret_var.inner > 4096) {
34738                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34739                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34740         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34741                 ret_ref = (uintptr_t)ret_var.inner;
34742                 if (ret_var.is_owned) {
34743                         ret_ref |= 1;
34744                 }
34745         }
34746         return ret_ref;
34747 }
34748
34749 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_counterparty_parameters"))) TS_ChannelTransactionParameters_set_counterparty_parameters(uint32_t this_ptr, uint32_t val) {
34750         LDKChannelTransactionParameters this_ptr_conv;
34751         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34752         this_ptr_conv.is_owned = false;
34753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34754         LDKCounterpartyChannelTransactionParameters val_conv;
34755         val_conv.inner = (void*)(val & (~1));
34756         val_conv.is_owned = (val & 1) || (val == 0);
34757         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34758         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
34759         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
34760 }
34761
34762 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_funding_outpoint"))) TS_ChannelTransactionParameters_get_funding_outpoint(uint32_t this_ptr) {
34763         LDKChannelTransactionParameters this_ptr_conv;
34764         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34765         this_ptr_conv.is_owned = false;
34766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34767         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
34768         uint32_t ret_ref = 0;
34769         if ((uintptr_t)ret_var.inner > 4096) {
34770                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34771                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34772         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34773                 ret_ref = (uintptr_t)ret_var.inner;
34774                 if (ret_var.is_owned) {
34775                         ret_ref |= 1;
34776                 }
34777         }
34778         return ret_ref;
34779 }
34780
34781 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_funding_outpoint"))) TS_ChannelTransactionParameters_set_funding_outpoint(uint32_t this_ptr, uint32_t val) {
34782         LDKChannelTransactionParameters this_ptr_conv;
34783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34784         this_ptr_conv.is_owned = false;
34785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34786         LDKOutPoint val_conv;
34787         val_conv.inner = (void*)(val & (~1));
34788         val_conv.is_owned = (val & 1) || (val == 0);
34789         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34790         val_conv = OutPoint_clone(&val_conv);
34791         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
34792 }
34793
34794 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_opt_anchors"))) TS_ChannelTransactionParameters_get_opt_anchors(uint32_t this_ptr) {
34795         LDKChannelTransactionParameters this_ptr_conv;
34796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34797         this_ptr_conv.is_owned = false;
34798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34799         uint32_t ret_conv = LDKCOption_NoneZ_to_js(ChannelTransactionParameters_get_opt_anchors(&this_ptr_conv));
34800         return ret_conv;
34801 }
34802
34803 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_opt_anchors"))) TS_ChannelTransactionParameters_set_opt_anchors(uint32_t this_ptr, uint32_t val) {
34804         LDKChannelTransactionParameters this_ptr_conv;
34805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34806         this_ptr_conv.is_owned = false;
34807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34808         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_js(val);
34809         ChannelTransactionParameters_set_opt_anchors(&this_ptr_conv, val_conv);
34810 }
34811
34812 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) {
34813         LDKChannelPublicKeys holder_pubkeys_arg_conv;
34814         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
34815         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
34816         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
34817         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
34818         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
34819         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
34820         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
34821         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
34822         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
34823         LDKOutPoint funding_outpoint_arg_conv;
34824         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
34825         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
34826         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
34827         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
34828         LDKCOption_NoneZ opt_anchors_arg_conv = LDKCOption_NoneZ_from_js(opt_anchors_arg);
34829         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);
34830         uint32_t ret_ref = 0;
34831         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34832         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34833         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34834         ret_ref = (uintptr_t)ret_var.inner;
34835         if (ret_var.is_owned) {
34836                 ret_ref |= 1;
34837         }
34838         return ret_ref;
34839 }
34840
34841 static inline uintptr_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
34842         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(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 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_clone_ptr"))) TS_ChannelTransactionParameters_clone_ptr(uint32_t arg) {
34854         LDKChannelTransactionParameters arg_conv;
34855         arg_conv.inner = (void*)(arg & (~1));
34856         arg_conv.is_owned = false;
34857         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34858         uint32_t ret_conv = ChannelTransactionParameters_clone_ptr(&arg_conv);
34859         return ret_conv;
34860 }
34861
34862 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_clone"))) TS_ChannelTransactionParameters_clone(uint32_t orig) {
34863         LDKChannelTransactionParameters orig_conv;
34864         orig_conv.inner = (void*)(orig & (~1));
34865         orig_conv.is_owned = false;
34866         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34867         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
34868         uint32_t ret_ref = 0;
34869         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34870         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34871         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34872         ret_ref = (uintptr_t)ret_var.inner;
34873         if (ret_var.is_owned) {
34874                 ret_ref |= 1;
34875         }
34876         return ret_ref;
34877 }
34878
34879 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_free"))) TS_CounterpartyChannelTransactionParameters_free(uint32_t this_obj) {
34880         LDKCounterpartyChannelTransactionParameters this_obj_conv;
34881         this_obj_conv.inner = (void*)(this_obj & (~1));
34882         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34884         CounterpartyChannelTransactionParameters_free(this_obj_conv);
34885 }
34886
34887 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_get_pubkeys"))) TS_CounterpartyChannelTransactionParameters_get_pubkeys(uint32_t this_ptr) {
34888         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
34889         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34890         this_ptr_conv.is_owned = false;
34891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34892         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
34893         uint32_t ret_ref = 0;
34894         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34895         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34896         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34897         ret_ref = (uintptr_t)ret_var.inner;
34898         if (ret_var.is_owned) {
34899                 ret_ref |= 1;
34900         }
34901         return ret_ref;
34902 }
34903
34904 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_set_pubkeys"))) TS_CounterpartyChannelTransactionParameters_set_pubkeys(uint32_t this_ptr, uint32_t val) {
34905         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
34906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34907         this_ptr_conv.is_owned = false;
34908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34909         LDKChannelPublicKeys val_conv;
34910         val_conv.inner = (void*)(val & (~1));
34911         val_conv.is_owned = (val & 1) || (val == 0);
34912         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34913         val_conv = ChannelPublicKeys_clone(&val_conv);
34914         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
34915 }
34916
34917 int16_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay"))) TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay(uint32_t this_ptr) {
34918         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
34919         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34920         this_ptr_conv.is_owned = false;
34921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34922         int16_t ret_conv = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
34923         return ret_conv;
34924 }
34925
34926 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay"))) TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay(uint32_t this_ptr, int16_t val) {
34927         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
34928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34929         this_ptr_conv.is_owned = false;
34930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34931         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
34932 }
34933
34934 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_new"))) TS_CounterpartyChannelTransactionParameters_new(uint32_t pubkeys_arg, int16_t selected_contest_delay_arg) {
34935         LDKChannelPublicKeys pubkeys_arg_conv;
34936         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
34937         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
34938         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
34939         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
34940         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
34941         uint32_t ret_ref = 0;
34942         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34943         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34944         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34945         ret_ref = (uintptr_t)ret_var.inner;
34946         if (ret_var.is_owned) {
34947                 ret_ref |= 1;
34948         }
34949         return ret_ref;
34950 }
34951
34952 static inline uintptr_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
34953         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
34954 uint32_t ret_ref = 0;
34955 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34956 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34957 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34958 ret_ref = (uintptr_t)ret_var.inner;
34959 if (ret_var.is_owned) {
34960         ret_ref |= 1;
34961 }
34962         return ret_ref;
34963 }
34964 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_clone_ptr"))) TS_CounterpartyChannelTransactionParameters_clone_ptr(uint32_t arg) {
34965         LDKCounterpartyChannelTransactionParameters arg_conv;
34966         arg_conv.inner = (void*)(arg & (~1));
34967         arg_conv.is_owned = false;
34968         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34969         uint32_t ret_conv = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
34970         return ret_conv;
34971 }
34972
34973 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_clone"))) TS_CounterpartyChannelTransactionParameters_clone(uint32_t orig) {
34974         LDKCounterpartyChannelTransactionParameters orig_conv;
34975         orig_conv.inner = (void*)(orig & (~1));
34976         orig_conv.is_owned = false;
34977         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34978         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
34979         uint32_t ret_ref = 0;
34980         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34981         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34982         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34983         ret_ref = (uintptr_t)ret_var.inner;
34984         if (ret_var.is_owned) {
34985                 ret_ref |= 1;
34986         }
34987         return ret_ref;
34988 }
34989
34990 jboolean  __attribute__((export_name("TS_ChannelTransactionParameters_is_populated"))) TS_ChannelTransactionParameters_is_populated(uint32_t this_arg) {
34991         LDKChannelTransactionParameters this_arg_conv;
34992         this_arg_conv.inner = (void*)(this_arg & (~1));
34993         this_arg_conv.is_owned = false;
34994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34995         jboolean ret_conv = ChannelTransactionParameters_is_populated(&this_arg_conv);
34996         return ret_conv;
34997 }
34998
34999 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_as_holder_broadcastable"))) TS_ChannelTransactionParameters_as_holder_broadcastable(uint32_t this_arg) {
35000         LDKChannelTransactionParameters this_arg_conv;
35001         this_arg_conv.inner = (void*)(this_arg & (~1));
35002         this_arg_conv.is_owned = false;
35003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35004         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
35005         uint32_t ret_ref = 0;
35006         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35007         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35008         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35009         ret_ref = (uintptr_t)ret_var.inner;
35010         if (ret_var.is_owned) {
35011                 ret_ref |= 1;
35012         }
35013         return ret_ref;
35014 }
35015
35016 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_as_counterparty_broadcastable"))) TS_ChannelTransactionParameters_as_counterparty_broadcastable(uint32_t this_arg) {
35017         LDKChannelTransactionParameters this_arg_conv;
35018         this_arg_conv.inner = (void*)(this_arg & (~1));
35019         this_arg_conv.is_owned = false;
35020         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35021         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
35022         uint32_t ret_ref = 0;
35023         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35024         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35025         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35026         ret_ref = (uintptr_t)ret_var.inner;
35027         if (ret_var.is_owned) {
35028                 ret_ref |= 1;
35029         }
35030         return ret_ref;
35031 }
35032
35033 int8_tArray  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_write"))) TS_CounterpartyChannelTransactionParameters_write(uint32_t obj) {
35034         LDKCounterpartyChannelTransactionParameters obj_conv;
35035         obj_conv.inner = (void*)(obj & (~1));
35036         obj_conv.is_owned = false;
35037         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35038         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
35039         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35040         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35041         CVec_u8Z_free(ret_var);
35042         return ret_arr;
35043 }
35044
35045 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_read"))) TS_CounterpartyChannelTransactionParameters_read(int8_tArray ser) {
35046         LDKu8slice ser_ref;
35047         ser_ref.datalen = ser->arr_len;
35048         ser_ref.data = ser->elems /* XXX ser leaks */;
35049         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
35050         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
35051         return (uint32_t)ret_conv;
35052 }
35053
35054 int8_tArray  __attribute__((export_name("TS_ChannelTransactionParameters_write"))) TS_ChannelTransactionParameters_write(uint32_t obj) {
35055         LDKChannelTransactionParameters obj_conv;
35056         obj_conv.inner = (void*)(obj & (~1));
35057         obj_conv.is_owned = false;
35058         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35059         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
35060         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35061         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35062         CVec_u8Z_free(ret_var);
35063         return ret_arr;
35064 }
35065
35066 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_read"))) TS_ChannelTransactionParameters_read(int8_tArray ser) {
35067         LDKu8slice ser_ref;
35068         ser_ref.datalen = ser->arr_len;
35069         ser_ref.data = ser->elems /* XXX ser leaks */;
35070         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
35071         *ret_conv = ChannelTransactionParameters_read(ser_ref);
35072         return (uint32_t)ret_conv;
35073 }
35074
35075 void  __attribute__((export_name("TS_DirectedChannelTransactionParameters_free"))) TS_DirectedChannelTransactionParameters_free(uint32_t this_obj) {
35076         LDKDirectedChannelTransactionParameters this_obj_conv;
35077         this_obj_conv.inner = (void*)(this_obj & (~1));
35078         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35080         DirectedChannelTransactionParameters_free(this_obj_conv);
35081 }
35082
35083 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_broadcaster_pubkeys"))) TS_DirectedChannelTransactionParameters_broadcaster_pubkeys(uint32_t this_arg) {
35084         LDKDirectedChannelTransactionParameters this_arg_conv;
35085         this_arg_conv.inner = (void*)(this_arg & (~1));
35086         this_arg_conv.is_owned = false;
35087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35088         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
35089         uint32_t ret_ref = 0;
35090         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35091         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35092         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35093         ret_ref = (uintptr_t)ret_var.inner;
35094         if (ret_var.is_owned) {
35095                 ret_ref |= 1;
35096         }
35097         return ret_ref;
35098 }
35099
35100 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_countersignatory_pubkeys"))) TS_DirectedChannelTransactionParameters_countersignatory_pubkeys(uint32_t this_arg) {
35101         LDKDirectedChannelTransactionParameters this_arg_conv;
35102         this_arg_conv.inner = (void*)(this_arg & (~1));
35103         this_arg_conv.is_owned = false;
35104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35105         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
35106         uint32_t ret_ref = 0;
35107         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35108         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35109         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35110         ret_ref = (uintptr_t)ret_var.inner;
35111         if (ret_var.is_owned) {
35112                 ret_ref |= 1;
35113         }
35114         return ret_ref;
35115 }
35116
35117 int16_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_contest_delay"))) TS_DirectedChannelTransactionParameters_contest_delay(uint32_t this_arg) {
35118         LDKDirectedChannelTransactionParameters this_arg_conv;
35119         this_arg_conv.inner = (void*)(this_arg & (~1));
35120         this_arg_conv.is_owned = false;
35121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35122         int16_t ret_conv = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
35123         return ret_conv;
35124 }
35125
35126 jboolean  __attribute__((export_name("TS_DirectedChannelTransactionParameters_is_outbound"))) TS_DirectedChannelTransactionParameters_is_outbound(uint32_t this_arg) {
35127         LDKDirectedChannelTransactionParameters this_arg_conv;
35128         this_arg_conv.inner = (void*)(this_arg & (~1));
35129         this_arg_conv.is_owned = false;
35130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35131         jboolean ret_conv = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
35132         return ret_conv;
35133 }
35134
35135 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_funding_outpoint"))) TS_DirectedChannelTransactionParameters_funding_outpoint(uint32_t this_arg) {
35136         LDKDirectedChannelTransactionParameters this_arg_conv;
35137         this_arg_conv.inner = (void*)(this_arg & (~1));
35138         this_arg_conv.is_owned = false;
35139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35140         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
35141         uint32_t ret_ref = 0;
35142         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35143         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35144         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35145         ret_ref = (uintptr_t)ret_var.inner;
35146         if (ret_var.is_owned) {
35147                 ret_ref |= 1;
35148         }
35149         return ret_ref;
35150 }
35151
35152 jboolean  __attribute__((export_name("TS_DirectedChannelTransactionParameters_opt_anchors"))) TS_DirectedChannelTransactionParameters_opt_anchors(uint32_t this_arg) {
35153         LDKDirectedChannelTransactionParameters this_arg_conv;
35154         this_arg_conv.inner = (void*)(this_arg & (~1));
35155         this_arg_conv.is_owned = false;
35156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35157         jboolean ret_conv = DirectedChannelTransactionParameters_opt_anchors(&this_arg_conv);
35158         return ret_conv;
35159 }
35160
35161 void  __attribute__((export_name("TS_HolderCommitmentTransaction_free"))) TS_HolderCommitmentTransaction_free(uint32_t this_obj) {
35162         LDKHolderCommitmentTransaction this_obj_conv;
35163         this_obj_conv.inner = (void*)(this_obj & (~1));
35164         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35166         HolderCommitmentTransaction_free(this_obj_conv);
35167 }
35168
35169 int8_tArray  __attribute__((export_name("TS_HolderCommitmentTransaction_get_counterparty_sig"))) TS_HolderCommitmentTransaction_get_counterparty_sig(uint32_t this_ptr) {
35170         LDKHolderCommitmentTransaction this_ptr_conv;
35171         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35172         this_ptr_conv.is_owned = false;
35173         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35174         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
35175         memcpy(ret_arr->elems, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form, 64);
35176         return ret_arr;
35177 }
35178
35179 void  __attribute__((export_name("TS_HolderCommitmentTransaction_set_counterparty_sig"))) TS_HolderCommitmentTransaction_set_counterparty_sig(uint32_t this_ptr, int8_tArray val) {
35180         LDKHolderCommitmentTransaction this_ptr_conv;
35181         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35182         this_ptr_conv.is_owned = false;
35183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35184         LDKSignature val_ref;
35185         CHECK(val->arr_len == 64);
35186         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
35187         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
35188 }
35189
35190 void  __attribute__((export_name("TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs"))) TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs(uint32_t this_ptr, ptrArray val) {
35191         LDKHolderCommitmentTransaction this_ptr_conv;
35192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35193         this_ptr_conv.is_owned = false;
35194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35195         LDKCVec_SignatureZ val_constr;
35196         val_constr.datalen = val->arr_len;
35197         if (val_constr.datalen > 0)
35198                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
35199         else
35200                 val_constr.data = NULL;
35201         int8_tArray* val_vals = (void*) val->elems /* XXX val leaks */;
35202         for (size_t m = 0; m < val_constr.datalen; m++) {
35203                 int8_tArray val_conv_12 = val_vals[m];
35204                 LDKSignature val_conv_12_ref;
35205                 CHECK(val_conv_12->arr_len == 64);
35206                 memcpy(val_conv_12_ref.compact_form, val_conv_12->elems, 64); FREE(val_conv_12);
35207                 val_constr.data[m] = val_conv_12_ref;
35208         }
35209         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
35210 }
35211
35212 static inline uintptr_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
35213         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
35214 uint32_t ret_ref = 0;
35215 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35216 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35217 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35218 ret_ref = (uintptr_t)ret_var.inner;
35219 if (ret_var.is_owned) {
35220         ret_ref |= 1;
35221 }
35222         return ret_ref;
35223 }
35224 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_clone_ptr"))) TS_HolderCommitmentTransaction_clone_ptr(uint32_t arg) {
35225         LDKHolderCommitmentTransaction arg_conv;
35226         arg_conv.inner = (void*)(arg & (~1));
35227         arg_conv.is_owned = false;
35228         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35229         uint32_t ret_conv = HolderCommitmentTransaction_clone_ptr(&arg_conv);
35230         return ret_conv;
35231 }
35232
35233 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_clone"))) TS_HolderCommitmentTransaction_clone(uint32_t orig) {
35234         LDKHolderCommitmentTransaction orig_conv;
35235         orig_conv.inner = (void*)(orig & (~1));
35236         orig_conv.is_owned = false;
35237         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35238         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
35239         uint32_t ret_ref = 0;
35240         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35241         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35242         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35243         ret_ref = (uintptr_t)ret_var.inner;
35244         if (ret_var.is_owned) {
35245                 ret_ref |= 1;
35246         }
35247         return ret_ref;
35248 }
35249
35250 int8_tArray  __attribute__((export_name("TS_HolderCommitmentTransaction_write"))) TS_HolderCommitmentTransaction_write(uint32_t obj) {
35251         LDKHolderCommitmentTransaction obj_conv;
35252         obj_conv.inner = (void*)(obj & (~1));
35253         obj_conv.is_owned = false;
35254         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35255         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
35256         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35257         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35258         CVec_u8Z_free(ret_var);
35259         return ret_arr;
35260 }
35261
35262 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_read"))) TS_HolderCommitmentTransaction_read(int8_tArray ser) {
35263         LDKu8slice ser_ref;
35264         ser_ref.datalen = ser->arr_len;
35265         ser_ref.data = ser->elems /* XXX ser leaks */;
35266         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
35267         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
35268         return (uint32_t)ret_conv;
35269 }
35270
35271 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) {
35272         LDKCommitmentTransaction commitment_tx_conv;
35273         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
35274         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
35275         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
35276         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
35277         LDKSignature counterparty_sig_ref;
35278         CHECK(counterparty_sig->arr_len == 64);
35279         memcpy(counterparty_sig_ref.compact_form, counterparty_sig->elems, 64); FREE(counterparty_sig);
35280         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
35281         counterparty_htlc_sigs_constr.datalen = counterparty_htlc_sigs->arr_len;
35282         if (counterparty_htlc_sigs_constr.datalen > 0)
35283                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
35284         else
35285                 counterparty_htlc_sigs_constr.data = NULL;
35286         int8_tArray* counterparty_htlc_sigs_vals = (void*) counterparty_htlc_sigs->elems /* XXX counterparty_htlc_sigs leaks */;
35287         for (size_t m = 0; m < counterparty_htlc_sigs_constr.datalen; m++) {
35288                 int8_tArray counterparty_htlc_sigs_conv_12 = counterparty_htlc_sigs_vals[m];
35289                 LDKSignature counterparty_htlc_sigs_conv_12_ref;
35290                 CHECK(counterparty_htlc_sigs_conv_12->arr_len == 64);
35291                 memcpy(counterparty_htlc_sigs_conv_12_ref.compact_form, counterparty_htlc_sigs_conv_12->elems, 64); FREE(counterparty_htlc_sigs_conv_12);
35292                 counterparty_htlc_sigs_constr.data[m] = counterparty_htlc_sigs_conv_12_ref;
35293         }
35294         LDKPublicKey holder_funding_key_ref;
35295         CHECK(holder_funding_key->arr_len == 33);
35296         memcpy(holder_funding_key_ref.compressed_form, holder_funding_key->elems, 33); FREE(holder_funding_key);
35297         LDKPublicKey counterparty_funding_key_ref;
35298         CHECK(counterparty_funding_key->arr_len == 33);
35299         memcpy(counterparty_funding_key_ref.compressed_form, counterparty_funding_key->elems, 33); FREE(counterparty_funding_key);
35300         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
35301         uint32_t ret_ref = 0;
35302         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35303         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35304         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35305         ret_ref = (uintptr_t)ret_var.inner;
35306         if (ret_var.is_owned) {
35307                 ret_ref |= 1;
35308         }
35309         return ret_ref;
35310 }
35311
35312 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_free"))) TS_BuiltCommitmentTransaction_free(uint32_t this_obj) {
35313         LDKBuiltCommitmentTransaction this_obj_conv;
35314         this_obj_conv.inner = (void*)(this_obj & (~1));
35315         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35317         BuiltCommitmentTransaction_free(this_obj_conv);
35318 }
35319
35320 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_get_transaction"))) TS_BuiltCommitmentTransaction_get_transaction(uint32_t this_ptr) {
35321         LDKBuiltCommitmentTransaction this_ptr_conv;
35322         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35323         this_ptr_conv.is_owned = false;
35324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35325         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
35326         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35327         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35328         Transaction_free(ret_var);
35329         return ret_arr;
35330 }
35331
35332 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_set_transaction"))) TS_BuiltCommitmentTransaction_set_transaction(uint32_t this_ptr, int8_tArray val) {
35333         LDKBuiltCommitmentTransaction 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         LDKTransaction val_ref;
35338         val_ref.datalen = val->arr_len;
35339         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
35340         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
35341         val_ref.data_is_owned = true;
35342         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
35343 }
35344
35345 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_get_txid"))) TS_BuiltCommitmentTransaction_get_txid(uint32_t this_ptr) {
35346         LDKBuiltCommitmentTransaction this_ptr_conv;
35347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35348         this_ptr_conv.is_owned = false;
35349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35350         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
35351         memcpy(ret_arr->elems, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv), 32);
35352         return ret_arr;
35353 }
35354
35355 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_set_txid"))) TS_BuiltCommitmentTransaction_set_txid(uint32_t this_ptr, int8_tArray val) {
35356         LDKBuiltCommitmentTransaction this_ptr_conv;
35357         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35358         this_ptr_conv.is_owned = false;
35359         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35360         LDKThirtyTwoBytes val_ref;
35361         CHECK(val->arr_len == 32);
35362         memcpy(val_ref.data, val->elems, 32); FREE(val);
35363         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
35364 }
35365
35366 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_new"))) TS_BuiltCommitmentTransaction_new(int8_tArray transaction_arg, int8_tArray txid_arg) {
35367         LDKTransaction transaction_arg_ref;
35368         transaction_arg_ref.datalen = transaction_arg->arr_len;
35369         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
35370         memcpy(transaction_arg_ref.data, transaction_arg->elems, transaction_arg_ref.datalen); FREE(transaction_arg);
35371         transaction_arg_ref.data_is_owned = true;
35372         LDKThirtyTwoBytes txid_arg_ref;
35373         CHECK(txid_arg->arr_len == 32);
35374         memcpy(txid_arg_ref.data, txid_arg->elems, 32); FREE(txid_arg);
35375         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
35376         uint32_t ret_ref = 0;
35377         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35378         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35379         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35380         ret_ref = (uintptr_t)ret_var.inner;
35381         if (ret_var.is_owned) {
35382                 ret_ref |= 1;
35383         }
35384         return ret_ref;
35385 }
35386
35387 static inline uintptr_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
35388         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
35389 uint32_t ret_ref = 0;
35390 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35391 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35392 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35393 ret_ref = (uintptr_t)ret_var.inner;
35394 if (ret_var.is_owned) {
35395         ret_ref |= 1;
35396 }
35397         return ret_ref;
35398 }
35399 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_clone_ptr"))) TS_BuiltCommitmentTransaction_clone_ptr(uint32_t arg) {
35400         LDKBuiltCommitmentTransaction arg_conv;
35401         arg_conv.inner = (void*)(arg & (~1));
35402         arg_conv.is_owned = false;
35403         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35404         uint32_t ret_conv = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
35405         return ret_conv;
35406 }
35407
35408 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_clone"))) TS_BuiltCommitmentTransaction_clone(uint32_t orig) {
35409         LDKBuiltCommitmentTransaction orig_conv;
35410         orig_conv.inner = (void*)(orig & (~1));
35411         orig_conv.is_owned = false;
35412         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35413         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
35414         uint32_t ret_ref = 0;
35415         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35416         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35417         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35418         ret_ref = (uintptr_t)ret_var.inner;
35419         if (ret_var.is_owned) {
35420                 ret_ref |= 1;
35421         }
35422         return ret_ref;
35423 }
35424
35425 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_write"))) TS_BuiltCommitmentTransaction_write(uint32_t obj) {
35426         LDKBuiltCommitmentTransaction obj_conv;
35427         obj_conv.inner = (void*)(obj & (~1));
35428         obj_conv.is_owned = false;
35429         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35430         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
35431         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35432         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35433         CVec_u8Z_free(ret_var);
35434         return ret_arr;
35435 }
35436
35437 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_read"))) TS_BuiltCommitmentTransaction_read(int8_tArray ser) {
35438         LDKu8slice ser_ref;
35439         ser_ref.datalen = ser->arr_len;
35440         ser_ref.data = ser->elems /* XXX ser leaks */;
35441         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
35442         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
35443         return (uint32_t)ret_conv;
35444 }
35445
35446 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) {
35447         LDKBuiltCommitmentTransaction this_arg_conv;
35448         this_arg_conv.inner = (void*)(this_arg & (~1));
35449         this_arg_conv.is_owned = false;
35450         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35451         LDKu8slice funding_redeemscript_ref;
35452         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
35453         funding_redeemscript_ref.data = funding_redeemscript->elems /* XXX funding_redeemscript leaks */;
35454         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
35455         memcpy(ret_arr->elems, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
35456         return ret_arr;
35457 }
35458
35459 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) {
35460         LDKBuiltCommitmentTransaction this_arg_conv;
35461         this_arg_conv.inner = (void*)(this_arg & (~1));
35462         this_arg_conv.is_owned = false;
35463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35464         unsigned char funding_key_arr[32];
35465         CHECK(funding_key->arr_len == 32);
35466         memcpy(funding_key_arr, funding_key->elems, 32); FREE(funding_key);
35467         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
35468         LDKu8slice funding_redeemscript_ref;
35469         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
35470         funding_redeemscript_ref.data = funding_redeemscript->elems /* XXX funding_redeemscript leaks */;
35471         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
35472         memcpy(ret_arr->elems, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
35473         return ret_arr;
35474 }
35475
35476 void  __attribute__((export_name("TS_ClosingTransaction_free"))) TS_ClosingTransaction_free(uint32_t this_obj) {
35477         LDKClosingTransaction this_obj_conv;
35478         this_obj_conv.inner = (void*)(this_obj & (~1));
35479         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35481         ClosingTransaction_free(this_obj_conv);
35482 }
35483
35484 static inline uintptr_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
35485         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
35486 uint32_t ret_ref = 0;
35487 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35488 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35489 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35490 ret_ref = (uintptr_t)ret_var.inner;
35491 if (ret_var.is_owned) {
35492         ret_ref |= 1;
35493 }
35494         return ret_ref;
35495 }
35496 uint32_t  __attribute__((export_name("TS_ClosingTransaction_clone_ptr"))) TS_ClosingTransaction_clone_ptr(uint32_t arg) {
35497         LDKClosingTransaction arg_conv;
35498         arg_conv.inner = (void*)(arg & (~1));
35499         arg_conv.is_owned = false;
35500         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35501         uint32_t ret_conv = ClosingTransaction_clone_ptr(&arg_conv);
35502         return ret_conv;
35503 }
35504
35505 uint32_t  __attribute__((export_name("TS_ClosingTransaction_clone"))) TS_ClosingTransaction_clone(uint32_t orig) {
35506         LDKClosingTransaction orig_conv;
35507         orig_conv.inner = (void*)(orig & (~1));
35508         orig_conv.is_owned = false;
35509         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35510         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
35511         uint32_t ret_ref = 0;
35512         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35513         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35514         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35515         ret_ref = (uintptr_t)ret_var.inner;
35516         if (ret_var.is_owned) {
35517                 ret_ref |= 1;
35518         }
35519         return ret_ref;
35520 }
35521
35522 int64_t  __attribute__((export_name("TS_ClosingTransaction_hash"))) TS_ClosingTransaction_hash(uint32_t o) {
35523         LDKClosingTransaction o_conv;
35524         o_conv.inner = (void*)(o & (~1));
35525         o_conv.is_owned = false;
35526         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
35527         int64_t ret_conv = ClosingTransaction_hash(&o_conv);
35528         return ret_conv;
35529 }
35530
35531 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) {
35532         LDKCVec_u8Z to_holder_script_ref;
35533         to_holder_script_ref.datalen = to_holder_script->arr_len;
35534         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
35535         memcpy(to_holder_script_ref.data, to_holder_script->elems, to_holder_script_ref.datalen); FREE(to_holder_script);
35536         LDKCVec_u8Z to_counterparty_script_ref;
35537         to_counterparty_script_ref.datalen = to_counterparty_script->arr_len;
35538         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
35539         memcpy(to_counterparty_script_ref.data, to_counterparty_script->elems, to_counterparty_script_ref.datalen); FREE(to_counterparty_script);
35540         LDKOutPoint funding_outpoint_conv;
35541         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
35542         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
35543         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
35544         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
35545         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
35546         uint32_t ret_ref = 0;
35547         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35548         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35549         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35550         ret_ref = (uintptr_t)ret_var.inner;
35551         if (ret_var.is_owned) {
35552                 ret_ref |= 1;
35553         }
35554         return ret_ref;
35555 }
35556
35557 uint32_t  __attribute__((export_name("TS_ClosingTransaction_trust"))) TS_ClosingTransaction_trust(uint32_t this_arg) {
35558         LDKClosingTransaction this_arg_conv;
35559         this_arg_conv.inner = (void*)(this_arg & (~1));
35560         this_arg_conv.is_owned = false;
35561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35562         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
35563         uint32_t ret_ref = 0;
35564         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35565         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35566         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35567         ret_ref = (uintptr_t)ret_var.inner;
35568         if (ret_var.is_owned) {
35569                 ret_ref |= 1;
35570         }
35571         return ret_ref;
35572 }
35573
35574 uint32_t  __attribute__((export_name("TS_ClosingTransaction_verify"))) TS_ClosingTransaction_verify(uint32_t this_arg, uint32_t funding_outpoint) {
35575         LDKClosingTransaction this_arg_conv;
35576         this_arg_conv.inner = (void*)(this_arg & (~1));
35577         this_arg_conv.is_owned = false;
35578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35579         LDKOutPoint funding_outpoint_conv;
35580         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
35581         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
35582         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
35583         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
35584         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
35585         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
35586         return (uint32_t)ret_conv;
35587 }
35588
35589 int64_t  __attribute__((export_name("TS_ClosingTransaction_to_holder_value_sat"))) TS_ClosingTransaction_to_holder_value_sat(uint32_t this_arg) {
35590         LDKClosingTransaction this_arg_conv;
35591         this_arg_conv.inner = (void*)(this_arg & (~1));
35592         this_arg_conv.is_owned = false;
35593         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35594         int64_t ret_conv = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
35595         return ret_conv;
35596 }
35597
35598 int64_t  __attribute__((export_name("TS_ClosingTransaction_to_counterparty_value_sat"))) TS_ClosingTransaction_to_counterparty_value_sat(uint32_t this_arg) {
35599         LDKClosingTransaction this_arg_conv;
35600         this_arg_conv.inner = (void*)(this_arg & (~1));
35601         this_arg_conv.is_owned = false;
35602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35603         int64_t ret_conv = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
35604         return ret_conv;
35605 }
35606
35607 int8_tArray  __attribute__((export_name("TS_ClosingTransaction_to_holder_script"))) TS_ClosingTransaction_to_holder_script(uint32_t this_arg) {
35608         LDKClosingTransaction this_arg_conv;
35609         this_arg_conv.inner = (void*)(this_arg & (~1));
35610         this_arg_conv.is_owned = false;
35611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35612         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
35613         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35614         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35615         return ret_arr;
35616 }
35617
35618 int8_tArray  __attribute__((export_name("TS_ClosingTransaction_to_counterparty_script"))) TS_ClosingTransaction_to_counterparty_script(uint32_t this_arg) {
35619         LDKClosingTransaction this_arg_conv;
35620         this_arg_conv.inner = (void*)(this_arg & (~1));
35621         this_arg_conv.is_owned = false;
35622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35623         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
35624         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35625         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35626         return ret_arr;
35627 }
35628
35629 void  __attribute__((export_name("TS_TrustedClosingTransaction_free"))) TS_TrustedClosingTransaction_free(uint32_t this_obj) {
35630         LDKTrustedClosingTransaction this_obj_conv;
35631         this_obj_conv.inner = (void*)(this_obj & (~1));
35632         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35634         TrustedClosingTransaction_free(this_obj_conv);
35635 }
35636
35637 int8_tArray  __attribute__((export_name("TS_TrustedClosingTransaction_built_transaction"))) TS_TrustedClosingTransaction_built_transaction(uint32_t this_arg) {
35638         LDKTrustedClosingTransaction this_arg_conv;
35639         this_arg_conv.inner = (void*)(this_arg & (~1));
35640         this_arg_conv.is_owned = false;
35641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35642         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
35643         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35644         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35645         Transaction_free(ret_var);
35646         return ret_arr;
35647 }
35648
35649 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) {
35650         LDKTrustedClosingTransaction this_arg_conv;
35651         this_arg_conv.inner = (void*)(this_arg & (~1));
35652         this_arg_conv.is_owned = false;
35653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35654         LDKu8slice funding_redeemscript_ref;
35655         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
35656         funding_redeemscript_ref.data = funding_redeemscript->elems /* XXX funding_redeemscript leaks */;
35657         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
35658         memcpy(ret_arr->elems, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
35659         return ret_arr;
35660 }
35661
35662 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) {
35663         LDKTrustedClosingTransaction this_arg_conv;
35664         this_arg_conv.inner = (void*)(this_arg & (~1));
35665         this_arg_conv.is_owned = false;
35666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35667         unsigned char funding_key_arr[32];
35668         CHECK(funding_key->arr_len == 32);
35669         memcpy(funding_key_arr, funding_key->elems, 32); FREE(funding_key);
35670         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
35671         LDKu8slice funding_redeemscript_ref;
35672         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
35673         funding_redeemscript_ref.data = funding_redeemscript->elems /* XXX funding_redeemscript leaks */;
35674         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
35675         memcpy(ret_arr->elems, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
35676         return ret_arr;
35677 }
35678
35679 void  __attribute__((export_name("TS_CommitmentTransaction_free"))) TS_CommitmentTransaction_free(uint32_t this_obj) {
35680         LDKCommitmentTransaction this_obj_conv;
35681         this_obj_conv.inner = (void*)(this_obj & (~1));
35682         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35683         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35684         CommitmentTransaction_free(this_obj_conv);
35685 }
35686
35687 static inline uintptr_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
35688         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
35689 uint32_t ret_ref = 0;
35690 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35691 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35692 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35693 ret_ref = (uintptr_t)ret_var.inner;
35694 if (ret_var.is_owned) {
35695         ret_ref |= 1;
35696 }
35697         return ret_ref;
35698 }
35699 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_clone_ptr"))) TS_CommitmentTransaction_clone_ptr(uint32_t arg) {
35700         LDKCommitmentTransaction arg_conv;
35701         arg_conv.inner = (void*)(arg & (~1));
35702         arg_conv.is_owned = false;
35703         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35704         uint32_t ret_conv = CommitmentTransaction_clone_ptr(&arg_conv);
35705         return ret_conv;
35706 }
35707
35708 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_clone"))) TS_CommitmentTransaction_clone(uint32_t orig) {
35709         LDKCommitmentTransaction orig_conv;
35710         orig_conv.inner = (void*)(orig & (~1));
35711         orig_conv.is_owned = false;
35712         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35713         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
35714         uint32_t ret_ref = 0;
35715         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35716         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35717         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35718         ret_ref = (uintptr_t)ret_var.inner;
35719         if (ret_var.is_owned) {
35720                 ret_ref |= 1;
35721         }
35722         return ret_ref;
35723 }
35724
35725 int8_tArray  __attribute__((export_name("TS_CommitmentTransaction_write"))) TS_CommitmentTransaction_write(uint32_t obj) {
35726         LDKCommitmentTransaction obj_conv;
35727         obj_conv.inner = (void*)(obj & (~1));
35728         obj_conv.is_owned = false;
35729         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35730         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
35731         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35732         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35733         CVec_u8Z_free(ret_var);
35734         return ret_arr;
35735 }
35736
35737 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_read"))) TS_CommitmentTransaction_read(int8_tArray ser) {
35738         LDKu8slice ser_ref;
35739         ser_ref.datalen = ser->arr_len;
35740         ser_ref.data = ser->elems /* XXX ser leaks */;
35741         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
35742         *ret_conv = CommitmentTransaction_read(ser_ref);
35743         return (uint32_t)ret_conv;
35744 }
35745
35746 int64_t  __attribute__((export_name("TS_CommitmentTransaction_commitment_number"))) TS_CommitmentTransaction_commitment_number(uint32_t this_arg) {
35747         LDKCommitmentTransaction this_arg_conv;
35748         this_arg_conv.inner = (void*)(this_arg & (~1));
35749         this_arg_conv.is_owned = false;
35750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35751         int64_t ret_conv = CommitmentTransaction_commitment_number(&this_arg_conv);
35752         return ret_conv;
35753 }
35754
35755 int64_t  __attribute__((export_name("TS_CommitmentTransaction_to_broadcaster_value_sat"))) TS_CommitmentTransaction_to_broadcaster_value_sat(uint32_t this_arg) {
35756         LDKCommitmentTransaction this_arg_conv;
35757         this_arg_conv.inner = (void*)(this_arg & (~1));
35758         this_arg_conv.is_owned = false;
35759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35760         int64_t ret_conv = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
35761         return ret_conv;
35762 }
35763
35764 int64_t  __attribute__((export_name("TS_CommitmentTransaction_to_countersignatory_value_sat"))) TS_CommitmentTransaction_to_countersignatory_value_sat(uint32_t this_arg) {
35765         LDKCommitmentTransaction this_arg_conv;
35766         this_arg_conv.inner = (void*)(this_arg & (~1));
35767         this_arg_conv.is_owned = false;
35768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35769         int64_t ret_conv = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
35770         return ret_conv;
35771 }
35772
35773 int32_t  __attribute__((export_name("TS_CommitmentTransaction_feerate_per_kw"))) TS_CommitmentTransaction_feerate_per_kw(uint32_t this_arg) {
35774         LDKCommitmentTransaction this_arg_conv;
35775         this_arg_conv.inner = (void*)(this_arg & (~1));
35776         this_arg_conv.is_owned = false;
35777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35778         int32_t ret_conv = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
35779         return ret_conv;
35780 }
35781
35782 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_trust"))) TS_CommitmentTransaction_trust(uint32_t this_arg) {
35783         LDKCommitmentTransaction this_arg_conv;
35784         this_arg_conv.inner = (void*)(this_arg & (~1));
35785         this_arg_conv.is_owned = false;
35786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35787         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
35788         uint32_t ret_ref = 0;
35789         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35790         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35791         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35792         ret_ref = (uintptr_t)ret_var.inner;
35793         if (ret_var.is_owned) {
35794                 ret_ref |= 1;
35795         }
35796         return ret_ref;
35797 }
35798
35799 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) {
35800         LDKCommitmentTransaction this_arg_conv;
35801         this_arg_conv.inner = (void*)(this_arg & (~1));
35802         this_arg_conv.is_owned = false;
35803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35804         LDKDirectedChannelTransactionParameters channel_parameters_conv;
35805         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
35806         channel_parameters_conv.is_owned = false;
35807         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
35808         LDKChannelPublicKeys broadcaster_keys_conv;
35809         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
35810         broadcaster_keys_conv.is_owned = false;
35811         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
35812         LDKChannelPublicKeys countersignatory_keys_conv;
35813         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
35814         countersignatory_keys_conv.is_owned = false;
35815         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
35816         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
35817         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
35818         return (uint32_t)ret_conv;
35819 }
35820
35821 void  __attribute__((export_name("TS_TrustedCommitmentTransaction_free"))) TS_TrustedCommitmentTransaction_free(uint32_t this_obj) {
35822         LDKTrustedCommitmentTransaction this_obj_conv;
35823         this_obj_conv.inner = (void*)(this_obj & (~1));
35824         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35826         TrustedCommitmentTransaction_free(this_obj_conv);
35827 }
35828
35829 int8_tArray  __attribute__((export_name("TS_TrustedCommitmentTransaction_txid"))) TS_TrustedCommitmentTransaction_txid(uint32_t this_arg) {
35830         LDKTrustedCommitmentTransaction this_arg_conv;
35831         this_arg_conv.inner = (void*)(this_arg & (~1));
35832         this_arg_conv.is_owned = false;
35833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35834         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
35835         memcpy(ret_arr->elems, TrustedCommitmentTransaction_txid(&this_arg_conv).data, 32);
35836         return ret_arr;
35837 }
35838
35839 uint32_t  __attribute__((export_name("TS_TrustedCommitmentTransaction_built_transaction"))) TS_TrustedCommitmentTransaction_built_transaction(uint32_t this_arg) {
35840         LDKTrustedCommitmentTransaction this_arg_conv;
35841         this_arg_conv.inner = (void*)(this_arg & (~1));
35842         this_arg_conv.is_owned = false;
35843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35844         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
35845         uint32_t ret_ref = 0;
35846         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35847         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35848         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35849         ret_ref = (uintptr_t)ret_var.inner;
35850         if (ret_var.is_owned) {
35851                 ret_ref |= 1;
35852         }
35853         return ret_ref;
35854 }
35855
35856 uint32_t  __attribute__((export_name("TS_TrustedCommitmentTransaction_keys"))) TS_TrustedCommitmentTransaction_keys(uint32_t this_arg) {
35857         LDKTrustedCommitmentTransaction this_arg_conv;
35858         this_arg_conv.inner = (void*)(this_arg & (~1));
35859         this_arg_conv.is_owned = false;
35860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35861         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
35862         uint32_t ret_ref = 0;
35863         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35864         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35865         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35866         ret_ref = (uintptr_t)ret_var.inner;
35867         if (ret_var.is_owned) {
35868                 ret_ref |= 1;
35869         }
35870         return ret_ref;
35871 }
35872
35873 jboolean  __attribute__((export_name("TS_TrustedCommitmentTransaction_opt_anchors"))) TS_TrustedCommitmentTransaction_opt_anchors(uint32_t this_arg) {
35874         LDKTrustedCommitmentTransaction this_arg_conv;
35875         this_arg_conv.inner = (void*)(this_arg & (~1));
35876         this_arg_conv.is_owned = false;
35877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35878         jboolean ret_conv = TrustedCommitmentTransaction_opt_anchors(&this_arg_conv);
35879         return ret_conv;
35880 }
35881
35882 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) {
35883         LDKTrustedCommitmentTransaction this_arg_conv;
35884         this_arg_conv.inner = (void*)(this_arg & (~1));
35885         this_arg_conv.is_owned = false;
35886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35887         unsigned char htlc_base_key_arr[32];
35888         CHECK(htlc_base_key->arr_len == 32);
35889         memcpy(htlc_base_key_arr, htlc_base_key->elems, 32); FREE(htlc_base_key);
35890         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
35891         LDKDirectedChannelTransactionParameters channel_parameters_conv;
35892         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
35893         channel_parameters_conv.is_owned = false;
35894         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
35895         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
35896         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
35897         return (uint32_t)ret_conv;
35898 }
35899
35900 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) {
35901         LDKPublicKey broadcaster_payment_basepoint_ref;
35902         CHECK(broadcaster_payment_basepoint->arr_len == 33);
35903         memcpy(broadcaster_payment_basepoint_ref.compressed_form, broadcaster_payment_basepoint->elems, 33); FREE(broadcaster_payment_basepoint);
35904         LDKPublicKey countersignatory_payment_basepoint_ref;
35905         CHECK(countersignatory_payment_basepoint->arr_len == 33);
35906         memcpy(countersignatory_payment_basepoint_ref.compressed_form, countersignatory_payment_basepoint->elems, 33); FREE(countersignatory_payment_basepoint);
35907         int64_t ret_conv = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
35908         return ret_conv;
35909 }
35910
35911 jboolean  __attribute__((export_name("TS_InitFeatures_eq"))) TS_InitFeatures_eq(uint32_t a, uint32_t b) {
35912         LDKInitFeatures a_conv;
35913         a_conv.inner = (void*)(a & (~1));
35914         a_conv.is_owned = false;
35915         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35916         LDKInitFeatures b_conv;
35917         b_conv.inner = (void*)(b & (~1));
35918         b_conv.is_owned = false;
35919         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35920         jboolean ret_conv = InitFeatures_eq(&a_conv, &b_conv);
35921         return ret_conv;
35922 }
35923
35924 jboolean  __attribute__((export_name("TS_NodeFeatures_eq"))) TS_NodeFeatures_eq(uint32_t a, uint32_t b) {
35925         LDKNodeFeatures a_conv;
35926         a_conv.inner = (void*)(a & (~1));
35927         a_conv.is_owned = false;
35928         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35929         LDKNodeFeatures b_conv;
35930         b_conv.inner = (void*)(b & (~1));
35931         b_conv.is_owned = false;
35932         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35933         jboolean ret_conv = NodeFeatures_eq(&a_conv, &b_conv);
35934         return ret_conv;
35935 }
35936
35937 jboolean  __attribute__((export_name("TS_ChannelFeatures_eq"))) TS_ChannelFeatures_eq(uint32_t a, uint32_t b) {
35938         LDKChannelFeatures a_conv;
35939         a_conv.inner = (void*)(a & (~1));
35940         a_conv.is_owned = false;
35941         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35942         LDKChannelFeatures b_conv;
35943         b_conv.inner = (void*)(b & (~1));
35944         b_conv.is_owned = false;
35945         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35946         jboolean ret_conv = ChannelFeatures_eq(&a_conv, &b_conv);
35947         return ret_conv;
35948 }
35949
35950 jboolean  __attribute__((export_name("TS_InvoiceFeatures_eq"))) TS_InvoiceFeatures_eq(uint32_t a, uint32_t b) {
35951         LDKInvoiceFeatures a_conv;
35952         a_conv.inner = (void*)(a & (~1));
35953         a_conv.is_owned = false;
35954         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35955         LDKInvoiceFeatures b_conv;
35956         b_conv.inner = (void*)(b & (~1));
35957         b_conv.is_owned = false;
35958         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35959         jboolean ret_conv = InvoiceFeatures_eq(&a_conv, &b_conv);
35960         return ret_conv;
35961 }
35962
35963 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_eq"))) TS_ChannelTypeFeatures_eq(uint32_t a, uint32_t b) {
35964         LDKChannelTypeFeatures a_conv;
35965         a_conv.inner = (void*)(a & (~1));
35966         a_conv.is_owned = false;
35967         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35968         LDKChannelTypeFeatures b_conv;
35969         b_conv.inner = (void*)(b & (~1));
35970         b_conv.is_owned = false;
35971         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35972         jboolean ret_conv = ChannelTypeFeatures_eq(&a_conv, &b_conv);
35973         return ret_conv;
35974 }
35975
35976 static inline uintptr_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
35977         LDKInitFeatures ret_var = InitFeatures_clone(arg);
35978 uint32_t ret_ref = 0;
35979 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35980 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35981 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35982 ret_ref = (uintptr_t)ret_var.inner;
35983 if (ret_var.is_owned) {
35984         ret_ref |= 1;
35985 }
35986         return ret_ref;
35987 }
35988 uint32_t  __attribute__((export_name("TS_InitFeatures_clone_ptr"))) TS_InitFeatures_clone_ptr(uint32_t arg) {
35989         LDKInitFeatures arg_conv;
35990         arg_conv.inner = (void*)(arg & (~1));
35991         arg_conv.is_owned = false;
35992         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35993         uint32_t ret_conv = InitFeatures_clone_ptr(&arg_conv);
35994         return ret_conv;
35995 }
35996
35997 uint32_t  __attribute__((export_name("TS_InitFeatures_clone"))) TS_InitFeatures_clone(uint32_t orig) {
35998         LDKInitFeatures orig_conv;
35999         orig_conv.inner = (void*)(orig & (~1));
36000         orig_conv.is_owned = false;
36001         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36002         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
36003         uint32_t ret_ref = 0;
36004         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36005         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36006         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36007         ret_ref = (uintptr_t)ret_var.inner;
36008         if (ret_var.is_owned) {
36009                 ret_ref |= 1;
36010         }
36011         return ret_ref;
36012 }
36013
36014 static inline uintptr_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
36015         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
36016 uint32_t ret_ref = 0;
36017 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36018 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36019 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36020 ret_ref = (uintptr_t)ret_var.inner;
36021 if (ret_var.is_owned) {
36022         ret_ref |= 1;
36023 }
36024         return ret_ref;
36025 }
36026 uint32_t  __attribute__((export_name("TS_NodeFeatures_clone_ptr"))) TS_NodeFeatures_clone_ptr(uint32_t arg) {
36027         LDKNodeFeatures arg_conv;
36028         arg_conv.inner = (void*)(arg & (~1));
36029         arg_conv.is_owned = false;
36030         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36031         uint32_t ret_conv = NodeFeatures_clone_ptr(&arg_conv);
36032         return ret_conv;
36033 }
36034
36035 uint32_t  __attribute__((export_name("TS_NodeFeatures_clone"))) TS_NodeFeatures_clone(uint32_t orig) {
36036         LDKNodeFeatures orig_conv;
36037         orig_conv.inner = (void*)(orig & (~1));
36038         orig_conv.is_owned = false;
36039         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36040         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
36041         uint32_t ret_ref = 0;
36042         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36043         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36044         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36045         ret_ref = (uintptr_t)ret_var.inner;
36046         if (ret_var.is_owned) {
36047                 ret_ref |= 1;
36048         }
36049         return ret_ref;
36050 }
36051
36052 static inline uintptr_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
36053         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
36054 uint32_t ret_ref = 0;
36055 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36056 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36057 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36058 ret_ref = (uintptr_t)ret_var.inner;
36059 if (ret_var.is_owned) {
36060         ret_ref |= 1;
36061 }
36062         return ret_ref;
36063 }
36064 uint32_t  __attribute__((export_name("TS_ChannelFeatures_clone_ptr"))) TS_ChannelFeatures_clone_ptr(uint32_t arg) {
36065         LDKChannelFeatures arg_conv;
36066         arg_conv.inner = (void*)(arg & (~1));
36067         arg_conv.is_owned = false;
36068         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36069         uint32_t ret_conv = ChannelFeatures_clone_ptr(&arg_conv);
36070         return ret_conv;
36071 }
36072
36073 uint32_t  __attribute__((export_name("TS_ChannelFeatures_clone"))) TS_ChannelFeatures_clone(uint32_t orig) {
36074         LDKChannelFeatures orig_conv;
36075         orig_conv.inner = (void*)(orig & (~1));
36076         orig_conv.is_owned = false;
36077         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36078         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
36079         uint32_t ret_ref = 0;
36080         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36081         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36082         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36083         ret_ref = (uintptr_t)ret_var.inner;
36084         if (ret_var.is_owned) {
36085                 ret_ref |= 1;
36086         }
36087         return ret_ref;
36088 }
36089
36090 static inline uintptr_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
36091         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
36092 uint32_t ret_ref = 0;
36093 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36094 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36095 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36096 ret_ref = (uintptr_t)ret_var.inner;
36097 if (ret_var.is_owned) {
36098         ret_ref |= 1;
36099 }
36100         return ret_ref;
36101 }
36102 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_clone_ptr"))) TS_InvoiceFeatures_clone_ptr(uint32_t arg) {
36103         LDKInvoiceFeatures arg_conv;
36104         arg_conv.inner = (void*)(arg & (~1));
36105         arg_conv.is_owned = false;
36106         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36107         uint32_t ret_conv = InvoiceFeatures_clone_ptr(&arg_conv);
36108         return ret_conv;
36109 }
36110
36111 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_clone"))) TS_InvoiceFeatures_clone(uint32_t orig) {
36112         LDKInvoiceFeatures orig_conv;
36113         orig_conv.inner = (void*)(orig & (~1));
36114         orig_conv.is_owned = false;
36115         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36116         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
36117         uint32_t ret_ref = 0;
36118         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36119         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36120         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36121         ret_ref = (uintptr_t)ret_var.inner;
36122         if (ret_var.is_owned) {
36123                 ret_ref |= 1;
36124         }
36125         return ret_ref;
36126 }
36127
36128 static inline uintptr_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
36129         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
36130 uint32_t ret_ref = 0;
36131 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36132 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36133 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36134 ret_ref = (uintptr_t)ret_var.inner;
36135 if (ret_var.is_owned) {
36136         ret_ref |= 1;
36137 }
36138         return ret_ref;
36139 }
36140 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_clone_ptr"))) TS_ChannelTypeFeatures_clone_ptr(uint32_t arg) {
36141         LDKChannelTypeFeatures arg_conv;
36142         arg_conv.inner = (void*)(arg & (~1));
36143         arg_conv.is_owned = false;
36144         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36145         uint32_t ret_conv = ChannelTypeFeatures_clone_ptr(&arg_conv);
36146         return ret_conv;
36147 }
36148
36149 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_clone"))) TS_ChannelTypeFeatures_clone(uint32_t orig) {
36150         LDKChannelTypeFeatures orig_conv;
36151         orig_conv.inner = (void*)(orig & (~1));
36152         orig_conv.is_owned = false;
36153         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36154         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_conv);
36155         uint32_t ret_ref = 0;
36156         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36157         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36158         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36159         ret_ref = (uintptr_t)ret_var.inner;
36160         if (ret_var.is_owned) {
36161                 ret_ref |= 1;
36162         }
36163         return ret_ref;
36164 }
36165
36166 void  __attribute__((export_name("TS_InitFeatures_free"))) TS_InitFeatures_free(uint32_t this_obj) {
36167         LDKInitFeatures this_obj_conv;
36168         this_obj_conv.inner = (void*)(this_obj & (~1));
36169         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36171         InitFeatures_free(this_obj_conv);
36172 }
36173
36174 void  __attribute__((export_name("TS_NodeFeatures_free"))) TS_NodeFeatures_free(uint32_t this_obj) {
36175         LDKNodeFeatures this_obj_conv;
36176         this_obj_conv.inner = (void*)(this_obj & (~1));
36177         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36178         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36179         NodeFeatures_free(this_obj_conv);
36180 }
36181
36182 void  __attribute__((export_name("TS_ChannelFeatures_free"))) TS_ChannelFeatures_free(uint32_t this_obj) {
36183         LDKChannelFeatures this_obj_conv;
36184         this_obj_conv.inner = (void*)(this_obj & (~1));
36185         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36187         ChannelFeatures_free(this_obj_conv);
36188 }
36189
36190 void  __attribute__((export_name("TS_InvoiceFeatures_free"))) TS_InvoiceFeatures_free(uint32_t this_obj) {
36191         LDKInvoiceFeatures this_obj_conv;
36192         this_obj_conv.inner = (void*)(this_obj & (~1));
36193         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36195         InvoiceFeatures_free(this_obj_conv);
36196 }
36197
36198 void  __attribute__((export_name("TS_ChannelTypeFeatures_free"))) TS_ChannelTypeFeatures_free(uint32_t this_obj) {
36199         LDKChannelTypeFeatures this_obj_conv;
36200         this_obj_conv.inner = (void*)(this_obj & (~1));
36201         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36203         ChannelTypeFeatures_free(this_obj_conv);
36204 }
36205
36206 uint32_t  __attribute__((export_name("TS_InitFeatures_empty"))) TS_InitFeatures_empty() {
36207         LDKInitFeatures ret_var = InitFeatures_empty();
36208         uint32_t ret_ref = 0;
36209         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36210         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36211         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36212         ret_ref = (uintptr_t)ret_var.inner;
36213         if (ret_var.is_owned) {
36214                 ret_ref |= 1;
36215         }
36216         return ret_ref;
36217 }
36218
36219 uint32_t  __attribute__((export_name("TS_InitFeatures_known"))) TS_InitFeatures_known() {
36220         LDKInitFeatures ret_var = InitFeatures_known();
36221         uint32_t ret_ref = 0;
36222         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36223         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36224         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36225         ret_ref = (uintptr_t)ret_var.inner;
36226         if (ret_var.is_owned) {
36227                 ret_ref |= 1;
36228         }
36229         return ret_ref;
36230 }
36231
36232 jboolean  __attribute__((export_name("TS_InitFeatures_requires_unknown_bits"))) TS_InitFeatures_requires_unknown_bits(uint32_t this_arg) {
36233         LDKInitFeatures this_arg_conv;
36234         this_arg_conv.inner = (void*)(this_arg & (~1));
36235         this_arg_conv.is_owned = false;
36236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36237         jboolean ret_conv = InitFeatures_requires_unknown_bits(&this_arg_conv);
36238         return ret_conv;
36239 }
36240
36241 uint32_t  __attribute__((export_name("TS_NodeFeatures_empty"))) TS_NodeFeatures_empty() {
36242         LDKNodeFeatures ret_var = NodeFeatures_empty();
36243         uint32_t ret_ref = 0;
36244         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36245         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36246         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36247         ret_ref = (uintptr_t)ret_var.inner;
36248         if (ret_var.is_owned) {
36249                 ret_ref |= 1;
36250         }
36251         return ret_ref;
36252 }
36253
36254 uint32_t  __attribute__((export_name("TS_NodeFeatures_known"))) TS_NodeFeatures_known() {
36255         LDKNodeFeatures ret_var = NodeFeatures_known();
36256         uint32_t ret_ref = 0;
36257         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36258         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36259         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36260         ret_ref = (uintptr_t)ret_var.inner;
36261         if (ret_var.is_owned) {
36262                 ret_ref |= 1;
36263         }
36264         return ret_ref;
36265 }
36266
36267 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_unknown_bits"))) TS_NodeFeatures_requires_unknown_bits(uint32_t this_arg) {
36268         LDKNodeFeatures this_arg_conv;
36269         this_arg_conv.inner = (void*)(this_arg & (~1));
36270         this_arg_conv.is_owned = false;
36271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36272         jboolean ret_conv = NodeFeatures_requires_unknown_bits(&this_arg_conv);
36273         return ret_conv;
36274 }
36275
36276 uint32_t  __attribute__((export_name("TS_ChannelFeatures_empty"))) TS_ChannelFeatures_empty() {
36277         LDKChannelFeatures ret_var = ChannelFeatures_empty();
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
36289 uint32_t  __attribute__((export_name("TS_ChannelFeatures_known"))) TS_ChannelFeatures_known() {
36290         LDKChannelFeatures ret_var = ChannelFeatures_known();
36291         uint32_t ret_ref = 0;
36292         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36293         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36294         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36295         ret_ref = (uintptr_t)ret_var.inner;
36296         if (ret_var.is_owned) {
36297                 ret_ref |= 1;
36298         }
36299         return ret_ref;
36300 }
36301
36302 jboolean  __attribute__((export_name("TS_ChannelFeatures_requires_unknown_bits"))) TS_ChannelFeatures_requires_unknown_bits(uint32_t this_arg) {
36303         LDKChannelFeatures this_arg_conv;
36304         this_arg_conv.inner = (void*)(this_arg & (~1));
36305         this_arg_conv.is_owned = false;
36306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36307         jboolean ret_conv = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
36308         return ret_conv;
36309 }
36310
36311 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_empty"))) TS_InvoiceFeatures_empty() {
36312         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
36313         uint32_t ret_ref = 0;
36314         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36315         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36316         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36317         ret_ref = (uintptr_t)ret_var.inner;
36318         if (ret_var.is_owned) {
36319                 ret_ref |= 1;
36320         }
36321         return ret_ref;
36322 }
36323
36324 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_known"))) TS_InvoiceFeatures_known() {
36325         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
36326         uint32_t ret_ref = 0;
36327         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36328         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36329         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36330         ret_ref = (uintptr_t)ret_var.inner;
36331         if (ret_var.is_owned) {
36332                 ret_ref |= 1;
36333         }
36334         return ret_ref;
36335 }
36336
36337 jboolean  __attribute__((export_name("TS_InvoiceFeatures_requires_unknown_bits"))) TS_InvoiceFeatures_requires_unknown_bits(uint32_t this_arg) {
36338         LDKInvoiceFeatures this_arg_conv;
36339         this_arg_conv.inner = (void*)(this_arg & (~1));
36340         this_arg_conv.is_owned = false;
36341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36342         jboolean ret_conv = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
36343         return ret_conv;
36344 }
36345
36346 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_empty"))) TS_ChannelTypeFeatures_empty() {
36347         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
36348         uint32_t ret_ref = 0;
36349         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36350         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36351         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36352         ret_ref = (uintptr_t)ret_var.inner;
36353         if (ret_var.is_owned) {
36354                 ret_ref |= 1;
36355         }
36356         return ret_ref;
36357 }
36358
36359 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_known"))) TS_ChannelTypeFeatures_known() {
36360         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_known();
36361         uint32_t ret_ref = 0;
36362         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36363         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36364         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36365         ret_ref = (uintptr_t)ret_var.inner;
36366         if (ret_var.is_owned) {
36367                 ret_ref |= 1;
36368         }
36369         return ret_ref;
36370 }
36371
36372 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_requires_unknown_bits"))) TS_ChannelTypeFeatures_requires_unknown_bits(uint32_t this_arg) {
36373         LDKChannelTypeFeatures this_arg_conv;
36374         this_arg_conv.inner = (void*)(this_arg & (~1));
36375         this_arg_conv.is_owned = false;
36376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36377         jboolean ret_conv = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
36378         return ret_conv;
36379 }
36380
36381 int8_tArray  __attribute__((export_name("TS_InitFeatures_write"))) TS_InitFeatures_write(uint32_t obj) {
36382         LDKInitFeatures obj_conv;
36383         obj_conv.inner = (void*)(obj & (~1));
36384         obj_conv.is_owned = false;
36385         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36386         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
36387         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36388         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36389         CVec_u8Z_free(ret_var);
36390         return ret_arr;
36391 }
36392
36393 uint32_t  __attribute__((export_name("TS_InitFeatures_read"))) TS_InitFeatures_read(int8_tArray ser) {
36394         LDKu8slice ser_ref;
36395         ser_ref.datalen = ser->arr_len;
36396         ser_ref.data = ser->elems /* XXX ser leaks */;
36397         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
36398         *ret_conv = InitFeatures_read(ser_ref);
36399         return (uint32_t)ret_conv;
36400 }
36401
36402 int8_tArray  __attribute__((export_name("TS_ChannelFeatures_write"))) TS_ChannelFeatures_write(uint32_t obj) {
36403         LDKChannelFeatures obj_conv;
36404         obj_conv.inner = (void*)(obj & (~1));
36405         obj_conv.is_owned = false;
36406         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36407         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
36408         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36409         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36410         CVec_u8Z_free(ret_var);
36411         return ret_arr;
36412 }
36413
36414 uint32_t  __attribute__((export_name("TS_ChannelFeatures_read"))) TS_ChannelFeatures_read(int8_tArray ser) {
36415         LDKu8slice ser_ref;
36416         ser_ref.datalen = ser->arr_len;
36417         ser_ref.data = ser->elems /* XXX ser leaks */;
36418         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
36419         *ret_conv = ChannelFeatures_read(ser_ref);
36420         return (uint32_t)ret_conv;
36421 }
36422
36423 int8_tArray  __attribute__((export_name("TS_NodeFeatures_write"))) TS_NodeFeatures_write(uint32_t obj) {
36424         LDKNodeFeatures obj_conv;
36425         obj_conv.inner = (void*)(obj & (~1));
36426         obj_conv.is_owned = false;
36427         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36428         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
36429         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36430         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36431         CVec_u8Z_free(ret_var);
36432         return ret_arr;
36433 }
36434
36435 uint32_t  __attribute__((export_name("TS_NodeFeatures_read"))) TS_NodeFeatures_read(int8_tArray ser) {
36436         LDKu8slice ser_ref;
36437         ser_ref.datalen = ser->arr_len;
36438         ser_ref.data = ser->elems /* XXX ser leaks */;
36439         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
36440         *ret_conv = NodeFeatures_read(ser_ref);
36441         return (uint32_t)ret_conv;
36442 }
36443
36444 int8_tArray  __attribute__((export_name("TS_InvoiceFeatures_write"))) TS_InvoiceFeatures_write(uint32_t obj) {
36445         LDKInvoiceFeatures obj_conv;
36446         obj_conv.inner = (void*)(obj & (~1));
36447         obj_conv.is_owned = false;
36448         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36449         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
36450         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36451         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36452         CVec_u8Z_free(ret_var);
36453         return ret_arr;
36454 }
36455
36456 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_read"))) TS_InvoiceFeatures_read(int8_tArray ser) {
36457         LDKu8slice ser_ref;
36458         ser_ref.datalen = ser->arr_len;
36459         ser_ref.data = ser->elems /* XXX ser leaks */;
36460         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
36461         *ret_conv = InvoiceFeatures_read(ser_ref);
36462         return (uint32_t)ret_conv;
36463 }
36464
36465 int8_tArray  __attribute__((export_name("TS_ChannelTypeFeatures_write"))) TS_ChannelTypeFeatures_write(uint32_t obj) {
36466         LDKChannelTypeFeatures obj_conv;
36467         obj_conv.inner = (void*)(obj & (~1));
36468         obj_conv.is_owned = false;
36469         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36470         LDKCVec_u8Z ret_var = ChannelTypeFeatures_write(&obj_conv);
36471         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36472         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36473         CVec_u8Z_free(ret_var);
36474         return ret_arr;
36475 }
36476
36477 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_read"))) TS_ChannelTypeFeatures_read(int8_tArray ser) {
36478         LDKu8slice ser_ref;
36479         ser_ref.datalen = ser->arr_len;
36480         ser_ref.data = ser->elems /* XXX ser leaks */;
36481         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
36482         *ret_conv = ChannelTypeFeatures_read(ser_ref);
36483         return (uint32_t)ret_conv;
36484 }
36485
36486 void  __attribute__((export_name("TS_InitFeatures_set_data_loss_protect_optional"))) TS_InitFeatures_set_data_loss_protect_optional(uint32_t this_arg) {
36487         LDKInitFeatures this_arg_conv;
36488         this_arg_conv.inner = (void*)(this_arg & (~1));
36489         this_arg_conv.is_owned = false;
36490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36491         InitFeatures_set_data_loss_protect_optional(&this_arg_conv);
36492 }
36493
36494 void  __attribute__((export_name("TS_InitFeatures_set_data_loss_protect_required"))) TS_InitFeatures_set_data_loss_protect_required(uint32_t this_arg) {
36495         LDKInitFeatures this_arg_conv;
36496         this_arg_conv.inner = (void*)(this_arg & (~1));
36497         this_arg_conv.is_owned = false;
36498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36499         InitFeatures_set_data_loss_protect_required(&this_arg_conv);
36500 }
36501
36502 jboolean  __attribute__((export_name("TS_InitFeatures_supports_data_loss_protect"))) TS_InitFeatures_supports_data_loss_protect(uint32_t this_arg) {
36503         LDKInitFeatures this_arg_conv;
36504         this_arg_conv.inner = (void*)(this_arg & (~1));
36505         this_arg_conv.is_owned = false;
36506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36507         jboolean ret_conv = InitFeatures_supports_data_loss_protect(&this_arg_conv);
36508         return ret_conv;
36509 }
36510
36511 void  __attribute__((export_name("TS_NodeFeatures_set_data_loss_protect_optional"))) TS_NodeFeatures_set_data_loss_protect_optional(uint32_t this_arg) {
36512         LDKNodeFeatures this_arg_conv;
36513         this_arg_conv.inner = (void*)(this_arg & (~1));
36514         this_arg_conv.is_owned = false;
36515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36516         NodeFeatures_set_data_loss_protect_optional(&this_arg_conv);
36517 }
36518
36519 void  __attribute__((export_name("TS_NodeFeatures_set_data_loss_protect_required"))) TS_NodeFeatures_set_data_loss_protect_required(uint32_t this_arg) {
36520         LDKNodeFeatures this_arg_conv;
36521         this_arg_conv.inner = (void*)(this_arg & (~1));
36522         this_arg_conv.is_owned = false;
36523         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36524         NodeFeatures_set_data_loss_protect_required(&this_arg_conv);
36525 }
36526
36527 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_data_loss_protect"))) TS_NodeFeatures_supports_data_loss_protect(uint32_t this_arg) {
36528         LDKNodeFeatures this_arg_conv;
36529         this_arg_conv.inner = (void*)(this_arg & (~1));
36530         this_arg_conv.is_owned = false;
36531         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36532         jboolean ret_conv = NodeFeatures_supports_data_loss_protect(&this_arg_conv);
36533         return ret_conv;
36534 }
36535
36536 jboolean  __attribute__((export_name("TS_InitFeatures_requires_data_loss_protect"))) TS_InitFeatures_requires_data_loss_protect(uint32_t this_arg) {
36537         LDKInitFeatures this_arg_conv;
36538         this_arg_conv.inner = (void*)(this_arg & (~1));
36539         this_arg_conv.is_owned = false;
36540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36541         jboolean ret_conv = InitFeatures_requires_data_loss_protect(&this_arg_conv);
36542         return ret_conv;
36543 }
36544
36545 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_data_loss_protect"))) TS_NodeFeatures_requires_data_loss_protect(uint32_t this_arg) {
36546         LDKNodeFeatures this_arg_conv;
36547         this_arg_conv.inner = (void*)(this_arg & (~1));
36548         this_arg_conv.is_owned = false;
36549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36550         jboolean ret_conv = NodeFeatures_requires_data_loss_protect(&this_arg_conv);
36551         return ret_conv;
36552 }
36553
36554 void  __attribute__((export_name("TS_InitFeatures_set_initial_routing_sync_optional"))) TS_InitFeatures_set_initial_routing_sync_optional(uint32_t this_arg) {
36555         LDKInitFeatures this_arg_conv;
36556         this_arg_conv.inner = (void*)(this_arg & (~1));
36557         this_arg_conv.is_owned = false;
36558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36559         InitFeatures_set_initial_routing_sync_optional(&this_arg_conv);
36560 }
36561
36562 void  __attribute__((export_name("TS_InitFeatures_set_initial_routing_sync_required"))) TS_InitFeatures_set_initial_routing_sync_required(uint32_t this_arg) {
36563         LDKInitFeatures this_arg_conv;
36564         this_arg_conv.inner = (void*)(this_arg & (~1));
36565         this_arg_conv.is_owned = false;
36566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36567         InitFeatures_set_initial_routing_sync_required(&this_arg_conv);
36568 }
36569
36570 jboolean  __attribute__((export_name("TS_InitFeatures_initial_routing_sync"))) TS_InitFeatures_initial_routing_sync(uint32_t this_arg) {
36571         LDKInitFeatures this_arg_conv;
36572         this_arg_conv.inner = (void*)(this_arg & (~1));
36573         this_arg_conv.is_owned = false;
36574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36575         jboolean ret_conv = InitFeatures_initial_routing_sync(&this_arg_conv);
36576         return ret_conv;
36577 }
36578
36579 void  __attribute__((export_name("TS_InitFeatures_set_upfront_shutdown_script_optional"))) TS_InitFeatures_set_upfront_shutdown_script_optional(uint32_t this_arg) {
36580         LDKInitFeatures this_arg_conv;
36581         this_arg_conv.inner = (void*)(this_arg & (~1));
36582         this_arg_conv.is_owned = false;
36583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36584         InitFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
36585 }
36586
36587 void  __attribute__((export_name("TS_InitFeatures_set_upfront_shutdown_script_required"))) TS_InitFeatures_set_upfront_shutdown_script_required(uint32_t this_arg) {
36588         LDKInitFeatures this_arg_conv;
36589         this_arg_conv.inner = (void*)(this_arg & (~1));
36590         this_arg_conv.is_owned = false;
36591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36592         InitFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
36593 }
36594
36595 jboolean  __attribute__((export_name("TS_InitFeatures_supports_upfront_shutdown_script"))) TS_InitFeatures_supports_upfront_shutdown_script(uint32_t this_arg) {
36596         LDKInitFeatures this_arg_conv;
36597         this_arg_conv.inner = (void*)(this_arg & (~1));
36598         this_arg_conv.is_owned = false;
36599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36600         jboolean ret_conv = InitFeatures_supports_upfront_shutdown_script(&this_arg_conv);
36601         return ret_conv;
36602 }
36603
36604 void  __attribute__((export_name("TS_NodeFeatures_set_upfront_shutdown_script_optional"))) TS_NodeFeatures_set_upfront_shutdown_script_optional(uint32_t this_arg) {
36605         LDKNodeFeatures this_arg_conv;
36606         this_arg_conv.inner = (void*)(this_arg & (~1));
36607         this_arg_conv.is_owned = false;
36608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36609         NodeFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
36610 }
36611
36612 void  __attribute__((export_name("TS_NodeFeatures_set_upfront_shutdown_script_required"))) TS_NodeFeatures_set_upfront_shutdown_script_required(uint32_t this_arg) {
36613         LDKNodeFeatures this_arg_conv;
36614         this_arg_conv.inner = (void*)(this_arg & (~1));
36615         this_arg_conv.is_owned = false;
36616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36617         NodeFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
36618 }
36619
36620 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_upfront_shutdown_script"))) TS_NodeFeatures_supports_upfront_shutdown_script(uint32_t this_arg) {
36621         LDKNodeFeatures this_arg_conv;
36622         this_arg_conv.inner = (void*)(this_arg & (~1));
36623         this_arg_conv.is_owned = false;
36624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36625         jboolean ret_conv = NodeFeatures_supports_upfront_shutdown_script(&this_arg_conv);
36626         return ret_conv;
36627 }
36628
36629 jboolean  __attribute__((export_name("TS_InitFeatures_requires_upfront_shutdown_script"))) TS_InitFeatures_requires_upfront_shutdown_script(uint32_t this_arg) {
36630         LDKInitFeatures this_arg_conv;
36631         this_arg_conv.inner = (void*)(this_arg & (~1));
36632         this_arg_conv.is_owned = false;
36633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36634         jboolean ret_conv = InitFeatures_requires_upfront_shutdown_script(&this_arg_conv);
36635         return ret_conv;
36636 }
36637
36638 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_upfront_shutdown_script"))) TS_NodeFeatures_requires_upfront_shutdown_script(uint32_t this_arg) {
36639         LDKNodeFeatures this_arg_conv;
36640         this_arg_conv.inner = (void*)(this_arg & (~1));
36641         this_arg_conv.is_owned = false;
36642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36643         jboolean ret_conv = NodeFeatures_requires_upfront_shutdown_script(&this_arg_conv);
36644         return ret_conv;
36645 }
36646
36647 void  __attribute__((export_name("TS_InitFeatures_set_gossip_queries_optional"))) TS_InitFeatures_set_gossip_queries_optional(uint32_t this_arg) {
36648         LDKInitFeatures this_arg_conv;
36649         this_arg_conv.inner = (void*)(this_arg & (~1));
36650         this_arg_conv.is_owned = false;
36651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36652         InitFeatures_set_gossip_queries_optional(&this_arg_conv);
36653 }
36654
36655 void  __attribute__((export_name("TS_InitFeatures_set_gossip_queries_required"))) TS_InitFeatures_set_gossip_queries_required(uint32_t this_arg) {
36656         LDKInitFeatures this_arg_conv;
36657         this_arg_conv.inner = (void*)(this_arg & (~1));
36658         this_arg_conv.is_owned = false;
36659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36660         InitFeatures_set_gossip_queries_required(&this_arg_conv);
36661 }
36662
36663 jboolean  __attribute__((export_name("TS_InitFeatures_supports_gossip_queries"))) TS_InitFeatures_supports_gossip_queries(uint32_t this_arg) {
36664         LDKInitFeatures this_arg_conv;
36665         this_arg_conv.inner = (void*)(this_arg & (~1));
36666         this_arg_conv.is_owned = false;
36667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36668         jboolean ret_conv = InitFeatures_supports_gossip_queries(&this_arg_conv);
36669         return ret_conv;
36670 }
36671
36672 void  __attribute__((export_name("TS_NodeFeatures_set_gossip_queries_optional"))) TS_NodeFeatures_set_gossip_queries_optional(uint32_t this_arg) {
36673         LDKNodeFeatures this_arg_conv;
36674         this_arg_conv.inner = (void*)(this_arg & (~1));
36675         this_arg_conv.is_owned = false;
36676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36677         NodeFeatures_set_gossip_queries_optional(&this_arg_conv);
36678 }
36679
36680 void  __attribute__((export_name("TS_NodeFeatures_set_gossip_queries_required"))) TS_NodeFeatures_set_gossip_queries_required(uint32_t this_arg) {
36681         LDKNodeFeatures this_arg_conv;
36682         this_arg_conv.inner = (void*)(this_arg & (~1));
36683         this_arg_conv.is_owned = false;
36684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36685         NodeFeatures_set_gossip_queries_required(&this_arg_conv);
36686 }
36687
36688 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_gossip_queries"))) TS_NodeFeatures_supports_gossip_queries(uint32_t this_arg) {
36689         LDKNodeFeatures this_arg_conv;
36690         this_arg_conv.inner = (void*)(this_arg & (~1));
36691         this_arg_conv.is_owned = false;
36692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36693         jboolean ret_conv = NodeFeatures_supports_gossip_queries(&this_arg_conv);
36694         return ret_conv;
36695 }
36696
36697 jboolean  __attribute__((export_name("TS_InitFeatures_requires_gossip_queries"))) TS_InitFeatures_requires_gossip_queries(uint32_t this_arg) {
36698         LDKInitFeatures this_arg_conv;
36699         this_arg_conv.inner = (void*)(this_arg & (~1));
36700         this_arg_conv.is_owned = false;
36701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36702         jboolean ret_conv = InitFeatures_requires_gossip_queries(&this_arg_conv);
36703         return ret_conv;
36704 }
36705
36706 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_gossip_queries"))) TS_NodeFeatures_requires_gossip_queries(uint32_t this_arg) {
36707         LDKNodeFeatures this_arg_conv;
36708         this_arg_conv.inner = (void*)(this_arg & (~1));
36709         this_arg_conv.is_owned = false;
36710         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36711         jboolean ret_conv = NodeFeatures_requires_gossip_queries(&this_arg_conv);
36712         return ret_conv;
36713 }
36714
36715 void  __attribute__((export_name("TS_InitFeatures_set_variable_length_onion_optional"))) TS_InitFeatures_set_variable_length_onion_optional(uint32_t this_arg) {
36716         LDKInitFeatures this_arg_conv;
36717         this_arg_conv.inner = (void*)(this_arg & (~1));
36718         this_arg_conv.is_owned = false;
36719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36720         InitFeatures_set_variable_length_onion_optional(&this_arg_conv);
36721 }
36722
36723 void  __attribute__((export_name("TS_InitFeatures_set_variable_length_onion_required"))) TS_InitFeatures_set_variable_length_onion_required(uint32_t this_arg) {
36724         LDKInitFeatures this_arg_conv;
36725         this_arg_conv.inner = (void*)(this_arg & (~1));
36726         this_arg_conv.is_owned = false;
36727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36728         InitFeatures_set_variable_length_onion_required(&this_arg_conv);
36729 }
36730
36731 jboolean  __attribute__((export_name("TS_InitFeatures_supports_variable_length_onion"))) TS_InitFeatures_supports_variable_length_onion(uint32_t this_arg) {
36732         LDKInitFeatures this_arg_conv;
36733         this_arg_conv.inner = (void*)(this_arg & (~1));
36734         this_arg_conv.is_owned = false;
36735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36736         jboolean ret_conv = InitFeatures_supports_variable_length_onion(&this_arg_conv);
36737         return ret_conv;
36738 }
36739
36740 void  __attribute__((export_name("TS_NodeFeatures_set_variable_length_onion_optional"))) TS_NodeFeatures_set_variable_length_onion_optional(uint32_t this_arg) {
36741         LDKNodeFeatures this_arg_conv;
36742         this_arg_conv.inner = (void*)(this_arg & (~1));
36743         this_arg_conv.is_owned = false;
36744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36745         NodeFeatures_set_variable_length_onion_optional(&this_arg_conv);
36746 }
36747
36748 void  __attribute__((export_name("TS_NodeFeatures_set_variable_length_onion_required"))) TS_NodeFeatures_set_variable_length_onion_required(uint32_t this_arg) {
36749         LDKNodeFeatures this_arg_conv;
36750         this_arg_conv.inner = (void*)(this_arg & (~1));
36751         this_arg_conv.is_owned = false;
36752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36753         NodeFeatures_set_variable_length_onion_required(&this_arg_conv);
36754 }
36755
36756 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_variable_length_onion"))) TS_NodeFeatures_supports_variable_length_onion(uint32_t this_arg) {
36757         LDKNodeFeatures this_arg_conv;
36758         this_arg_conv.inner = (void*)(this_arg & (~1));
36759         this_arg_conv.is_owned = false;
36760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36761         jboolean ret_conv = NodeFeatures_supports_variable_length_onion(&this_arg_conv);
36762         return ret_conv;
36763 }
36764
36765 void  __attribute__((export_name("TS_InvoiceFeatures_set_variable_length_onion_optional"))) TS_InvoiceFeatures_set_variable_length_onion_optional(uint32_t this_arg) {
36766         LDKInvoiceFeatures this_arg_conv;
36767         this_arg_conv.inner = (void*)(this_arg & (~1));
36768         this_arg_conv.is_owned = false;
36769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36770         InvoiceFeatures_set_variable_length_onion_optional(&this_arg_conv);
36771 }
36772
36773 void  __attribute__((export_name("TS_InvoiceFeatures_set_variable_length_onion_required"))) TS_InvoiceFeatures_set_variable_length_onion_required(uint32_t this_arg) {
36774         LDKInvoiceFeatures this_arg_conv;
36775         this_arg_conv.inner = (void*)(this_arg & (~1));
36776         this_arg_conv.is_owned = false;
36777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36778         InvoiceFeatures_set_variable_length_onion_required(&this_arg_conv);
36779 }
36780
36781 jboolean  __attribute__((export_name("TS_InvoiceFeatures_supports_variable_length_onion"))) TS_InvoiceFeatures_supports_variable_length_onion(uint32_t this_arg) {
36782         LDKInvoiceFeatures this_arg_conv;
36783         this_arg_conv.inner = (void*)(this_arg & (~1));
36784         this_arg_conv.is_owned = false;
36785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36786         jboolean ret_conv = InvoiceFeatures_supports_variable_length_onion(&this_arg_conv);
36787         return ret_conv;
36788 }
36789
36790 jboolean  __attribute__((export_name("TS_InitFeatures_requires_variable_length_onion"))) TS_InitFeatures_requires_variable_length_onion(uint32_t this_arg) {
36791         LDKInitFeatures this_arg_conv;
36792         this_arg_conv.inner = (void*)(this_arg & (~1));
36793         this_arg_conv.is_owned = false;
36794         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36795         jboolean ret_conv = InitFeatures_requires_variable_length_onion(&this_arg_conv);
36796         return ret_conv;
36797 }
36798
36799 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_variable_length_onion"))) TS_NodeFeatures_requires_variable_length_onion(uint32_t this_arg) {
36800         LDKNodeFeatures this_arg_conv;
36801         this_arg_conv.inner = (void*)(this_arg & (~1));
36802         this_arg_conv.is_owned = false;
36803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36804         jboolean ret_conv = NodeFeatures_requires_variable_length_onion(&this_arg_conv);
36805         return ret_conv;
36806 }
36807
36808 jboolean  __attribute__((export_name("TS_InvoiceFeatures_requires_variable_length_onion"))) TS_InvoiceFeatures_requires_variable_length_onion(uint32_t this_arg) {
36809         LDKInvoiceFeatures this_arg_conv;
36810         this_arg_conv.inner = (void*)(this_arg & (~1));
36811         this_arg_conv.is_owned = false;
36812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36813         jboolean ret_conv = InvoiceFeatures_requires_variable_length_onion(&this_arg_conv);
36814         return ret_conv;
36815 }
36816
36817 void  __attribute__((export_name("TS_InitFeatures_set_static_remote_key_optional"))) TS_InitFeatures_set_static_remote_key_optional(uint32_t this_arg) {
36818         LDKInitFeatures this_arg_conv;
36819         this_arg_conv.inner = (void*)(this_arg & (~1));
36820         this_arg_conv.is_owned = false;
36821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36822         InitFeatures_set_static_remote_key_optional(&this_arg_conv);
36823 }
36824
36825 void  __attribute__((export_name("TS_InitFeatures_set_static_remote_key_required"))) TS_InitFeatures_set_static_remote_key_required(uint32_t this_arg) {
36826         LDKInitFeatures this_arg_conv;
36827         this_arg_conv.inner = (void*)(this_arg & (~1));
36828         this_arg_conv.is_owned = false;
36829         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36830         InitFeatures_set_static_remote_key_required(&this_arg_conv);
36831 }
36832
36833 jboolean  __attribute__((export_name("TS_InitFeatures_supports_static_remote_key"))) TS_InitFeatures_supports_static_remote_key(uint32_t this_arg) {
36834         LDKInitFeatures this_arg_conv;
36835         this_arg_conv.inner = (void*)(this_arg & (~1));
36836         this_arg_conv.is_owned = false;
36837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36838         jboolean ret_conv = InitFeatures_supports_static_remote_key(&this_arg_conv);
36839         return ret_conv;
36840 }
36841
36842 void  __attribute__((export_name("TS_NodeFeatures_set_static_remote_key_optional"))) TS_NodeFeatures_set_static_remote_key_optional(uint32_t this_arg) {
36843         LDKNodeFeatures this_arg_conv;
36844         this_arg_conv.inner = (void*)(this_arg & (~1));
36845         this_arg_conv.is_owned = false;
36846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36847         NodeFeatures_set_static_remote_key_optional(&this_arg_conv);
36848 }
36849
36850 void  __attribute__((export_name("TS_NodeFeatures_set_static_remote_key_required"))) TS_NodeFeatures_set_static_remote_key_required(uint32_t this_arg) {
36851         LDKNodeFeatures this_arg_conv;
36852         this_arg_conv.inner = (void*)(this_arg & (~1));
36853         this_arg_conv.is_owned = false;
36854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36855         NodeFeatures_set_static_remote_key_required(&this_arg_conv);
36856 }
36857
36858 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_static_remote_key"))) TS_NodeFeatures_supports_static_remote_key(uint32_t this_arg) {
36859         LDKNodeFeatures this_arg_conv;
36860         this_arg_conv.inner = (void*)(this_arg & (~1));
36861         this_arg_conv.is_owned = false;
36862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36863         jboolean ret_conv = NodeFeatures_supports_static_remote_key(&this_arg_conv);
36864         return ret_conv;
36865 }
36866
36867 void  __attribute__((export_name("TS_ChannelTypeFeatures_set_static_remote_key_optional"))) TS_ChannelTypeFeatures_set_static_remote_key_optional(uint32_t this_arg) {
36868         LDKChannelTypeFeatures this_arg_conv;
36869         this_arg_conv.inner = (void*)(this_arg & (~1));
36870         this_arg_conv.is_owned = false;
36871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36872         ChannelTypeFeatures_set_static_remote_key_optional(&this_arg_conv);
36873 }
36874
36875 void  __attribute__((export_name("TS_ChannelTypeFeatures_set_static_remote_key_required"))) TS_ChannelTypeFeatures_set_static_remote_key_required(uint32_t this_arg) {
36876         LDKChannelTypeFeatures this_arg_conv;
36877         this_arg_conv.inner = (void*)(this_arg & (~1));
36878         this_arg_conv.is_owned = false;
36879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36880         ChannelTypeFeatures_set_static_remote_key_required(&this_arg_conv);
36881 }
36882
36883 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_supports_static_remote_key"))) TS_ChannelTypeFeatures_supports_static_remote_key(uint32_t this_arg) {
36884         LDKChannelTypeFeatures this_arg_conv;
36885         this_arg_conv.inner = (void*)(this_arg & (~1));
36886         this_arg_conv.is_owned = false;
36887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36888         jboolean ret_conv = ChannelTypeFeatures_supports_static_remote_key(&this_arg_conv);
36889         return ret_conv;
36890 }
36891
36892 jboolean  __attribute__((export_name("TS_InitFeatures_requires_static_remote_key"))) TS_InitFeatures_requires_static_remote_key(uint32_t this_arg) {
36893         LDKInitFeatures this_arg_conv;
36894         this_arg_conv.inner = (void*)(this_arg & (~1));
36895         this_arg_conv.is_owned = false;
36896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36897         jboolean ret_conv = InitFeatures_requires_static_remote_key(&this_arg_conv);
36898         return ret_conv;
36899 }
36900
36901 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_static_remote_key"))) TS_NodeFeatures_requires_static_remote_key(uint32_t this_arg) {
36902         LDKNodeFeatures this_arg_conv;
36903         this_arg_conv.inner = (void*)(this_arg & (~1));
36904         this_arg_conv.is_owned = false;
36905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36906         jboolean ret_conv = NodeFeatures_requires_static_remote_key(&this_arg_conv);
36907         return ret_conv;
36908 }
36909
36910 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_requires_static_remote_key"))) TS_ChannelTypeFeatures_requires_static_remote_key(uint32_t this_arg) {
36911         LDKChannelTypeFeatures this_arg_conv;
36912         this_arg_conv.inner = (void*)(this_arg & (~1));
36913         this_arg_conv.is_owned = false;
36914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36915         jboolean ret_conv = ChannelTypeFeatures_requires_static_remote_key(&this_arg_conv);
36916         return ret_conv;
36917 }
36918
36919 void  __attribute__((export_name("TS_InitFeatures_set_payment_secret_optional"))) TS_InitFeatures_set_payment_secret_optional(uint32_t this_arg) {
36920         LDKInitFeatures this_arg_conv;
36921         this_arg_conv.inner = (void*)(this_arg & (~1));
36922         this_arg_conv.is_owned = false;
36923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36924         InitFeatures_set_payment_secret_optional(&this_arg_conv);
36925 }
36926
36927 void  __attribute__((export_name("TS_InitFeatures_set_payment_secret_required"))) TS_InitFeatures_set_payment_secret_required(uint32_t this_arg) {
36928         LDKInitFeatures this_arg_conv;
36929         this_arg_conv.inner = (void*)(this_arg & (~1));
36930         this_arg_conv.is_owned = false;
36931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36932         InitFeatures_set_payment_secret_required(&this_arg_conv);
36933 }
36934
36935 jboolean  __attribute__((export_name("TS_InitFeatures_supports_payment_secret"))) TS_InitFeatures_supports_payment_secret(uint32_t this_arg) {
36936         LDKInitFeatures this_arg_conv;
36937         this_arg_conv.inner = (void*)(this_arg & (~1));
36938         this_arg_conv.is_owned = false;
36939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36940         jboolean ret_conv = InitFeatures_supports_payment_secret(&this_arg_conv);
36941         return ret_conv;
36942 }
36943
36944 void  __attribute__((export_name("TS_NodeFeatures_set_payment_secret_optional"))) TS_NodeFeatures_set_payment_secret_optional(uint32_t this_arg) {
36945         LDKNodeFeatures this_arg_conv;
36946         this_arg_conv.inner = (void*)(this_arg & (~1));
36947         this_arg_conv.is_owned = false;
36948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36949         NodeFeatures_set_payment_secret_optional(&this_arg_conv);
36950 }
36951
36952 void  __attribute__((export_name("TS_NodeFeatures_set_payment_secret_required"))) TS_NodeFeatures_set_payment_secret_required(uint32_t this_arg) {
36953         LDKNodeFeatures this_arg_conv;
36954         this_arg_conv.inner = (void*)(this_arg & (~1));
36955         this_arg_conv.is_owned = false;
36956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36957         NodeFeatures_set_payment_secret_required(&this_arg_conv);
36958 }
36959
36960 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_payment_secret"))) TS_NodeFeatures_supports_payment_secret(uint32_t this_arg) {
36961         LDKNodeFeatures this_arg_conv;
36962         this_arg_conv.inner = (void*)(this_arg & (~1));
36963         this_arg_conv.is_owned = false;
36964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36965         jboolean ret_conv = NodeFeatures_supports_payment_secret(&this_arg_conv);
36966         return ret_conv;
36967 }
36968
36969 void  __attribute__((export_name("TS_InvoiceFeatures_set_payment_secret_optional"))) TS_InvoiceFeatures_set_payment_secret_optional(uint32_t this_arg) {
36970         LDKInvoiceFeatures 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         InvoiceFeatures_set_payment_secret_optional(&this_arg_conv);
36975 }
36976
36977 void  __attribute__((export_name("TS_InvoiceFeatures_set_payment_secret_required"))) TS_InvoiceFeatures_set_payment_secret_required(uint32_t this_arg) {
36978         LDKInvoiceFeatures this_arg_conv;
36979         this_arg_conv.inner = (void*)(this_arg & (~1));
36980         this_arg_conv.is_owned = false;
36981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36982         InvoiceFeatures_set_payment_secret_required(&this_arg_conv);
36983 }
36984
36985 jboolean  __attribute__((export_name("TS_InvoiceFeatures_supports_payment_secret"))) TS_InvoiceFeatures_supports_payment_secret(uint32_t this_arg) {
36986         LDKInvoiceFeatures this_arg_conv;
36987         this_arg_conv.inner = (void*)(this_arg & (~1));
36988         this_arg_conv.is_owned = false;
36989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36990         jboolean ret_conv = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
36991         return ret_conv;
36992 }
36993
36994 jboolean  __attribute__((export_name("TS_InitFeatures_requires_payment_secret"))) TS_InitFeatures_requires_payment_secret(uint32_t this_arg) {
36995         LDKInitFeatures this_arg_conv;
36996         this_arg_conv.inner = (void*)(this_arg & (~1));
36997         this_arg_conv.is_owned = false;
36998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36999         jboolean ret_conv = InitFeatures_requires_payment_secret(&this_arg_conv);
37000         return ret_conv;
37001 }
37002
37003 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_payment_secret"))) TS_NodeFeatures_requires_payment_secret(uint32_t this_arg) {
37004         LDKNodeFeatures this_arg_conv;
37005         this_arg_conv.inner = (void*)(this_arg & (~1));
37006         this_arg_conv.is_owned = false;
37007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37008         jboolean ret_conv = NodeFeatures_requires_payment_secret(&this_arg_conv);
37009         return ret_conv;
37010 }
37011
37012 jboolean  __attribute__((export_name("TS_InvoiceFeatures_requires_payment_secret"))) TS_InvoiceFeatures_requires_payment_secret(uint32_t this_arg) {
37013         LDKInvoiceFeatures this_arg_conv;
37014         this_arg_conv.inner = (void*)(this_arg & (~1));
37015         this_arg_conv.is_owned = false;
37016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37017         jboolean ret_conv = InvoiceFeatures_requires_payment_secret(&this_arg_conv);
37018         return ret_conv;
37019 }
37020
37021 void  __attribute__((export_name("TS_InitFeatures_set_basic_mpp_optional"))) TS_InitFeatures_set_basic_mpp_optional(uint32_t this_arg) {
37022         LDKInitFeatures this_arg_conv;
37023         this_arg_conv.inner = (void*)(this_arg & (~1));
37024         this_arg_conv.is_owned = false;
37025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37026         InitFeatures_set_basic_mpp_optional(&this_arg_conv);
37027 }
37028
37029 void  __attribute__((export_name("TS_InitFeatures_set_basic_mpp_required"))) TS_InitFeatures_set_basic_mpp_required(uint32_t this_arg) {
37030         LDKInitFeatures this_arg_conv;
37031         this_arg_conv.inner = (void*)(this_arg & (~1));
37032         this_arg_conv.is_owned = false;
37033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37034         InitFeatures_set_basic_mpp_required(&this_arg_conv);
37035 }
37036
37037 jboolean  __attribute__((export_name("TS_InitFeatures_supports_basic_mpp"))) TS_InitFeatures_supports_basic_mpp(uint32_t this_arg) {
37038         LDKInitFeatures this_arg_conv;
37039         this_arg_conv.inner = (void*)(this_arg & (~1));
37040         this_arg_conv.is_owned = false;
37041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37042         jboolean ret_conv = InitFeatures_supports_basic_mpp(&this_arg_conv);
37043         return ret_conv;
37044 }
37045
37046 void  __attribute__((export_name("TS_NodeFeatures_set_basic_mpp_optional"))) TS_NodeFeatures_set_basic_mpp_optional(uint32_t this_arg) {
37047         LDKNodeFeatures this_arg_conv;
37048         this_arg_conv.inner = (void*)(this_arg & (~1));
37049         this_arg_conv.is_owned = false;
37050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37051         NodeFeatures_set_basic_mpp_optional(&this_arg_conv);
37052 }
37053
37054 void  __attribute__((export_name("TS_NodeFeatures_set_basic_mpp_required"))) TS_NodeFeatures_set_basic_mpp_required(uint32_t this_arg) {
37055         LDKNodeFeatures this_arg_conv;
37056         this_arg_conv.inner = (void*)(this_arg & (~1));
37057         this_arg_conv.is_owned = false;
37058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37059         NodeFeatures_set_basic_mpp_required(&this_arg_conv);
37060 }
37061
37062 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_basic_mpp"))) TS_NodeFeatures_supports_basic_mpp(uint32_t this_arg) {
37063         LDKNodeFeatures this_arg_conv;
37064         this_arg_conv.inner = (void*)(this_arg & (~1));
37065         this_arg_conv.is_owned = false;
37066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37067         jboolean ret_conv = NodeFeatures_supports_basic_mpp(&this_arg_conv);
37068         return ret_conv;
37069 }
37070
37071 void  __attribute__((export_name("TS_InvoiceFeatures_set_basic_mpp_optional"))) TS_InvoiceFeatures_set_basic_mpp_optional(uint32_t this_arg) {
37072         LDKInvoiceFeatures this_arg_conv;
37073         this_arg_conv.inner = (void*)(this_arg & (~1));
37074         this_arg_conv.is_owned = false;
37075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37076         InvoiceFeatures_set_basic_mpp_optional(&this_arg_conv);
37077 }
37078
37079 void  __attribute__((export_name("TS_InvoiceFeatures_set_basic_mpp_required"))) TS_InvoiceFeatures_set_basic_mpp_required(uint32_t this_arg) {
37080         LDKInvoiceFeatures this_arg_conv;
37081         this_arg_conv.inner = (void*)(this_arg & (~1));
37082         this_arg_conv.is_owned = false;
37083         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37084         InvoiceFeatures_set_basic_mpp_required(&this_arg_conv);
37085 }
37086
37087 jboolean  __attribute__((export_name("TS_InvoiceFeatures_supports_basic_mpp"))) TS_InvoiceFeatures_supports_basic_mpp(uint32_t this_arg) {
37088         LDKInvoiceFeatures this_arg_conv;
37089         this_arg_conv.inner = (void*)(this_arg & (~1));
37090         this_arg_conv.is_owned = false;
37091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37092         jboolean ret_conv = InvoiceFeatures_supports_basic_mpp(&this_arg_conv);
37093         return ret_conv;
37094 }
37095
37096 jboolean  __attribute__((export_name("TS_InitFeatures_requires_basic_mpp"))) TS_InitFeatures_requires_basic_mpp(uint32_t this_arg) {
37097         LDKInitFeatures this_arg_conv;
37098         this_arg_conv.inner = (void*)(this_arg & (~1));
37099         this_arg_conv.is_owned = false;
37100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37101         jboolean ret_conv = InitFeatures_requires_basic_mpp(&this_arg_conv);
37102         return ret_conv;
37103 }
37104
37105 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_basic_mpp"))) TS_NodeFeatures_requires_basic_mpp(uint32_t this_arg) {
37106         LDKNodeFeatures this_arg_conv;
37107         this_arg_conv.inner = (void*)(this_arg & (~1));
37108         this_arg_conv.is_owned = false;
37109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37110         jboolean ret_conv = NodeFeatures_requires_basic_mpp(&this_arg_conv);
37111         return ret_conv;
37112 }
37113
37114 jboolean  __attribute__((export_name("TS_InvoiceFeatures_requires_basic_mpp"))) TS_InvoiceFeatures_requires_basic_mpp(uint32_t this_arg) {
37115         LDKInvoiceFeatures this_arg_conv;
37116         this_arg_conv.inner = (void*)(this_arg & (~1));
37117         this_arg_conv.is_owned = false;
37118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37119         jboolean ret_conv = InvoiceFeatures_requires_basic_mpp(&this_arg_conv);
37120         return ret_conv;
37121 }
37122
37123 void  __attribute__((export_name("TS_InitFeatures_set_wumbo_optional"))) TS_InitFeatures_set_wumbo_optional(uint32_t this_arg) {
37124         LDKInitFeatures this_arg_conv;
37125         this_arg_conv.inner = (void*)(this_arg & (~1));
37126         this_arg_conv.is_owned = false;
37127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37128         InitFeatures_set_wumbo_optional(&this_arg_conv);
37129 }
37130
37131 void  __attribute__((export_name("TS_InitFeatures_set_wumbo_required"))) TS_InitFeatures_set_wumbo_required(uint32_t this_arg) {
37132         LDKInitFeatures this_arg_conv;
37133         this_arg_conv.inner = (void*)(this_arg & (~1));
37134         this_arg_conv.is_owned = false;
37135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37136         InitFeatures_set_wumbo_required(&this_arg_conv);
37137 }
37138
37139 jboolean  __attribute__((export_name("TS_InitFeatures_supports_wumbo"))) TS_InitFeatures_supports_wumbo(uint32_t this_arg) {
37140         LDKInitFeatures this_arg_conv;
37141         this_arg_conv.inner = (void*)(this_arg & (~1));
37142         this_arg_conv.is_owned = false;
37143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37144         jboolean ret_conv = InitFeatures_supports_wumbo(&this_arg_conv);
37145         return ret_conv;
37146 }
37147
37148 void  __attribute__((export_name("TS_NodeFeatures_set_wumbo_optional"))) TS_NodeFeatures_set_wumbo_optional(uint32_t this_arg) {
37149         LDKNodeFeatures this_arg_conv;
37150         this_arg_conv.inner = (void*)(this_arg & (~1));
37151         this_arg_conv.is_owned = false;
37152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37153         NodeFeatures_set_wumbo_optional(&this_arg_conv);
37154 }
37155
37156 void  __attribute__((export_name("TS_NodeFeatures_set_wumbo_required"))) TS_NodeFeatures_set_wumbo_required(uint32_t this_arg) {
37157         LDKNodeFeatures this_arg_conv;
37158         this_arg_conv.inner = (void*)(this_arg & (~1));
37159         this_arg_conv.is_owned = false;
37160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37161         NodeFeatures_set_wumbo_required(&this_arg_conv);
37162 }
37163
37164 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_wumbo"))) TS_NodeFeatures_supports_wumbo(uint32_t this_arg) {
37165         LDKNodeFeatures this_arg_conv;
37166         this_arg_conv.inner = (void*)(this_arg & (~1));
37167         this_arg_conv.is_owned = false;
37168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37169         jboolean ret_conv = NodeFeatures_supports_wumbo(&this_arg_conv);
37170         return ret_conv;
37171 }
37172
37173 jboolean  __attribute__((export_name("TS_InitFeatures_requires_wumbo"))) TS_InitFeatures_requires_wumbo(uint32_t this_arg) {
37174         LDKInitFeatures this_arg_conv;
37175         this_arg_conv.inner = (void*)(this_arg & (~1));
37176         this_arg_conv.is_owned = false;
37177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37178         jboolean ret_conv = InitFeatures_requires_wumbo(&this_arg_conv);
37179         return ret_conv;
37180 }
37181
37182 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_wumbo"))) TS_NodeFeatures_requires_wumbo(uint32_t this_arg) {
37183         LDKNodeFeatures this_arg_conv;
37184         this_arg_conv.inner = (void*)(this_arg & (~1));
37185         this_arg_conv.is_owned = false;
37186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37187         jboolean ret_conv = NodeFeatures_requires_wumbo(&this_arg_conv);
37188         return ret_conv;
37189 }
37190
37191 void  __attribute__((export_name("TS_InitFeatures_set_shutdown_any_segwit_optional"))) TS_InitFeatures_set_shutdown_any_segwit_optional(uint32_t this_arg) {
37192         LDKInitFeatures this_arg_conv;
37193         this_arg_conv.inner = (void*)(this_arg & (~1));
37194         this_arg_conv.is_owned = false;
37195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37196         InitFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
37197 }
37198
37199 void  __attribute__((export_name("TS_InitFeatures_set_shutdown_any_segwit_required"))) TS_InitFeatures_set_shutdown_any_segwit_required(uint32_t this_arg) {
37200         LDKInitFeatures this_arg_conv;
37201         this_arg_conv.inner = (void*)(this_arg & (~1));
37202         this_arg_conv.is_owned = false;
37203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37204         InitFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
37205 }
37206
37207 jboolean  __attribute__((export_name("TS_InitFeatures_supports_shutdown_anysegwit"))) TS_InitFeatures_supports_shutdown_anysegwit(uint32_t this_arg) {
37208         LDKInitFeatures this_arg_conv;
37209         this_arg_conv.inner = (void*)(this_arg & (~1));
37210         this_arg_conv.is_owned = false;
37211         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37212         jboolean ret_conv = InitFeatures_supports_shutdown_anysegwit(&this_arg_conv);
37213         return ret_conv;
37214 }
37215
37216 void  __attribute__((export_name("TS_NodeFeatures_set_shutdown_any_segwit_optional"))) TS_NodeFeatures_set_shutdown_any_segwit_optional(uint32_t this_arg) {
37217         LDKNodeFeatures this_arg_conv;
37218         this_arg_conv.inner = (void*)(this_arg & (~1));
37219         this_arg_conv.is_owned = false;
37220         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37221         NodeFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
37222 }
37223
37224 void  __attribute__((export_name("TS_NodeFeatures_set_shutdown_any_segwit_required"))) TS_NodeFeatures_set_shutdown_any_segwit_required(uint32_t this_arg) {
37225         LDKNodeFeatures this_arg_conv;
37226         this_arg_conv.inner = (void*)(this_arg & (~1));
37227         this_arg_conv.is_owned = false;
37228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37229         NodeFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
37230 }
37231
37232 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_shutdown_anysegwit"))) TS_NodeFeatures_supports_shutdown_anysegwit(uint32_t this_arg) {
37233         LDKNodeFeatures this_arg_conv;
37234         this_arg_conv.inner = (void*)(this_arg & (~1));
37235         this_arg_conv.is_owned = false;
37236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37237         jboolean ret_conv = NodeFeatures_supports_shutdown_anysegwit(&this_arg_conv);
37238         return ret_conv;
37239 }
37240
37241 jboolean  __attribute__((export_name("TS_InitFeatures_requires_shutdown_anysegwit"))) TS_InitFeatures_requires_shutdown_anysegwit(uint32_t this_arg) {
37242         LDKInitFeatures this_arg_conv;
37243         this_arg_conv.inner = (void*)(this_arg & (~1));
37244         this_arg_conv.is_owned = false;
37245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37246         jboolean ret_conv = InitFeatures_requires_shutdown_anysegwit(&this_arg_conv);
37247         return ret_conv;
37248 }
37249
37250 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_shutdown_anysegwit"))) TS_NodeFeatures_requires_shutdown_anysegwit(uint32_t this_arg) {
37251         LDKNodeFeatures this_arg_conv;
37252         this_arg_conv.inner = (void*)(this_arg & (~1));
37253         this_arg_conv.is_owned = false;
37254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37255         jboolean ret_conv = NodeFeatures_requires_shutdown_anysegwit(&this_arg_conv);
37256         return ret_conv;
37257 }
37258
37259 void  __attribute__((export_name("TS_InitFeatures_set_channel_type_optional"))) TS_InitFeatures_set_channel_type_optional(uint32_t this_arg) {
37260         LDKInitFeatures this_arg_conv;
37261         this_arg_conv.inner = (void*)(this_arg & (~1));
37262         this_arg_conv.is_owned = false;
37263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37264         InitFeatures_set_channel_type_optional(&this_arg_conv);
37265 }
37266
37267 void  __attribute__((export_name("TS_InitFeatures_set_channel_type_required"))) TS_InitFeatures_set_channel_type_required(uint32_t this_arg) {
37268         LDKInitFeatures this_arg_conv;
37269         this_arg_conv.inner = (void*)(this_arg & (~1));
37270         this_arg_conv.is_owned = false;
37271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37272         InitFeatures_set_channel_type_required(&this_arg_conv);
37273 }
37274
37275 jboolean  __attribute__((export_name("TS_InitFeatures_supports_channel_type"))) TS_InitFeatures_supports_channel_type(uint32_t this_arg) {
37276         LDKInitFeatures this_arg_conv;
37277         this_arg_conv.inner = (void*)(this_arg & (~1));
37278         this_arg_conv.is_owned = false;
37279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37280         jboolean ret_conv = InitFeatures_supports_channel_type(&this_arg_conv);
37281         return ret_conv;
37282 }
37283
37284 void  __attribute__((export_name("TS_NodeFeatures_set_channel_type_optional"))) TS_NodeFeatures_set_channel_type_optional(uint32_t this_arg) {
37285         LDKNodeFeatures this_arg_conv;
37286         this_arg_conv.inner = (void*)(this_arg & (~1));
37287         this_arg_conv.is_owned = false;
37288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37289         NodeFeatures_set_channel_type_optional(&this_arg_conv);
37290 }
37291
37292 void  __attribute__((export_name("TS_NodeFeatures_set_channel_type_required"))) TS_NodeFeatures_set_channel_type_required(uint32_t this_arg) {
37293         LDKNodeFeatures this_arg_conv;
37294         this_arg_conv.inner = (void*)(this_arg & (~1));
37295         this_arg_conv.is_owned = false;
37296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37297         NodeFeatures_set_channel_type_required(&this_arg_conv);
37298 }
37299
37300 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_channel_type"))) TS_NodeFeatures_supports_channel_type(uint32_t this_arg) {
37301         LDKNodeFeatures this_arg_conv;
37302         this_arg_conv.inner = (void*)(this_arg & (~1));
37303         this_arg_conv.is_owned = false;
37304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37305         jboolean ret_conv = NodeFeatures_supports_channel_type(&this_arg_conv);
37306         return ret_conv;
37307 }
37308
37309 jboolean  __attribute__((export_name("TS_InitFeatures_requires_channel_type"))) TS_InitFeatures_requires_channel_type(uint32_t this_arg) {
37310         LDKInitFeatures this_arg_conv;
37311         this_arg_conv.inner = (void*)(this_arg & (~1));
37312         this_arg_conv.is_owned = false;
37313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37314         jboolean ret_conv = InitFeatures_requires_channel_type(&this_arg_conv);
37315         return ret_conv;
37316 }
37317
37318 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_channel_type"))) TS_NodeFeatures_requires_channel_type(uint32_t this_arg) {
37319         LDKNodeFeatures this_arg_conv;
37320         this_arg_conv.inner = (void*)(this_arg & (~1));
37321         this_arg_conv.is_owned = false;
37322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37323         jboolean ret_conv = NodeFeatures_requires_channel_type(&this_arg_conv);
37324         return ret_conv;
37325 }
37326
37327 void  __attribute__((export_name("TS_InitFeatures_set_scid_privacy_optional"))) TS_InitFeatures_set_scid_privacy_optional(uint32_t this_arg) {
37328         LDKInitFeatures this_arg_conv;
37329         this_arg_conv.inner = (void*)(this_arg & (~1));
37330         this_arg_conv.is_owned = false;
37331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37332         InitFeatures_set_scid_privacy_optional(&this_arg_conv);
37333 }
37334
37335 void  __attribute__((export_name("TS_InitFeatures_set_scid_privacy_required"))) TS_InitFeatures_set_scid_privacy_required(uint32_t this_arg) {
37336         LDKInitFeatures this_arg_conv;
37337         this_arg_conv.inner = (void*)(this_arg & (~1));
37338         this_arg_conv.is_owned = false;
37339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37340         InitFeatures_set_scid_privacy_required(&this_arg_conv);
37341 }
37342
37343 jboolean  __attribute__((export_name("TS_InitFeatures_supports_scid_privacy"))) TS_InitFeatures_supports_scid_privacy(uint32_t this_arg) {
37344         LDKInitFeatures this_arg_conv;
37345         this_arg_conv.inner = (void*)(this_arg & (~1));
37346         this_arg_conv.is_owned = false;
37347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37348         jboolean ret_conv = InitFeatures_supports_scid_privacy(&this_arg_conv);
37349         return ret_conv;
37350 }
37351
37352 void  __attribute__((export_name("TS_NodeFeatures_set_scid_privacy_optional"))) TS_NodeFeatures_set_scid_privacy_optional(uint32_t this_arg) {
37353         LDKNodeFeatures this_arg_conv;
37354         this_arg_conv.inner = (void*)(this_arg & (~1));
37355         this_arg_conv.is_owned = false;
37356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37357         NodeFeatures_set_scid_privacy_optional(&this_arg_conv);
37358 }
37359
37360 void  __attribute__((export_name("TS_NodeFeatures_set_scid_privacy_required"))) TS_NodeFeatures_set_scid_privacy_required(uint32_t this_arg) {
37361         LDKNodeFeatures this_arg_conv;
37362         this_arg_conv.inner = (void*)(this_arg & (~1));
37363         this_arg_conv.is_owned = false;
37364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37365         NodeFeatures_set_scid_privacy_required(&this_arg_conv);
37366 }
37367
37368 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_scid_privacy"))) TS_NodeFeatures_supports_scid_privacy(uint32_t this_arg) {
37369         LDKNodeFeatures this_arg_conv;
37370         this_arg_conv.inner = (void*)(this_arg & (~1));
37371         this_arg_conv.is_owned = false;
37372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37373         jboolean ret_conv = NodeFeatures_supports_scid_privacy(&this_arg_conv);
37374         return ret_conv;
37375 }
37376
37377 void  __attribute__((export_name("TS_ChannelTypeFeatures_set_scid_privacy_optional"))) TS_ChannelTypeFeatures_set_scid_privacy_optional(uint32_t this_arg) {
37378         LDKChannelTypeFeatures this_arg_conv;
37379         this_arg_conv.inner = (void*)(this_arg & (~1));
37380         this_arg_conv.is_owned = false;
37381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37382         ChannelTypeFeatures_set_scid_privacy_optional(&this_arg_conv);
37383 }
37384
37385 void  __attribute__((export_name("TS_ChannelTypeFeatures_set_scid_privacy_required"))) TS_ChannelTypeFeatures_set_scid_privacy_required(uint32_t this_arg) {
37386         LDKChannelTypeFeatures this_arg_conv;
37387         this_arg_conv.inner = (void*)(this_arg & (~1));
37388         this_arg_conv.is_owned = false;
37389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37390         ChannelTypeFeatures_set_scid_privacy_required(&this_arg_conv);
37391 }
37392
37393 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_supports_scid_privacy"))) TS_ChannelTypeFeatures_supports_scid_privacy(uint32_t this_arg) {
37394         LDKChannelTypeFeatures this_arg_conv;
37395         this_arg_conv.inner = (void*)(this_arg & (~1));
37396         this_arg_conv.is_owned = false;
37397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37398         jboolean ret_conv = ChannelTypeFeatures_supports_scid_privacy(&this_arg_conv);
37399         return ret_conv;
37400 }
37401
37402 jboolean  __attribute__((export_name("TS_InitFeatures_requires_scid_privacy"))) TS_InitFeatures_requires_scid_privacy(uint32_t this_arg) {
37403         LDKInitFeatures this_arg_conv;
37404         this_arg_conv.inner = (void*)(this_arg & (~1));
37405         this_arg_conv.is_owned = false;
37406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37407         jboolean ret_conv = InitFeatures_requires_scid_privacy(&this_arg_conv);
37408         return ret_conv;
37409 }
37410
37411 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_scid_privacy"))) TS_NodeFeatures_requires_scid_privacy(uint32_t this_arg) {
37412         LDKNodeFeatures this_arg_conv;
37413         this_arg_conv.inner = (void*)(this_arg & (~1));
37414         this_arg_conv.is_owned = false;
37415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37416         jboolean ret_conv = NodeFeatures_requires_scid_privacy(&this_arg_conv);
37417         return ret_conv;
37418 }
37419
37420 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_requires_scid_privacy"))) TS_ChannelTypeFeatures_requires_scid_privacy(uint32_t this_arg) {
37421         LDKChannelTypeFeatures this_arg_conv;
37422         this_arg_conv.inner = (void*)(this_arg & (~1));
37423         this_arg_conv.is_owned = false;
37424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37425         jboolean ret_conv = ChannelTypeFeatures_requires_scid_privacy(&this_arg_conv);
37426         return ret_conv;
37427 }
37428
37429 void  __attribute__((export_name("TS_InitFeatures_set_zero_conf_optional"))) TS_InitFeatures_set_zero_conf_optional(uint32_t this_arg) {
37430         LDKInitFeatures this_arg_conv;
37431         this_arg_conv.inner = (void*)(this_arg & (~1));
37432         this_arg_conv.is_owned = false;
37433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37434         InitFeatures_set_zero_conf_optional(&this_arg_conv);
37435 }
37436
37437 void  __attribute__((export_name("TS_InitFeatures_set_zero_conf_required"))) TS_InitFeatures_set_zero_conf_required(uint32_t this_arg) {
37438         LDKInitFeatures this_arg_conv;
37439         this_arg_conv.inner = (void*)(this_arg & (~1));
37440         this_arg_conv.is_owned = false;
37441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37442         InitFeatures_set_zero_conf_required(&this_arg_conv);
37443 }
37444
37445 jboolean  __attribute__((export_name("TS_InitFeatures_supports_zero_conf"))) TS_InitFeatures_supports_zero_conf(uint32_t this_arg) {
37446         LDKInitFeatures this_arg_conv;
37447         this_arg_conv.inner = (void*)(this_arg & (~1));
37448         this_arg_conv.is_owned = false;
37449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37450         jboolean ret_conv = InitFeatures_supports_zero_conf(&this_arg_conv);
37451         return ret_conv;
37452 }
37453
37454 void  __attribute__((export_name("TS_NodeFeatures_set_zero_conf_optional"))) TS_NodeFeatures_set_zero_conf_optional(uint32_t this_arg) {
37455         LDKNodeFeatures this_arg_conv;
37456         this_arg_conv.inner = (void*)(this_arg & (~1));
37457         this_arg_conv.is_owned = false;
37458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37459         NodeFeatures_set_zero_conf_optional(&this_arg_conv);
37460 }
37461
37462 void  __attribute__((export_name("TS_NodeFeatures_set_zero_conf_required"))) TS_NodeFeatures_set_zero_conf_required(uint32_t this_arg) {
37463         LDKNodeFeatures this_arg_conv;
37464         this_arg_conv.inner = (void*)(this_arg & (~1));
37465         this_arg_conv.is_owned = false;
37466         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37467         NodeFeatures_set_zero_conf_required(&this_arg_conv);
37468 }
37469
37470 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_zero_conf"))) TS_NodeFeatures_supports_zero_conf(uint32_t this_arg) {
37471         LDKNodeFeatures this_arg_conv;
37472         this_arg_conv.inner = (void*)(this_arg & (~1));
37473         this_arg_conv.is_owned = false;
37474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37475         jboolean ret_conv = NodeFeatures_supports_zero_conf(&this_arg_conv);
37476         return ret_conv;
37477 }
37478
37479 void  __attribute__((export_name("TS_ChannelTypeFeatures_set_zero_conf_optional"))) TS_ChannelTypeFeatures_set_zero_conf_optional(uint32_t this_arg) {
37480         LDKChannelTypeFeatures this_arg_conv;
37481         this_arg_conv.inner = (void*)(this_arg & (~1));
37482         this_arg_conv.is_owned = false;
37483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37484         ChannelTypeFeatures_set_zero_conf_optional(&this_arg_conv);
37485 }
37486
37487 void  __attribute__((export_name("TS_ChannelTypeFeatures_set_zero_conf_required"))) TS_ChannelTypeFeatures_set_zero_conf_required(uint32_t this_arg) {
37488         LDKChannelTypeFeatures this_arg_conv;
37489         this_arg_conv.inner = (void*)(this_arg & (~1));
37490         this_arg_conv.is_owned = false;
37491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37492         ChannelTypeFeatures_set_zero_conf_required(&this_arg_conv);
37493 }
37494
37495 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_supports_zero_conf"))) TS_ChannelTypeFeatures_supports_zero_conf(uint32_t this_arg) {
37496         LDKChannelTypeFeatures this_arg_conv;
37497         this_arg_conv.inner = (void*)(this_arg & (~1));
37498         this_arg_conv.is_owned = false;
37499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37500         jboolean ret_conv = ChannelTypeFeatures_supports_zero_conf(&this_arg_conv);
37501         return ret_conv;
37502 }
37503
37504 jboolean  __attribute__((export_name("TS_InitFeatures_requires_zero_conf"))) TS_InitFeatures_requires_zero_conf(uint32_t this_arg) {
37505         LDKInitFeatures this_arg_conv;
37506         this_arg_conv.inner = (void*)(this_arg & (~1));
37507         this_arg_conv.is_owned = false;
37508         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37509         jboolean ret_conv = InitFeatures_requires_zero_conf(&this_arg_conv);
37510         return ret_conv;
37511 }
37512
37513 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_zero_conf"))) TS_NodeFeatures_requires_zero_conf(uint32_t this_arg) {
37514         LDKNodeFeatures this_arg_conv;
37515         this_arg_conv.inner = (void*)(this_arg & (~1));
37516         this_arg_conv.is_owned = false;
37517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37518         jboolean ret_conv = NodeFeatures_requires_zero_conf(&this_arg_conv);
37519         return ret_conv;
37520 }
37521
37522 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_requires_zero_conf"))) TS_ChannelTypeFeatures_requires_zero_conf(uint32_t this_arg) {
37523         LDKChannelTypeFeatures this_arg_conv;
37524         this_arg_conv.inner = (void*)(this_arg & (~1));
37525         this_arg_conv.is_owned = false;
37526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37527         jboolean ret_conv = ChannelTypeFeatures_requires_zero_conf(&this_arg_conv);
37528         return ret_conv;
37529 }
37530
37531 void  __attribute__((export_name("TS_NodeFeatures_set_keysend_optional"))) TS_NodeFeatures_set_keysend_optional(uint32_t this_arg) {
37532         LDKNodeFeatures this_arg_conv;
37533         this_arg_conv.inner = (void*)(this_arg & (~1));
37534         this_arg_conv.is_owned = false;
37535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37536         NodeFeatures_set_keysend_optional(&this_arg_conv);
37537 }
37538
37539 void  __attribute__((export_name("TS_NodeFeatures_set_keysend_required"))) TS_NodeFeatures_set_keysend_required(uint32_t this_arg) {
37540         LDKNodeFeatures this_arg_conv;
37541         this_arg_conv.inner = (void*)(this_arg & (~1));
37542         this_arg_conv.is_owned = false;
37543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37544         NodeFeatures_set_keysend_required(&this_arg_conv);
37545 }
37546
37547 jboolean  __attribute__((export_name("TS_NodeFeatures_supports_keysend"))) TS_NodeFeatures_supports_keysend(uint32_t this_arg) {
37548         LDKNodeFeatures this_arg_conv;
37549         this_arg_conv.inner = (void*)(this_arg & (~1));
37550         this_arg_conv.is_owned = false;
37551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37552         jboolean ret_conv = NodeFeatures_supports_keysend(&this_arg_conv);
37553         return ret_conv;
37554 }
37555
37556 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_keysend"))) TS_NodeFeatures_requires_keysend(uint32_t this_arg) {
37557         LDKNodeFeatures this_arg_conv;
37558         this_arg_conv.inner = (void*)(this_arg & (~1));
37559         this_arg_conv.is_owned = false;
37560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37561         jboolean ret_conv = NodeFeatures_requires_keysend(&this_arg_conv);
37562         return ret_conv;
37563 }
37564
37565 void  __attribute__((export_name("TS_ShutdownScript_free"))) TS_ShutdownScript_free(uint32_t this_obj) {
37566         LDKShutdownScript this_obj_conv;
37567         this_obj_conv.inner = (void*)(this_obj & (~1));
37568         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37570         ShutdownScript_free(this_obj_conv);
37571 }
37572
37573 static inline uintptr_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
37574         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
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 uint32_t  __attribute__((export_name("TS_ShutdownScript_clone_ptr"))) TS_ShutdownScript_clone_ptr(uint32_t arg) {
37586         LDKShutdownScript arg_conv;
37587         arg_conv.inner = (void*)(arg & (~1));
37588         arg_conv.is_owned = false;
37589         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37590         uint32_t ret_conv = ShutdownScript_clone_ptr(&arg_conv);
37591         return ret_conv;
37592 }
37593
37594 uint32_t  __attribute__((export_name("TS_ShutdownScript_clone"))) TS_ShutdownScript_clone(uint32_t orig) {
37595         LDKShutdownScript orig_conv;
37596         orig_conv.inner = (void*)(orig & (~1));
37597         orig_conv.is_owned = false;
37598         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37599         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
37600         uint32_t ret_ref = 0;
37601         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37602         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37603         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37604         ret_ref = (uintptr_t)ret_var.inner;
37605         if (ret_var.is_owned) {
37606                 ret_ref |= 1;
37607         }
37608         return ret_ref;
37609 }
37610
37611 void  __attribute__((export_name("TS_InvalidShutdownScript_free"))) TS_InvalidShutdownScript_free(uint32_t this_obj) {
37612         LDKInvalidShutdownScript this_obj_conv;
37613         this_obj_conv.inner = (void*)(this_obj & (~1));
37614         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37616         InvalidShutdownScript_free(this_obj_conv);
37617 }
37618
37619 int8_tArray  __attribute__((export_name("TS_InvalidShutdownScript_get_script"))) TS_InvalidShutdownScript_get_script(uint32_t this_ptr) {
37620         LDKInvalidShutdownScript this_ptr_conv;
37621         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37622         this_ptr_conv.is_owned = false;
37623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37624         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
37625         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37626         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37627         return ret_arr;
37628 }
37629
37630 void  __attribute__((export_name("TS_InvalidShutdownScript_set_script"))) TS_InvalidShutdownScript_set_script(uint32_t this_ptr, int8_tArray val) {
37631         LDKInvalidShutdownScript this_ptr_conv;
37632         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37633         this_ptr_conv.is_owned = false;
37634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37635         LDKCVec_u8Z val_ref;
37636         val_ref.datalen = val->arr_len;
37637         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
37638         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
37639         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
37640 }
37641
37642 uint32_t  __attribute__((export_name("TS_InvalidShutdownScript_new"))) TS_InvalidShutdownScript_new(int8_tArray script_arg) {
37643         LDKCVec_u8Z script_arg_ref;
37644         script_arg_ref.datalen = script_arg->arr_len;
37645         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
37646         memcpy(script_arg_ref.data, script_arg->elems, script_arg_ref.datalen); FREE(script_arg);
37647         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
37648         uint32_t ret_ref = 0;
37649         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37650         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37651         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37652         ret_ref = (uintptr_t)ret_var.inner;
37653         if (ret_var.is_owned) {
37654                 ret_ref |= 1;
37655         }
37656         return ret_ref;
37657 }
37658
37659 static inline uintptr_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
37660         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
37661 uint32_t ret_ref = 0;
37662 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37663 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37664 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37665 ret_ref = (uintptr_t)ret_var.inner;
37666 if (ret_var.is_owned) {
37667         ret_ref |= 1;
37668 }
37669         return ret_ref;
37670 }
37671 uint32_t  __attribute__((export_name("TS_InvalidShutdownScript_clone_ptr"))) TS_InvalidShutdownScript_clone_ptr(uint32_t arg) {
37672         LDKInvalidShutdownScript arg_conv;
37673         arg_conv.inner = (void*)(arg & (~1));
37674         arg_conv.is_owned = false;
37675         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37676         uint32_t ret_conv = InvalidShutdownScript_clone_ptr(&arg_conv);
37677         return ret_conv;
37678 }
37679
37680 uint32_t  __attribute__((export_name("TS_InvalidShutdownScript_clone"))) TS_InvalidShutdownScript_clone(uint32_t orig) {
37681         LDKInvalidShutdownScript orig_conv;
37682         orig_conv.inner = (void*)(orig & (~1));
37683         orig_conv.is_owned = false;
37684         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37685         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
37686         uint32_t ret_ref = 0;
37687         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37688         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37689         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37690         ret_ref = (uintptr_t)ret_var.inner;
37691         if (ret_var.is_owned) {
37692                 ret_ref |= 1;
37693         }
37694         return ret_ref;
37695 }
37696
37697 int8_tArray  __attribute__((export_name("TS_ShutdownScript_write"))) TS_ShutdownScript_write(uint32_t obj) {
37698         LDKShutdownScript obj_conv;
37699         obj_conv.inner = (void*)(obj & (~1));
37700         obj_conv.is_owned = false;
37701         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37702         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
37703         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37704         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37705         CVec_u8Z_free(ret_var);
37706         return ret_arr;
37707 }
37708
37709 uint32_t  __attribute__((export_name("TS_ShutdownScript_read"))) TS_ShutdownScript_read(int8_tArray ser) {
37710         LDKu8slice ser_ref;
37711         ser_ref.datalen = ser->arr_len;
37712         ser_ref.data = ser->elems /* XXX ser leaks */;
37713         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
37714         *ret_conv = ShutdownScript_read(ser_ref);
37715         return (uint32_t)ret_conv;
37716 }
37717
37718 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_p2wpkh"))) TS_ShutdownScript_new_p2wpkh(int8_tArray pubkey_hash) {
37719         unsigned char pubkey_hash_arr[20];
37720         CHECK(pubkey_hash->arr_len == 20);
37721         memcpy(pubkey_hash_arr, pubkey_hash->elems, 20); FREE(pubkey_hash);
37722         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
37723         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
37724         uint32_t ret_ref = 0;
37725         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37726         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37727         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37728         ret_ref = (uintptr_t)ret_var.inner;
37729         if (ret_var.is_owned) {
37730                 ret_ref |= 1;
37731         }
37732         return ret_ref;
37733 }
37734
37735 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_p2wsh"))) TS_ShutdownScript_new_p2wsh(int8_tArray script_hash) {
37736         unsigned char script_hash_arr[32];
37737         CHECK(script_hash->arr_len == 32);
37738         memcpy(script_hash_arr, script_hash->elems, 32); FREE(script_hash);
37739         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
37740         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
37741         uint32_t ret_ref = 0;
37742         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37743         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37744         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37745         ret_ref = (uintptr_t)ret_var.inner;
37746         if (ret_var.is_owned) {
37747                 ret_ref |= 1;
37748         }
37749         return ret_ref;
37750 }
37751
37752 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_witness_program"))) TS_ShutdownScript_new_witness_program(int8_t version, int8_tArray program) {
37753         
37754         LDKu8slice program_ref;
37755         program_ref.datalen = program->arr_len;
37756         program_ref.data = program->elems /* XXX program leaks */;
37757         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
37758         *ret_conv = ShutdownScript_new_witness_program((LDKWitnessVersion){ ._0 = version }, program_ref);
37759         return (uint32_t)ret_conv;
37760 }
37761
37762 int8_tArray  __attribute__((export_name("TS_ShutdownScript_into_inner"))) TS_ShutdownScript_into_inner(uint32_t this_arg) {
37763         LDKShutdownScript this_arg_conv;
37764         this_arg_conv.inner = (void*)(this_arg & (~1));
37765         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
37766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37767         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
37768         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
37769         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37770         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37771         CVec_u8Z_free(ret_var);
37772         return ret_arr;
37773 }
37774
37775 int8_tArray  __attribute__((export_name("TS_ShutdownScript_as_legacy_pubkey"))) TS_ShutdownScript_as_legacy_pubkey(uint32_t this_arg) {
37776         LDKShutdownScript this_arg_conv;
37777         this_arg_conv.inner = (void*)(this_arg & (~1));
37778         this_arg_conv.is_owned = false;
37779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37780         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
37781         memcpy(ret_arr->elems, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form, 33);
37782         return ret_arr;
37783 }
37784
37785 jboolean  __attribute__((export_name("TS_ShutdownScript_is_compatible"))) TS_ShutdownScript_is_compatible(uint32_t this_arg, uint32_t features) {
37786         LDKShutdownScript this_arg_conv;
37787         this_arg_conv.inner = (void*)(this_arg & (~1));
37788         this_arg_conv.is_owned = false;
37789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37790         LDKInitFeatures features_conv;
37791         features_conv.inner = (void*)(features & (~1));
37792         features_conv.is_owned = false;
37793         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
37794         jboolean ret_conv = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
37795         return ret_conv;
37796 }
37797
37798 void  __attribute__((export_name("TS_CustomMessageReader_free"))) TS_CustomMessageReader_free(uint32_t this_ptr) {
37799         if ((this_ptr & 1) != 0) return;
37800         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
37801         CHECK_ACCESS(this_ptr_ptr);
37802         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
37803         FREE((void*)this_ptr);
37804         CustomMessageReader_free(this_ptr_conv);
37805 }
37806
37807 static inline uintptr_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
37808         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
37809         *ret_ret = Type_clone(arg);
37810         return (uint32_t)ret_ret;
37811 }
37812 uint32_t  __attribute__((export_name("TS_Type_clone_ptr"))) TS_Type_clone_ptr(uint32_t arg) {
37813         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
37814         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
37815         LDKType* arg_conv = (LDKType*)arg_ptr;
37816         uint32_t ret_conv = Type_clone_ptr(arg_conv);
37817         return ret_conv;
37818 }
37819
37820 uint32_t  __attribute__((export_name("TS_Type_clone"))) TS_Type_clone(uint32_t orig) {
37821         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
37822         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
37823         LDKType* orig_conv = (LDKType*)orig_ptr;
37824         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
37825         *ret_ret = Type_clone(orig_conv);
37826         return (uint32_t)ret_ret;
37827 }
37828
37829 void  __attribute__((export_name("TS_Type_free"))) TS_Type_free(uint32_t this_ptr) {
37830         if ((this_ptr & 1) != 0) return;
37831         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
37832         CHECK_ACCESS(this_ptr_ptr);
37833         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
37834         FREE((void*)this_ptr);
37835         Type_free(this_ptr_conv);
37836 }
37837
37838 void  __attribute__((export_name("TS_NodeId_free"))) TS_NodeId_free(uint32_t this_obj) {
37839         LDKNodeId this_obj_conv;
37840         this_obj_conv.inner = (void*)(this_obj & (~1));
37841         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37842         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37843         NodeId_free(this_obj_conv);
37844 }
37845
37846 static inline uintptr_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
37847         LDKNodeId ret_var = NodeId_clone(arg);
37848 uint32_t ret_ref = 0;
37849 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37850 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37851 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37852 ret_ref = (uintptr_t)ret_var.inner;
37853 if (ret_var.is_owned) {
37854         ret_ref |= 1;
37855 }
37856         return ret_ref;
37857 }
37858 uint32_t  __attribute__((export_name("TS_NodeId_clone_ptr"))) TS_NodeId_clone_ptr(uint32_t arg) {
37859         LDKNodeId arg_conv;
37860         arg_conv.inner = (void*)(arg & (~1));
37861         arg_conv.is_owned = false;
37862         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37863         uint32_t ret_conv = NodeId_clone_ptr(&arg_conv);
37864         return ret_conv;
37865 }
37866
37867 uint32_t  __attribute__((export_name("TS_NodeId_clone"))) TS_NodeId_clone(uint32_t orig) {
37868         LDKNodeId orig_conv;
37869         orig_conv.inner = (void*)(orig & (~1));
37870         orig_conv.is_owned = false;
37871         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37872         LDKNodeId ret_var = NodeId_clone(&orig_conv);
37873         uint32_t ret_ref = 0;
37874         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37875         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37876         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37877         ret_ref = (uintptr_t)ret_var.inner;
37878         if (ret_var.is_owned) {
37879                 ret_ref |= 1;
37880         }
37881         return ret_ref;
37882 }
37883
37884 uint32_t  __attribute__((export_name("TS_NodeId_from_pubkey"))) TS_NodeId_from_pubkey(int8_tArray pubkey) {
37885         LDKPublicKey pubkey_ref;
37886         CHECK(pubkey->arr_len == 33);
37887         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
37888         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
37889         uint32_t ret_ref = 0;
37890         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37891         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37892         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37893         ret_ref = (uintptr_t)ret_var.inner;
37894         if (ret_var.is_owned) {
37895                 ret_ref |= 1;
37896         }
37897         return ret_ref;
37898 }
37899
37900 int8_tArray  __attribute__((export_name("TS_NodeId_as_slice"))) TS_NodeId_as_slice(uint32_t this_arg) {
37901         LDKNodeId this_arg_conv;
37902         this_arg_conv.inner = (void*)(this_arg & (~1));
37903         this_arg_conv.is_owned = false;
37904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37905         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
37906         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37907         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37908         return ret_arr;
37909 }
37910
37911 int64_t  __attribute__((export_name("TS_NodeId_hash"))) TS_NodeId_hash(uint32_t o) {
37912         LDKNodeId o_conv;
37913         o_conv.inner = (void*)(o & (~1));
37914         o_conv.is_owned = false;
37915         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
37916         int64_t ret_conv = NodeId_hash(&o_conv);
37917         return ret_conv;
37918 }
37919
37920 int8_tArray  __attribute__((export_name("TS_NodeId_write"))) TS_NodeId_write(uint32_t obj) {
37921         LDKNodeId obj_conv;
37922         obj_conv.inner = (void*)(obj & (~1));
37923         obj_conv.is_owned = false;
37924         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37925         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
37926         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37927         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37928         CVec_u8Z_free(ret_var);
37929         return ret_arr;
37930 }
37931
37932 uint32_t  __attribute__((export_name("TS_NodeId_read"))) TS_NodeId_read(int8_tArray ser) {
37933         LDKu8slice ser_ref;
37934         ser_ref.datalen = ser->arr_len;
37935         ser_ref.data = ser->elems /* XXX ser leaks */;
37936         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
37937         *ret_conv = NodeId_read(ser_ref);
37938         return (uint32_t)ret_conv;
37939 }
37940
37941 void  __attribute__((export_name("TS_NetworkGraph_free"))) TS_NetworkGraph_free(uint32_t this_obj) {
37942         LDKNetworkGraph this_obj_conv;
37943         this_obj_conv.inner = (void*)(this_obj & (~1));
37944         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37946         NetworkGraph_free(this_obj_conv);
37947 }
37948
37949 void  __attribute__((export_name("TS_ReadOnlyNetworkGraph_free"))) TS_ReadOnlyNetworkGraph_free(uint32_t this_obj) {
37950         LDKReadOnlyNetworkGraph this_obj_conv;
37951         this_obj_conv.inner = (void*)(this_obj & (~1));
37952         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37953         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37954         ReadOnlyNetworkGraph_free(this_obj_conv);
37955 }
37956
37957 void  __attribute__((export_name("TS_NetworkUpdate_free"))) TS_NetworkUpdate_free(uint32_t this_ptr) {
37958         if ((this_ptr & 1) != 0) return;
37959         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
37960         CHECK_ACCESS(this_ptr_ptr);
37961         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
37962         FREE((void*)this_ptr);
37963         NetworkUpdate_free(this_ptr_conv);
37964 }
37965
37966 static inline uintptr_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
37967         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
37968         *ret_copy = NetworkUpdate_clone(arg);
37969 uint32_t ret_ref = (uintptr_t)ret_copy;
37970         return ret_ref;
37971 }
37972 uint32_t  __attribute__((export_name("TS_NetworkUpdate_clone_ptr"))) TS_NetworkUpdate_clone_ptr(uint32_t arg) {
37973         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)arg;
37974         uint32_t ret_conv = NetworkUpdate_clone_ptr(arg_conv);
37975         return ret_conv;
37976 }
37977
37978 uint32_t  __attribute__((export_name("TS_NetworkUpdate_clone"))) TS_NetworkUpdate_clone(uint32_t orig) {
37979         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig;
37980         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
37981         *ret_copy = NetworkUpdate_clone(orig_conv);
37982         uint32_t ret_ref = (uintptr_t)ret_copy;
37983         return ret_ref;
37984 }
37985
37986 uint32_t  __attribute__((export_name("TS_NetworkUpdate_channel_update_message"))) TS_NetworkUpdate_channel_update_message(uint32_t msg) {
37987         LDKChannelUpdate msg_conv;
37988         msg_conv.inner = (void*)(msg & (~1));
37989         msg_conv.is_owned = (msg & 1) || (msg == 0);
37990         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
37991         msg_conv = ChannelUpdate_clone(&msg_conv);
37992         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
37993         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
37994         uint32_t ret_ref = (uintptr_t)ret_copy;
37995         return ret_ref;
37996 }
37997
37998 uint32_t  __attribute__((export_name("TS_NetworkUpdate_channel_failure"))) TS_NetworkUpdate_channel_failure(int64_t short_channel_id, jboolean is_permanent) {
37999         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
38000         *ret_copy = NetworkUpdate_channel_failure(short_channel_id, is_permanent);
38001         uint32_t ret_ref = (uintptr_t)ret_copy;
38002         return ret_ref;
38003 }
38004
38005 uint32_t  __attribute__((export_name("TS_NetworkUpdate_node_failure"))) TS_NetworkUpdate_node_failure(int8_tArray node_id, jboolean is_permanent) {
38006         LDKPublicKey node_id_ref;
38007         CHECK(node_id->arr_len == 33);
38008         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
38009         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
38010         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
38011         uint32_t ret_ref = (uintptr_t)ret_copy;
38012         return ret_ref;
38013 }
38014
38015 int8_tArray  __attribute__((export_name("TS_NetworkUpdate_write"))) TS_NetworkUpdate_write(uint32_t obj) {
38016         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj;
38017         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
38018         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38019         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38020         CVec_u8Z_free(ret_var);
38021         return ret_arr;
38022 }
38023
38024 uint32_t  __attribute__((export_name("TS_NetworkUpdate_read"))) TS_NetworkUpdate_read(int8_tArray ser) {
38025         LDKu8slice ser_ref;
38026         ser_ref.datalen = ser->arr_len;
38027         ser_ref.data = ser->elems /* XXX ser leaks */;
38028         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
38029         *ret_conv = NetworkUpdate_read(ser_ref);
38030         return (uint32_t)ret_conv;
38031 }
38032
38033 void  __attribute__((export_name("TS_P2PGossipSync_free"))) TS_P2PGossipSync_free(uint32_t this_obj) {
38034         LDKP2PGossipSync this_obj_conv;
38035         this_obj_conv.inner = (void*)(this_obj & (~1));
38036         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38038         P2PGossipSync_free(this_obj_conv);
38039 }
38040
38041 uint32_t  __attribute__((export_name("TS_P2PGossipSync_new"))) TS_P2PGossipSync_new(uint32_t network_graph, uint32_t chain_access, uint32_t logger) {
38042         LDKNetworkGraph network_graph_conv;
38043         network_graph_conv.inner = (void*)(network_graph & (~1));
38044         network_graph_conv.is_owned = false;
38045         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
38046         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
38047         CHECK_ACCESS(chain_access_ptr);
38048         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
38049         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
38050         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
38051                 // Manually implement clone for Java trait instances
38052                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
38053                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38054                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
38055                 }
38056         }
38057         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
38058         CHECK_ACCESS(logger_ptr);
38059         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
38060         if (logger_conv.free == LDKLogger_JCalls_free) {
38061                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38062                 LDKLogger_JCalls_cloned(&logger_conv);
38063         }
38064         LDKP2PGossipSync ret_var = P2PGossipSync_new(&network_graph_conv, chain_access_conv, logger_conv);
38065         uint32_t ret_ref = 0;
38066         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38067         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38068         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38069         ret_ref = (uintptr_t)ret_var.inner;
38070         if (ret_var.is_owned) {
38071                 ret_ref |= 1;
38072         }
38073         return ret_ref;
38074 }
38075
38076 void  __attribute__((export_name("TS_P2PGossipSync_add_chain_access"))) TS_P2PGossipSync_add_chain_access(uint32_t this_arg, uint32_t chain_access) {
38077         LDKP2PGossipSync this_arg_conv;
38078         this_arg_conv.inner = (void*)(this_arg & (~1));
38079         this_arg_conv.is_owned = false;
38080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38081         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
38082         CHECK_ACCESS(chain_access_ptr);
38083         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
38084         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
38085         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
38086                 // Manually implement clone for Java trait instances
38087                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
38088                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38089                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
38090                 }
38091         }
38092         P2PGossipSync_add_chain_access(&this_arg_conv, chain_access_conv);
38093 }
38094
38095 uint32_t  __attribute__((export_name("TS_NetworkGraph_as_EventHandler"))) TS_NetworkGraph_as_EventHandler(uint32_t this_arg) {
38096         LDKNetworkGraph this_arg_conv;
38097         this_arg_conv.inner = (void*)(this_arg & (~1));
38098         this_arg_conv.is_owned = false;
38099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38100         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
38101         *ret_ret = NetworkGraph_as_EventHandler(&this_arg_conv);
38102         return (uint32_t)ret_ret;
38103 }
38104
38105 uint32_t  __attribute__((export_name("TS_P2PGossipSync_as_RoutingMessageHandler"))) TS_P2PGossipSync_as_RoutingMessageHandler(uint32_t this_arg) {
38106         LDKP2PGossipSync this_arg_conv;
38107         this_arg_conv.inner = (void*)(this_arg & (~1));
38108         this_arg_conv.is_owned = false;
38109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38110         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
38111         *ret_ret = P2PGossipSync_as_RoutingMessageHandler(&this_arg_conv);
38112         return (uint32_t)ret_ret;
38113 }
38114
38115 uint32_t  __attribute__((export_name("TS_P2PGossipSync_as_MessageSendEventsProvider"))) TS_P2PGossipSync_as_MessageSendEventsProvider(uint32_t this_arg) {
38116         LDKP2PGossipSync 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         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
38121         *ret_ret = P2PGossipSync_as_MessageSendEventsProvider(&this_arg_conv);
38122         return (uint32_t)ret_ret;
38123 }
38124
38125 void  __attribute__((export_name("TS_ChannelUpdateInfo_free"))) TS_ChannelUpdateInfo_free(uint32_t this_obj) {
38126         LDKChannelUpdateInfo this_obj_conv;
38127         this_obj_conv.inner = (void*)(this_obj & (~1));
38128         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38130         ChannelUpdateInfo_free(this_obj_conv);
38131 }
38132
38133 int32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_last_update"))) TS_ChannelUpdateInfo_get_last_update(uint32_t this_ptr) {
38134         LDKChannelUpdateInfo this_ptr_conv;
38135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38136         this_ptr_conv.is_owned = false;
38137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38138         int32_t ret_conv = ChannelUpdateInfo_get_last_update(&this_ptr_conv);
38139         return ret_conv;
38140 }
38141
38142 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_last_update"))) TS_ChannelUpdateInfo_set_last_update(uint32_t this_ptr, int32_t val) {
38143         LDKChannelUpdateInfo this_ptr_conv;
38144         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38145         this_ptr_conv.is_owned = false;
38146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38147         ChannelUpdateInfo_set_last_update(&this_ptr_conv, val);
38148 }
38149
38150 jboolean  __attribute__((export_name("TS_ChannelUpdateInfo_get_enabled"))) TS_ChannelUpdateInfo_get_enabled(uint32_t this_ptr) {
38151         LDKChannelUpdateInfo this_ptr_conv;
38152         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38153         this_ptr_conv.is_owned = false;
38154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38155         jboolean ret_conv = ChannelUpdateInfo_get_enabled(&this_ptr_conv);
38156         return ret_conv;
38157 }
38158
38159 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_enabled"))) TS_ChannelUpdateInfo_set_enabled(uint32_t this_ptr, jboolean val) {
38160         LDKChannelUpdateInfo this_ptr_conv;
38161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38162         this_ptr_conv.is_owned = false;
38163         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38164         ChannelUpdateInfo_set_enabled(&this_ptr_conv, val);
38165 }
38166
38167 int16_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_cltv_expiry_delta"))) TS_ChannelUpdateInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
38168         LDKChannelUpdateInfo this_ptr_conv;
38169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38170         this_ptr_conv.is_owned = false;
38171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38172         int16_t ret_conv = ChannelUpdateInfo_get_cltv_expiry_delta(&this_ptr_conv);
38173         return ret_conv;
38174 }
38175
38176 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_cltv_expiry_delta"))) TS_ChannelUpdateInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
38177         LDKChannelUpdateInfo this_ptr_conv;
38178         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38179         this_ptr_conv.is_owned = false;
38180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38181         ChannelUpdateInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
38182 }
38183
38184 int64_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_htlc_minimum_msat"))) TS_ChannelUpdateInfo_get_htlc_minimum_msat(uint32_t this_ptr) {
38185         LDKChannelUpdateInfo this_ptr_conv;
38186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38187         this_ptr_conv.is_owned = false;
38188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38189         int64_t ret_conv = ChannelUpdateInfo_get_htlc_minimum_msat(&this_ptr_conv);
38190         return ret_conv;
38191 }
38192
38193 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_htlc_minimum_msat"))) TS_ChannelUpdateInfo_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
38194         LDKChannelUpdateInfo this_ptr_conv;
38195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38196         this_ptr_conv.is_owned = false;
38197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38198         ChannelUpdateInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
38199 }
38200
38201 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_htlc_maximum_msat"))) TS_ChannelUpdateInfo_get_htlc_maximum_msat(uint32_t this_ptr) {
38202         LDKChannelUpdateInfo this_ptr_conv;
38203         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38204         this_ptr_conv.is_owned = false;
38205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38206         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
38207         *ret_copy = ChannelUpdateInfo_get_htlc_maximum_msat(&this_ptr_conv);
38208         uint32_t ret_ref = (uintptr_t)ret_copy;
38209         return ret_ref;
38210 }
38211
38212 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_htlc_maximum_msat"))) TS_ChannelUpdateInfo_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
38213         LDKChannelUpdateInfo this_ptr_conv;
38214         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38215         this_ptr_conv.is_owned = false;
38216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38217         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
38218         CHECK_ACCESS(val_ptr);
38219         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
38220         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
38221         ChannelUpdateInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
38222 }
38223
38224 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_fees"))) TS_ChannelUpdateInfo_get_fees(uint32_t this_ptr) {
38225         LDKChannelUpdateInfo this_ptr_conv;
38226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38227         this_ptr_conv.is_owned = false;
38228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38229         LDKRoutingFees ret_var = ChannelUpdateInfo_get_fees(&this_ptr_conv);
38230         uint32_t ret_ref = 0;
38231         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38232         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38233         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38234         ret_ref = (uintptr_t)ret_var.inner;
38235         if (ret_var.is_owned) {
38236                 ret_ref |= 1;
38237         }
38238         return ret_ref;
38239 }
38240
38241 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_fees"))) TS_ChannelUpdateInfo_set_fees(uint32_t this_ptr, uint32_t val) {
38242         LDKChannelUpdateInfo this_ptr_conv;
38243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38244         this_ptr_conv.is_owned = false;
38245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38246         LDKRoutingFees val_conv;
38247         val_conv.inner = (void*)(val & (~1));
38248         val_conv.is_owned = (val & 1) || (val == 0);
38249         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38250         val_conv = RoutingFees_clone(&val_conv);
38251         ChannelUpdateInfo_set_fees(&this_ptr_conv, val_conv);
38252 }
38253
38254 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_last_update_message"))) TS_ChannelUpdateInfo_get_last_update_message(uint32_t this_ptr) {
38255         LDKChannelUpdateInfo this_ptr_conv;
38256         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38257         this_ptr_conv.is_owned = false;
38258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38259         LDKChannelUpdate ret_var = ChannelUpdateInfo_get_last_update_message(&this_ptr_conv);
38260         uint32_t ret_ref = 0;
38261         if ((uintptr_t)ret_var.inner > 4096) {
38262                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38263                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38264         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38265                 ret_ref = (uintptr_t)ret_var.inner;
38266                 if (ret_var.is_owned) {
38267                         ret_ref |= 1;
38268                 }
38269         }
38270         return ret_ref;
38271 }
38272
38273 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_last_update_message"))) TS_ChannelUpdateInfo_set_last_update_message(uint32_t this_ptr, uint32_t val) {
38274         LDKChannelUpdateInfo this_ptr_conv;
38275         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38276         this_ptr_conv.is_owned = false;
38277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38278         LDKChannelUpdate val_conv;
38279         val_conv.inner = (void*)(val & (~1));
38280         val_conv.is_owned = (val & 1) || (val == 0);
38281         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38282         val_conv = ChannelUpdate_clone(&val_conv);
38283         ChannelUpdateInfo_set_last_update_message(&this_ptr_conv, val_conv);
38284 }
38285
38286 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, uint32_t htlc_maximum_msat_arg, uint32_t fees_arg, uint32_t last_update_message_arg) {
38287         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
38288         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
38289         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
38290         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
38291         LDKRoutingFees fees_arg_conv;
38292         fees_arg_conv.inner = (void*)(fees_arg & (~1));
38293         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
38294         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
38295         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
38296         LDKChannelUpdate last_update_message_arg_conv;
38297         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
38298         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
38299         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
38300         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
38301         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_new(last_update_arg, enabled_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg_conv, fees_arg_conv, last_update_message_arg_conv);
38302         uint32_t ret_ref = 0;
38303         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38304         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38305         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38306         ret_ref = (uintptr_t)ret_var.inner;
38307         if (ret_var.is_owned) {
38308                 ret_ref |= 1;
38309         }
38310         return ret_ref;
38311 }
38312
38313 static inline uintptr_t ChannelUpdateInfo_clone_ptr(LDKChannelUpdateInfo *NONNULL_PTR arg) {
38314         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(arg);
38315 uint32_t ret_ref = 0;
38316 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38317 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38318 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38319 ret_ref = (uintptr_t)ret_var.inner;
38320 if (ret_var.is_owned) {
38321         ret_ref |= 1;
38322 }
38323         return ret_ref;
38324 }
38325 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_clone_ptr"))) TS_ChannelUpdateInfo_clone_ptr(uint32_t arg) {
38326         LDKChannelUpdateInfo arg_conv;
38327         arg_conv.inner = (void*)(arg & (~1));
38328         arg_conv.is_owned = false;
38329         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38330         uint32_t ret_conv = ChannelUpdateInfo_clone_ptr(&arg_conv);
38331         return ret_conv;
38332 }
38333
38334 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_clone"))) TS_ChannelUpdateInfo_clone(uint32_t orig) {
38335         LDKChannelUpdateInfo orig_conv;
38336         orig_conv.inner = (void*)(orig & (~1));
38337         orig_conv.is_owned = false;
38338         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38339         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(&orig_conv);
38340         uint32_t ret_ref = 0;
38341         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38342         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38343         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38344         ret_ref = (uintptr_t)ret_var.inner;
38345         if (ret_var.is_owned) {
38346                 ret_ref |= 1;
38347         }
38348         return ret_ref;
38349 }
38350
38351 int8_tArray  __attribute__((export_name("TS_ChannelUpdateInfo_write"))) TS_ChannelUpdateInfo_write(uint32_t obj) {
38352         LDKChannelUpdateInfo obj_conv;
38353         obj_conv.inner = (void*)(obj & (~1));
38354         obj_conv.is_owned = false;
38355         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38356         LDKCVec_u8Z ret_var = ChannelUpdateInfo_write(&obj_conv);
38357         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38358         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38359         CVec_u8Z_free(ret_var);
38360         return ret_arr;
38361 }
38362
38363 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_read"))) TS_ChannelUpdateInfo_read(int8_tArray ser) {
38364         LDKu8slice ser_ref;
38365         ser_ref.datalen = ser->arr_len;
38366         ser_ref.data = ser->elems /* XXX ser leaks */;
38367         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
38368         *ret_conv = ChannelUpdateInfo_read(ser_ref);
38369         return (uint32_t)ret_conv;
38370 }
38371
38372 void  __attribute__((export_name("TS_ChannelInfo_free"))) TS_ChannelInfo_free(uint32_t this_obj) {
38373         LDKChannelInfo this_obj_conv;
38374         this_obj_conv.inner = (void*)(this_obj & (~1));
38375         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38377         ChannelInfo_free(this_obj_conv);
38378 }
38379
38380 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_features"))) TS_ChannelInfo_get_features(uint32_t this_ptr) {
38381         LDKChannelInfo this_ptr_conv;
38382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38383         this_ptr_conv.is_owned = false;
38384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38385         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
38386         uint32_t ret_ref = 0;
38387         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38388         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38389         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38390         ret_ref = (uintptr_t)ret_var.inner;
38391         if (ret_var.is_owned) {
38392                 ret_ref |= 1;
38393         }
38394         return ret_ref;
38395 }
38396
38397 void  __attribute__((export_name("TS_ChannelInfo_set_features"))) TS_ChannelInfo_set_features(uint32_t this_ptr, uint32_t val) {
38398         LDKChannelInfo this_ptr_conv;
38399         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38400         this_ptr_conv.is_owned = false;
38401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38402         LDKChannelFeatures val_conv;
38403         val_conv.inner = (void*)(val & (~1));
38404         val_conv.is_owned = (val & 1) || (val == 0);
38405         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38406         val_conv = ChannelFeatures_clone(&val_conv);
38407         ChannelInfo_set_features(&this_ptr_conv, val_conv);
38408 }
38409
38410 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_node_one"))) TS_ChannelInfo_get_node_one(uint32_t this_ptr) {
38411         LDKChannelInfo this_ptr_conv;
38412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38413         this_ptr_conv.is_owned = false;
38414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38415         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
38416         uint32_t ret_ref = 0;
38417         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38418         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38419         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38420         ret_ref = (uintptr_t)ret_var.inner;
38421         if (ret_var.is_owned) {
38422                 ret_ref |= 1;
38423         }
38424         return ret_ref;
38425 }
38426
38427 void  __attribute__((export_name("TS_ChannelInfo_set_node_one"))) TS_ChannelInfo_set_node_one(uint32_t this_ptr, uint32_t val) {
38428         LDKChannelInfo this_ptr_conv;
38429         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38430         this_ptr_conv.is_owned = false;
38431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38432         LDKNodeId val_conv;
38433         val_conv.inner = (void*)(val & (~1));
38434         val_conv.is_owned = (val & 1) || (val == 0);
38435         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38436         val_conv = NodeId_clone(&val_conv);
38437         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
38438 }
38439
38440 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_one_to_two"))) TS_ChannelInfo_get_one_to_two(uint32_t this_ptr) {
38441         LDKChannelInfo this_ptr_conv;
38442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38443         this_ptr_conv.is_owned = false;
38444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38445         LDKChannelUpdateInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
38446         uint32_t ret_ref = 0;
38447         if ((uintptr_t)ret_var.inner > 4096) {
38448                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38449                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38450         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38451                 ret_ref = (uintptr_t)ret_var.inner;
38452                 if (ret_var.is_owned) {
38453                         ret_ref |= 1;
38454                 }
38455         }
38456         return ret_ref;
38457 }
38458
38459 void  __attribute__((export_name("TS_ChannelInfo_set_one_to_two"))) TS_ChannelInfo_set_one_to_two(uint32_t this_ptr, uint32_t val) {
38460         LDKChannelInfo this_ptr_conv;
38461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38462         this_ptr_conv.is_owned = false;
38463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38464         LDKChannelUpdateInfo val_conv;
38465         val_conv.inner = (void*)(val & (~1));
38466         val_conv.is_owned = (val & 1) || (val == 0);
38467         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38468         val_conv = ChannelUpdateInfo_clone(&val_conv);
38469         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
38470 }
38471
38472 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_node_two"))) TS_ChannelInfo_get_node_two(uint32_t this_ptr) {
38473         LDKChannelInfo this_ptr_conv;
38474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38475         this_ptr_conv.is_owned = false;
38476         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38477         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
38478         uint32_t ret_ref = 0;
38479         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38480         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38481         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38482         ret_ref = (uintptr_t)ret_var.inner;
38483         if (ret_var.is_owned) {
38484                 ret_ref |= 1;
38485         }
38486         return ret_ref;
38487 }
38488
38489 void  __attribute__((export_name("TS_ChannelInfo_set_node_two"))) TS_ChannelInfo_set_node_two(uint32_t this_ptr, uint32_t val) {
38490         LDKChannelInfo this_ptr_conv;
38491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38492         this_ptr_conv.is_owned = false;
38493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38494         LDKNodeId val_conv;
38495         val_conv.inner = (void*)(val & (~1));
38496         val_conv.is_owned = (val & 1) || (val == 0);
38497         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38498         val_conv = NodeId_clone(&val_conv);
38499         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
38500 }
38501
38502 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_two_to_one"))) TS_ChannelInfo_get_two_to_one(uint32_t this_ptr) {
38503         LDKChannelInfo this_ptr_conv;
38504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38505         this_ptr_conv.is_owned = false;
38506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38507         LDKChannelUpdateInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
38508         uint32_t ret_ref = 0;
38509         if ((uintptr_t)ret_var.inner > 4096) {
38510                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38511                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38512         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38513                 ret_ref = (uintptr_t)ret_var.inner;
38514                 if (ret_var.is_owned) {
38515                         ret_ref |= 1;
38516                 }
38517         }
38518         return ret_ref;
38519 }
38520
38521 void  __attribute__((export_name("TS_ChannelInfo_set_two_to_one"))) TS_ChannelInfo_set_two_to_one(uint32_t this_ptr, uint32_t val) {
38522         LDKChannelInfo this_ptr_conv;
38523         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38524         this_ptr_conv.is_owned = false;
38525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38526         LDKChannelUpdateInfo val_conv;
38527         val_conv.inner = (void*)(val & (~1));
38528         val_conv.is_owned = (val & 1) || (val == 0);
38529         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38530         val_conv = ChannelUpdateInfo_clone(&val_conv);
38531         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
38532 }
38533
38534 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_capacity_sats"))) TS_ChannelInfo_get_capacity_sats(uint32_t this_ptr) {
38535         LDKChannelInfo this_ptr_conv;
38536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38537         this_ptr_conv.is_owned = false;
38538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38539         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
38540         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
38541         uint32_t ret_ref = (uintptr_t)ret_copy;
38542         return ret_ref;
38543 }
38544
38545 void  __attribute__((export_name("TS_ChannelInfo_set_capacity_sats"))) TS_ChannelInfo_set_capacity_sats(uint32_t this_ptr, uint32_t val) {
38546         LDKChannelInfo this_ptr_conv;
38547         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38548         this_ptr_conv.is_owned = false;
38549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38550         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
38551         CHECK_ACCESS(val_ptr);
38552         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
38553         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
38554         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
38555 }
38556
38557 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_announcement_message"))) TS_ChannelInfo_get_announcement_message(uint32_t this_ptr) {
38558         LDKChannelInfo this_ptr_conv;
38559         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38560         this_ptr_conv.is_owned = false;
38561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38562         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
38563         uint32_t ret_ref = 0;
38564         if ((uintptr_t)ret_var.inner > 4096) {
38565                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38566                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38567         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38568                 ret_ref = (uintptr_t)ret_var.inner;
38569                 if (ret_var.is_owned) {
38570                         ret_ref |= 1;
38571                 }
38572         }
38573         return ret_ref;
38574 }
38575
38576 void  __attribute__((export_name("TS_ChannelInfo_set_announcement_message"))) TS_ChannelInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
38577         LDKChannelInfo this_ptr_conv;
38578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38579         this_ptr_conv.is_owned = false;
38580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38581         LDKChannelAnnouncement val_conv;
38582         val_conv.inner = (void*)(val & (~1));
38583         val_conv.is_owned = (val & 1) || (val == 0);
38584         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38585         val_conv = ChannelAnnouncement_clone(&val_conv);
38586         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
38587 }
38588
38589 static inline uintptr_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
38590         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
38591 uint32_t ret_ref = 0;
38592 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38593 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38594 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38595 ret_ref = (uintptr_t)ret_var.inner;
38596 if (ret_var.is_owned) {
38597         ret_ref |= 1;
38598 }
38599         return ret_ref;
38600 }
38601 uint32_t  __attribute__((export_name("TS_ChannelInfo_clone_ptr"))) TS_ChannelInfo_clone_ptr(uint32_t arg) {
38602         LDKChannelInfo arg_conv;
38603         arg_conv.inner = (void*)(arg & (~1));
38604         arg_conv.is_owned = false;
38605         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38606         uint32_t ret_conv = ChannelInfo_clone_ptr(&arg_conv);
38607         return ret_conv;
38608 }
38609
38610 uint32_t  __attribute__((export_name("TS_ChannelInfo_clone"))) TS_ChannelInfo_clone(uint32_t orig) {
38611         LDKChannelInfo orig_conv;
38612         orig_conv.inner = (void*)(orig & (~1));
38613         orig_conv.is_owned = false;
38614         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38615         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
38616         uint32_t ret_ref = 0;
38617         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38618         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38619         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38620         ret_ref = (uintptr_t)ret_var.inner;
38621         if (ret_var.is_owned) {
38622                 ret_ref |= 1;
38623         }
38624         return ret_ref;
38625 }
38626
38627 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_directional_info"))) TS_ChannelInfo_get_directional_info(uint32_t this_arg, int8_t channel_flags) {
38628         LDKChannelInfo this_arg_conv;
38629         this_arg_conv.inner = (void*)(this_arg & (~1));
38630         this_arg_conv.is_owned = false;
38631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38632         LDKChannelUpdateInfo ret_var = ChannelInfo_get_directional_info(&this_arg_conv, channel_flags);
38633         uint32_t ret_ref = 0;
38634         if ((uintptr_t)ret_var.inner > 4096) {
38635                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38636                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38637         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38638                 ret_ref = (uintptr_t)ret_var.inner;
38639                 if (ret_var.is_owned) {
38640                         ret_ref |= 1;
38641                 }
38642         }
38643         return ret_ref;
38644 }
38645
38646 int8_tArray  __attribute__((export_name("TS_ChannelInfo_write"))) TS_ChannelInfo_write(uint32_t obj) {
38647         LDKChannelInfo obj_conv;
38648         obj_conv.inner = (void*)(obj & (~1));
38649         obj_conv.is_owned = false;
38650         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38651         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
38652         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38653         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38654         CVec_u8Z_free(ret_var);
38655         return ret_arr;
38656 }
38657
38658 uint32_t  __attribute__((export_name("TS_ChannelInfo_read"))) TS_ChannelInfo_read(int8_tArray ser) {
38659         LDKu8slice ser_ref;
38660         ser_ref.datalen = ser->arr_len;
38661         ser_ref.data = ser->elems /* XXX ser leaks */;
38662         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
38663         *ret_conv = ChannelInfo_read(ser_ref);
38664         return (uint32_t)ret_conv;
38665 }
38666
38667 void  __attribute__((export_name("TS_DirectedChannelInfo_free"))) TS_DirectedChannelInfo_free(uint32_t this_obj) {
38668         LDKDirectedChannelInfo this_obj_conv;
38669         this_obj_conv.inner = (void*)(this_obj & (~1));
38670         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38672         DirectedChannelInfo_free(this_obj_conv);
38673 }
38674
38675 static inline uintptr_t DirectedChannelInfo_clone_ptr(LDKDirectedChannelInfo *NONNULL_PTR arg) {
38676         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(arg);
38677 uint32_t ret_ref = 0;
38678 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38679 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38680 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38681 ret_ref = (uintptr_t)ret_var.inner;
38682 if (ret_var.is_owned) {
38683         ret_ref |= 1;
38684 }
38685         return ret_ref;
38686 }
38687 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_clone_ptr"))) TS_DirectedChannelInfo_clone_ptr(uint32_t arg) {
38688         LDKDirectedChannelInfo arg_conv;
38689         arg_conv.inner = (void*)(arg & (~1));
38690         arg_conv.is_owned = false;
38691         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38692         uint32_t ret_conv = DirectedChannelInfo_clone_ptr(&arg_conv);
38693         return ret_conv;
38694 }
38695
38696 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_clone"))) TS_DirectedChannelInfo_clone(uint32_t orig) {
38697         LDKDirectedChannelInfo orig_conv;
38698         orig_conv.inner = (void*)(orig & (~1));
38699         orig_conv.is_owned = false;
38700         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38701         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(&orig_conv);
38702         uint32_t ret_ref = 0;
38703         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38704         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38705         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38706         ret_ref = (uintptr_t)ret_var.inner;
38707         if (ret_var.is_owned) {
38708                 ret_ref |= 1;
38709         }
38710         return ret_ref;
38711 }
38712
38713 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_channel"))) TS_DirectedChannelInfo_channel(uint32_t this_arg) {
38714         LDKDirectedChannelInfo this_arg_conv;
38715         this_arg_conv.inner = (void*)(this_arg & (~1));
38716         this_arg_conv.is_owned = false;
38717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38718         LDKChannelInfo ret_var = DirectedChannelInfo_channel(&this_arg_conv);
38719         uint32_t ret_ref = 0;
38720         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38721         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38722         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38723         ret_ref = (uintptr_t)ret_var.inner;
38724         if (ret_var.is_owned) {
38725                 ret_ref |= 1;
38726         }
38727         return ret_ref;
38728 }
38729
38730 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_direction"))) TS_DirectedChannelInfo_direction(uint32_t this_arg) {
38731         LDKDirectedChannelInfo this_arg_conv;
38732         this_arg_conv.inner = (void*)(this_arg & (~1));
38733         this_arg_conv.is_owned = false;
38734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38735         LDKChannelUpdateInfo ret_var = DirectedChannelInfo_direction(&this_arg_conv);
38736         uint32_t ret_ref = 0;
38737         if ((uintptr_t)ret_var.inner > 4096) {
38738                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38739                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38740         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38741                 ret_ref = (uintptr_t)ret_var.inner;
38742                 if (ret_var.is_owned) {
38743                         ret_ref |= 1;
38744                 }
38745         }
38746         return ret_ref;
38747 }
38748
38749 int64_t  __attribute__((export_name("TS_DirectedChannelInfo_htlc_maximum_msat"))) TS_DirectedChannelInfo_htlc_maximum_msat(uint32_t this_arg) {
38750         LDKDirectedChannelInfo this_arg_conv;
38751         this_arg_conv.inner = (void*)(this_arg & (~1));
38752         this_arg_conv.is_owned = false;
38753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38754         int64_t ret_conv = DirectedChannelInfo_htlc_maximum_msat(&this_arg_conv);
38755         return ret_conv;
38756 }
38757
38758 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_effective_capacity"))) TS_DirectedChannelInfo_effective_capacity(uint32_t this_arg) {
38759         LDKDirectedChannelInfo this_arg_conv;
38760         this_arg_conv.inner = (void*)(this_arg & (~1));
38761         this_arg_conv.is_owned = false;
38762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38763         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
38764         *ret_copy = DirectedChannelInfo_effective_capacity(&this_arg_conv);
38765         uint32_t ret_ref = (uintptr_t)ret_copy;
38766         return ret_ref;
38767 }
38768
38769 void  __attribute__((export_name("TS_EffectiveCapacity_free"))) TS_EffectiveCapacity_free(uint32_t this_ptr) {
38770         if ((this_ptr & 1) != 0) return;
38771         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
38772         CHECK_ACCESS(this_ptr_ptr);
38773         LDKEffectiveCapacity this_ptr_conv = *(LDKEffectiveCapacity*)(this_ptr_ptr);
38774         FREE((void*)this_ptr);
38775         EffectiveCapacity_free(this_ptr_conv);
38776 }
38777
38778 static inline uintptr_t EffectiveCapacity_clone_ptr(LDKEffectiveCapacity *NONNULL_PTR arg) {
38779         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
38780         *ret_copy = EffectiveCapacity_clone(arg);
38781 uint32_t ret_ref = (uintptr_t)ret_copy;
38782         return ret_ref;
38783 }
38784 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_clone_ptr"))) TS_EffectiveCapacity_clone_ptr(uint32_t arg) {
38785         LDKEffectiveCapacity* arg_conv = (LDKEffectiveCapacity*)arg;
38786         uint32_t ret_conv = EffectiveCapacity_clone_ptr(arg_conv);
38787         return ret_conv;
38788 }
38789
38790 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_clone"))) TS_EffectiveCapacity_clone(uint32_t orig) {
38791         LDKEffectiveCapacity* orig_conv = (LDKEffectiveCapacity*)orig;
38792         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
38793         *ret_copy = EffectiveCapacity_clone(orig_conv);
38794         uint32_t ret_ref = (uintptr_t)ret_copy;
38795         return ret_ref;
38796 }
38797
38798 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_exact_liquidity"))) TS_EffectiveCapacity_exact_liquidity(int64_t liquidity_msat) {
38799         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
38800         *ret_copy = EffectiveCapacity_exact_liquidity(liquidity_msat);
38801         uint32_t ret_ref = (uintptr_t)ret_copy;
38802         return ret_ref;
38803 }
38804
38805 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_maximum_htlc"))) TS_EffectiveCapacity_maximum_htlc(int64_t amount_msat) {
38806         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
38807         *ret_copy = EffectiveCapacity_maximum_htlc(amount_msat);
38808         uint32_t ret_ref = (uintptr_t)ret_copy;
38809         return ret_ref;
38810 }
38811
38812 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_total"))) TS_EffectiveCapacity_total(int64_t capacity_msat) {
38813         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
38814         *ret_copy = EffectiveCapacity_total(capacity_msat);
38815         uint32_t ret_ref = (uintptr_t)ret_copy;
38816         return ret_ref;
38817 }
38818
38819 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_infinite"))) TS_EffectiveCapacity_infinite() {
38820         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
38821         *ret_copy = EffectiveCapacity_infinite();
38822         uint32_t ret_ref = (uintptr_t)ret_copy;
38823         return ret_ref;
38824 }
38825
38826 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_unknown"))) TS_EffectiveCapacity_unknown() {
38827         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
38828         *ret_copy = EffectiveCapacity_unknown();
38829         uint32_t ret_ref = (uintptr_t)ret_copy;
38830         return ret_ref;
38831 }
38832
38833 int64_t  __attribute__((export_name("TS_EffectiveCapacity_as_msat"))) TS_EffectiveCapacity_as_msat(uint32_t this_arg) {
38834         LDKEffectiveCapacity* this_arg_conv = (LDKEffectiveCapacity*)this_arg;
38835         int64_t ret_conv = EffectiveCapacity_as_msat(this_arg_conv);
38836         return ret_conv;
38837 }
38838
38839 void  __attribute__((export_name("TS_RoutingFees_free"))) TS_RoutingFees_free(uint32_t this_obj) {
38840         LDKRoutingFees this_obj_conv;
38841         this_obj_conv.inner = (void*)(this_obj & (~1));
38842         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38844         RoutingFees_free(this_obj_conv);
38845 }
38846
38847 int32_t  __attribute__((export_name("TS_RoutingFees_get_base_msat"))) TS_RoutingFees_get_base_msat(uint32_t this_ptr) {
38848         LDKRoutingFees this_ptr_conv;
38849         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38850         this_ptr_conv.is_owned = false;
38851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38852         int32_t ret_conv = RoutingFees_get_base_msat(&this_ptr_conv);
38853         return ret_conv;
38854 }
38855
38856 void  __attribute__((export_name("TS_RoutingFees_set_base_msat"))) TS_RoutingFees_set_base_msat(uint32_t this_ptr, int32_t val) {
38857         LDKRoutingFees this_ptr_conv;
38858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38859         this_ptr_conv.is_owned = false;
38860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38861         RoutingFees_set_base_msat(&this_ptr_conv, val);
38862 }
38863
38864 int32_t  __attribute__((export_name("TS_RoutingFees_get_proportional_millionths"))) TS_RoutingFees_get_proportional_millionths(uint32_t this_ptr) {
38865         LDKRoutingFees this_ptr_conv;
38866         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38867         this_ptr_conv.is_owned = false;
38868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38869         int32_t ret_conv = RoutingFees_get_proportional_millionths(&this_ptr_conv);
38870         return ret_conv;
38871 }
38872
38873 void  __attribute__((export_name("TS_RoutingFees_set_proportional_millionths"))) TS_RoutingFees_set_proportional_millionths(uint32_t this_ptr, int32_t val) {
38874         LDKRoutingFees this_ptr_conv;
38875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38876         this_ptr_conv.is_owned = false;
38877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38878         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
38879 }
38880
38881 uint32_t  __attribute__((export_name("TS_RoutingFees_new"))) TS_RoutingFees_new(int32_t base_msat_arg, int32_t proportional_millionths_arg) {
38882         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
38883         uint32_t ret_ref = 0;
38884         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38885         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38886         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38887         ret_ref = (uintptr_t)ret_var.inner;
38888         if (ret_var.is_owned) {
38889                 ret_ref |= 1;
38890         }
38891         return ret_ref;
38892 }
38893
38894 jboolean  __attribute__((export_name("TS_RoutingFees_eq"))) TS_RoutingFees_eq(uint32_t a, uint32_t b) {
38895         LDKRoutingFees a_conv;
38896         a_conv.inner = (void*)(a & (~1));
38897         a_conv.is_owned = false;
38898         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38899         LDKRoutingFees b_conv;
38900         b_conv.inner = (void*)(b & (~1));
38901         b_conv.is_owned = false;
38902         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38903         jboolean ret_conv = RoutingFees_eq(&a_conv, &b_conv);
38904         return ret_conv;
38905 }
38906
38907 static inline uintptr_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
38908         LDKRoutingFees ret_var = RoutingFees_clone(arg);
38909 uint32_t ret_ref = 0;
38910 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38911 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38912 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38913 ret_ref = (uintptr_t)ret_var.inner;
38914 if (ret_var.is_owned) {
38915         ret_ref |= 1;
38916 }
38917         return ret_ref;
38918 }
38919 uint32_t  __attribute__((export_name("TS_RoutingFees_clone_ptr"))) TS_RoutingFees_clone_ptr(uint32_t arg) {
38920         LDKRoutingFees arg_conv;
38921         arg_conv.inner = (void*)(arg & (~1));
38922         arg_conv.is_owned = false;
38923         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38924         uint32_t ret_conv = RoutingFees_clone_ptr(&arg_conv);
38925         return ret_conv;
38926 }
38927
38928 uint32_t  __attribute__((export_name("TS_RoutingFees_clone"))) TS_RoutingFees_clone(uint32_t orig) {
38929         LDKRoutingFees orig_conv;
38930         orig_conv.inner = (void*)(orig & (~1));
38931         orig_conv.is_owned = false;
38932         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38933         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
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
38945 int64_t  __attribute__((export_name("TS_RoutingFees_hash"))) TS_RoutingFees_hash(uint32_t o) {
38946         LDKRoutingFees o_conv;
38947         o_conv.inner = (void*)(o & (~1));
38948         o_conv.is_owned = false;
38949         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38950         int64_t ret_conv = RoutingFees_hash(&o_conv);
38951         return ret_conv;
38952 }
38953
38954 int8_tArray  __attribute__((export_name("TS_RoutingFees_write"))) TS_RoutingFees_write(uint32_t obj) {
38955         LDKRoutingFees obj_conv;
38956         obj_conv.inner = (void*)(obj & (~1));
38957         obj_conv.is_owned = false;
38958         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38959         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
38960         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38961         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38962         CVec_u8Z_free(ret_var);
38963         return ret_arr;
38964 }
38965
38966 uint32_t  __attribute__((export_name("TS_RoutingFees_read"))) TS_RoutingFees_read(int8_tArray ser) {
38967         LDKu8slice ser_ref;
38968         ser_ref.datalen = ser->arr_len;
38969         ser_ref.data = ser->elems /* XXX ser leaks */;
38970         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
38971         *ret_conv = RoutingFees_read(ser_ref);
38972         return (uint32_t)ret_conv;
38973 }
38974
38975 void  __attribute__((export_name("TS_NodeAnnouncementInfo_free"))) TS_NodeAnnouncementInfo_free(uint32_t this_obj) {
38976         LDKNodeAnnouncementInfo this_obj_conv;
38977         this_obj_conv.inner = (void*)(this_obj & (~1));
38978         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38980         NodeAnnouncementInfo_free(this_obj_conv);
38981 }
38982
38983 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_features"))) TS_NodeAnnouncementInfo_get_features(uint32_t this_ptr) {
38984         LDKNodeAnnouncementInfo this_ptr_conv;
38985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38986         this_ptr_conv.is_owned = false;
38987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38988         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
38989         uint32_t ret_ref = 0;
38990         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38991         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38992         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38993         ret_ref = (uintptr_t)ret_var.inner;
38994         if (ret_var.is_owned) {
38995                 ret_ref |= 1;
38996         }
38997         return ret_ref;
38998 }
38999
39000 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_features"))) TS_NodeAnnouncementInfo_set_features(uint32_t this_ptr, uint32_t val) {
39001         LDKNodeAnnouncementInfo this_ptr_conv;
39002         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39003         this_ptr_conv.is_owned = false;
39004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39005         LDKNodeFeatures val_conv;
39006         val_conv.inner = (void*)(val & (~1));
39007         val_conv.is_owned = (val & 1) || (val == 0);
39008         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39009         val_conv = NodeFeatures_clone(&val_conv);
39010         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
39011 }
39012
39013 int32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_last_update"))) TS_NodeAnnouncementInfo_get_last_update(uint32_t this_ptr) {
39014         LDKNodeAnnouncementInfo this_ptr_conv;
39015         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39016         this_ptr_conv.is_owned = false;
39017         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39018         int32_t ret_conv = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
39019         return ret_conv;
39020 }
39021
39022 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_last_update"))) TS_NodeAnnouncementInfo_set_last_update(uint32_t this_ptr, int32_t val) {
39023         LDKNodeAnnouncementInfo this_ptr_conv;
39024         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39025         this_ptr_conv.is_owned = false;
39026         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39027         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
39028 }
39029
39030 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_get_rgb"))) TS_NodeAnnouncementInfo_get_rgb(uint32_t this_ptr) {
39031         LDKNodeAnnouncementInfo this_ptr_conv;
39032         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39033         this_ptr_conv.is_owned = false;
39034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39035         int8_tArray ret_arr = init_int8_tArray(3, __LINE__);
39036         memcpy(ret_arr->elems, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv), 3);
39037         return ret_arr;
39038 }
39039
39040 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_rgb"))) TS_NodeAnnouncementInfo_set_rgb(uint32_t this_ptr, int8_tArray val) {
39041         LDKNodeAnnouncementInfo this_ptr_conv;
39042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39043         this_ptr_conv.is_owned = false;
39044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39045         LDKThreeBytes val_ref;
39046         CHECK(val->arr_len == 3);
39047         memcpy(val_ref.data, val->elems, 3); FREE(val);
39048         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
39049 }
39050
39051 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_get_alias"))) TS_NodeAnnouncementInfo_get_alias(uint32_t this_ptr) {
39052         LDKNodeAnnouncementInfo this_ptr_conv;
39053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39054         this_ptr_conv.is_owned = false;
39055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39056         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
39057         memcpy(ret_arr->elems, *NodeAnnouncementInfo_get_alias(&this_ptr_conv), 32);
39058         return ret_arr;
39059 }
39060
39061 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_alias"))) TS_NodeAnnouncementInfo_set_alias(uint32_t this_ptr, int8_tArray val) {
39062         LDKNodeAnnouncementInfo this_ptr_conv;
39063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39064         this_ptr_conv.is_owned = false;
39065         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39066         LDKThirtyTwoBytes val_ref;
39067         CHECK(val->arr_len == 32);
39068         memcpy(val_ref.data, val->elems, 32); FREE(val);
39069         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
39070 }
39071
39072 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_addresses"))) TS_NodeAnnouncementInfo_set_addresses(uint32_t this_ptr, uint32_tArray val) {
39073         LDKNodeAnnouncementInfo this_ptr_conv;
39074         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39075         this_ptr_conv.is_owned = false;
39076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39077         LDKCVec_NetAddressZ val_constr;
39078         val_constr.datalen = val->arr_len;
39079         if (val_constr.datalen > 0)
39080                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
39081         else
39082                 val_constr.data = NULL;
39083         uint32_t* val_vals = val->elems /* XXX val leaks */;
39084         for (size_t m = 0; m < val_constr.datalen; m++) {
39085                 uint32_t val_conv_12 = val_vals[m];
39086                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
39087                 CHECK_ACCESS(val_conv_12_ptr);
39088                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
39089                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
39090                 val_constr.data[m] = val_conv_12_conv;
39091         }
39092         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
39093 }
39094
39095 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_announcement_message"))) TS_NodeAnnouncementInfo_get_announcement_message(uint32_t this_ptr) {
39096         LDKNodeAnnouncementInfo this_ptr_conv;
39097         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39098         this_ptr_conv.is_owned = false;
39099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39100         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
39101         uint32_t ret_ref = 0;
39102         if ((uintptr_t)ret_var.inner > 4096) {
39103                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39104                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39105         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39106                 ret_ref = (uintptr_t)ret_var.inner;
39107                 if (ret_var.is_owned) {
39108                         ret_ref |= 1;
39109                 }
39110         }
39111         return ret_ref;
39112 }
39113
39114 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_announcement_message"))) TS_NodeAnnouncementInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
39115         LDKNodeAnnouncementInfo this_ptr_conv;
39116         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39117         this_ptr_conv.is_owned = false;
39118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39119         LDKNodeAnnouncement val_conv;
39120         val_conv.inner = (void*)(val & (~1));
39121         val_conv.is_owned = (val & 1) || (val == 0);
39122         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39123         val_conv = NodeAnnouncement_clone(&val_conv);
39124         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
39125 }
39126
39127 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_new"))) TS_NodeAnnouncementInfo_new(uint32_t features_arg, int32_t last_update_arg, int8_tArray rgb_arg, int8_tArray alias_arg, uint32_tArray addresses_arg, uint32_t announcement_message_arg) {
39128         LDKNodeFeatures features_arg_conv;
39129         features_arg_conv.inner = (void*)(features_arg & (~1));
39130         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
39131         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
39132         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
39133         LDKThreeBytes rgb_arg_ref;
39134         CHECK(rgb_arg->arr_len == 3);
39135         memcpy(rgb_arg_ref.data, rgb_arg->elems, 3); FREE(rgb_arg);
39136         LDKThirtyTwoBytes alias_arg_ref;
39137         CHECK(alias_arg->arr_len == 32);
39138         memcpy(alias_arg_ref.data, alias_arg->elems, 32); FREE(alias_arg);
39139         LDKCVec_NetAddressZ addresses_arg_constr;
39140         addresses_arg_constr.datalen = addresses_arg->arr_len;
39141         if (addresses_arg_constr.datalen > 0)
39142                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
39143         else
39144                 addresses_arg_constr.data = NULL;
39145         uint32_t* addresses_arg_vals = addresses_arg->elems /* XXX addresses_arg leaks */;
39146         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
39147                 uint32_t addresses_arg_conv_12 = addresses_arg_vals[m];
39148                 void* addresses_arg_conv_12_ptr = (void*)(((uintptr_t)addresses_arg_conv_12) & ~1);
39149                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
39150                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
39151                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
39152         }
39153         LDKNodeAnnouncement announcement_message_arg_conv;
39154         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
39155         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
39156         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
39157         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
39158         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
39159         uint32_t ret_ref = 0;
39160         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39161         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39162         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39163         ret_ref = (uintptr_t)ret_var.inner;
39164         if (ret_var.is_owned) {
39165                 ret_ref |= 1;
39166         }
39167         return ret_ref;
39168 }
39169
39170 static inline uintptr_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
39171         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
39172 uint32_t ret_ref = 0;
39173 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39174 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39175 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39176 ret_ref = (uintptr_t)ret_var.inner;
39177 if (ret_var.is_owned) {
39178         ret_ref |= 1;
39179 }
39180         return ret_ref;
39181 }
39182 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_clone_ptr"))) TS_NodeAnnouncementInfo_clone_ptr(uint32_t arg) {
39183         LDKNodeAnnouncementInfo arg_conv;
39184         arg_conv.inner = (void*)(arg & (~1));
39185         arg_conv.is_owned = false;
39186         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39187         uint32_t ret_conv = NodeAnnouncementInfo_clone_ptr(&arg_conv);
39188         return ret_conv;
39189 }
39190
39191 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_clone"))) TS_NodeAnnouncementInfo_clone(uint32_t orig) {
39192         LDKNodeAnnouncementInfo orig_conv;
39193         orig_conv.inner = (void*)(orig & (~1));
39194         orig_conv.is_owned = false;
39195         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39196         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
39197         uint32_t ret_ref = 0;
39198         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39199         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39200         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39201         ret_ref = (uintptr_t)ret_var.inner;
39202         if (ret_var.is_owned) {
39203                 ret_ref |= 1;
39204         }
39205         return ret_ref;
39206 }
39207
39208 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_write"))) TS_NodeAnnouncementInfo_write(uint32_t obj) {
39209         LDKNodeAnnouncementInfo obj_conv;
39210         obj_conv.inner = (void*)(obj & (~1));
39211         obj_conv.is_owned = false;
39212         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39213         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
39214         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39215         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39216         CVec_u8Z_free(ret_var);
39217         return ret_arr;
39218 }
39219
39220 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_read"))) TS_NodeAnnouncementInfo_read(int8_tArray ser) {
39221         LDKu8slice ser_ref;
39222         ser_ref.datalen = ser->arr_len;
39223         ser_ref.data = ser->elems /* XXX ser leaks */;
39224         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
39225         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
39226         return (uint32_t)ret_conv;
39227 }
39228
39229 void  __attribute__((export_name("TS_NodeInfo_free"))) TS_NodeInfo_free(uint32_t this_obj) {
39230         LDKNodeInfo this_obj_conv;
39231         this_obj_conv.inner = (void*)(this_obj & (~1));
39232         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39234         NodeInfo_free(this_obj_conv);
39235 }
39236
39237 void  __attribute__((export_name("TS_NodeInfo_set_channels"))) TS_NodeInfo_set_channels(uint32_t this_ptr, int64_tArray val) {
39238         LDKNodeInfo this_ptr_conv;
39239         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39240         this_ptr_conv.is_owned = false;
39241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39242         LDKCVec_u64Z val_constr;
39243         val_constr.datalen = val->arr_len;
39244         if (val_constr.datalen > 0)
39245                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
39246         else
39247                 val_constr.data = NULL;
39248         int64_t* val_vals = val->elems /* XXX val leaks */;
39249         for (size_t i = 0; i < val_constr.datalen; i++) {
39250                 int64_t val_conv_8 = val_vals[i];
39251                 val_constr.data[i] = val_conv_8;
39252         }
39253         NodeInfo_set_channels(&this_ptr_conv, val_constr);
39254 }
39255
39256 uint32_t  __attribute__((export_name("TS_NodeInfo_get_lowest_inbound_channel_fees"))) TS_NodeInfo_get_lowest_inbound_channel_fees(uint32_t this_ptr) {
39257         LDKNodeInfo this_ptr_conv;
39258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39259         this_ptr_conv.is_owned = false;
39260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39261         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
39262         uint32_t ret_ref = 0;
39263         if ((uintptr_t)ret_var.inner > 4096) {
39264                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39265                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39266         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39267                 ret_ref = (uintptr_t)ret_var.inner;
39268                 if (ret_var.is_owned) {
39269                         ret_ref |= 1;
39270                 }
39271         }
39272         return ret_ref;
39273 }
39274
39275 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) {
39276         LDKNodeInfo this_ptr_conv;
39277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39278         this_ptr_conv.is_owned = false;
39279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39280         LDKRoutingFees val_conv;
39281         val_conv.inner = (void*)(val & (~1));
39282         val_conv.is_owned = (val & 1) || (val == 0);
39283         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39284         val_conv = RoutingFees_clone(&val_conv);
39285         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
39286 }
39287
39288 uint32_t  __attribute__((export_name("TS_NodeInfo_get_announcement_info"))) TS_NodeInfo_get_announcement_info(uint32_t this_ptr) {
39289         LDKNodeInfo this_ptr_conv;
39290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39291         this_ptr_conv.is_owned = false;
39292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39293         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
39294         uint32_t ret_ref = 0;
39295         if ((uintptr_t)ret_var.inner > 4096) {
39296                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39297                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39298         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39299                 ret_ref = (uintptr_t)ret_var.inner;
39300                 if (ret_var.is_owned) {
39301                         ret_ref |= 1;
39302                 }
39303         }
39304         return ret_ref;
39305 }
39306
39307 void  __attribute__((export_name("TS_NodeInfo_set_announcement_info"))) TS_NodeInfo_set_announcement_info(uint32_t this_ptr, uint32_t val) {
39308         LDKNodeInfo this_ptr_conv;
39309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39310         this_ptr_conv.is_owned = false;
39311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39312         LDKNodeAnnouncementInfo val_conv;
39313         val_conv.inner = (void*)(val & (~1));
39314         val_conv.is_owned = (val & 1) || (val == 0);
39315         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39316         val_conv = NodeAnnouncementInfo_clone(&val_conv);
39317         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
39318 }
39319
39320 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) {
39321         LDKCVec_u64Z channels_arg_constr;
39322         channels_arg_constr.datalen = channels_arg->arr_len;
39323         if (channels_arg_constr.datalen > 0)
39324                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
39325         else
39326                 channels_arg_constr.data = NULL;
39327         int64_t* channels_arg_vals = channels_arg->elems /* XXX channels_arg leaks */;
39328         for (size_t i = 0; i < channels_arg_constr.datalen; i++) {
39329                 int64_t channels_arg_conv_8 = channels_arg_vals[i];
39330                 channels_arg_constr.data[i] = channels_arg_conv_8;
39331         }
39332         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
39333         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
39334         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
39335         CHECK_INNER_FIELD_ACCESS_OR_NULL(lowest_inbound_channel_fees_arg_conv);
39336         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
39337         LDKNodeAnnouncementInfo announcement_info_arg_conv;
39338         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
39339         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
39340         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
39341         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
39342         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
39343         uint32_t ret_ref = 0;
39344         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39345         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39346         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39347         ret_ref = (uintptr_t)ret_var.inner;
39348         if (ret_var.is_owned) {
39349                 ret_ref |= 1;
39350         }
39351         return ret_ref;
39352 }
39353
39354 static inline uintptr_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
39355         LDKNodeInfo ret_var = NodeInfo_clone(arg);
39356 uint32_t ret_ref = 0;
39357 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39358 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39359 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39360 ret_ref = (uintptr_t)ret_var.inner;
39361 if (ret_var.is_owned) {
39362         ret_ref |= 1;
39363 }
39364         return ret_ref;
39365 }
39366 uint32_t  __attribute__((export_name("TS_NodeInfo_clone_ptr"))) TS_NodeInfo_clone_ptr(uint32_t arg) {
39367         LDKNodeInfo arg_conv;
39368         arg_conv.inner = (void*)(arg & (~1));
39369         arg_conv.is_owned = false;
39370         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39371         uint32_t ret_conv = NodeInfo_clone_ptr(&arg_conv);
39372         return ret_conv;
39373 }
39374
39375 uint32_t  __attribute__((export_name("TS_NodeInfo_clone"))) TS_NodeInfo_clone(uint32_t orig) {
39376         LDKNodeInfo orig_conv;
39377         orig_conv.inner = (void*)(orig & (~1));
39378         orig_conv.is_owned = false;
39379         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39380         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
39381         uint32_t ret_ref = 0;
39382         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39383         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39384         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39385         ret_ref = (uintptr_t)ret_var.inner;
39386         if (ret_var.is_owned) {
39387                 ret_ref |= 1;
39388         }
39389         return ret_ref;
39390 }
39391
39392 int8_tArray  __attribute__((export_name("TS_NodeInfo_write"))) TS_NodeInfo_write(uint32_t obj) {
39393         LDKNodeInfo obj_conv;
39394         obj_conv.inner = (void*)(obj & (~1));
39395         obj_conv.is_owned = false;
39396         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39397         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
39398         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39399         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39400         CVec_u8Z_free(ret_var);
39401         return ret_arr;
39402 }
39403
39404 uint32_t  __attribute__((export_name("TS_NodeInfo_read"))) TS_NodeInfo_read(int8_tArray ser) {
39405         LDKu8slice ser_ref;
39406         ser_ref.datalen = ser->arr_len;
39407         ser_ref.data = ser->elems /* XXX ser leaks */;
39408         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
39409         *ret_conv = NodeInfo_read(ser_ref);
39410         return (uint32_t)ret_conv;
39411 }
39412
39413 int8_tArray  __attribute__((export_name("TS_NetworkGraph_write"))) TS_NetworkGraph_write(uint32_t obj) {
39414         LDKNetworkGraph obj_conv;
39415         obj_conv.inner = (void*)(obj & (~1));
39416         obj_conv.is_owned = false;
39417         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39418         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
39419         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39420         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39421         CVec_u8Z_free(ret_var);
39422         return ret_arr;
39423 }
39424
39425 uint32_t  __attribute__((export_name("TS_NetworkGraph_read"))) TS_NetworkGraph_read(int8_tArray ser, uint32_t arg) {
39426         LDKu8slice ser_ref;
39427         ser_ref.datalen = ser->arr_len;
39428         ser_ref.data = ser->elems /* XXX ser leaks */;
39429         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
39430         CHECK_ACCESS(arg_ptr);
39431         LDKLogger arg_conv = *(LDKLogger*)(arg_ptr);
39432         if (arg_conv.free == LDKLogger_JCalls_free) {
39433                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39434                 LDKLogger_JCalls_cloned(&arg_conv);
39435         }
39436         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
39437         *ret_conv = NetworkGraph_read(ser_ref, arg_conv);
39438         return (uint32_t)ret_conv;
39439 }
39440
39441 uint32_t  __attribute__((export_name("TS_NetworkGraph_new"))) TS_NetworkGraph_new(int8_tArray genesis_hash, uint32_t logger) {
39442         LDKThirtyTwoBytes genesis_hash_ref;
39443         CHECK(genesis_hash->arr_len == 32);
39444         memcpy(genesis_hash_ref.data, genesis_hash->elems, 32); FREE(genesis_hash);
39445         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
39446         CHECK_ACCESS(logger_ptr);
39447         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
39448         if (logger_conv.free == LDKLogger_JCalls_free) {
39449                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39450                 LDKLogger_JCalls_cloned(&logger_conv);
39451         }
39452         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref, logger_conv);
39453         uint32_t ret_ref = 0;
39454         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39455         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39456         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39457         ret_ref = (uintptr_t)ret_var.inner;
39458         if (ret_var.is_owned) {
39459                 ret_ref |= 1;
39460         }
39461         return ret_ref;
39462 }
39463
39464 uint32_t  __attribute__((export_name("TS_NetworkGraph_read_only"))) TS_NetworkGraph_read_only(uint32_t this_arg) {
39465         LDKNetworkGraph this_arg_conv;
39466         this_arg_conv.inner = (void*)(this_arg & (~1));
39467         this_arg_conv.is_owned = false;
39468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39469         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
39470         uint32_t ret_ref = 0;
39471         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39472         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39473         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39474         ret_ref = (uintptr_t)ret_var.inner;
39475         if (ret_var.is_owned) {
39476                 ret_ref |= 1;
39477         }
39478         return ret_ref;
39479 }
39480
39481 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) {
39482         LDKNetworkGraph this_arg_conv;
39483         this_arg_conv.inner = (void*)(this_arg & (~1));
39484         this_arg_conv.is_owned = false;
39485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39486         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
39487         *ret_copy = NetworkGraph_get_last_rapid_gossip_sync_timestamp(&this_arg_conv);
39488         uint32_t ret_ref = (uintptr_t)ret_copy;
39489         return ret_ref;
39490 }
39491
39492 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) {
39493         LDKNetworkGraph this_arg_conv;
39494         this_arg_conv.inner = (void*)(this_arg & (~1));
39495         this_arg_conv.is_owned = false;
39496         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39497         NetworkGraph_set_last_rapid_gossip_sync_timestamp(&this_arg_conv, last_rapid_gossip_sync_timestamp);
39498 }
39499
39500 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_node_from_announcement"))) TS_NetworkGraph_update_node_from_announcement(uint32_t this_arg, uint32_t msg) {
39501         LDKNetworkGraph this_arg_conv;
39502         this_arg_conv.inner = (void*)(this_arg & (~1));
39503         this_arg_conv.is_owned = false;
39504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39505         LDKNodeAnnouncement msg_conv;
39506         msg_conv.inner = (void*)(msg & (~1));
39507         msg_conv.is_owned = false;
39508         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
39509         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
39510         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
39511         return (uint32_t)ret_conv;
39512 }
39513
39514 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) {
39515         LDKNetworkGraph this_arg_conv;
39516         this_arg_conv.inner = (void*)(this_arg & (~1));
39517         this_arg_conv.is_owned = false;
39518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39519         LDKUnsignedNodeAnnouncement msg_conv;
39520         msg_conv.inner = (void*)(msg & (~1));
39521         msg_conv.is_owned = false;
39522         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
39523         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
39524         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
39525         return (uint32_t)ret_conv;
39526 }
39527
39528 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) {
39529         LDKNetworkGraph this_arg_conv;
39530         this_arg_conv.inner = (void*)(this_arg & (~1));
39531         this_arg_conv.is_owned = false;
39532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39533         LDKChannelAnnouncement msg_conv;
39534         msg_conv.inner = (void*)(msg & (~1));
39535         msg_conv.is_owned = false;
39536         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
39537         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
39538         CHECK_ACCESS(chain_access_ptr);
39539         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
39540         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
39541         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
39542                 // Manually implement clone for Java trait instances
39543                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
39544                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39545                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
39546                 }
39547         }
39548         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
39549         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
39550         return (uint32_t)ret_conv;
39551 }
39552
39553 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) {
39554         LDKNetworkGraph this_arg_conv;
39555         this_arg_conv.inner = (void*)(this_arg & (~1));
39556         this_arg_conv.is_owned = false;
39557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39558         LDKUnsignedChannelAnnouncement msg_conv;
39559         msg_conv.inner = (void*)(msg & (~1));
39560         msg_conv.is_owned = false;
39561         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
39562         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
39563         CHECK_ACCESS(chain_access_ptr);
39564         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
39565         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
39566         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
39567                 // Manually implement clone for Java trait instances
39568                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
39569                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39570                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
39571                 }
39572         }
39573         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
39574         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
39575         return (uint32_t)ret_conv;
39576 }
39577
39578 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) {
39579         LDKNetworkGraph this_arg_conv;
39580         this_arg_conv.inner = (void*)(this_arg & (~1));
39581         this_arg_conv.is_owned = false;
39582         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39583         LDKChannelFeatures features_conv;
39584         features_conv.inner = (void*)(features & (~1));
39585         features_conv.is_owned = (features & 1) || (features == 0);
39586         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
39587         features_conv = ChannelFeatures_clone(&features_conv);
39588         LDKPublicKey node_id_1_ref;
39589         CHECK(node_id_1->arr_len == 33);
39590         memcpy(node_id_1_ref.compressed_form, node_id_1->elems, 33); FREE(node_id_1);
39591         LDKPublicKey node_id_2_ref;
39592         CHECK(node_id_2->arr_len == 33);
39593         memcpy(node_id_2_ref.compressed_form, node_id_2->elems, 33); FREE(node_id_2);
39594         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
39595         *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);
39596         return (uint32_t)ret_conv;
39597 }
39598
39599 void  __attribute__((export_name("TS_NetworkGraph_channel_failed"))) TS_NetworkGraph_channel_failed(uint32_t this_arg, int64_t short_channel_id, jboolean is_permanent) {
39600         LDKNetworkGraph this_arg_conv;
39601         this_arg_conv.inner = (void*)(this_arg & (~1));
39602         this_arg_conv.is_owned = false;
39603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39604         NetworkGraph_channel_failed(&this_arg_conv, short_channel_id, is_permanent);
39605 }
39606
39607 void  __attribute__((export_name("TS_NetworkGraph_node_failed"))) TS_NetworkGraph_node_failed(uint32_t this_arg, int8_tArray _node_id, jboolean is_permanent) {
39608         LDKNetworkGraph this_arg_conv;
39609         this_arg_conv.inner = (void*)(this_arg & (~1));
39610         this_arg_conv.is_owned = false;
39611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39612         LDKPublicKey _node_id_ref;
39613         CHECK(_node_id->arr_len == 33);
39614         memcpy(_node_id_ref.compressed_form, _node_id->elems, 33); FREE(_node_id);
39615         NetworkGraph_node_failed(&this_arg_conv, _node_id_ref, is_permanent);
39616 }
39617
39618 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) {
39619         LDKNetworkGraph this_arg_conv;
39620         this_arg_conv.inner = (void*)(this_arg & (~1));
39621         this_arg_conv.is_owned = false;
39622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39623         NetworkGraph_remove_stale_channels_with_time(&this_arg_conv, current_time_unix);
39624 }
39625
39626 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_channel"))) TS_NetworkGraph_update_channel(uint32_t this_arg, uint32_t msg) {
39627         LDKNetworkGraph this_arg_conv;
39628         this_arg_conv.inner = (void*)(this_arg & (~1));
39629         this_arg_conv.is_owned = false;
39630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39631         LDKChannelUpdate msg_conv;
39632         msg_conv.inner = (void*)(msg & (~1));
39633         msg_conv.is_owned = false;
39634         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
39635         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
39636         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
39637         return (uint32_t)ret_conv;
39638 }
39639
39640 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_channel_unsigned"))) TS_NetworkGraph_update_channel_unsigned(uint32_t this_arg, uint32_t msg) {
39641         LDKNetworkGraph this_arg_conv;
39642         this_arg_conv.inner = (void*)(this_arg & (~1));
39643         this_arg_conv.is_owned = false;
39644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39645         LDKUnsignedChannelUpdate msg_conv;
39646         msg_conv.inner = (void*)(msg & (~1));
39647         msg_conv.is_owned = false;
39648         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
39649         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
39650         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
39651         return (uint32_t)ret_conv;
39652 }
39653
39654 uint32_t  __attribute__((export_name("TS_ReadOnlyNetworkGraph_get_addresses"))) TS_ReadOnlyNetworkGraph_get_addresses(uint32_t this_arg, int8_tArray pubkey) {
39655         LDKReadOnlyNetworkGraph this_arg_conv;
39656         this_arg_conv.inner = (void*)(this_arg & (~1));
39657         this_arg_conv.is_owned = false;
39658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39659         LDKPublicKey pubkey_ref;
39660         CHECK(pubkey->arr_len == 33);
39661         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
39662         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
39663         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
39664         uint32_t ret_ref = (uintptr_t)ret_copy;
39665         return ret_ref;
39666 }
39667
39668 void  __attribute__((export_name("TS_RouteHop_free"))) TS_RouteHop_free(uint32_t this_obj) {
39669         LDKRouteHop this_obj_conv;
39670         this_obj_conv.inner = (void*)(this_obj & (~1));
39671         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39673         RouteHop_free(this_obj_conv);
39674 }
39675
39676 int8_tArray  __attribute__((export_name("TS_RouteHop_get_pubkey"))) TS_RouteHop_get_pubkey(uint32_t this_ptr) {
39677         LDKRouteHop this_ptr_conv;
39678         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39679         this_ptr_conv.is_owned = false;
39680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39681         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
39682         memcpy(ret_arr->elems, RouteHop_get_pubkey(&this_ptr_conv).compressed_form, 33);
39683         return ret_arr;
39684 }
39685
39686 void  __attribute__((export_name("TS_RouteHop_set_pubkey"))) TS_RouteHop_set_pubkey(uint32_t this_ptr, int8_tArray val) {
39687         LDKRouteHop this_ptr_conv;
39688         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39689         this_ptr_conv.is_owned = false;
39690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39691         LDKPublicKey val_ref;
39692         CHECK(val->arr_len == 33);
39693         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
39694         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
39695 }
39696
39697 uint32_t  __attribute__((export_name("TS_RouteHop_get_node_features"))) TS_RouteHop_get_node_features(uint32_t this_ptr) {
39698         LDKRouteHop this_ptr_conv;
39699         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39700         this_ptr_conv.is_owned = false;
39701         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39702         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
39703         uint32_t ret_ref = 0;
39704         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39705         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39706         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39707         ret_ref = (uintptr_t)ret_var.inner;
39708         if (ret_var.is_owned) {
39709                 ret_ref |= 1;
39710         }
39711         return ret_ref;
39712 }
39713
39714 void  __attribute__((export_name("TS_RouteHop_set_node_features"))) TS_RouteHop_set_node_features(uint32_t this_ptr, uint32_t val) {
39715         LDKRouteHop this_ptr_conv;
39716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39717         this_ptr_conv.is_owned = false;
39718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39719         LDKNodeFeatures val_conv;
39720         val_conv.inner = (void*)(val & (~1));
39721         val_conv.is_owned = (val & 1) || (val == 0);
39722         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39723         val_conv = NodeFeatures_clone(&val_conv);
39724         RouteHop_set_node_features(&this_ptr_conv, val_conv);
39725 }
39726
39727 int64_t  __attribute__((export_name("TS_RouteHop_get_short_channel_id"))) TS_RouteHop_get_short_channel_id(uint32_t this_ptr) {
39728         LDKRouteHop this_ptr_conv;
39729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39730         this_ptr_conv.is_owned = false;
39731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39732         int64_t ret_conv = RouteHop_get_short_channel_id(&this_ptr_conv);
39733         return ret_conv;
39734 }
39735
39736 void  __attribute__((export_name("TS_RouteHop_set_short_channel_id"))) TS_RouteHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
39737         LDKRouteHop this_ptr_conv;
39738         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39739         this_ptr_conv.is_owned = false;
39740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39741         RouteHop_set_short_channel_id(&this_ptr_conv, val);
39742 }
39743
39744 uint32_t  __attribute__((export_name("TS_RouteHop_get_channel_features"))) TS_RouteHop_get_channel_features(uint32_t this_ptr) {
39745         LDKRouteHop this_ptr_conv;
39746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39747         this_ptr_conv.is_owned = false;
39748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39749         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
39750         uint32_t ret_ref = 0;
39751         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39752         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39753         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39754         ret_ref = (uintptr_t)ret_var.inner;
39755         if (ret_var.is_owned) {
39756                 ret_ref |= 1;
39757         }
39758         return ret_ref;
39759 }
39760
39761 void  __attribute__((export_name("TS_RouteHop_set_channel_features"))) TS_RouteHop_set_channel_features(uint32_t this_ptr, uint32_t val) {
39762         LDKRouteHop this_ptr_conv;
39763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39764         this_ptr_conv.is_owned = false;
39765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39766         LDKChannelFeatures val_conv;
39767         val_conv.inner = (void*)(val & (~1));
39768         val_conv.is_owned = (val & 1) || (val == 0);
39769         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39770         val_conv = ChannelFeatures_clone(&val_conv);
39771         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
39772 }
39773
39774 int64_t  __attribute__((export_name("TS_RouteHop_get_fee_msat"))) TS_RouteHop_get_fee_msat(uint32_t this_ptr) {
39775         LDKRouteHop this_ptr_conv;
39776         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39777         this_ptr_conv.is_owned = false;
39778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39779         int64_t ret_conv = RouteHop_get_fee_msat(&this_ptr_conv);
39780         return ret_conv;
39781 }
39782
39783 void  __attribute__((export_name("TS_RouteHop_set_fee_msat"))) TS_RouteHop_set_fee_msat(uint32_t this_ptr, int64_t val) {
39784         LDKRouteHop this_ptr_conv;
39785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39786         this_ptr_conv.is_owned = false;
39787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39788         RouteHop_set_fee_msat(&this_ptr_conv, val);
39789 }
39790
39791 int32_t  __attribute__((export_name("TS_RouteHop_get_cltv_expiry_delta"))) TS_RouteHop_get_cltv_expiry_delta(uint32_t this_ptr) {
39792         LDKRouteHop this_ptr_conv;
39793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39794         this_ptr_conv.is_owned = false;
39795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39796         int32_t ret_conv = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
39797         return ret_conv;
39798 }
39799
39800 void  __attribute__((export_name("TS_RouteHop_set_cltv_expiry_delta"))) TS_RouteHop_set_cltv_expiry_delta(uint32_t this_ptr, int32_t val) {
39801         LDKRouteHop this_ptr_conv;
39802         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39803         this_ptr_conv.is_owned = false;
39804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39805         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
39806 }
39807
39808 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) {
39809         LDKPublicKey pubkey_arg_ref;
39810         CHECK(pubkey_arg->arr_len == 33);
39811         memcpy(pubkey_arg_ref.compressed_form, pubkey_arg->elems, 33); FREE(pubkey_arg);
39812         LDKNodeFeatures node_features_arg_conv;
39813         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
39814         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
39815         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
39816         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
39817         LDKChannelFeatures channel_features_arg_conv;
39818         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
39819         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
39820         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
39821         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
39822         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);
39823         uint32_t ret_ref = 0;
39824         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39825         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39826         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39827         ret_ref = (uintptr_t)ret_var.inner;
39828         if (ret_var.is_owned) {
39829                 ret_ref |= 1;
39830         }
39831         return ret_ref;
39832 }
39833
39834 static inline uintptr_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
39835         LDKRouteHop ret_var = RouteHop_clone(arg);
39836 uint32_t ret_ref = 0;
39837 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39838 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39839 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39840 ret_ref = (uintptr_t)ret_var.inner;
39841 if (ret_var.is_owned) {
39842         ret_ref |= 1;
39843 }
39844         return ret_ref;
39845 }
39846 uint32_t  __attribute__((export_name("TS_RouteHop_clone_ptr"))) TS_RouteHop_clone_ptr(uint32_t arg) {
39847         LDKRouteHop arg_conv;
39848         arg_conv.inner = (void*)(arg & (~1));
39849         arg_conv.is_owned = false;
39850         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39851         uint32_t ret_conv = RouteHop_clone_ptr(&arg_conv);
39852         return ret_conv;
39853 }
39854
39855 uint32_t  __attribute__((export_name("TS_RouteHop_clone"))) TS_RouteHop_clone(uint32_t orig) {
39856         LDKRouteHop orig_conv;
39857         orig_conv.inner = (void*)(orig & (~1));
39858         orig_conv.is_owned = false;
39859         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39860         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
39861         uint32_t ret_ref = 0;
39862         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39863         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39864         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39865         ret_ref = (uintptr_t)ret_var.inner;
39866         if (ret_var.is_owned) {
39867                 ret_ref |= 1;
39868         }
39869         return ret_ref;
39870 }
39871
39872 int64_t  __attribute__((export_name("TS_RouteHop_hash"))) TS_RouteHop_hash(uint32_t o) {
39873         LDKRouteHop o_conv;
39874         o_conv.inner = (void*)(o & (~1));
39875         o_conv.is_owned = false;
39876         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
39877         int64_t ret_conv = RouteHop_hash(&o_conv);
39878         return ret_conv;
39879 }
39880
39881 jboolean  __attribute__((export_name("TS_RouteHop_eq"))) TS_RouteHop_eq(uint32_t a, uint32_t b) {
39882         LDKRouteHop a_conv;
39883         a_conv.inner = (void*)(a & (~1));
39884         a_conv.is_owned = false;
39885         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39886         LDKRouteHop b_conv;
39887         b_conv.inner = (void*)(b & (~1));
39888         b_conv.is_owned = false;
39889         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39890         jboolean ret_conv = RouteHop_eq(&a_conv, &b_conv);
39891         return ret_conv;
39892 }
39893
39894 int8_tArray  __attribute__((export_name("TS_RouteHop_write"))) TS_RouteHop_write(uint32_t obj) {
39895         LDKRouteHop obj_conv;
39896         obj_conv.inner = (void*)(obj & (~1));
39897         obj_conv.is_owned = false;
39898         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39899         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
39900         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39901         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39902         CVec_u8Z_free(ret_var);
39903         return ret_arr;
39904 }
39905
39906 uint32_t  __attribute__((export_name("TS_RouteHop_read"))) TS_RouteHop_read(int8_tArray ser) {
39907         LDKu8slice ser_ref;
39908         ser_ref.datalen = ser->arr_len;
39909         ser_ref.data = ser->elems /* XXX ser leaks */;
39910         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
39911         *ret_conv = RouteHop_read(ser_ref);
39912         return (uint32_t)ret_conv;
39913 }
39914
39915 void  __attribute__((export_name("TS_Route_free"))) TS_Route_free(uint32_t this_obj) {
39916         LDKRoute this_obj_conv;
39917         this_obj_conv.inner = (void*)(this_obj & (~1));
39918         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39920         Route_free(this_obj_conv);
39921 }
39922
39923 ptrArray  __attribute__((export_name("TS_Route_get_paths"))) TS_Route_get_paths(uint32_t this_ptr) {
39924         LDKRoute this_ptr_conv;
39925         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39926         this_ptr_conv.is_owned = false;
39927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39928         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
39929         ptrArray ret_arr = NULL;
39930         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
39931         uint32_tArray *ret_arr_ptr = (uint32_tArray*)(((uint8_t*)ret_arr) + 4);
39932         for (size_t m = 0; m < ret_var.datalen; m++) {
39933                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
39934                 uint32_tArray ret_conv_12_arr = NULL;
39935                 ret_conv_12_arr = init_uint32_tArray(ret_conv_12_var.datalen, __LINE__);
39936                 uint32_t *ret_conv_12_arr_ptr = (uint32_t*)(((uint8_t*)ret_conv_12_arr) + 4);
39937                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
39938                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
39939                         uint32_t ret_conv_12_conv_10_ref = 0;
39940                         CHECK((((uintptr_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39941                         CHECK((((uintptr_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39942                         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_conv_10_var);
39943                         ret_conv_12_conv_10_ref = (uintptr_t)ret_conv_12_conv_10_var.inner;
39944                         if (ret_conv_12_conv_10_var.is_owned) {
39945                                 ret_conv_12_conv_10_ref |= 1;
39946                         }
39947                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
39948                 }
39949                 
39950                 FREE(ret_conv_12_var.data);
39951                 ret_arr_ptr[m] = ret_conv_12_arr;
39952         }
39953         
39954         FREE(ret_var.data);
39955         return ret_arr;
39956 }
39957
39958 void  __attribute__((export_name("TS_Route_set_paths"))) TS_Route_set_paths(uint32_t this_ptr, ptrArray val) {
39959         LDKRoute this_ptr_conv;
39960         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39961         this_ptr_conv.is_owned = false;
39962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39963         LDKCVec_CVec_RouteHopZZ val_constr;
39964         val_constr.datalen = val->arr_len;
39965         if (val_constr.datalen > 0)
39966                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
39967         else
39968                 val_constr.data = NULL;
39969         uint32_tArray* val_vals = (void*) val->elems /* XXX val leaks */;
39970         for (size_t m = 0; m < val_constr.datalen; m++) {
39971                 uint32_tArray val_conv_12 = val_vals[m];
39972                 LDKCVec_RouteHopZ val_conv_12_constr;
39973                 val_conv_12_constr.datalen = val_conv_12->arr_len;
39974                 if (val_conv_12_constr.datalen > 0)
39975                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
39976                 else
39977                         val_conv_12_constr.data = NULL;
39978                 uint32_t* val_conv_12_vals = val_conv_12->elems /* XXX val_conv_12 leaks */;
39979                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
39980                         uint32_t val_conv_12_conv_10 = val_conv_12_vals[k];
39981                         LDKRouteHop val_conv_12_conv_10_conv;
39982                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
39983                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
39984                         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv_10_conv);
39985                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
39986                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
39987                 }
39988                 val_constr.data[m] = val_conv_12_constr;
39989         }
39990         Route_set_paths(&this_ptr_conv, val_constr);
39991 }
39992
39993 uint32_t  __attribute__((export_name("TS_Route_get_payment_params"))) TS_Route_get_payment_params(uint32_t this_ptr) {
39994         LDKRoute this_ptr_conv;
39995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39996         this_ptr_conv.is_owned = false;
39997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39998         LDKPaymentParameters ret_var = Route_get_payment_params(&this_ptr_conv);
39999         uint32_t ret_ref = 0;
40000         if ((uintptr_t)ret_var.inner > 4096) {
40001                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40002                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40003         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40004                 ret_ref = (uintptr_t)ret_var.inner;
40005                 if (ret_var.is_owned) {
40006                         ret_ref |= 1;
40007                 }
40008         }
40009         return ret_ref;
40010 }
40011
40012 void  __attribute__((export_name("TS_Route_set_payment_params"))) TS_Route_set_payment_params(uint32_t this_ptr, uint32_t val) {
40013         LDKRoute this_ptr_conv;
40014         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40015         this_ptr_conv.is_owned = false;
40016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40017         LDKPaymentParameters val_conv;
40018         val_conv.inner = (void*)(val & (~1));
40019         val_conv.is_owned = (val & 1) || (val == 0);
40020         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40021         val_conv = PaymentParameters_clone(&val_conv);
40022         Route_set_payment_params(&this_ptr_conv, val_conv);
40023 }
40024
40025 uint32_t  __attribute__((export_name("TS_Route_new"))) TS_Route_new(ptrArray paths_arg, uint32_t payment_params_arg) {
40026         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
40027         paths_arg_constr.datalen = paths_arg->arr_len;
40028         if (paths_arg_constr.datalen > 0)
40029                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
40030         else
40031                 paths_arg_constr.data = NULL;
40032         uint32_tArray* paths_arg_vals = (void*) paths_arg->elems /* XXX paths_arg leaks */;
40033         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
40034                 uint32_tArray paths_arg_conv_12 = paths_arg_vals[m];
40035                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
40036                 paths_arg_conv_12_constr.datalen = paths_arg_conv_12->arr_len;
40037                 if (paths_arg_conv_12_constr.datalen > 0)
40038                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
40039                 else
40040                         paths_arg_conv_12_constr.data = NULL;
40041                 uint32_t* paths_arg_conv_12_vals = paths_arg_conv_12->elems /* XXX paths_arg_conv_12 leaks */;
40042                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
40043                         uint32_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
40044                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
40045                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
40046                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
40047                         CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_12_conv_10_conv);
40048                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
40049                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
40050                 }
40051                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
40052         }
40053         LDKPaymentParameters payment_params_arg_conv;
40054         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
40055         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
40056         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
40057         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
40058         LDKRoute ret_var = Route_new(paths_arg_constr, payment_params_arg_conv);
40059         uint32_t ret_ref = 0;
40060         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40061         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40062         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40063         ret_ref = (uintptr_t)ret_var.inner;
40064         if (ret_var.is_owned) {
40065                 ret_ref |= 1;
40066         }
40067         return ret_ref;
40068 }
40069
40070 static inline uintptr_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
40071         LDKRoute ret_var = Route_clone(arg);
40072 uint32_t ret_ref = 0;
40073 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40074 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40075 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40076 ret_ref = (uintptr_t)ret_var.inner;
40077 if (ret_var.is_owned) {
40078         ret_ref |= 1;
40079 }
40080         return ret_ref;
40081 }
40082 uint32_t  __attribute__((export_name("TS_Route_clone_ptr"))) TS_Route_clone_ptr(uint32_t arg) {
40083         LDKRoute arg_conv;
40084         arg_conv.inner = (void*)(arg & (~1));
40085         arg_conv.is_owned = false;
40086         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40087         uint32_t ret_conv = Route_clone_ptr(&arg_conv);
40088         return ret_conv;
40089 }
40090
40091 uint32_t  __attribute__((export_name("TS_Route_clone"))) TS_Route_clone(uint32_t orig) {
40092         LDKRoute orig_conv;
40093         orig_conv.inner = (void*)(orig & (~1));
40094         orig_conv.is_owned = false;
40095         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40096         LDKRoute ret_var = Route_clone(&orig_conv);
40097         uint32_t ret_ref = 0;
40098         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40099         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40100         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40101         ret_ref = (uintptr_t)ret_var.inner;
40102         if (ret_var.is_owned) {
40103                 ret_ref |= 1;
40104         }
40105         return ret_ref;
40106 }
40107
40108 int64_t  __attribute__((export_name("TS_Route_hash"))) TS_Route_hash(uint32_t o) {
40109         LDKRoute o_conv;
40110         o_conv.inner = (void*)(o & (~1));
40111         o_conv.is_owned = false;
40112         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40113         int64_t ret_conv = Route_hash(&o_conv);
40114         return ret_conv;
40115 }
40116
40117 jboolean  __attribute__((export_name("TS_Route_eq"))) TS_Route_eq(uint32_t a, uint32_t b) {
40118         LDKRoute a_conv;
40119         a_conv.inner = (void*)(a & (~1));
40120         a_conv.is_owned = false;
40121         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40122         LDKRoute b_conv;
40123         b_conv.inner = (void*)(b & (~1));
40124         b_conv.is_owned = false;
40125         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40126         jboolean ret_conv = Route_eq(&a_conv, &b_conv);
40127         return ret_conv;
40128 }
40129
40130 int64_t  __attribute__((export_name("TS_Route_get_total_fees"))) TS_Route_get_total_fees(uint32_t this_arg) {
40131         LDKRoute this_arg_conv;
40132         this_arg_conv.inner = (void*)(this_arg & (~1));
40133         this_arg_conv.is_owned = false;
40134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40135         int64_t ret_conv = Route_get_total_fees(&this_arg_conv);
40136         return ret_conv;
40137 }
40138
40139 int64_t  __attribute__((export_name("TS_Route_get_total_amount"))) TS_Route_get_total_amount(uint32_t this_arg) {
40140         LDKRoute this_arg_conv;
40141         this_arg_conv.inner = (void*)(this_arg & (~1));
40142         this_arg_conv.is_owned = false;
40143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40144         int64_t ret_conv = Route_get_total_amount(&this_arg_conv);
40145         return ret_conv;
40146 }
40147
40148 int8_tArray  __attribute__((export_name("TS_Route_write"))) TS_Route_write(uint32_t obj) {
40149         LDKRoute obj_conv;
40150         obj_conv.inner = (void*)(obj & (~1));
40151         obj_conv.is_owned = false;
40152         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40153         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
40154         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
40155         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
40156         CVec_u8Z_free(ret_var);
40157         return ret_arr;
40158 }
40159
40160 uint32_t  __attribute__((export_name("TS_Route_read"))) TS_Route_read(int8_tArray ser) {
40161         LDKu8slice ser_ref;
40162         ser_ref.datalen = ser->arr_len;
40163         ser_ref.data = ser->elems /* XXX ser leaks */;
40164         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
40165         *ret_conv = Route_read(ser_ref);
40166         return (uint32_t)ret_conv;
40167 }
40168
40169 void  __attribute__((export_name("TS_RouteParameters_free"))) TS_RouteParameters_free(uint32_t this_obj) {
40170         LDKRouteParameters this_obj_conv;
40171         this_obj_conv.inner = (void*)(this_obj & (~1));
40172         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40173         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40174         RouteParameters_free(this_obj_conv);
40175 }
40176
40177 uint32_t  __attribute__((export_name("TS_RouteParameters_get_payment_params"))) TS_RouteParameters_get_payment_params(uint32_t this_ptr) {
40178         LDKRouteParameters this_ptr_conv;
40179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40180         this_ptr_conv.is_owned = false;
40181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40182         LDKPaymentParameters ret_var = RouteParameters_get_payment_params(&this_ptr_conv);
40183         uint32_t ret_ref = 0;
40184         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40185         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40186         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40187         ret_ref = (uintptr_t)ret_var.inner;
40188         if (ret_var.is_owned) {
40189                 ret_ref |= 1;
40190         }
40191         return ret_ref;
40192 }
40193
40194 void  __attribute__((export_name("TS_RouteParameters_set_payment_params"))) TS_RouteParameters_set_payment_params(uint32_t this_ptr, uint32_t val) {
40195         LDKRouteParameters this_ptr_conv;
40196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40197         this_ptr_conv.is_owned = false;
40198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40199         LDKPaymentParameters val_conv;
40200         val_conv.inner = (void*)(val & (~1));
40201         val_conv.is_owned = (val & 1) || (val == 0);
40202         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40203         val_conv = PaymentParameters_clone(&val_conv);
40204         RouteParameters_set_payment_params(&this_ptr_conv, val_conv);
40205 }
40206
40207 int64_t  __attribute__((export_name("TS_RouteParameters_get_final_value_msat"))) TS_RouteParameters_get_final_value_msat(uint32_t this_ptr) {
40208         LDKRouteParameters this_ptr_conv;
40209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40210         this_ptr_conv.is_owned = false;
40211         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40212         int64_t ret_conv = RouteParameters_get_final_value_msat(&this_ptr_conv);
40213         return ret_conv;
40214 }
40215
40216 void  __attribute__((export_name("TS_RouteParameters_set_final_value_msat"))) TS_RouteParameters_set_final_value_msat(uint32_t this_ptr, int64_t val) {
40217         LDKRouteParameters this_ptr_conv;
40218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40219         this_ptr_conv.is_owned = false;
40220         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40221         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
40222 }
40223
40224 int32_t  __attribute__((export_name("TS_RouteParameters_get_final_cltv_expiry_delta"))) TS_RouteParameters_get_final_cltv_expiry_delta(uint32_t this_ptr) {
40225         LDKRouteParameters this_ptr_conv;
40226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40227         this_ptr_conv.is_owned = false;
40228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40229         int32_t ret_conv = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
40230         return ret_conv;
40231 }
40232
40233 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) {
40234         LDKRouteParameters this_ptr_conv;
40235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40236         this_ptr_conv.is_owned = false;
40237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40238         RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
40239 }
40240
40241 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) {
40242         LDKPaymentParameters payment_params_arg_conv;
40243         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
40244         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
40245         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
40246         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
40247         LDKRouteParameters ret_var = RouteParameters_new(payment_params_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
40248         uint32_t ret_ref = 0;
40249         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40250         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40251         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40252         ret_ref = (uintptr_t)ret_var.inner;
40253         if (ret_var.is_owned) {
40254                 ret_ref |= 1;
40255         }
40256         return ret_ref;
40257 }
40258
40259 static inline uintptr_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
40260         LDKRouteParameters ret_var = RouteParameters_clone(arg);
40261 uint32_t ret_ref = 0;
40262 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40263 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40264 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40265 ret_ref = (uintptr_t)ret_var.inner;
40266 if (ret_var.is_owned) {
40267         ret_ref |= 1;
40268 }
40269         return ret_ref;
40270 }
40271 uint32_t  __attribute__((export_name("TS_RouteParameters_clone_ptr"))) TS_RouteParameters_clone_ptr(uint32_t arg) {
40272         LDKRouteParameters arg_conv;
40273         arg_conv.inner = (void*)(arg & (~1));
40274         arg_conv.is_owned = false;
40275         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40276         uint32_t ret_conv = RouteParameters_clone_ptr(&arg_conv);
40277         return ret_conv;
40278 }
40279
40280 uint32_t  __attribute__((export_name("TS_RouteParameters_clone"))) TS_RouteParameters_clone(uint32_t orig) {
40281         LDKRouteParameters orig_conv;
40282         orig_conv.inner = (void*)(orig & (~1));
40283         orig_conv.is_owned = false;
40284         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40285         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
40286         uint32_t ret_ref = 0;
40287         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40288         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40289         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40290         ret_ref = (uintptr_t)ret_var.inner;
40291         if (ret_var.is_owned) {
40292                 ret_ref |= 1;
40293         }
40294         return ret_ref;
40295 }
40296
40297 int8_tArray  __attribute__((export_name("TS_RouteParameters_write"))) TS_RouteParameters_write(uint32_t obj) {
40298         LDKRouteParameters obj_conv;
40299         obj_conv.inner = (void*)(obj & (~1));
40300         obj_conv.is_owned = false;
40301         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40302         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
40303         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
40304         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
40305         CVec_u8Z_free(ret_var);
40306         return ret_arr;
40307 }
40308
40309 uint32_t  __attribute__((export_name("TS_RouteParameters_read"))) TS_RouteParameters_read(int8_tArray ser) {
40310         LDKu8slice ser_ref;
40311         ser_ref.datalen = ser->arr_len;
40312         ser_ref.data = ser->elems /* XXX ser leaks */;
40313         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
40314         *ret_conv = RouteParameters_read(ser_ref);
40315         return (uint32_t)ret_conv;
40316 }
40317
40318 void  __attribute__((export_name("TS_PaymentParameters_free"))) TS_PaymentParameters_free(uint32_t this_obj) {
40319         LDKPaymentParameters this_obj_conv;
40320         this_obj_conv.inner = (void*)(this_obj & (~1));
40321         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40323         PaymentParameters_free(this_obj_conv);
40324 }
40325
40326 int8_tArray  __attribute__((export_name("TS_PaymentParameters_get_payee_pubkey"))) TS_PaymentParameters_get_payee_pubkey(uint32_t this_ptr) {
40327         LDKPaymentParameters this_ptr_conv;
40328         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40329         this_ptr_conv.is_owned = false;
40330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40331         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
40332         memcpy(ret_arr->elems, PaymentParameters_get_payee_pubkey(&this_ptr_conv).compressed_form, 33);
40333         return ret_arr;
40334 }
40335
40336 void  __attribute__((export_name("TS_PaymentParameters_set_payee_pubkey"))) TS_PaymentParameters_set_payee_pubkey(uint32_t this_ptr, int8_tArray val) {
40337         LDKPaymentParameters this_ptr_conv;
40338         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40339         this_ptr_conv.is_owned = false;
40340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40341         LDKPublicKey val_ref;
40342         CHECK(val->arr_len == 33);
40343         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
40344         PaymentParameters_set_payee_pubkey(&this_ptr_conv, val_ref);
40345 }
40346
40347 uint32_t  __attribute__((export_name("TS_PaymentParameters_get_features"))) TS_PaymentParameters_get_features(uint32_t this_ptr) {
40348         LDKPaymentParameters this_ptr_conv;
40349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40350         this_ptr_conv.is_owned = false;
40351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40352         LDKInvoiceFeatures ret_var = PaymentParameters_get_features(&this_ptr_conv);
40353         uint32_t ret_ref = 0;
40354         if ((uintptr_t)ret_var.inner > 4096) {
40355                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40356                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40357         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40358                 ret_ref = (uintptr_t)ret_var.inner;
40359                 if (ret_var.is_owned) {
40360                         ret_ref |= 1;
40361                 }
40362         }
40363         return ret_ref;
40364 }
40365
40366 void  __attribute__((export_name("TS_PaymentParameters_set_features"))) TS_PaymentParameters_set_features(uint32_t this_ptr, uint32_t val) {
40367         LDKPaymentParameters this_ptr_conv;
40368         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40369         this_ptr_conv.is_owned = false;
40370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40371         LDKInvoiceFeatures val_conv;
40372         val_conv.inner = (void*)(val & (~1));
40373         val_conv.is_owned = (val & 1) || (val == 0);
40374         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40375         val_conv = InvoiceFeatures_clone(&val_conv);
40376         PaymentParameters_set_features(&this_ptr_conv, val_conv);
40377 }
40378
40379 uint32_tArray  __attribute__((export_name("TS_PaymentParameters_get_route_hints"))) TS_PaymentParameters_get_route_hints(uint32_t this_ptr) {
40380         LDKPaymentParameters this_ptr_conv;
40381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40382         this_ptr_conv.is_owned = false;
40383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40384         LDKCVec_RouteHintZ ret_var = PaymentParameters_get_route_hints(&this_ptr_conv);
40385         uint32_tArray ret_arr = NULL;
40386         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
40387         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
40388         for (size_t l = 0; l < ret_var.datalen; l++) {
40389                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
40390                 uint32_t ret_conv_11_ref = 0;
40391                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40392                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40393                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
40394                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
40395                 if (ret_conv_11_var.is_owned) {
40396                         ret_conv_11_ref |= 1;
40397                 }
40398                 ret_arr_ptr[l] = ret_conv_11_ref;
40399         }
40400         
40401         FREE(ret_var.data);
40402         return ret_arr;
40403 }
40404
40405 void  __attribute__((export_name("TS_PaymentParameters_set_route_hints"))) TS_PaymentParameters_set_route_hints(uint32_t this_ptr, uint32_tArray val) {
40406         LDKPaymentParameters this_ptr_conv;
40407         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40408         this_ptr_conv.is_owned = false;
40409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40410         LDKCVec_RouteHintZ val_constr;
40411         val_constr.datalen = val->arr_len;
40412         if (val_constr.datalen > 0)
40413                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
40414         else
40415                 val_constr.data = NULL;
40416         uint32_t* val_vals = val->elems /* XXX val leaks */;
40417         for (size_t l = 0; l < val_constr.datalen; l++) {
40418                 uint32_t val_conv_11 = val_vals[l];
40419                 LDKRouteHint val_conv_11_conv;
40420                 val_conv_11_conv.inner = (void*)(val_conv_11 & (~1));
40421                 val_conv_11_conv.is_owned = (val_conv_11 & 1) || (val_conv_11 == 0);
40422                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_11_conv);
40423                 val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
40424                 val_constr.data[l] = val_conv_11_conv;
40425         }
40426         PaymentParameters_set_route_hints(&this_ptr_conv, val_constr);
40427 }
40428
40429 uint32_t  __attribute__((export_name("TS_PaymentParameters_get_expiry_time"))) TS_PaymentParameters_get_expiry_time(uint32_t this_ptr) {
40430         LDKPaymentParameters this_ptr_conv;
40431         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40432         this_ptr_conv.is_owned = false;
40433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40434         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
40435         *ret_copy = PaymentParameters_get_expiry_time(&this_ptr_conv);
40436         uint32_t ret_ref = (uintptr_t)ret_copy;
40437         return ret_ref;
40438 }
40439
40440 void  __attribute__((export_name("TS_PaymentParameters_set_expiry_time"))) TS_PaymentParameters_set_expiry_time(uint32_t this_ptr, uint32_t val) {
40441         LDKPaymentParameters this_ptr_conv;
40442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40443         this_ptr_conv.is_owned = false;
40444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40445         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
40446         CHECK_ACCESS(val_ptr);
40447         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
40448         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
40449         PaymentParameters_set_expiry_time(&this_ptr_conv, val_conv);
40450 }
40451
40452 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) {
40453         LDKPaymentParameters this_ptr_conv;
40454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40455         this_ptr_conv.is_owned = false;
40456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40457         int32_t ret_conv = PaymentParameters_get_max_total_cltv_expiry_delta(&this_ptr_conv);
40458         return ret_conv;
40459 }
40460
40461 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) {
40462         LDKPaymentParameters 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         PaymentParameters_set_max_total_cltv_expiry_delta(&this_ptr_conv, val);
40467 }
40468
40469 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) {
40470         LDKPublicKey payee_pubkey_arg_ref;
40471         CHECK(payee_pubkey_arg->arr_len == 33);
40472         memcpy(payee_pubkey_arg_ref.compressed_form, payee_pubkey_arg->elems, 33); FREE(payee_pubkey_arg);
40473         LDKInvoiceFeatures features_arg_conv;
40474         features_arg_conv.inner = (void*)(features_arg & (~1));
40475         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
40476         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
40477         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
40478         LDKCVec_RouteHintZ route_hints_arg_constr;
40479         route_hints_arg_constr.datalen = route_hints_arg->arr_len;
40480         if (route_hints_arg_constr.datalen > 0)
40481                 route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
40482         else
40483                 route_hints_arg_constr.data = NULL;
40484         uint32_t* route_hints_arg_vals = route_hints_arg->elems /* XXX route_hints_arg leaks */;
40485         for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
40486                 uint32_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
40487                 LDKRouteHint route_hints_arg_conv_11_conv;
40488                 route_hints_arg_conv_11_conv.inner = (void*)(route_hints_arg_conv_11 & (~1));
40489                 route_hints_arg_conv_11_conv.is_owned = (route_hints_arg_conv_11 & 1) || (route_hints_arg_conv_11 == 0);
40490                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_arg_conv_11_conv);
40491                 route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
40492                 route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
40493         }
40494         void* expiry_time_arg_ptr = (void*)(((uintptr_t)expiry_time_arg) & ~1);
40495         CHECK_ACCESS(expiry_time_arg_ptr);
40496         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
40497         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)expiry_time_arg) & ~1));
40498         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);
40499         uint32_t ret_ref = 0;
40500         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40501         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40502         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40503         ret_ref = (uintptr_t)ret_var.inner;
40504         if (ret_var.is_owned) {
40505                 ret_ref |= 1;
40506         }
40507         return ret_ref;
40508 }
40509
40510 static inline uintptr_t PaymentParameters_clone_ptr(LDKPaymentParameters *NONNULL_PTR arg) {
40511         LDKPaymentParameters ret_var = PaymentParameters_clone(arg);
40512 uint32_t ret_ref = 0;
40513 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40514 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40515 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40516 ret_ref = (uintptr_t)ret_var.inner;
40517 if (ret_var.is_owned) {
40518         ret_ref |= 1;
40519 }
40520         return ret_ref;
40521 }
40522 uint32_t  __attribute__((export_name("TS_PaymentParameters_clone_ptr"))) TS_PaymentParameters_clone_ptr(uint32_t arg) {
40523         LDKPaymentParameters arg_conv;
40524         arg_conv.inner = (void*)(arg & (~1));
40525         arg_conv.is_owned = false;
40526         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40527         uint32_t ret_conv = PaymentParameters_clone_ptr(&arg_conv);
40528         return ret_conv;
40529 }
40530
40531 uint32_t  __attribute__((export_name("TS_PaymentParameters_clone"))) TS_PaymentParameters_clone(uint32_t orig) {
40532         LDKPaymentParameters orig_conv;
40533         orig_conv.inner = (void*)(orig & (~1));
40534         orig_conv.is_owned = false;
40535         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40536         LDKPaymentParameters ret_var = PaymentParameters_clone(&orig_conv);
40537         uint32_t ret_ref = 0;
40538         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40539         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40540         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40541         ret_ref = (uintptr_t)ret_var.inner;
40542         if (ret_var.is_owned) {
40543                 ret_ref |= 1;
40544         }
40545         return ret_ref;
40546 }
40547
40548 int64_t  __attribute__((export_name("TS_PaymentParameters_hash"))) TS_PaymentParameters_hash(uint32_t o) {
40549         LDKPaymentParameters o_conv;
40550         o_conv.inner = (void*)(o & (~1));
40551         o_conv.is_owned = false;
40552         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40553         int64_t ret_conv = PaymentParameters_hash(&o_conv);
40554         return ret_conv;
40555 }
40556
40557 jboolean  __attribute__((export_name("TS_PaymentParameters_eq"))) TS_PaymentParameters_eq(uint32_t a, uint32_t b) {
40558         LDKPaymentParameters a_conv;
40559         a_conv.inner = (void*)(a & (~1));
40560         a_conv.is_owned = false;
40561         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40562         LDKPaymentParameters b_conv;
40563         b_conv.inner = (void*)(b & (~1));
40564         b_conv.is_owned = false;
40565         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40566         jboolean ret_conv = PaymentParameters_eq(&a_conv, &b_conv);
40567         return ret_conv;
40568 }
40569
40570 int8_tArray  __attribute__((export_name("TS_PaymentParameters_write"))) TS_PaymentParameters_write(uint32_t obj) {
40571         LDKPaymentParameters obj_conv;
40572         obj_conv.inner = (void*)(obj & (~1));
40573         obj_conv.is_owned = false;
40574         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40575         LDKCVec_u8Z ret_var = PaymentParameters_write(&obj_conv);
40576         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
40577         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
40578         CVec_u8Z_free(ret_var);
40579         return ret_arr;
40580 }
40581
40582 uint32_t  __attribute__((export_name("TS_PaymentParameters_read"))) TS_PaymentParameters_read(int8_tArray ser) {
40583         LDKu8slice ser_ref;
40584         ser_ref.datalen = ser->arr_len;
40585         ser_ref.data = ser->elems /* XXX ser leaks */;
40586         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
40587         *ret_conv = PaymentParameters_read(ser_ref);
40588         return (uint32_t)ret_conv;
40589 }
40590
40591 uint32_t  __attribute__((export_name("TS_PaymentParameters_from_node_id"))) TS_PaymentParameters_from_node_id(int8_tArray payee_pubkey) {
40592         LDKPublicKey payee_pubkey_ref;
40593         CHECK(payee_pubkey->arr_len == 33);
40594         memcpy(payee_pubkey_ref.compressed_form, payee_pubkey->elems, 33); FREE(payee_pubkey);
40595         LDKPaymentParameters ret_var = PaymentParameters_from_node_id(payee_pubkey_ref);
40596         uint32_t ret_ref = 0;
40597         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40598         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40599         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40600         ret_ref = (uintptr_t)ret_var.inner;
40601         if (ret_var.is_owned) {
40602                 ret_ref |= 1;
40603         }
40604         return ret_ref;
40605 }
40606
40607 uint32_t  __attribute__((export_name("TS_PaymentParameters_for_keysend"))) TS_PaymentParameters_for_keysend(int8_tArray payee_pubkey) {
40608         LDKPublicKey payee_pubkey_ref;
40609         CHECK(payee_pubkey->arr_len == 33);
40610         memcpy(payee_pubkey_ref.compressed_form, payee_pubkey->elems, 33); FREE(payee_pubkey);
40611         LDKPaymentParameters ret_var = PaymentParameters_for_keysend(payee_pubkey_ref);
40612         uint32_t ret_ref = 0;
40613         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40614         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40615         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40616         ret_ref = (uintptr_t)ret_var.inner;
40617         if (ret_var.is_owned) {
40618                 ret_ref |= 1;
40619         }
40620         return ret_ref;
40621 }
40622
40623 void  __attribute__((export_name("TS_RouteHint_free"))) TS_RouteHint_free(uint32_t this_obj) {
40624         LDKRouteHint 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         RouteHint_free(this_obj_conv);
40629 }
40630
40631 uint32_tArray  __attribute__((export_name("TS_RouteHint_get_a"))) TS_RouteHint_get_a(uint32_t this_ptr) {
40632         LDKRouteHint 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         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
40637         uint32_tArray ret_arr = NULL;
40638         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
40639         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
40640         for (size_t o = 0; o < ret_var.datalen; o++) {
40641                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
40642                 uint32_t ret_conv_14_ref = 0;
40643                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40644                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40645                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
40646                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
40647                 if (ret_conv_14_var.is_owned) {
40648                         ret_conv_14_ref |= 1;
40649                 }
40650                 ret_arr_ptr[o] = ret_conv_14_ref;
40651         }
40652         
40653         FREE(ret_var.data);
40654         return ret_arr;
40655 }
40656
40657 void  __attribute__((export_name("TS_RouteHint_set_a"))) TS_RouteHint_set_a(uint32_t this_ptr, uint32_tArray val) {
40658         LDKRouteHint this_ptr_conv;
40659         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40660         this_ptr_conv.is_owned = false;
40661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40662         LDKCVec_RouteHintHopZ val_constr;
40663         val_constr.datalen = val->arr_len;
40664         if (val_constr.datalen > 0)
40665                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
40666         else
40667                 val_constr.data = NULL;
40668         uint32_t* val_vals = val->elems /* XXX val leaks */;
40669         for (size_t o = 0; o < val_constr.datalen; o++) {
40670                 uint32_t val_conv_14 = val_vals[o];
40671                 LDKRouteHintHop val_conv_14_conv;
40672                 val_conv_14_conv.inner = (void*)(val_conv_14 & (~1));
40673                 val_conv_14_conv.is_owned = (val_conv_14 & 1) || (val_conv_14 == 0);
40674                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
40675                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
40676                 val_constr.data[o] = val_conv_14_conv;
40677         }
40678         RouteHint_set_a(&this_ptr_conv, val_constr);
40679 }
40680
40681 uint32_t  __attribute__((export_name("TS_RouteHint_new"))) TS_RouteHint_new(uint32_tArray a_arg) {
40682         LDKCVec_RouteHintHopZ a_arg_constr;
40683         a_arg_constr.datalen = a_arg->arr_len;
40684         if (a_arg_constr.datalen > 0)
40685                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
40686         else
40687                 a_arg_constr.data = NULL;
40688         uint32_t* a_arg_vals = a_arg->elems /* XXX a_arg leaks */;
40689         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
40690                 uint32_t a_arg_conv_14 = a_arg_vals[o];
40691                 LDKRouteHintHop a_arg_conv_14_conv;
40692                 a_arg_conv_14_conv.inner = (void*)(a_arg_conv_14 & (~1));
40693                 a_arg_conv_14_conv.is_owned = (a_arg_conv_14 & 1) || (a_arg_conv_14 == 0);
40694                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
40695                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
40696                 a_arg_constr.data[o] = a_arg_conv_14_conv;
40697         }
40698         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
40699         uint32_t ret_ref = 0;
40700         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40701         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40702         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40703         ret_ref = (uintptr_t)ret_var.inner;
40704         if (ret_var.is_owned) {
40705                 ret_ref |= 1;
40706         }
40707         return ret_ref;
40708 }
40709
40710 static inline uintptr_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
40711         LDKRouteHint ret_var = RouteHint_clone(arg);
40712 uint32_t ret_ref = 0;
40713 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40714 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40715 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40716 ret_ref = (uintptr_t)ret_var.inner;
40717 if (ret_var.is_owned) {
40718         ret_ref |= 1;
40719 }
40720         return ret_ref;
40721 }
40722 uint32_t  __attribute__((export_name("TS_RouteHint_clone_ptr"))) TS_RouteHint_clone_ptr(uint32_t arg) {
40723         LDKRouteHint arg_conv;
40724         arg_conv.inner = (void*)(arg & (~1));
40725         arg_conv.is_owned = false;
40726         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40727         uint32_t ret_conv = RouteHint_clone_ptr(&arg_conv);
40728         return ret_conv;
40729 }
40730
40731 uint32_t  __attribute__((export_name("TS_RouteHint_clone"))) TS_RouteHint_clone(uint32_t orig) {
40732         LDKRouteHint orig_conv;
40733         orig_conv.inner = (void*)(orig & (~1));
40734         orig_conv.is_owned = false;
40735         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40736         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
40737         uint32_t ret_ref = 0;
40738         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40739         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40740         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40741         ret_ref = (uintptr_t)ret_var.inner;
40742         if (ret_var.is_owned) {
40743                 ret_ref |= 1;
40744         }
40745         return ret_ref;
40746 }
40747
40748 int64_t  __attribute__((export_name("TS_RouteHint_hash"))) TS_RouteHint_hash(uint32_t o) {
40749         LDKRouteHint o_conv;
40750         o_conv.inner = (void*)(o & (~1));
40751         o_conv.is_owned = false;
40752         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40753         int64_t ret_conv = RouteHint_hash(&o_conv);
40754         return ret_conv;
40755 }
40756
40757 jboolean  __attribute__((export_name("TS_RouteHint_eq"))) TS_RouteHint_eq(uint32_t a, uint32_t b) {
40758         LDKRouteHint a_conv;
40759         a_conv.inner = (void*)(a & (~1));
40760         a_conv.is_owned = false;
40761         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40762         LDKRouteHint b_conv;
40763         b_conv.inner = (void*)(b & (~1));
40764         b_conv.is_owned = false;
40765         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40766         jboolean ret_conv = RouteHint_eq(&a_conv, &b_conv);
40767         return ret_conv;
40768 }
40769
40770 int8_tArray  __attribute__((export_name("TS_RouteHint_write"))) TS_RouteHint_write(uint32_t obj) {
40771         LDKRouteHint obj_conv;
40772         obj_conv.inner = (void*)(obj & (~1));
40773         obj_conv.is_owned = false;
40774         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40775         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
40776         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
40777         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
40778         CVec_u8Z_free(ret_var);
40779         return ret_arr;
40780 }
40781
40782 uint32_t  __attribute__((export_name("TS_RouteHint_read"))) TS_RouteHint_read(int8_tArray ser) {
40783         LDKu8slice ser_ref;
40784         ser_ref.datalen = ser->arr_len;
40785         ser_ref.data = ser->elems /* XXX ser leaks */;
40786         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
40787         *ret_conv = RouteHint_read(ser_ref);
40788         return (uint32_t)ret_conv;
40789 }
40790
40791 void  __attribute__((export_name("TS_RouteHintHop_free"))) TS_RouteHintHop_free(uint32_t this_obj) {
40792         LDKRouteHintHop this_obj_conv;
40793         this_obj_conv.inner = (void*)(this_obj & (~1));
40794         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40796         RouteHintHop_free(this_obj_conv);
40797 }
40798
40799 int8_tArray  __attribute__((export_name("TS_RouteHintHop_get_src_node_id"))) TS_RouteHintHop_get_src_node_id(uint32_t this_ptr) {
40800         LDKRouteHintHop this_ptr_conv;
40801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40802         this_ptr_conv.is_owned = false;
40803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40804         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
40805         memcpy(ret_arr->elems, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form, 33);
40806         return ret_arr;
40807 }
40808
40809 void  __attribute__((export_name("TS_RouteHintHop_set_src_node_id"))) TS_RouteHintHop_set_src_node_id(uint32_t this_ptr, int8_tArray val) {
40810         LDKRouteHintHop this_ptr_conv;
40811         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40812         this_ptr_conv.is_owned = false;
40813         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40814         LDKPublicKey val_ref;
40815         CHECK(val->arr_len == 33);
40816         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
40817         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
40818 }
40819
40820 int64_t  __attribute__((export_name("TS_RouteHintHop_get_short_channel_id"))) TS_RouteHintHop_get_short_channel_id(uint32_t this_ptr) {
40821         LDKRouteHintHop this_ptr_conv;
40822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40823         this_ptr_conv.is_owned = false;
40824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40825         int64_t ret_conv = RouteHintHop_get_short_channel_id(&this_ptr_conv);
40826         return ret_conv;
40827 }
40828
40829 void  __attribute__((export_name("TS_RouteHintHop_set_short_channel_id"))) TS_RouteHintHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
40830         LDKRouteHintHop this_ptr_conv;
40831         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40832         this_ptr_conv.is_owned = false;
40833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40834         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
40835 }
40836
40837 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_fees"))) TS_RouteHintHop_get_fees(uint32_t this_ptr) {
40838         LDKRouteHintHop this_ptr_conv;
40839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40840         this_ptr_conv.is_owned = false;
40841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40842         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
40843         uint32_t ret_ref = 0;
40844         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40845         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40846         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40847         ret_ref = (uintptr_t)ret_var.inner;
40848         if (ret_var.is_owned) {
40849                 ret_ref |= 1;
40850         }
40851         return ret_ref;
40852 }
40853
40854 void  __attribute__((export_name("TS_RouteHintHop_set_fees"))) TS_RouteHintHop_set_fees(uint32_t this_ptr, uint32_t val) {
40855         LDKRouteHintHop this_ptr_conv;
40856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40857         this_ptr_conv.is_owned = false;
40858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40859         LDKRoutingFees val_conv;
40860         val_conv.inner = (void*)(val & (~1));
40861         val_conv.is_owned = (val & 1) || (val == 0);
40862         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40863         val_conv = RoutingFees_clone(&val_conv);
40864         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
40865 }
40866
40867 int16_t  __attribute__((export_name("TS_RouteHintHop_get_cltv_expiry_delta"))) TS_RouteHintHop_get_cltv_expiry_delta(uint32_t this_ptr) {
40868         LDKRouteHintHop this_ptr_conv;
40869         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40870         this_ptr_conv.is_owned = false;
40871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40872         int16_t ret_conv = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
40873         return ret_conv;
40874 }
40875
40876 void  __attribute__((export_name("TS_RouteHintHop_set_cltv_expiry_delta"))) TS_RouteHintHop_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
40877         LDKRouteHintHop this_ptr_conv;
40878         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40879         this_ptr_conv.is_owned = false;
40880         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40881         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
40882 }
40883
40884 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_htlc_minimum_msat"))) TS_RouteHintHop_get_htlc_minimum_msat(uint32_t this_ptr) {
40885         LDKRouteHintHop this_ptr_conv;
40886         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40887         this_ptr_conv.is_owned = false;
40888         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40889         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
40890         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
40891         uint32_t ret_ref = (uintptr_t)ret_copy;
40892         return ret_ref;
40893 }
40894
40895 void  __attribute__((export_name("TS_RouteHintHop_set_htlc_minimum_msat"))) TS_RouteHintHop_set_htlc_minimum_msat(uint32_t this_ptr, uint32_t val) {
40896         LDKRouteHintHop this_ptr_conv;
40897         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40898         this_ptr_conv.is_owned = false;
40899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40900         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
40901         CHECK_ACCESS(val_ptr);
40902         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
40903         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
40904         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
40905 }
40906
40907 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_htlc_maximum_msat"))) TS_RouteHintHop_get_htlc_maximum_msat(uint32_t this_ptr) {
40908         LDKRouteHintHop this_ptr_conv;
40909         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40910         this_ptr_conv.is_owned = false;
40911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40912         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
40913         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
40914         uint32_t ret_ref = (uintptr_t)ret_copy;
40915         return ret_ref;
40916 }
40917
40918 void  __attribute__((export_name("TS_RouteHintHop_set_htlc_maximum_msat"))) TS_RouteHintHop_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
40919         LDKRouteHintHop this_ptr_conv;
40920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40921         this_ptr_conv.is_owned = false;
40922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40923         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
40924         CHECK_ACCESS(val_ptr);
40925         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
40926         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
40927         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
40928 }
40929
40930 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) {
40931         LDKPublicKey src_node_id_arg_ref;
40932         CHECK(src_node_id_arg->arr_len == 33);
40933         memcpy(src_node_id_arg_ref.compressed_form, src_node_id_arg->elems, 33); FREE(src_node_id_arg);
40934         LDKRoutingFees fees_arg_conv;
40935         fees_arg_conv.inner = (void*)(fees_arg & (~1));
40936         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
40937         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
40938         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
40939         void* htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)htlc_minimum_msat_arg) & ~1);
40940         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
40941         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
40942         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_minimum_msat_arg) & ~1));
40943         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
40944         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
40945         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
40946         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
40947         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);
40948         uint32_t ret_ref = 0;
40949         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40950         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40951         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40952         ret_ref = (uintptr_t)ret_var.inner;
40953         if (ret_var.is_owned) {
40954                 ret_ref |= 1;
40955         }
40956         return ret_ref;
40957 }
40958
40959 static inline uintptr_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
40960         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
40961 uint32_t ret_ref = 0;
40962 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40963 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40964 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40965 ret_ref = (uintptr_t)ret_var.inner;
40966 if (ret_var.is_owned) {
40967         ret_ref |= 1;
40968 }
40969         return ret_ref;
40970 }
40971 uint32_t  __attribute__((export_name("TS_RouteHintHop_clone_ptr"))) TS_RouteHintHop_clone_ptr(uint32_t arg) {
40972         LDKRouteHintHop arg_conv;
40973         arg_conv.inner = (void*)(arg & (~1));
40974         arg_conv.is_owned = false;
40975         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40976         uint32_t ret_conv = RouteHintHop_clone_ptr(&arg_conv);
40977         return ret_conv;
40978 }
40979
40980 uint32_t  __attribute__((export_name("TS_RouteHintHop_clone"))) TS_RouteHintHop_clone(uint32_t orig) {
40981         LDKRouteHintHop orig_conv;
40982         orig_conv.inner = (void*)(orig & (~1));
40983         orig_conv.is_owned = false;
40984         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40985         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
40986         uint32_t ret_ref = 0;
40987         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40988         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40989         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40990         ret_ref = (uintptr_t)ret_var.inner;
40991         if (ret_var.is_owned) {
40992                 ret_ref |= 1;
40993         }
40994         return ret_ref;
40995 }
40996
40997 int64_t  __attribute__((export_name("TS_RouteHintHop_hash"))) TS_RouteHintHop_hash(uint32_t o) {
40998         LDKRouteHintHop o_conv;
40999         o_conv.inner = (void*)(o & (~1));
41000         o_conv.is_owned = false;
41001         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41002         int64_t ret_conv = RouteHintHop_hash(&o_conv);
41003         return ret_conv;
41004 }
41005
41006 jboolean  __attribute__((export_name("TS_RouteHintHop_eq"))) TS_RouteHintHop_eq(uint32_t a, uint32_t b) {
41007         LDKRouteHintHop a_conv;
41008         a_conv.inner = (void*)(a & (~1));
41009         a_conv.is_owned = false;
41010         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41011         LDKRouteHintHop b_conv;
41012         b_conv.inner = (void*)(b & (~1));
41013         b_conv.is_owned = false;
41014         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41015         jboolean ret_conv = RouteHintHop_eq(&a_conv, &b_conv);
41016         return ret_conv;
41017 }
41018
41019 int8_tArray  __attribute__((export_name("TS_RouteHintHop_write"))) TS_RouteHintHop_write(uint32_t obj) {
41020         LDKRouteHintHop obj_conv;
41021         obj_conv.inner = (void*)(obj & (~1));
41022         obj_conv.is_owned = false;
41023         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41024         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
41025         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
41026         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
41027         CVec_u8Z_free(ret_var);
41028         return ret_arr;
41029 }
41030
41031 uint32_t  __attribute__((export_name("TS_RouteHintHop_read"))) TS_RouteHintHop_read(int8_tArray ser) {
41032         LDKu8slice ser_ref;
41033         ser_ref.datalen = ser->arr_len;
41034         ser_ref.data = ser->elems /* XXX ser leaks */;
41035         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
41036         *ret_conv = RouteHintHop_read(ser_ref);
41037         return (uint32_t)ret_conv;
41038 }
41039
41040 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) {
41041         LDKPublicKey our_node_pubkey_ref;
41042         CHECK(our_node_pubkey->arr_len == 33);
41043         memcpy(our_node_pubkey_ref.compressed_form, our_node_pubkey->elems, 33); FREE(our_node_pubkey);
41044         LDKRouteParameters route_params_conv;
41045         route_params_conv.inner = (void*)(route_params & (~1));
41046         route_params_conv.is_owned = false;
41047         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
41048         LDKNetworkGraph network_graph_conv;
41049         network_graph_conv.inner = (void*)(network_graph & (~1));
41050         network_graph_conv.is_owned = false;
41051         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
41052         LDKCVec_ChannelDetailsZ first_hops_constr;
41053         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
41054         if (first_hops != 0) {
41055                 first_hops_constr.datalen = first_hops->arr_len;
41056                 if (first_hops_constr.datalen > 0)
41057                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
41058                 else
41059                         first_hops_constr.data = NULL;
41060                 uint32_t* first_hops_vals = first_hops->elems /* XXX first_hops leaks */;
41061                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
41062                         uint32_t first_hops_conv_16 = first_hops_vals[q];
41063                         LDKChannelDetails first_hops_conv_16_conv;
41064                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
41065                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
41066                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
41067                         first_hops_constr.data[q] = first_hops_conv_16_conv;
41068                 }
41069                 first_hops_ptr = &first_hops_constr;
41070         }
41071         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
41072         CHECK_ACCESS(logger_ptr);
41073         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
41074         if (logger_conv.free == LDKLogger_JCalls_free) {
41075                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41076                 LDKLogger_JCalls_cloned(&logger_conv);
41077         }
41078         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
41079         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
41080         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
41081         unsigned char random_seed_bytes_arr[32];
41082         CHECK(random_seed_bytes->arr_len == 32);
41083         memcpy(random_seed_bytes_arr, random_seed_bytes->elems, 32); FREE(random_seed_bytes);
41084         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
41085         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
41086         *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);
41087         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
41088         return (uint32_t)ret_conv;
41089 }
41090
41091 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) {
41092         LDKPublicKey our_node_pubkey_ref;
41093         CHECK(our_node_pubkey->arr_len == 33);
41094         memcpy(our_node_pubkey_ref.compressed_form, our_node_pubkey->elems, 33); FREE(our_node_pubkey);
41095         LDKCVec_PublicKeyZ hops_constr;
41096         hops_constr.datalen = hops->arr_len;
41097         if (hops_constr.datalen > 0)
41098                 hops_constr.data = MALLOC(hops_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
41099         else
41100                 hops_constr.data = NULL;
41101         int8_tArray* hops_vals = (void*) hops->elems /* XXX hops leaks */;
41102         for (size_t m = 0; m < hops_constr.datalen; m++) {
41103                 int8_tArray hops_conv_12 = hops_vals[m];
41104                 LDKPublicKey hops_conv_12_ref;
41105                 CHECK(hops_conv_12->arr_len == 33);
41106                 memcpy(hops_conv_12_ref.compressed_form, hops_conv_12->elems, 33); FREE(hops_conv_12);
41107                 hops_constr.data[m] = hops_conv_12_ref;
41108         }
41109         LDKRouteParameters route_params_conv;
41110         route_params_conv.inner = (void*)(route_params & (~1));
41111         route_params_conv.is_owned = false;
41112         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
41113         LDKNetworkGraph network_graph_conv;
41114         network_graph_conv.inner = (void*)(network_graph & (~1));
41115         network_graph_conv.is_owned = false;
41116         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
41117         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
41118         CHECK_ACCESS(logger_ptr);
41119         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
41120         if (logger_conv.free == LDKLogger_JCalls_free) {
41121                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41122                 LDKLogger_JCalls_cloned(&logger_conv);
41123         }
41124         unsigned char random_seed_bytes_arr[32];
41125         CHECK(random_seed_bytes->arr_len == 32);
41126         memcpy(random_seed_bytes_arr, random_seed_bytes->elems, 32); FREE(random_seed_bytes);
41127         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
41128         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
41129         *ret_conv = build_route_from_hops(our_node_pubkey_ref, hops_constr, &route_params_conv, &network_graph_conv, logger_conv, random_seed_bytes_ref);
41130         return (uint32_t)ret_conv;
41131 }
41132
41133 void  __attribute__((export_name("TS_Score_free"))) TS_Score_free(uint32_t this_ptr) {
41134         if ((this_ptr & 1) != 0) return;
41135         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
41136         CHECK_ACCESS(this_ptr_ptr);
41137         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
41138         FREE((void*)this_ptr);
41139         Score_free(this_ptr_conv);
41140 }
41141
41142 void  __attribute__((export_name("TS_LockableScore_free"))) TS_LockableScore_free(uint32_t this_ptr) {
41143         if ((this_ptr & 1) != 0) return;
41144         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
41145         CHECK_ACCESS(this_ptr_ptr);
41146         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
41147         FREE((void*)this_ptr);
41148         LockableScore_free(this_ptr_conv);
41149 }
41150
41151 void  __attribute__((export_name("TS_MultiThreadedLockableScore_free"))) TS_MultiThreadedLockableScore_free(uint32_t this_obj) {
41152         LDKMultiThreadedLockableScore this_obj_conv;
41153         this_obj_conv.inner = (void*)(this_obj & (~1));
41154         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41156         MultiThreadedLockableScore_free(this_obj_conv);
41157 }
41158
41159 int8_tArray  __attribute__((export_name("TS_MultiThreadedLockableScore_write"))) TS_MultiThreadedLockableScore_write(uint32_t obj) {
41160         LDKMultiThreadedLockableScore obj_conv;
41161         obj_conv.inner = (void*)(obj & (~1));
41162         obj_conv.is_owned = false;
41163         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41164         LDKCVec_u8Z ret_var = MultiThreadedLockableScore_write(&obj_conv);
41165         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
41166         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
41167         CVec_u8Z_free(ret_var);
41168         return ret_arr;
41169 }
41170
41171 uint32_t  __attribute__((export_name("TS_MultiThreadedLockableScore_new"))) TS_MultiThreadedLockableScore_new(uint32_t score) {
41172         void* score_ptr = (void*)(((uintptr_t)score) & ~1);
41173         CHECK_ACCESS(score_ptr);
41174         LDKScore score_conv = *(LDKScore*)(score_ptr);
41175         if (score_conv.free == LDKScore_JCalls_free) {
41176                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41177                 LDKScore_JCalls_cloned(&score_conv);
41178         }
41179         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
41180         uint32_t ret_ref = 0;
41181         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41182         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41183         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41184         ret_ref = (uintptr_t)ret_var.inner;
41185         if (ret_var.is_owned) {
41186                 ret_ref |= 1;
41187         }
41188         return ret_ref;
41189 }
41190
41191 void  __attribute__((export_name("TS_ChannelUsage_free"))) TS_ChannelUsage_free(uint32_t this_obj) {
41192         LDKChannelUsage this_obj_conv;
41193         this_obj_conv.inner = (void*)(this_obj & (~1));
41194         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41196         ChannelUsage_free(this_obj_conv);
41197 }
41198
41199 int64_t  __attribute__((export_name("TS_ChannelUsage_get_amount_msat"))) TS_ChannelUsage_get_amount_msat(uint32_t this_ptr) {
41200         LDKChannelUsage this_ptr_conv;
41201         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41202         this_ptr_conv.is_owned = false;
41203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41204         int64_t ret_conv = ChannelUsage_get_amount_msat(&this_ptr_conv);
41205         return ret_conv;
41206 }
41207
41208 void  __attribute__((export_name("TS_ChannelUsage_set_amount_msat"))) TS_ChannelUsage_set_amount_msat(uint32_t this_ptr, int64_t val) {
41209         LDKChannelUsage this_ptr_conv;
41210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41211         this_ptr_conv.is_owned = false;
41212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41213         ChannelUsage_set_amount_msat(&this_ptr_conv, val);
41214 }
41215
41216 int64_t  __attribute__((export_name("TS_ChannelUsage_get_inflight_htlc_msat"))) TS_ChannelUsage_get_inflight_htlc_msat(uint32_t this_ptr) {
41217         LDKChannelUsage this_ptr_conv;
41218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41219         this_ptr_conv.is_owned = false;
41220         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41221         int64_t ret_conv = ChannelUsage_get_inflight_htlc_msat(&this_ptr_conv);
41222         return ret_conv;
41223 }
41224
41225 void  __attribute__((export_name("TS_ChannelUsage_set_inflight_htlc_msat"))) TS_ChannelUsage_set_inflight_htlc_msat(uint32_t this_ptr, int64_t val) {
41226         LDKChannelUsage this_ptr_conv;
41227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41228         this_ptr_conv.is_owned = false;
41229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41230         ChannelUsage_set_inflight_htlc_msat(&this_ptr_conv, val);
41231 }
41232
41233 uint32_t  __attribute__((export_name("TS_ChannelUsage_get_effective_capacity"))) TS_ChannelUsage_get_effective_capacity(uint32_t this_ptr) {
41234         LDKChannelUsage this_ptr_conv;
41235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41236         this_ptr_conv.is_owned = false;
41237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41238         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
41239         *ret_copy = ChannelUsage_get_effective_capacity(&this_ptr_conv);
41240         uint32_t ret_ref = (uintptr_t)ret_copy;
41241         return ret_ref;
41242 }
41243
41244 void  __attribute__((export_name("TS_ChannelUsage_set_effective_capacity"))) TS_ChannelUsage_set_effective_capacity(uint32_t this_ptr, uint32_t val) {
41245         LDKChannelUsage this_ptr_conv;
41246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41247         this_ptr_conv.is_owned = false;
41248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41249         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
41250         CHECK_ACCESS(val_ptr);
41251         LDKEffectiveCapacity val_conv = *(LDKEffectiveCapacity*)(val_ptr);
41252         val_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)(((uintptr_t)val) & ~1));
41253         ChannelUsage_set_effective_capacity(&this_ptr_conv, val_conv);
41254 }
41255
41256 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) {
41257         void* effective_capacity_arg_ptr = (void*)(((uintptr_t)effective_capacity_arg) & ~1);
41258         CHECK_ACCESS(effective_capacity_arg_ptr);
41259         LDKEffectiveCapacity effective_capacity_arg_conv = *(LDKEffectiveCapacity*)(effective_capacity_arg_ptr);
41260         effective_capacity_arg_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)(((uintptr_t)effective_capacity_arg) & ~1));
41261         LDKChannelUsage ret_var = ChannelUsage_new(amount_msat_arg, inflight_htlc_msat_arg, effective_capacity_arg_conv);
41262         uint32_t ret_ref = 0;
41263         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41264         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41265         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41266         ret_ref = (uintptr_t)ret_var.inner;
41267         if (ret_var.is_owned) {
41268                 ret_ref |= 1;
41269         }
41270         return ret_ref;
41271 }
41272
41273 static inline uintptr_t ChannelUsage_clone_ptr(LDKChannelUsage *NONNULL_PTR arg) {
41274         LDKChannelUsage ret_var = ChannelUsage_clone(arg);
41275 uint32_t ret_ref = 0;
41276 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41277 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41278 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41279 ret_ref = (uintptr_t)ret_var.inner;
41280 if (ret_var.is_owned) {
41281         ret_ref |= 1;
41282 }
41283         return ret_ref;
41284 }
41285 uint32_t  __attribute__((export_name("TS_ChannelUsage_clone_ptr"))) TS_ChannelUsage_clone_ptr(uint32_t arg) {
41286         LDKChannelUsage arg_conv;
41287         arg_conv.inner = (void*)(arg & (~1));
41288         arg_conv.is_owned = false;
41289         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41290         uint32_t ret_conv = ChannelUsage_clone_ptr(&arg_conv);
41291         return ret_conv;
41292 }
41293
41294 uint32_t  __attribute__((export_name("TS_ChannelUsage_clone"))) TS_ChannelUsage_clone(uint32_t orig) {
41295         LDKChannelUsage orig_conv;
41296         orig_conv.inner = (void*)(orig & (~1));
41297         orig_conv.is_owned = false;
41298         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41299         LDKChannelUsage ret_var = ChannelUsage_clone(&orig_conv);
41300         uint32_t ret_ref = 0;
41301         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41302         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41303         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41304         ret_ref = (uintptr_t)ret_var.inner;
41305         if (ret_var.is_owned) {
41306                 ret_ref |= 1;
41307         }
41308         return ret_ref;
41309 }
41310
41311 void  __attribute__((export_name("TS_FixedPenaltyScorer_free"))) TS_FixedPenaltyScorer_free(uint32_t this_obj) {
41312         LDKFixedPenaltyScorer this_obj_conv;
41313         this_obj_conv.inner = (void*)(this_obj & (~1));
41314         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41316         FixedPenaltyScorer_free(this_obj_conv);
41317 }
41318
41319 static inline uintptr_t FixedPenaltyScorer_clone_ptr(LDKFixedPenaltyScorer *NONNULL_PTR arg) {
41320         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(arg);
41321 uint32_t ret_ref = 0;
41322 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41323 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41324 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41325 ret_ref = (uintptr_t)ret_var.inner;
41326 if (ret_var.is_owned) {
41327         ret_ref |= 1;
41328 }
41329         return ret_ref;
41330 }
41331 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_clone_ptr"))) TS_FixedPenaltyScorer_clone_ptr(uint32_t arg) {
41332         LDKFixedPenaltyScorer arg_conv;
41333         arg_conv.inner = (void*)(arg & (~1));
41334         arg_conv.is_owned = false;
41335         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41336         uint32_t ret_conv = FixedPenaltyScorer_clone_ptr(&arg_conv);
41337         return ret_conv;
41338 }
41339
41340 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_clone"))) TS_FixedPenaltyScorer_clone(uint32_t orig) {
41341         LDKFixedPenaltyScorer orig_conv;
41342         orig_conv.inner = (void*)(orig & (~1));
41343         orig_conv.is_owned = false;
41344         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41345         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(&orig_conv);
41346         uint32_t ret_ref = 0;
41347         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41348         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41349         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41350         ret_ref = (uintptr_t)ret_var.inner;
41351         if (ret_var.is_owned) {
41352                 ret_ref |= 1;
41353         }
41354         return ret_ref;
41355 }
41356
41357 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_with_penalty"))) TS_FixedPenaltyScorer_with_penalty(int64_t penalty_msat) {
41358         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_with_penalty(penalty_msat);
41359         uint32_t ret_ref = 0;
41360         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41361         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41362         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41363         ret_ref = (uintptr_t)ret_var.inner;
41364         if (ret_var.is_owned) {
41365                 ret_ref |= 1;
41366         }
41367         return ret_ref;
41368 }
41369
41370 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_as_Score"))) TS_FixedPenaltyScorer_as_Score(uint32_t this_arg) {
41371         LDKFixedPenaltyScorer this_arg_conv;
41372         this_arg_conv.inner = (void*)(this_arg & (~1));
41373         this_arg_conv.is_owned = false;
41374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41375         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
41376         *ret_ret = FixedPenaltyScorer_as_Score(&this_arg_conv);
41377         return (uint32_t)ret_ret;
41378 }
41379
41380 int8_tArray  __attribute__((export_name("TS_FixedPenaltyScorer_write"))) TS_FixedPenaltyScorer_write(uint32_t obj) {
41381         LDKFixedPenaltyScorer obj_conv;
41382         obj_conv.inner = (void*)(obj & (~1));
41383         obj_conv.is_owned = false;
41384         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41385         LDKCVec_u8Z ret_var = FixedPenaltyScorer_write(&obj_conv);
41386         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
41387         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
41388         CVec_u8Z_free(ret_var);
41389         return ret_arr;
41390 }
41391
41392 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_read"))) TS_FixedPenaltyScorer_read(int8_tArray ser, int64_t arg) {
41393         LDKu8slice ser_ref;
41394         ser_ref.datalen = ser->arr_len;
41395         ser_ref.data = ser->elems /* XXX ser leaks */;
41396         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
41397         *ret_conv = FixedPenaltyScorer_read(ser_ref, arg);
41398         return (uint32_t)ret_conv;
41399 }
41400
41401 void  __attribute__((export_name("TS_ProbabilisticScorer_free"))) TS_ProbabilisticScorer_free(uint32_t this_obj) {
41402         LDKProbabilisticScorer this_obj_conv;
41403         this_obj_conv.inner = (void*)(this_obj & (~1));
41404         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41405         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41406         ProbabilisticScorer_free(this_obj_conv);
41407 }
41408
41409 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_free"))) TS_ProbabilisticScoringParameters_free(uint32_t this_obj) {
41410         LDKProbabilisticScoringParameters this_obj_conv;
41411         this_obj_conv.inner = (void*)(this_obj & (~1));
41412         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41414         ProbabilisticScoringParameters_free(this_obj_conv);
41415 }
41416
41417 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_base_penalty_msat"))) TS_ProbabilisticScoringParameters_get_base_penalty_msat(uint32_t this_ptr) {
41418         LDKProbabilisticScoringParameters this_ptr_conv;
41419         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41420         this_ptr_conv.is_owned = false;
41421         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41422         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_msat(&this_ptr_conv);
41423         return ret_conv;
41424 }
41425
41426 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_set_base_penalty_msat"))) TS_ProbabilisticScoringParameters_set_base_penalty_msat(uint32_t this_ptr, int64_t val) {
41427         LDKProbabilisticScoringParameters this_ptr_conv;
41428         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41429         this_ptr_conv.is_owned = false;
41430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41431         ProbabilisticScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
41432 }
41433
41434 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat"))) TS_ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(uint32_t this_ptr) {
41435         LDKProbabilisticScoringParameters this_ptr_conv;
41436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41437         this_ptr_conv.is_owned = false;
41438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41439         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(&this_ptr_conv);
41440         return ret_conv;
41441 }
41442
41443 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) {
41444         LDKProbabilisticScoringParameters this_ptr_conv;
41445         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41446         this_ptr_conv.is_owned = false;
41447         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41448         ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
41449 }
41450
41451 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_liquidity_offset_half_life"))) TS_ProbabilisticScoringParameters_get_liquidity_offset_half_life(uint32_t this_ptr) {
41452         LDKProbabilisticScoringParameters this_ptr_conv;
41453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41454         this_ptr_conv.is_owned = false;
41455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41456         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_offset_half_life(&this_ptr_conv);
41457         return ret_conv;
41458 }
41459
41460 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) {
41461         LDKProbabilisticScoringParameters this_ptr_conv;
41462         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41463         this_ptr_conv.is_owned = false;
41464         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41465         ProbabilisticScoringParameters_set_liquidity_offset_half_life(&this_ptr_conv, val);
41466 }
41467
41468 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_amount_penalty_multiplier_msat"))) TS_ProbabilisticScoringParameters_get_amount_penalty_multiplier_msat(uint32_t this_ptr) {
41469         LDKProbabilisticScoringParameters this_ptr_conv;
41470         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41471         this_ptr_conv.is_owned = false;
41472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41473         int64_t ret_conv = ProbabilisticScoringParameters_get_amount_penalty_multiplier_msat(&this_ptr_conv);
41474         return ret_conv;
41475 }
41476
41477 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_set_amount_penalty_multiplier_msat"))) TS_ProbabilisticScoringParameters_set_amount_penalty_multiplier_msat(uint32_t this_ptr, int64_t val) {
41478         LDKProbabilisticScoringParameters this_ptr_conv;
41479         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41480         this_ptr_conv.is_owned = false;
41481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41482         ProbabilisticScoringParameters_set_amount_penalty_multiplier_msat(&this_ptr_conv, val);
41483 }
41484
41485 uint32_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_new"))) TS_ProbabilisticScoringParameters_new(int64_t base_penalty_msat_arg, int64_t liquidity_penalty_multiplier_msat_arg, int64_t liquidity_offset_half_life_arg, int64_t amount_penalty_multiplier_msat_arg) {
41486         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_new(base_penalty_msat_arg, liquidity_penalty_multiplier_msat_arg, liquidity_offset_half_life_arg, amount_penalty_multiplier_msat_arg);
41487         uint32_t ret_ref = 0;
41488         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41489         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41490         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41491         ret_ref = (uintptr_t)ret_var.inner;
41492         if (ret_var.is_owned) {
41493                 ret_ref |= 1;
41494         }
41495         return ret_ref;
41496 }
41497
41498 static inline uintptr_t ProbabilisticScoringParameters_clone_ptr(LDKProbabilisticScoringParameters *NONNULL_PTR arg) {
41499         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(arg);
41500 uint32_t ret_ref = 0;
41501 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41502 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41503 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41504 ret_ref = (uintptr_t)ret_var.inner;
41505 if (ret_var.is_owned) {
41506         ret_ref |= 1;
41507 }
41508         return ret_ref;
41509 }
41510 uint32_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_clone_ptr"))) TS_ProbabilisticScoringParameters_clone_ptr(uint32_t arg) {
41511         LDKProbabilisticScoringParameters arg_conv;
41512         arg_conv.inner = (void*)(arg & (~1));
41513         arg_conv.is_owned = false;
41514         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41515         uint32_t ret_conv = ProbabilisticScoringParameters_clone_ptr(&arg_conv);
41516         return ret_conv;
41517 }
41518
41519 uint32_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_clone"))) TS_ProbabilisticScoringParameters_clone(uint32_t orig) {
41520         LDKProbabilisticScoringParameters orig_conv;
41521         orig_conv.inner = (void*)(orig & (~1));
41522         orig_conv.is_owned = false;
41523         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41524         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(&orig_conv);
41525         uint32_t ret_ref = 0;
41526         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41527         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41528         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41529         ret_ref = (uintptr_t)ret_var.inner;
41530         if (ret_var.is_owned) {
41531                 ret_ref |= 1;
41532         }
41533         return ret_ref;
41534 }
41535
41536 uint32_t  __attribute__((export_name("TS_ProbabilisticScorer_new"))) TS_ProbabilisticScorer_new(uint32_t params, uint32_t network_graph, uint32_t logger) {
41537         LDKProbabilisticScoringParameters params_conv;
41538         params_conv.inner = (void*)(params & (~1));
41539         params_conv.is_owned = (params & 1) || (params == 0);
41540         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
41541         params_conv = ProbabilisticScoringParameters_clone(&params_conv);
41542         LDKNetworkGraph network_graph_conv;
41543         network_graph_conv.inner = (void*)(network_graph & (~1));
41544         network_graph_conv.is_owned = false;
41545         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
41546         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
41547         CHECK_ACCESS(logger_ptr);
41548         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
41549         if (logger_conv.free == LDKLogger_JCalls_free) {
41550                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41551                 LDKLogger_JCalls_cloned(&logger_conv);
41552         }
41553         LDKProbabilisticScorer ret_var = ProbabilisticScorer_new(params_conv, &network_graph_conv, logger_conv);
41554         uint32_t ret_ref = 0;
41555         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41556         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41557         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41558         ret_ref = (uintptr_t)ret_var.inner;
41559         if (ret_var.is_owned) {
41560                 ret_ref |= 1;
41561         }
41562         return ret_ref;
41563 }
41564
41565 void  __attribute__((export_name("TS_ProbabilisticScorer_debug_log_liquidity_stats"))) TS_ProbabilisticScorer_debug_log_liquidity_stats(uint32_t this_arg) {
41566         LDKProbabilisticScorer this_arg_conv;
41567         this_arg_conv.inner = (void*)(this_arg & (~1));
41568         this_arg_conv.is_owned = false;
41569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41570         ProbabilisticScorer_debug_log_liquidity_stats(&this_arg_conv);
41571 }
41572
41573 uint32_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_default"))) TS_ProbabilisticScoringParameters_default() {
41574         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_default();
41575         uint32_t ret_ref = 0;
41576         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41577         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41578         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41579         ret_ref = (uintptr_t)ret_var.inner;
41580         if (ret_var.is_owned) {
41581                 ret_ref |= 1;
41582         }
41583         return ret_ref;
41584 }
41585
41586 uint32_t  __attribute__((export_name("TS_ProbabilisticScorer_as_Score"))) TS_ProbabilisticScorer_as_Score(uint32_t this_arg) {
41587         LDKProbabilisticScorer this_arg_conv;
41588         this_arg_conv.inner = (void*)(this_arg & (~1));
41589         this_arg_conv.is_owned = false;
41590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41591         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
41592         *ret_ret = ProbabilisticScorer_as_Score(&this_arg_conv);
41593         return (uint32_t)ret_ret;
41594 }
41595
41596 int8_tArray  __attribute__((export_name("TS_ProbabilisticScorer_write"))) TS_ProbabilisticScorer_write(uint32_t obj) {
41597         LDKProbabilisticScorer obj_conv;
41598         obj_conv.inner = (void*)(obj & (~1));
41599         obj_conv.is_owned = false;
41600         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41601         LDKCVec_u8Z ret_var = ProbabilisticScorer_write(&obj_conv);
41602         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
41603         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
41604         CVec_u8Z_free(ret_var);
41605         return ret_arr;
41606 }
41607
41608 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) {
41609         LDKu8slice ser_ref;
41610         ser_ref.datalen = ser->arr_len;
41611         ser_ref.data = ser->elems /* XXX ser leaks */;
41612         LDKProbabilisticScoringParameters arg_a_conv;
41613         arg_a_conv.inner = (void*)(arg_a & (~1));
41614         arg_a_conv.is_owned = (arg_a & 1) || (arg_a == 0);
41615         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_a_conv);
41616         arg_a_conv = ProbabilisticScoringParameters_clone(&arg_a_conv);
41617         LDKNetworkGraph arg_b_conv;
41618         arg_b_conv.inner = (void*)(arg_b & (~1));
41619         arg_b_conv.is_owned = false;
41620         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_b_conv);
41621         void* arg_c_ptr = (void*)(((uintptr_t)arg_c) & ~1);
41622         CHECK_ACCESS(arg_c_ptr);
41623         LDKLogger arg_c_conv = *(LDKLogger*)(arg_c_ptr);
41624         if (arg_c_conv.free == LDKLogger_JCalls_free) {
41625                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41626                 LDKLogger_JCalls_cloned(&arg_c_conv);
41627         }
41628         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
41629         *ret_conv = ProbabilisticScorer_read(ser_ref, arg_a_conv, &arg_b_conv, arg_c_conv);
41630         return (uint32_t)ret_conv;
41631 }
41632
41633 void  __attribute__((export_name("TS_ParseError_free"))) TS_ParseError_free(uint32_t this_ptr) {
41634         if ((this_ptr & 1) != 0) return;
41635         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
41636         CHECK_ACCESS(this_ptr_ptr);
41637         LDKParseError this_ptr_conv = *(LDKParseError*)(this_ptr_ptr);
41638         FREE((void*)this_ptr);
41639         ParseError_free(this_ptr_conv);
41640 }
41641
41642 static inline uintptr_t ParseError_clone_ptr(LDKParseError *NONNULL_PTR arg) {
41643         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
41644         *ret_copy = ParseError_clone(arg);
41645 uint32_t ret_ref = (uintptr_t)ret_copy;
41646         return ret_ref;
41647 }
41648 uint32_t  __attribute__((export_name("TS_ParseError_clone_ptr"))) TS_ParseError_clone_ptr(uint32_t arg) {
41649         LDKParseError* arg_conv = (LDKParseError*)arg;
41650         uint32_t ret_conv = ParseError_clone_ptr(arg_conv);
41651         return ret_conv;
41652 }
41653
41654 uint32_t  __attribute__((export_name("TS_ParseError_clone"))) TS_ParseError_clone(uint32_t orig) {
41655         LDKParseError* orig_conv = (LDKParseError*)orig;
41656         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
41657         *ret_copy = ParseError_clone(orig_conv);
41658         uint32_t ret_ref = (uintptr_t)ret_copy;
41659         return ret_ref;
41660 }
41661
41662 uint32_t  __attribute__((export_name("TS_ParseError_bech32_error"))) TS_ParseError_bech32_error(uint32_t a) {
41663         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
41664         CHECK_ACCESS(a_ptr);
41665         LDKBech32Error a_conv = *(LDKBech32Error*)(a_ptr);
41666         a_conv = Bech32Error_clone((LDKBech32Error*)(((uintptr_t)a) & ~1));
41667         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
41668         *ret_copy = ParseError_bech32_error(a_conv);
41669         uint32_t ret_ref = (uintptr_t)ret_copy;
41670         return ret_ref;
41671 }
41672
41673 uint32_t  __attribute__((export_name("TS_ParseError_parse_amount_error"))) TS_ParseError_parse_amount_error(int32_t a) {
41674         
41675         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
41676         *ret_copy = ParseError_parse_amount_error((LDKError){ ._dummy = 0 });
41677         uint32_t ret_ref = (uintptr_t)ret_copy;
41678         return ret_ref;
41679 }
41680
41681 uint32_t  __attribute__((export_name("TS_ParseError_malformed_signature"))) TS_ParseError_malformed_signature(uint32_t a) {
41682         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_js(a);
41683         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
41684         *ret_copy = ParseError_malformed_signature(a_conv);
41685         uint32_t ret_ref = (uintptr_t)ret_copy;
41686         return ret_ref;
41687 }
41688
41689 uint32_t  __attribute__((export_name("TS_ParseError_bad_prefix"))) TS_ParseError_bad_prefix() {
41690         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
41691         *ret_copy = ParseError_bad_prefix();
41692         uint32_t ret_ref = (uintptr_t)ret_copy;
41693         return ret_ref;
41694 }
41695
41696 uint32_t  __attribute__((export_name("TS_ParseError_unknown_currency"))) TS_ParseError_unknown_currency() {
41697         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
41698         *ret_copy = ParseError_unknown_currency();
41699         uint32_t ret_ref = (uintptr_t)ret_copy;
41700         return ret_ref;
41701 }
41702
41703 uint32_t  __attribute__((export_name("TS_ParseError_unknown_si_prefix"))) TS_ParseError_unknown_si_prefix() {
41704         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
41705         *ret_copy = ParseError_unknown_si_prefix();
41706         uint32_t ret_ref = (uintptr_t)ret_copy;
41707         return ret_ref;
41708 }
41709
41710 uint32_t  __attribute__((export_name("TS_ParseError_malformed_hrp"))) TS_ParseError_malformed_hrp() {
41711         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
41712         *ret_copy = ParseError_malformed_hrp();
41713         uint32_t ret_ref = (uintptr_t)ret_copy;
41714         return ret_ref;
41715 }
41716
41717 uint32_t  __attribute__((export_name("TS_ParseError_too_short_data_part"))) TS_ParseError_too_short_data_part() {
41718         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
41719         *ret_copy = ParseError_too_short_data_part();
41720         uint32_t ret_ref = (uintptr_t)ret_copy;
41721         return ret_ref;
41722 }
41723
41724 uint32_t  __attribute__((export_name("TS_ParseError_unexpected_end_of_tagged_fields"))) TS_ParseError_unexpected_end_of_tagged_fields() {
41725         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
41726         *ret_copy = ParseError_unexpected_end_of_tagged_fields();
41727         uint32_t ret_ref = (uintptr_t)ret_copy;
41728         return ret_ref;
41729 }
41730
41731 uint32_t  __attribute__((export_name("TS_ParseError_description_decode_error"))) TS_ParseError_description_decode_error(int32_t a) {
41732         
41733         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
41734         *ret_copy = ParseError_description_decode_error((LDKError){ ._dummy = 0 });
41735         uint32_t ret_ref = (uintptr_t)ret_copy;
41736         return ret_ref;
41737 }
41738
41739 uint32_t  __attribute__((export_name("TS_ParseError_padding_error"))) TS_ParseError_padding_error() {
41740         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
41741         *ret_copy = ParseError_padding_error();
41742         uint32_t ret_ref = (uintptr_t)ret_copy;
41743         return ret_ref;
41744 }
41745
41746 uint32_t  __attribute__((export_name("TS_ParseError_integer_overflow_error"))) TS_ParseError_integer_overflow_error() {
41747         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
41748         *ret_copy = ParseError_integer_overflow_error();
41749         uint32_t ret_ref = (uintptr_t)ret_copy;
41750         return ret_ref;
41751 }
41752
41753 uint32_t  __attribute__((export_name("TS_ParseError_invalid_seg_wit_program_length"))) TS_ParseError_invalid_seg_wit_program_length() {
41754         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
41755         *ret_copy = ParseError_invalid_seg_wit_program_length();
41756         uint32_t ret_ref = (uintptr_t)ret_copy;
41757         return ret_ref;
41758 }
41759
41760 uint32_t  __attribute__((export_name("TS_ParseError_invalid_pub_key_hash_length"))) TS_ParseError_invalid_pub_key_hash_length() {
41761         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
41762         *ret_copy = ParseError_invalid_pub_key_hash_length();
41763         uint32_t ret_ref = (uintptr_t)ret_copy;
41764         return ret_ref;
41765 }
41766
41767 uint32_t  __attribute__((export_name("TS_ParseError_invalid_script_hash_length"))) TS_ParseError_invalid_script_hash_length() {
41768         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
41769         *ret_copy = ParseError_invalid_script_hash_length();
41770         uint32_t ret_ref = (uintptr_t)ret_copy;
41771         return ret_ref;
41772 }
41773
41774 uint32_t  __attribute__((export_name("TS_ParseError_invalid_recovery_id"))) TS_ParseError_invalid_recovery_id() {
41775         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
41776         *ret_copy = ParseError_invalid_recovery_id();
41777         uint32_t ret_ref = (uintptr_t)ret_copy;
41778         return ret_ref;
41779 }
41780
41781 uint32_t  __attribute__((export_name("TS_ParseError_invalid_slice_length"))) TS_ParseError_invalid_slice_length(jstring a) {
41782         LDKStr a_conv = str_ref_to_owned_c(a);
41783         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
41784         *ret_copy = ParseError_invalid_slice_length(a_conv);
41785         uint32_t ret_ref = (uintptr_t)ret_copy;
41786         return ret_ref;
41787 }
41788
41789 uint32_t  __attribute__((export_name("TS_ParseError_skip"))) TS_ParseError_skip() {
41790         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
41791         *ret_copy = ParseError_skip();
41792         uint32_t ret_ref = (uintptr_t)ret_copy;
41793         return ret_ref;
41794 }
41795
41796 void  __attribute__((export_name("TS_ParseOrSemanticError_free"))) TS_ParseOrSemanticError_free(uint32_t this_ptr) {
41797         if ((this_ptr & 1) != 0) return;
41798         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
41799         CHECK_ACCESS(this_ptr_ptr);
41800         LDKParseOrSemanticError this_ptr_conv = *(LDKParseOrSemanticError*)(this_ptr_ptr);
41801         FREE((void*)this_ptr);
41802         ParseOrSemanticError_free(this_ptr_conv);
41803 }
41804
41805 static inline uintptr_t ParseOrSemanticError_clone_ptr(LDKParseOrSemanticError *NONNULL_PTR arg) {
41806         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
41807         *ret_copy = ParseOrSemanticError_clone(arg);
41808 uint32_t ret_ref = (uintptr_t)ret_copy;
41809         return ret_ref;
41810 }
41811 uint32_t  __attribute__((export_name("TS_ParseOrSemanticError_clone_ptr"))) TS_ParseOrSemanticError_clone_ptr(uint32_t arg) {
41812         LDKParseOrSemanticError* arg_conv = (LDKParseOrSemanticError*)arg;
41813         uint32_t ret_conv = ParseOrSemanticError_clone_ptr(arg_conv);
41814         return ret_conv;
41815 }
41816
41817 uint32_t  __attribute__((export_name("TS_ParseOrSemanticError_clone"))) TS_ParseOrSemanticError_clone(uint32_t orig) {
41818         LDKParseOrSemanticError* orig_conv = (LDKParseOrSemanticError*)orig;
41819         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
41820         *ret_copy = ParseOrSemanticError_clone(orig_conv);
41821         uint32_t ret_ref = (uintptr_t)ret_copy;
41822         return ret_ref;
41823 }
41824
41825 uint32_t  __attribute__((export_name("TS_ParseOrSemanticError_parse_error"))) TS_ParseOrSemanticError_parse_error(uint32_t a) {
41826         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
41827         CHECK_ACCESS(a_ptr);
41828         LDKParseError a_conv = *(LDKParseError*)(a_ptr);
41829         a_conv = ParseError_clone((LDKParseError*)(((uintptr_t)a) & ~1));
41830         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
41831         *ret_copy = ParseOrSemanticError_parse_error(a_conv);
41832         uint32_t ret_ref = (uintptr_t)ret_copy;
41833         return ret_ref;
41834 }
41835
41836 uint32_t  __attribute__((export_name("TS_ParseOrSemanticError_semantic_error"))) TS_ParseOrSemanticError_semantic_error(uint32_t a) {
41837         LDKSemanticError a_conv = LDKSemanticError_from_js(a);
41838         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
41839         *ret_copy = ParseOrSemanticError_semantic_error(a_conv);
41840         uint32_t ret_ref = (uintptr_t)ret_copy;
41841         return ret_ref;
41842 }
41843
41844 void  __attribute__((export_name("TS_Invoice_free"))) TS_Invoice_free(uint32_t this_obj) {
41845         LDKInvoice this_obj_conv;
41846         this_obj_conv.inner = (void*)(this_obj & (~1));
41847         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41849         Invoice_free(this_obj_conv);
41850 }
41851
41852 jboolean  __attribute__((export_name("TS_Invoice_eq"))) TS_Invoice_eq(uint32_t a, uint32_t b) {
41853         LDKInvoice a_conv;
41854         a_conv.inner = (void*)(a & (~1));
41855         a_conv.is_owned = false;
41856         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41857         LDKInvoice b_conv;
41858         b_conv.inner = (void*)(b & (~1));
41859         b_conv.is_owned = false;
41860         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41861         jboolean ret_conv = Invoice_eq(&a_conv, &b_conv);
41862         return ret_conv;
41863 }
41864
41865 static inline uintptr_t Invoice_clone_ptr(LDKInvoice *NONNULL_PTR arg) {
41866         LDKInvoice ret_var = Invoice_clone(arg);
41867 uint32_t ret_ref = 0;
41868 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41869 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41870 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41871 ret_ref = (uintptr_t)ret_var.inner;
41872 if (ret_var.is_owned) {
41873         ret_ref |= 1;
41874 }
41875         return ret_ref;
41876 }
41877 uint32_t  __attribute__((export_name("TS_Invoice_clone_ptr"))) TS_Invoice_clone_ptr(uint32_t arg) {
41878         LDKInvoice arg_conv;
41879         arg_conv.inner = (void*)(arg & (~1));
41880         arg_conv.is_owned = false;
41881         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41882         uint32_t ret_conv = Invoice_clone_ptr(&arg_conv);
41883         return ret_conv;
41884 }
41885
41886 uint32_t  __attribute__((export_name("TS_Invoice_clone"))) TS_Invoice_clone(uint32_t orig) {
41887         LDKInvoice orig_conv;
41888         orig_conv.inner = (void*)(orig & (~1));
41889         orig_conv.is_owned = false;
41890         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41891         LDKInvoice ret_var = Invoice_clone(&orig_conv);
41892         uint32_t ret_ref = 0;
41893         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41894         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41895         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41896         ret_ref = (uintptr_t)ret_var.inner;
41897         if (ret_var.is_owned) {
41898                 ret_ref |= 1;
41899         }
41900         return ret_ref;
41901 }
41902
41903 void  __attribute__((export_name("TS_SignedRawInvoice_free"))) TS_SignedRawInvoice_free(uint32_t this_obj) {
41904         LDKSignedRawInvoice this_obj_conv;
41905         this_obj_conv.inner = (void*)(this_obj & (~1));
41906         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41908         SignedRawInvoice_free(this_obj_conv);
41909 }
41910
41911 jboolean  __attribute__((export_name("TS_SignedRawInvoice_eq"))) TS_SignedRawInvoice_eq(uint32_t a, uint32_t b) {
41912         LDKSignedRawInvoice a_conv;
41913         a_conv.inner = (void*)(a & (~1));
41914         a_conv.is_owned = false;
41915         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41916         LDKSignedRawInvoice b_conv;
41917         b_conv.inner = (void*)(b & (~1));
41918         b_conv.is_owned = false;
41919         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41920         jboolean ret_conv = SignedRawInvoice_eq(&a_conv, &b_conv);
41921         return ret_conv;
41922 }
41923
41924 static inline uintptr_t SignedRawInvoice_clone_ptr(LDKSignedRawInvoice *NONNULL_PTR arg) {
41925         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(arg);
41926 uint32_t ret_ref = 0;
41927 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41928 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41929 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41930 ret_ref = (uintptr_t)ret_var.inner;
41931 if (ret_var.is_owned) {
41932         ret_ref |= 1;
41933 }
41934         return ret_ref;
41935 }
41936 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_clone_ptr"))) TS_SignedRawInvoice_clone_ptr(uint32_t arg) {
41937         LDKSignedRawInvoice arg_conv;
41938         arg_conv.inner = (void*)(arg & (~1));
41939         arg_conv.is_owned = false;
41940         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41941         uint32_t ret_conv = SignedRawInvoice_clone_ptr(&arg_conv);
41942         return ret_conv;
41943 }
41944
41945 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_clone"))) TS_SignedRawInvoice_clone(uint32_t orig) {
41946         LDKSignedRawInvoice orig_conv;
41947         orig_conv.inner = (void*)(orig & (~1));
41948         orig_conv.is_owned = false;
41949         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41950         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
41951         uint32_t ret_ref = 0;
41952         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41953         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41954         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41955         ret_ref = (uintptr_t)ret_var.inner;
41956         if (ret_var.is_owned) {
41957                 ret_ref |= 1;
41958         }
41959         return ret_ref;
41960 }
41961
41962 void  __attribute__((export_name("TS_RawInvoice_free"))) TS_RawInvoice_free(uint32_t this_obj) {
41963         LDKRawInvoice this_obj_conv;
41964         this_obj_conv.inner = (void*)(this_obj & (~1));
41965         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41967         RawInvoice_free(this_obj_conv);
41968 }
41969
41970 uint32_t  __attribute__((export_name("TS_RawInvoice_get_data"))) TS_RawInvoice_get_data(uint32_t this_ptr) {
41971         LDKRawInvoice this_ptr_conv;
41972         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41973         this_ptr_conv.is_owned = false;
41974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41975         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
41976         uint32_t ret_ref = 0;
41977         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41978         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41979         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41980         ret_ref = (uintptr_t)ret_var.inner;
41981         if (ret_var.is_owned) {
41982                 ret_ref |= 1;
41983         }
41984         return ret_ref;
41985 }
41986
41987 void  __attribute__((export_name("TS_RawInvoice_set_data"))) TS_RawInvoice_set_data(uint32_t this_ptr, uint32_t val) {
41988         LDKRawInvoice this_ptr_conv;
41989         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41990         this_ptr_conv.is_owned = false;
41991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41992         LDKRawDataPart val_conv;
41993         val_conv.inner = (void*)(val & (~1));
41994         val_conv.is_owned = (val & 1) || (val == 0);
41995         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
41996         val_conv = RawDataPart_clone(&val_conv);
41997         RawInvoice_set_data(&this_ptr_conv, val_conv);
41998 }
41999
42000 jboolean  __attribute__((export_name("TS_RawInvoice_eq"))) TS_RawInvoice_eq(uint32_t a, uint32_t b) {
42001         LDKRawInvoice a_conv;
42002         a_conv.inner = (void*)(a & (~1));
42003         a_conv.is_owned = false;
42004         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42005         LDKRawInvoice b_conv;
42006         b_conv.inner = (void*)(b & (~1));
42007         b_conv.is_owned = false;
42008         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42009         jboolean ret_conv = RawInvoice_eq(&a_conv, &b_conv);
42010         return ret_conv;
42011 }
42012
42013 static inline uintptr_t RawInvoice_clone_ptr(LDKRawInvoice *NONNULL_PTR arg) {
42014         LDKRawInvoice ret_var = RawInvoice_clone(arg);
42015 uint32_t ret_ref = 0;
42016 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42017 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42018 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42019 ret_ref = (uintptr_t)ret_var.inner;
42020 if (ret_var.is_owned) {
42021         ret_ref |= 1;
42022 }
42023         return ret_ref;
42024 }
42025 uint32_t  __attribute__((export_name("TS_RawInvoice_clone_ptr"))) TS_RawInvoice_clone_ptr(uint32_t arg) {
42026         LDKRawInvoice arg_conv;
42027         arg_conv.inner = (void*)(arg & (~1));
42028         arg_conv.is_owned = false;
42029         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42030         uint32_t ret_conv = RawInvoice_clone_ptr(&arg_conv);
42031         return ret_conv;
42032 }
42033
42034 uint32_t  __attribute__((export_name("TS_RawInvoice_clone"))) TS_RawInvoice_clone(uint32_t orig) {
42035         LDKRawInvoice orig_conv;
42036         orig_conv.inner = (void*)(orig & (~1));
42037         orig_conv.is_owned = false;
42038         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42039         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
42040         uint32_t ret_ref = 0;
42041         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42042         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42043         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42044         ret_ref = (uintptr_t)ret_var.inner;
42045         if (ret_var.is_owned) {
42046                 ret_ref |= 1;
42047         }
42048         return ret_ref;
42049 }
42050
42051 void  __attribute__((export_name("TS_RawDataPart_free"))) TS_RawDataPart_free(uint32_t this_obj) {
42052         LDKRawDataPart this_obj_conv;
42053         this_obj_conv.inner = (void*)(this_obj & (~1));
42054         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42056         RawDataPart_free(this_obj_conv);
42057 }
42058
42059 uint32_t  __attribute__((export_name("TS_RawDataPart_get_timestamp"))) TS_RawDataPart_get_timestamp(uint32_t this_ptr) {
42060         LDKRawDataPart this_ptr_conv;
42061         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42062         this_ptr_conv.is_owned = false;
42063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42064         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
42065         uint32_t ret_ref = 0;
42066         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42067         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42068         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42069         ret_ref = (uintptr_t)ret_var.inner;
42070         if (ret_var.is_owned) {
42071                 ret_ref |= 1;
42072         }
42073         return ret_ref;
42074 }
42075
42076 void  __attribute__((export_name("TS_RawDataPart_set_timestamp"))) TS_RawDataPart_set_timestamp(uint32_t this_ptr, uint32_t val) {
42077         LDKRawDataPart 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         LDKPositiveTimestamp val_conv;
42082         val_conv.inner = (void*)(val & (~1));
42083         val_conv.is_owned = (val & 1) || (val == 0);
42084         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42085         val_conv = PositiveTimestamp_clone(&val_conv);
42086         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
42087 }
42088
42089 jboolean  __attribute__((export_name("TS_RawDataPart_eq"))) TS_RawDataPart_eq(uint32_t a, uint32_t b) {
42090         LDKRawDataPart a_conv;
42091         a_conv.inner = (void*)(a & (~1));
42092         a_conv.is_owned = false;
42093         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42094         LDKRawDataPart b_conv;
42095         b_conv.inner = (void*)(b & (~1));
42096         b_conv.is_owned = false;
42097         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42098         jboolean ret_conv = RawDataPart_eq(&a_conv, &b_conv);
42099         return ret_conv;
42100 }
42101
42102 static inline uintptr_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
42103         LDKRawDataPart ret_var = RawDataPart_clone(arg);
42104 uint32_t ret_ref = 0;
42105 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42106 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42107 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42108 ret_ref = (uintptr_t)ret_var.inner;
42109 if (ret_var.is_owned) {
42110         ret_ref |= 1;
42111 }
42112         return ret_ref;
42113 }
42114 uint32_t  __attribute__((export_name("TS_RawDataPart_clone_ptr"))) TS_RawDataPart_clone_ptr(uint32_t arg) {
42115         LDKRawDataPart arg_conv;
42116         arg_conv.inner = (void*)(arg & (~1));
42117         arg_conv.is_owned = false;
42118         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42119         uint32_t ret_conv = RawDataPart_clone_ptr(&arg_conv);
42120         return ret_conv;
42121 }
42122
42123 uint32_t  __attribute__((export_name("TS_RawDataPart_clone"))) TS_RawDataPart_clone(uint32_t orig) {
42124         LDKRawDataPart orig_conv;
42125         orig_conv.inner = (void*)(orig & (~1));
42126         orig_conv.is_owned = false;
42127         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42128         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
42129         uint32_t ret_ref = 0;
42130         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42131         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42132         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42133         ret_ref = (uintptr_t)ret_var.inner;
42134         if (ret_var.is_owned) {
42135                 ret_ref |= 1;
42136         }
42137         return ret_ref;
42138 }
42139
42140 void  __attribute__((export_name("TS_PositiveTimestamp_free"))) TS_PositiveTimestamp_free(uint32_t this_obj) {
42141         LDKPositiveTimestamp this_obj_conv;
42142         this_obj_conv.inner = (void*)(this_obj & (~1));
42143         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42145         PositiveTimestamp_free(this_obj_conv);
42146 }
42147
42148 jboolean  __attribute__((export_name("TS_PositiveTimestamp_eq"))) TS_PositiveTimestamp_eq(uint32_t a, uint32_t b) {
42149         LDKPositiveTimestamp a_conv;
42150         a_conv.inner = (void*)(a & (~1));
42151         a_conv.is_owned = false;
42152         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42153         LDKPositiveTimestamp b_conv;
42154         b_conv.inner = (void*)(b & (~1));
42155         b_conv.is_owned = false;
42156         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42157         jboolean ret_conv = PositiveTimestamp_eq(&a_conv, &b_conv);
42158         return ret_conv;
42159 }
42160
42161 static inline uintptr_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
42162         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
42163 uint32_t ret_ref = 0;
42164 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42165 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42166 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42167 ret_ref = (uintptr_t)ret_var.inner;
42168 if (ret_var.is_owned) {
42169         ret_ref |= 1;
42170 }
42171         return ret_ref;
42172 }
42173 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_clone_ptr"))) TS_PositiveTimestamp_clone_ptr(uint32_t arg) {
42174         LDKPositiveTimestamp arg_conv;
42175         arg_conv.inner = (void*)(arg & (~1));
42176         arg_conv.is_owned = false;
42177         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42178         uint32_t ret_conv = PositiveTimestamp_clone_ptr(&arg_conv);
42179         return ret_conv;
42180 }
42181
42182 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_clone"))) TS_PositiveTimestamp_clone(uint32_t orig) {
42183         LDKPositiveTimestamp orig_conv;
42184         orig_conv.inner = (void*)(orig & (~1));
42185         orig_conv.is_owned = false;
42186         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42187         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
42188         uint32_t ret_ref = 0;
42189         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42190         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42191         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42192         ret_ref = (uintptr_t)ret_var.inner;
42193         if (ret_var.is_owned) {
42194                 ret_ref |= 1;
42195         }
42196         return ret_ref;
42197 }
42198
42199 uint32_t  __attribute__((export_name("TS_SiPrefix_clone"))) TS_SiPrefix_clone(uint32_t orig) {
42200         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
42201         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_clone(orig_conv));
42202         return ret_conv;
42203 }
42204
42205 uint32_t  __attribute__((export_name("TS_SiPrefix_milli"))) TS_SiPrefix_milli() {
42206         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_milli());
42207         return ret_conv;
42208 }
42209
42210 uint32_t  __attribute__((export_name("TS_SiPrefix_micro"))) TS_SiPrefix_micro() {
42211         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_micro());
42212         return ret_conv;
42213 }
42214
42215 uint32_t  __attribute__((export_name("TS_SiPrefix_nano"))) TS_SiPrefix_nano() {
42216         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_nano());
42217         return ret_conv;
42218 }
42219
42220 uint32_t  __attribute__((export_name("TS_SiPrefix_pico"))) TS_SiPrefix_pico() {
42221         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_pico());
42222         return ret_conv;
42223 }
42224
42225 jboolean  __attribute__((export_name("TS_SiPrefix_eq"))) TS_SiPrefix_eq(uint32_t a, uint32_t b) {
42226         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
42227         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
42228         jboolean ret_conv = SiPrefix_eq(a_conv, b_conv);
42229         return ret_conv;
42230 }
42231
42232 int64_t  __attribute__((export_name("TS_SiPrefix_multiplier"))) TS_SiPrefix_multiplier(uint32_t this_arg) {
42233         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
42234         int64_t ret_conv = SiPrefix_multiplier(this_arg_conv);
42235         return ret_conv;
42236 }
42237
42238 uint32_t  __attribute__((export_name("TS_Currency_clone"))) TS_Currency_clone(uint32_t orig) {
42239         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
42240         uint32_t ret_conv = LDKCurrency_to_js(Currency_clone(orig_conv));
42241         return ret_conv;
42242 }
42243
42244 uint32_t  __attribute__((export_name("TS_Currency_bitcoin"))) TS_Currency_bitcoin() {
42245         uint32_t ret_conv = LDKCurrency_to_js(Currency_bitcoin());
42246         return ret_conv;
42247 }
42248
42249 uint32_t  __attribute__((export_name("TS_Currency_bitcoin_testnet"))) TS_Currency_bitcoin_testnet() {
42250         uint32_t ret_conv = LDKCurrency_to_js(Currency_bitcoin_testnet());
42251         return ret_conv;
42252 }
42253
42254 uint32_t  __attribute__((export_name("TS_Currency_regtest"))) TS_Currency_regtest() {
42255         uint32_t ret_conv = LDKCurrency_to_js(Currency_regtest());
42256         return ret_conv;
42257 }
42258
42259 uint32_t  __attribute__((export_name("TS_Currency_simnet"))) TS_Currency_simnet() {
42260         uint32_t ret_conv = LDKCurrency_to_js(Currency_simnet());
42261         return ret_conv;
42262 }
42263
42264 uint32_t  __attribute__((export_name("TS_Currency_signet"))) TS_Currency_signet() {
42265         uint32_t ret_conv = LDKCurrency_to_js(Currency_signet());
42266         return ret_conv;
42267 }
42268
42269 int64_t  __attribute__((export_name("TS_Currency_hash"))) TS_Currency_hash(uint32_t o) {
42270         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
42271         int64_t ret_conv = Currency_hash(o_conv);
42272         return ret_conv;
42273 }
42274
42275 jboolean  __attribute__((export_name("TS_Currency_eq"))) TS_Currency_eq(uint32_t a, uint32_t b) {
42276         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
42277         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
42278         jboolean ret_conv = Currency_eq(a_conv, b_conv);
42279         return ret_conv;
42280 }
42281
42282 void  __attribute__((export_name("TS_Sha256_free"))) TS_Sha256_free(uint32_t this_obj) {
42283         LDKSha256 this_obj_conv;
42284         this_obj_conv.inner = (void*)(this_obj & (~1));
42285         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42287         Sha256_free(this_obj_conv);
42288 }
42289
42290 static inline uintptr_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
42291         LDKSha256 ret_var = Sha256_clone(arg);
42292 uint32_t ret_ref = 0;
42293 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42294 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42295 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42296 ret_ref = (uintptr_t)ret_var.inner;
42297 if (ret_var.is_owned) {
42298         ret_ref |= 1;
42299 }
42300         return ret_ref;
42301 }
42302 uint32_t  __attribute__((export_name("TS_Sha256_clone_ptr"))) TS_Sha256_clone_ptr(uint32_t arg) {
42303         LDKSha256 arg_conv;
42304         arg_conv.inner = (void*)(arg & (~1));
42305         arg_conv.is_owned = false;
42306         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42307         uint32_t ret_conv = Sha256_clone_ptr(&arg_conv);
42308         return ret_conv;
42309 }
42310
42311 uint32_t  __attribute__((export_name("TS_Sha256_clone"))) TS_Sha256_clone(uint32_t orig) {
42312         LDKSha256 orig_conv;
42313         orig_conv.inner = (void*)(orig & (~1));
42314         orig_conv.is_owned = false;
42315         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42316         LDKSha256 ret_var = Sha256_clone(&orig_conv);
42317         uint32_t ret_ref = 0;
42318         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42319         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42320         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42321         ret_ref = (uintptr_t)ret_var.inner;
42322         if (ret_var.is_owned) {
42323                 ret_ref |= 1;
42324         }
42325         return ret_ref;
42326 }
42327
42328 int64_t  __attribute__((export_name("TS_Sha256_hash"))) TS_Sha256_hash(uint32_t o) {
42329         LDKSha256 o_conv;
42330         o_conv.inner = (void*)(o & (~1));
42331         o_conv.is_owned = false;
42332         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42333         int64_t ret_conv = Sha256_hash(&o_conv);
42334         return ret_conv;
42335 }
42336
42337 jboolean  __attribute__((export_name("TS_Sha256_eq"))) TS_Sha256_eq(uint32_t a, uint32_t b) {
42338         LDKSha256 a_conv;
42339         a_conv.inner = (void*)(a & (~1));
42340         a_conv.is_owned = false;
42341         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42342         LDKSha256 b_conv;
42343         b_conv.inner = (void*)(b & (~1));
42344         b_conv.is_owned = false;
42345         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42346         jboolean ret_conv = Sha256_eq(&a_conv, &b_conv);
42347         return ret_conv;
42348 }
42349
42350 void  __attribute__((export_name("TS_Description_free"))) TS_Description_free(uint32_t this_obj) {
42351         LDKDescription this_obj_conv;
42352         this_obj_conv.inner = (void*)(this_obj & (~1));
42353         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42355         Description_free(this_obj_conv);
42356 }
42357
42358 static inline uintptr_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
42359         LDKDescription ret_var = Description_clone(arg);
42360 uint32_t ret_ref = 0;
42361 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42362 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42363 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42364 ret_ref = (uintptr_t)ret_var.inner;
42365 if (ret_var.is_owned) {
42366         ret_ref |= 1;
42367 }
42368         return ret_ref;
42369 }
42370 uint32_t  __attribute__((export_name("TS_Description_clone_ptr"))) TS_Description_clone_ptr(uint32_t arg) {
42371         LDKDescription arg_conv;
42372         arg_conv.inner = (void*)(arg & (~1));
42373         arg_conv.is_owned = false;
42374         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42375         uint32_t ret_conv = Description_clone_ptr(&arg_conv);
42376         return ret_conv;
42377 }
42378
42379 uint32_t  __attribute__((export_name("TS_Description_clone"))) TS_Description_clone(uint32_t orig) {
42380         LDKDescription orig_conv;
42381         orig_conv.inner = (void*)(orig & (~1));
42382         orig_conv.is_owned = false;
42383         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42384         LDKDescription ret_var = Description_clone(&orig_conv);
42385         uint32_t ret_ref = 0;
42386         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42387         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42388         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42389         ret_ref = (uintptr_t)ret_var.inner;
42390         if (ret_var.is_owned) {
42391                 ret_ref |= 1;
42392         }
42393         return ret_ref;
42394 }
42395
42396 int64_t  __attribute__((export_name("TS_Description_hash"))) TS_Description_hash(uint32_t o) {
42397         LDKDescription o_conv;
42398         o_conv.inner = (void*)(o & (~1));
42399         o_conv.is_owned = false;
42400         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42401         int64_t ret_conv = Description_hash(&o_conv);
42402         return ret_conv;
42403 }
42404
42405 jboolean  __attribute__((export_name("TS_Description_eq"))) TS_Description_eq(uint32_t a, uint32_t b) {
42406         LDKDescription a_conv;
42407         a_conv.inner = (void*)(a & (~1));
42408         a_conv.is_owned = false;
42409         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42410         LDKDescription b_conv;
42411         b_conv.inner = (void*)(b & (~1));
42412         b_conv.is_owned = false;
42413         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42414         jboolean ret_conv = Description_eq(&a_conv, &b_conv);
42415         return ret_conv;
42416 }
42417
42418 void  __attribute__((export_name("TS_PayeePubKey_free"))) TS_PayeePubKey_free(uint32_t this_obj) {
42419         LDKPayeePubKey this_obj_conv;
42420         this_obj_conv.inner = (void*)(this_obj & (~1));
42421         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42423         PayeePubKey_free(this_obj_conv);
42424 }
42425
42426 int8_tArray  __attribute__((export_name("TS_PayeePubKey_get_a"))) TS_PayeePubKey_get_a(uint32_t this_ptr) {
42427         LDKPayeePubKey this_ptr_conv;
42428         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42429         this_ptr_conv.is_owned = false;
42430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42431         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
42432         memcpy(ret_arr->elems, PayeePubKey_get_a(&this_ptr_conv).compressed_form, 33);
42433         return ret_arr;
42434 }
42435
42436 void  __attribute__((export_name("TS_PayeePubKey_set_a"))) TS_PayeePubKey_set_a(uint32_t this_ptr, int8_tArray val) {
42437         LDKPayeePubKey this_ptr_conv;
42438         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42439         this_ptr_conv.is_owned = false;
42440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42441         LDKPublicKey val_ref;
42442         CHECK(val->arr_len == 33);
42443         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
42444         PayeePubKey_set_a(&this_ptr_conv, val_ref);
42445 }
42446
42447 uint32_t  __attribute__((export_name("TS_PayeePubKey_new"))) TS_PayeePubKey_new(int8_tArray a_arg) {
42448         LDKPublicKey a_arg_ref;
42449         CHECK(a_arg->arr_len == 33);
42450         memcpy(a_arg_ref.compressed_form, a_arg->elems, 33); FREE(a_arg);
42451         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
42452         uint32_t ret_ref = 0;
42453         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42454         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42455         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42456         ret_ref = (uintptr_t)ret_var.inner;
42457         if (ret_var.is_owned) {
42458                 ret_ref |= 1;
42459         }
42460         return ret_ref;
42461 }
42462
42463 static inline uintptr_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
42464         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
42465 uint32_t ret_ref = 0;
42466 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42467 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42468 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42469 ret_ref = (uintptr_t)ret_var.inner;
42470 if (ret_var.is_owned) {
42471         ret_ref |= 1;
42472 }
42473         return ret_ref;
42474 }
42475 uint32_t  __attribute__((export_name("TS_PayeePubKey_clone_ptr"))) TS_PayeePubKey_clone_ptr(uint32_t arg) {
42476         LDKPayeePubKey arg_conv;
42477         arg_conv.inner = (void*)(arg & (~1));
42478         arg_conv.is_owned = false;
42479         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42480         uint32_t ret_conv = PayeePubKey_clone_ptr(&arg_conv);
42481         return ret_conv;
42482 }
42483
42484 uint32_t  __attribute__((export_name("TS_PayeePubKey_clone"))) TS_PayeePubKey_clone(uint32_t orig) {
42485         LDKPayeePubKey orig_conv;
42486         orig_conv.inner = (void*)(orig & (~1));
42487         orig_conv.is_owned = false;
42488         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42489         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
42490         uint32_t ret_ref = 0;
42491         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42492         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42493         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42494         ret_ref = (uintptr_t)ret_var.inner;
42495         if (ret_var.is_owned) {
42496                 ret_ref |= 1;
42497         }
42498         return ret_ref;
42499 }
42500
42501 int64_t  __attribute__((export_name("TS_PayeePubKey_hash"))) TS_PayeePubKey_hash(uint32_t o) {
42502         LDKPayeePubKey o_conv;
42503         o_conv.inner = (void*)(o & (~1));
42504         o_conv.is_owned = false;
42505         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42506         int64_t ret_conv = PayeePubKey_hash(&o_conv);
42507         return ret_conv;
42508 }
42509
42510 jboolean  __attribute__((export_name("TS_PayeePubKey_eq"))) TS_PayeePubKey_eq(uint32_t a, uint32_t b) {
42511         LDKPayeePubKey a_conv;
42512         a_conv.inner = (void*)(a & (~1));
42513         a_conv.is_owned = false;
42514         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42515         LDKPayeePubKey b_conv;
42516         b_conv.inner = (void*)(b & (~1));
42517         b_conv.is_owned = false;
42518         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42519         jboolean ret_conv = PayeePubKey_eq(&a_conv, &b_conv);
42520         return ret_conv;
42521 }
42522
42523 void  __attribute__((export_name("TS_ExpiryTime_free"))) TS_ExpiryTime_free(uint32_t this_obj) {
42524         LDKExpiryTime this_obj_conv;
42525         this_obj_conv.inner = (void*)(this_obj & (~1));
42526         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42528         ExpiryTime_free(this_obj_conv);
42529 }
42530
42531 static inline uintptr_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
42532         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
42533 uint32_t ret_ref = 0;
42534 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42535 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42536 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42537 ret_ref = (uintptr_t)ret_var.inner;
42538 if (ret_var.is_owned) {
42539         ret_ref |= 1;
42540 }
42541         return ret_ref;
42542 }
42543 uint32_t  __attribute__((export_name("TS_ExpiryTime_clone_ptr"))) TS_ExpiryTime_clone_ptr(uint32_t arg) {
42544         LDKExpiryTime arg_conv;
42545         arg_conv.inner = (void*)(arg & (~1));
42546         arg_conv.is_owned = false;
42547         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42548         uint32_t ret_conv = ExpiryTime_clone_ptr(&arg_conv);
42549         return ret_conv;
42550 }
42551
42552 uint32_t  __attribute__((export_name("TS_ExpiryTime_clone"))) TS_ExpiryTime_clone(uint32_t orig) {
42553         LDKExpiryTime orig_conv;
42554         orig_conv.inner = (void*)(orig & (~1));
42555         orig_conv.is_owned = false;
42556         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42557         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
42558         uint32_t ret_ref = 0;
42559         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42560         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42561         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42562         ret_ref = (uintptr_t)ret_var.inner;
42563         if (ret_var.is_owned) {
42564                 ret_ref |= 1;
42565         }
42566         return ret_ref;
42567 }
42568
42569 int64_t  __attribute__((export_name("TS_ExpiryTime_hash"))) TS_ExpiryTime_hash(uint32_t o) {
42570         LDKExpiryTime o_conv;
42571         o_conv.inner = (void*)(o & (~1));
42572         o_conv.is_owned = false;
42573         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42574         int64_t ret_conv = ExpiryTime_hash(&o_conv);
42575         return ret_conv;
42576 }
42577
42578 jboolean  __attribute__((export_name("TS_ExpiryTime_eq"))) TS_ExpiryTime_eq(uint32_t a, uint32_t b) {
42579         LDKExpiryTime a_conv;
42580         a_conv.inner = (void*)(a & (~1));
42581         a_conv.is_owned = false;
42582         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42583         LDKExpiryTime b_conv;
42584         b_conv.inner = (void*)(b & (~1));
42585         b_conv.is_owned = false;
42586         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42587         jboolean ret_conv = ExpiryTime_eq(&a_conv, &b_conv);
42588         return ret_conv;
42589 }
42590
42591 void  __attribute__((export_name("TS_MinFinalCltvExpiry_free"))) TS_MinFinalCltvExpiry_free(uint32_t this_obj) {
42592         LDKMinFinalCltvExpiry this_obj_conv;
42593         this_obj_conv.inner = (void*)(this_obj & (~1));
42594         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42596         MinFinalCltvExpiry_free(this_obj_conv);
42597 }
42598
42599 int64_t  __attribute__((export_name("TS_MinFinalCltvExpiry_get_a"))) TS_MinFinalCltvExpiry_get_a(uint32_t this_ptr) {
42600         LDKMinFinalCltvExpiry 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         int64_t ret_conv = MinFinalCltvExpiry_get_a(&this_ptr_conv);
42605         return ret_conv;
42606 }
42607
42608 void  __attribute__((export_name("TS_MinFinalCltvExpiry_set_a"))) TS_MinFinalCltvExpiry_set_a(uint32_t this_ptr, int64_t val) {
42609         LDKMinFinalCltvExpiry this_ptr_conv;
42610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
42611         this_ptr_conv.is_owned = false;
42612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42613         MinFinalCltvExpiry_set_a(&this_ptr_conv, val);
42614 }
42615
42616 uint32_t  __attribute__((export_name("TS_MinFinalCltvExpiry_new"))) TS_MinFinalCltvExpiry_new(int64_t a_arg) {
42617         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_new(a_arg);
42618         uint32_t ret_ref = 0;
42619         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42620         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42621         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42622         ret_ref = (uintptr_t)ret_var.inner;
42623         if (ret_var.is_owned) {
42624                 ret_ref |= 1;
42625         }
42626         return ret_ref;
42627 }
42628
42629 static inline uintptr_t MinFinalCltvExpiry_clone_ptr(LDKMinFinalCltvExpiry *NONNULL_PTR arg) {
42630         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(arg);
42631 uint32_t ret_ref = 0;
42632 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42633 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42634 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42635 ret_ref = (uintptr_t)ret_var.inner;
42636 if (ret_var.is_owned) {
42637         ret_ref |= 1;
42638 }
42639         return ret_ref;
42640 }
42641 uint32_t  __attribute__((export_name("TS_MinFinalCltvExpiry_clone_ptr"))) TS_MinFinalCltvExpiry_clone_ptr(uint32_t arg) {
42642         LDKMinFinalCltvExpiry arg_conv;
42643         arg_conv.inner = (void*)(arg & (~1));
42644         arg_conv.is_owned = false;
42645         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42646         uint32_t ret_conv = MinFinalCltvExpiry_clone_ptr(&arg_conv);
42647         return ret_conv;
42648 }
42649
42650 uint32_t  __attribute__((export_name("TS_MinFinalCltvExpiry_clone"))) TS_MinFinalCltvExpiry_clone(uint32_t orig) {
42651         LDKMinFinalCltvExpiry orig_conv;
42652         orig_conv.inner = (void*)(orig & (~1));
42653         orig_conv.is_owned = false;
42654         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42655         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
42656         uint32_t ret_ref = 0;
42657         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42658         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42659         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42660         ret_ref = (uintptr_t)ret_var.inner;
42661         if (ret_var.is_owned) {
42662                 ret_ref |= 1;
42663         }
42664         return ret_ref;
42665 }
42666
42667 int64_t  __attribute__((export_name("TS_MinFinalCltvExpiry_hash"))) TS_MinFinalCltvExpiry_hash(uint32_t o) {
42668         LDKMinFinalCltvExpiry o_conv;
42669         o_conv.inner = (void*)(o & (~1));
42670         o_conv.is_owned = false;
42671         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42672         int64_t ret_conv = MinFinalCltvExpiry_hash(&o_conv);
42673         return ret_conv;
42674 }
42675
42676 jboolean  __attribute__((export_name("TS_MinFinalCltvExpiry_eq"))) TS_MinFinalCltvExpiry_eq(uint32_t a, uint32_t b) {
42677         LDKMinFinalCltvExpiry a_conv;
42678         a_conv.inner = (void*)(a & (~1));
42679         a_conv.is_owned = false;
42680         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42681         LDKMinFinalCltvExpiry b_conv;
42682         b_conv.inner = (void*)(b & (~1));
42683         b_conv.is_owned = false;
42684         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42685         jboolean ret_conv = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
42686         return ret_conv;
42687 }
42688
42689 void  __attribute__((export_name("TS_Fallback_free"))) TS_Fallback_free(uint32_t this_ptr) {
42690         if ((this_ptr & 1) != 0) return;
42691         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
42692         CHECK_ACCESS(this_ptr_ptr);
42693         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
42694         FREE((void*)this_ptr);
42695         Fallback_free(this_ptr_conv);
42696 }
42697
42698 static inline uintptr_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
42699         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
42700         *ret_copy = Fallback_clone(arg);
42701 uint32_t ret_ref = (uintptr_t)ret_copy;
42702         return ret_ref;
42703 }
42704 uint32_t  __attribute__((export_name("TS_Fallback_clone_ptr"))) TS_Fallback_clone_ptr(uint32_t arg) {
42705         LDKFallback* arg_conv = (LDKFallback*)arg;
42706         uint32_t ret_conv = Fallback_clone_ptr(arg_conv);
42707         return ret_conv;
42708 }
42709
42710 uint32_t  __attribute__((export_name("TS_Fallback_clone"))) TS_Fallback_clone(uint32_t orig) {
42711         LDKFallback* orig_conv = (LDKFallback*)orig;
42712         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
42713         *ret_copy = Fallback_clone(orig_conv);
42714         uint32_t ret_ref = (uintptr_t)ret_copy;
42715         return ret_ref;
42716 }
42717
42718 uint32_t  __attribute__((export_name("TS_Fallback_seg_wit_program"))) TS_Fallback_seg_wit_program(int8_t version, int8_tArray program) {
42719         
42720         LDKCVec_u8Z program_ref;
42721         program_ref.datalen = program->arr_len;
42722         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
42723         memcpy(program_ref.data, program->elems, program_ref.datalen); FREE(program);
42724         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
42725         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
42726         uint32_t ret_ref = (uintptr_t)ret_copy;
42727         return ret_ref;
42728 }
42729
42730 uint32_t  __attribute__((export_name("TS_Fallback_pub_key_hash"))) TS_Fallback_pub_key_hash(int8_tArray a) {
42731         LDKTwentyBytes a_ref;
42732         CHECK(a->arr_len == 20);
42733         memcpy(a_ref.data, a->elems, 20); FREE(a);
42734         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
42735         *ret_copy = Fallback_pub_key_hash(a_ref);
42736         uint32_t ret_ref = (uintptr_t)ret_copy;
42737         return ret_ref;
42738 }
42739
42740 uint32_t  __attribute__((export_name("TS_Fallback_script_hash"))) TS_Fallback_script_hash(int8_tArray a) {
42741         LDKTwentyBytes a_ref;
42742         CHECK(a->arr_len == 20);
42743         memcpy(a_ref.data, a->elems, 20); FREE(a);
42744         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
42745         *ret_copy = Fallback_script_hash(a_ref);
42746         uint32_t ret_ref = (uintptr_t)ret_copy;
42747         return ret_ref;
42748 }
42749
42750 int64_t  __attribute__((export_name("TS_Fallback_hash"))) TS_Fallback_hash(uint32_t o) {
42751         LDKFallback* o_conv = (LDKFallback*)o;
42752         int64_t ret_conv = Fallback_hash(o_conv);
42753         return ret_conv;
42754 }
42755
42756 jboolean  __attribute__((export_name("TS_Fallback_eq"))) TS_Fallback_eq(uint32_t a, uint32_t b) {
42757         LDKFallback* a_conv = (LDKFallback*)a;
42758         LDKFallback* b_conv = (LDKFallback*)b;
42759         jboolean ret_conv = Fallback_eq(a_conv, b_conv);
42760         return ret_conv;
42761 }
42762
42763 void  __attribute__((export_name("TS_InvoiceSignature_free"))) TS_InvoiceSignature_free(uint32_t this_obj) {
42764         LDKInvoiceSignature this_obj_conv;
42765         this_obj_conv.inner = (void*)(this_obj & (~1));
42766         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42768         InvoiceSignature_free(this_obj_conv);
42769 }
42770
42771 static inline uintptr_t InvoiceSignature_clone_ptr(LDKInvoiceSignature *NONNULL_PTR arg) {
42772         LDKInvoiceSignature ret_var = InvoiceSignature_clone(arg);
42773 uint32_t ret_ref = 0;
42774 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42775 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42776 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42777 ret_ref = (uintptr_t)ret_var.inner;
42778 if (ret_var.is_owned) {
42779         ret_ref |= 1;
42780 }
42781         return ret_ref;
42782 }
42783 uint32_t  __attribute__((export_name("TS_InvoiceSignature_clone_ptr"))) TS_InvoiceSignature_clone_ptr(uint32_t arg) {
42784         LDKInvoiceSignature arg_conv;
42785         arg_conv.inner = (void*)(arg & (~1));
42786         arg_conv.is_owned = false;
42787         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42788         uint32_t ret_conv = InvoiceSignature_clone_ptr(&arg_conv);
42789         return ret_conv;
42790 }
42791
42792 uint32_t  __attribute__((export_name("TS_InvoiceSignature_clone"))) TS_InvoiceSignature_clone(uint32_t orig) {
42793         LDKInvoiceSignature orig_conv;
42794         orig_conv.inner = (void*)(orig & (~1));
42795         orig_conv.is_owned = false;
42796         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42797         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
42798         uint32_t ret_ref = 0;
42799         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42800         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42801         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42802         ret_ref = (uintptr_t)ret_var.inner;
42803         if (ret_var.is_owned) {
42804                 ret_ref |= 1;
42805         }
42806         return ret_ref;
42807 }
42808
42809 jboolean  __attribute__((export_name("TS_InvoiceSignature_eq"))) TS_InvoiceSignature_eq(uint32_t a, uint32_t b) {
42810         LDKInvoiceSignature a_conv;
42811         a_conv.inner = (void*)(a & (~1));
42812         a_conv.is_owned = false;
42813         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42814         LDKInvoiceSignature b_conv;
42815         b_conv.inner = (void*)(b & (~1));
42816         b_conv.is_owned = false;
42817         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42818         jboolean ret_conv = InvoiceSignature_eq(&a_conv, &b_conv);
42819         return ret_conv;
42820 }
42821
42822 void  __attribute__((export_name("TS_PrivateRoute_free"))) TS_PrivateRoute_free(uint32_t this_obj) {
42823         LDKPrivateRoute this_obj_conv;
42824         this_obj_conv.inner = (void*)(this_obj & (~1));
42825         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42827         PrivateRoute_free(this_obj_conv);
42828 }
42829
42830 static inline uintptr_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
42831         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
42832 uint32_t ret_ref = 0;
42833 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42834 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42835 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42836 ret_ref = (uintptr_t)ret_var.inner;
42837 if (ret_var.is_owned) {
42838         ret_ref |= 1;
42839 }
42840         return ret_ref;
42841 }
42842 uint32_t  __attribute__((export_name("TS_PrivateRoute_clone_ptr"))) TS_PrivateRoute_clone_ptr(uint32_t arg) {
42843         LDKPrivateRoute arg_conv;
42844         arg_conv.inner = (void*)(arg & (~1));
42845         arg_conv.is_owned = false;
42846         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42847         uint32_t ret_conv = PrivateRoute_clone_ptr(&arg_conv);
42848         return ret_conv;
42849 }
42850
42851 uint32_t  __attribute__((export_name("TS_PrivateRoute_clone"))) TS_PrivateRoute_clone(uint32_t orig) {
42852         LDKPrivateRoute orig_conv;
42853         orig_conv.inner = (void*)(orig & (~1));
42854         orig_conv.is_owned = false;
42855         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42856         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
42857         uint32_t ret_ref = 0;
42858         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42859         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42860         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42861         ret_ref = (uintptr_t)ret_var.inner;
42862         if (ret_var.is_owned) {
42863                 ret_ref |= 1;
42864         }
42865         return ret_ref;
42866 }
42867
42868 int64_t  __attribute__((export_name("TS_PrivateRoute_hash"))) TS_PrivateRoute_hash(uint32_t o) {
42869         LDKPrivateRoute o_conv;
42870         o_conv.inner = (void*)(o & (~1));
42871         o_conv.is_owned = false;
42872         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42873         int64_t ret_conv = PrivateRoute_hash(&o_conv);
42874         return ret_conv;
42875 }
42876
42877 jboolean  __attribute__((export_name("TS_PrivateRoute_eq"))) TS_PrivateRoute_eq(uint32_t a, uint32_t b) {
42878         LDKPrivateRoute a_conv;
42879         a_conv.inner = (void*)(a & (~1));
42880         a_conv.is_owned = false;
42881         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42882         LDKPrivateRoute b_conv;
42883         b_conv.inner = (void*)(b & (~1));
42884         b_conv.is_owned = false;
42885         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42886         jboolean ret_conv = PrivateRoute_eq(&a_conv, &b_conv);
42887         return ret_conv;
42888 }
42889
42890 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_into_parts"))) TS_SignedRawInvoice_into_parts(uint32_t this_arg) {
42891         LDKSignedRawInvoice this_arg_conv;
42892         this_arg_conv.inner = (void*)(this_arg & (~1));
42893         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
42894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42895         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
42896         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
42897         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
42898         return ((uint32_t)ret_conv);
42899 }
42900
42901 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_raw_invoice"))) TS_SignedRawInvoice_raw_invoice(uint32_t this_arg) {
42902         LDKSignedRawInvoice this_arg_conv;
42903         this_arg_conv.inner = (void*)(this_arg & (~1));
42904         this_arg_conv.is_owned = false;
42905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42906         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
42907         uint32_t ret_ref = 0;
42908         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42909         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42910         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42911         ret_ref = (uintptr_t)ret_var.inner;
42912         if (ret_var.is_owned) {
42913                 ret_ref |= 1;
42914         }
42915         return ret_ref;
42916 }
42917
42918 int8_tArray  __attribute__((export_name("TS_SignedRawInvoice_hash"))) TS_SignedRawInvoice_hash(uint32_t this_arg) {
42919         LDKSignedRawInvoice this_arg_conv;
42920         this_arg_conv.inner = (void*)(this_arg & (~1));
42921         this_arg_conv.is_owned = false;
42922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42923         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
42924         memcpy(ret_arr->elems, *SignedRawInvoice_hash(&this_arg_conv), 32);
42925         return ret_arr;
42926 }
42927
42928 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_signature"))) TS_SignedRawInvoice_signature(uint32_t this_arg) {
42929         LDKSignedRawInvoice this_arg_conv;
42930         this_arg_conv.inner = (void*)(this_arg & (~1));
42931         this_arg_conv.is_owned = false;
42932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42933         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
42934         uint32_t ret_ref = 0;
42935         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42936         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42937         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42938         ret_ref = (uintptr_t)ret_var.inner;
42939         if (ret_var.is_owned) {
42940                 ret_ref |= 1;
42941         }
42942         return ret_ref;
42943 }
42944
42945 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_recover_payee_pub_key"))) TS_SignedRawInvoice_recover_payee_pub_key(uint32_t this_arg) {
42946         LDKSignedRawInvoice this_arg_conv;
42947         this_arg_conv.inner = (void*)(this_arg & (~1));
42948         this_arg_conv.is_owned = false;
42949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42950         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
42951         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
42952         return (uint32_t)ret_conv;
42953 }
42954
42955 jboolean  __attribute__((export_name("TS_SignedRawInvoice_check_signature"))) TS_SignedRawInvoice_check_signature(uint32_t this_arg) {
42956         LDKSignedRawInvoice this_arg_conv;
42957         this_arg_conv.inner = (void*)(this_arg & (~1));
42958         this_arg_conv.is_owned = false;
42959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42960         jboolean ret_conv = SignedRawInvoice_check_signature(&this_arg_conv);
42961         return ret_conv;
42962 }
42963
42964 int8_tArray  __attribute__((export_name("TS_RawInvoice_hash"))) TS_RawInvoice_hash(uint32_t this_arg) {
42965         LDKRawInvoice this_arg_conv;
42966         this_arg_conv.inner = (void*)(this_arg & (~1));
42967         this_arg_conv.is_owned = false;
42968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42969         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
42970         memcpy(ret_arr->elems, RawInvoice_hash(&this_arg_conv).data, 32);
42971         return ret_arr;
42972 }
42973
42974 uint32_t  __attribute__((export_name("TS_RawInvoice_payment_hash"))) TS_RawInvoice_payment_hash(uint32_t this_arg) {
42975         LDKRawInvoice this_arg_conv;
42976         this_arg_conv.inner = (void*)(this_arg & (~1));
42977         this_arg_conv.is_owned = false;
42978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42979         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
42980         uint32_t ret_ref = 0;
42981         if ((uintptr_t)ret_var.inner > 4096) {
42982                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42983                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42984         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42985                 ret_ref = (uintptr_t)ret_var.inner;
42986                 if (ret_var.is_owned) {
42987                         ret_ref |= 1;
42988                 }
42989         }
42990         return ret_ref;
42991 }
42992
42993 uint32_t  __attribute__((export_name("TS_RawInvoice_description"))) TS_RawInvoice_description(uint32_t this_arg) {
42994         LDKRawInvoice this_arg_conv;
42995         this_arg_conv.inner = (void*)(this_arg & (~1));
42996         this_arg_conv.is_owned = false;
42997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42998         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
42999         uint32_t ret_ref = 0;
43000         if ((uintptr_t)ret_var.inner > 4096) {
43001                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43002                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43003         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43004                 ret_ref = (uintptr_t)ret_var.inner;
43005                 if (ret_var.is_owned) {
43006                         ret_ref |= 1;
43007                 }
43008         }
43009         return ret_ref;
43010 }
43011
43012 uint32_t  __attribute__((export_name("TS_RawInvoice_payee_pub_key"))) TS_RawInvoice_payee_pub_key(uint32_t this_arg) {
43013         LDKRawInvoice this_arg_conv;
43014         this_arg_conv.inner = (void*)(this_arg & (~1));
43015         this_arg_conv.is_owned = false;
43016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43017         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
43018         uint32_t ret_ref = 0;
43019         if ((uintptr_t)ret_var.inner > 4096) {
43020                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43021                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43022         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43023                 ret_ref = (uintptr_t)ret_var.inner;
43024                 if (ret_var.is_owned) {
43025                         ret_ref |= 1;
43026                 }
43027         }
43028         return ret_ref;
43029 }
43030
43031 uint32_t  __attribute__((export_name("TS_RawInvoice_description_hash"))) TS_RawInvoice_description_hash(uint32_t this_arg) {
43032         LDKRawInvoice this_arg_conv;
43033         this_arg_conv.inner = (void*)(this_arg & (~1));
43034         this_arg_conv.is_owned = false;
43035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43036         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
43037         uint32_t ret_ref = 0;
43038         if ((uintptr_t)ret_var.inner > 4096) {
43039                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43040                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43041         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43042                 ret_ref = (uintptr_t)ret_var.inner;
43043                 if (ret_var.is_owned) {
43044                         ret_ref |= 1;
43045                 }
43046         }
43047         return ret_ref;
43048 }
43049
43050 uint32_t  __attribute__((export_name("TS_RawInvoice_expiry_time"))) TS_RawInvoice_expiry_time(uint32_t this_arg) {
43051         LDKRawInvoice this_arg_conv;
43052         this_arg_conv.inner = (void*)(this_arg & (~1));
43053         this_arg_conv.is_owned = false;
43054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43055         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
43056         uint32_t ret_ref = 0;
43057         if ((uintptr_t)ret_var.inner > 4096) {
43058                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43059                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43060         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43061                 ret_ref = (uintptr_t)ret_var.inner;
43062                 if (ret_var.is_owned) {
43063                         ret_ref |= 1;
43064                 }
43065         }
43066         return ret_ref;
43067 }
43068
43069 uint32_t  __attribute__((export_name("TS_RawInvoice_min_final_cltv_expiry"))) TS_RawInvoice_min_final_cltv_expiry(uint32_t this_arg) {
43070         LDKRawInvoice this_arg_conv;
43071         this_arg_conv.inner = (void*)(this_arg & (~1));
43072         this_arg_conv.is_owned = false;
43073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43074         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
43075         uint32_t ret_ref = 0;
43076         if ((uintptr_t)ret_var.inner > 4096) {
43077                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43078                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43079         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43080                 ret_ref = (uintptr_t)ret_var.inner;
43081                 if (ret_var.is_owned) {
43082                         ret_ref |= 1;
43083                 }
43084         }
43085         return ret_ref;
43086 }
43087
43088 int8_tArray  __attribute__((export_name("TS_RawInvoice_payment_secret"))) TS_RawInvoice_payment_secret(uint32_t this_arg) {
43089         LDKRawInvoice this_arg_conv;
43090         this_arg_conv.inner = (void*)(this_arg & (~1));
43091         this_arg_conv.is_owned = false;
43092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43093         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
43094         memcpy(ret_arr->elems, RawInvoice_payment_secret(&this_arg_conv).data, 32);
43095         return ret_arr;
43096 }
43097
43098 uint32_t  __attribute__((export_name("TS_RawInvoice_features"))) TS_RawInvoice_features(uint32_t this_arg) {
43099         LDKRawInvoice this_arg_conv;
43100         this_arg_conv.inner = (void*)(this_arg & (~1));
43101         this_arg_conv.is_owned = false;
43102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43103         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
43104         uint32_t ret_ref = 0;
43105         if ((uintptr_t)ret_var.inner > 4096) {
43106                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43107                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43108         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43109                 ret_ref = (uintptr_t)ret_var.inner;
43110                 if (ret_var.is_owned) {
43111                         ret_ref |= 1;
43112                 }
43113         }
43114         return ret_ref;
43115 }
43116
43117 uint32_tArray  __attribute__((export_name("TS_RawInvoice_private_routes"))) TS_RawInvoice_private_routes(uint32_t this_arg) {
43118         LDKRawInvoice this_arg_conv;
43119         this_arg_conv.inner = (void*)(this_arg & (~1));
43120         this_arg_conv.is_owned = false;
43121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43122         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
43123         uint32_tArray ret_arr = NULL;
43124         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
43125         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
43126         for (size_t o = 0; o < ret_var.datalen; o++) {
43127                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
43128                 uint32_t ret_conv_14_ref = 0;
43129                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43130                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43131                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
43132                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
43133                 if (ret_conv_14_var.is_owned) {
43134                         ret_conv_14_ref |= 1;
43135                 }
43136                 ret_arr_ptr[o] = ret_conv_14_ref;
43137         }
43138         
43139         FREE(ret_var.data);
43140         return ret_arr;
43141 }
43142
43143 uint32_t  __attribute__((export_name("TS_RawInvoice_amount_pico_btc"))) TS_RawInvoice_amount_pico_btc(uint32_t this_arg) {
43144         LDKRawInvoice this_arg_conv;
43145         this_arg_conv.inner = (void*)(this_arg & (~1));
43146         this_arg_conv.is_owned = false;
43147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43148         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
43149         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
43150         uint32_t ret_ref = (uintptr_t)ret_copy;
43151         return ret_ref;
43152 }
43153
43154 uint32_t  __attribute__((export_name("TS_RawInvoice_currency"))) TS_RawInvoice_currency(uint32_t this_arg) {
43155         LDKRawInvoice this_arg_conv;
43156         this_arg_conv.inner = (void*)(this_arg & (~1));
43157         this_arg_conv.is_owned = false;
43158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43159         uint32_t ret_conv = LDKCurrency_to_js(RawInvoice_currency(&this_arg_conv));
43160         return ret_conv;
43161 }
43162
43163 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_from_unix_timestamp"))) TS_PositiveTimestamp_from_unix_timestamp(int64_t unix_seconds) {
43164         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
43165         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
43166         return (uint32_t)ret_conv;
43167 }
43168
43169 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_from_duration_since_epoch"))) TS_PositiveTimestamp_from_duration_since_epoch(int64_t duration) {
43170         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
43171         *ret_conv = PositiveTimestamp_from_duration_since_epoch(duration);
43172         return (uint32_t)ret_conv;
43173 }
43174
43175 int64_t  __attribute__((export_name("TS_PositiveTimestamp_as_unix_timestamp"))) TS_PositiveTimestamp_as_unix_timestamp(uint32_t this_arg) {
43176         LDKPositiveTimestamp this_arg_conv;
43177         this_arg_conv.inner = (void*)(this_arg & (~1));
43178         this_arg_conv.is_owned = false;
43179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43180         int64_t ret_conv = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
43181         return ret_conv;
43182 }
43183
43184 int64_t  __attribute__((export_name("TS_PositiveTimestamp_as_duration_since_epoch"))) TS_PositiveTimestamp_as_duration_since_epoch(uint32_t this_arg) {
43185         LDKPositiveTimestamp this_arg_conv;
43186         this_arg_conv.inner = (void*)(this_arg & (~1));
43187         this_arg_conv.is_owned = false;
43188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43189         int64_t ret_conv = PositiveTimestamp_as_duration_since_epoch(&this_arg_conv);
43190         return ret_conv;
43191 }
43192
43193 uint32_t  __attribute__((export_name("TS_Invoice_into_signed_raw"))) TS_Invoice_into_signed_raw(uint32_t this_arg) {
43194         LDKInvoice this_arg_conv;
43195         this_arg_conv.inner = (void*)(this_arg & (~1));
43196         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
43197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43198         this_arg_conv = Invoice_clone(&this_arg_conv);
43199         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
43200         uint32_t ret_ref = 0;
43201         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43202         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43203         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43204         ret_ref = (uintptr_t)ret_var.inner;
43205         if (ret_var.is_owned) {
43206                 ret_ref |= 1;
43207         }
43208         return ret_ref;
43209 }
43210
43211 uint32_t  __attribute__((export_name("TS_Invoice_check_signature"))) TS_Invoice_check_signature(uint32_t this_arg) {
43212         LDKInvoice this_arg_conv;
43213         this_arg_conv.inner = (void*)(this_arg & (~1));
43214         this_arg_conv.is_owned = false;
43215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43216         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
43217         *ret_conv = Invoice_check_signature(&this_arg_conv);
43218         return (uint32_t)ret_conv;
43219 }
43220
43221 uint32_t  __attribute__((export_name("TS_Invoice_from_signed"))) TS_Invoice_from_signed(uint32_t signed_invoice) {
43222         LDKSignedRawInvoice signed_invoice_conv;
43223         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
43224         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
43225         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
43226         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
43227         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
43228         *ret_conv = Invoice_from_signed(signed_invoice_conv);
43229         return (uint32_t)ret_conv;
43230 }
43231
43232 int64_t  __attribute__((export_name("TS_Invoice_duration_since_epoch"))) TS_Invoice_duration_since_epoch(uint32_t this_arg) {
43233         LDKInvoice this_arg_conv;
43234         this_arg_conv.inner = (void*)(this_arg & (~1));
43235         this_arg_conv.is_owned = false;
43236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43237         int64_t ret_conv = Invoice_duration_since_epoch(&this_arg_conv);
43238         return ret_conv;
43239 }
43240
43241 int8_tArray  __attribute__((export_name("TS_Invoice_payment_hash"))) TS_Invoice_payment_hash(uint32_t this_arg) {
43242         LDKInvoice this_arg_conv;
43243         this_arg_conv.inner = (void*)(this_arg & (~1));
43244         this_arg_conv.is_owned = false;
43245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43246         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
43247         memcpy(ret_arr->elems, *Invoice_payment_hash(&this_arg_conv), 32);
43248         return ret_arr;
43249 }
43250
43251 int8_tArray  __attribute__((export_name("TS_Invoice_payee_pub_key"))) TS_Invoice_payee_pub_key(uint32_t this_arg) {
43252         LDKInvoice this_arg_conv;
43253         this_arg_conv.inner = (void*)(this_arg & (~1));
43254         this_arg_conv.is_owned = false;
43255         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43256         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
43257         memcpy(ret_arr->elems, Invoice_payee_pub_key(&this_arg_conv).compressed_form, 33);
43258         return ret_arr;
43259 }
43260
43261 int8_tArray  __attribute__((export_name("TS_Invoice_payment_secret"))) TS_Invoice_payment_secret(uint32_t this_arg) {
43262         LDKInvoice this_arg_conv;
43263         this_arg_conv.inner = (void*)(this_arg & (~1));
43264         this_arg_conv.is_owned = false;
43265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43266         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
43267         memcpy(ret_arr->elems, *Invoice_payment_secret(&this_arg_conv), 32);
43268         return ret_arr;
43269 }
43270
43271 uint32_t  __attribute__((export_name("TS_Invoice_features"))) TS_Invoice_features(uint32_t this_arg) {
43272         LDKInvoice this_arg_conv;
43273         this_arg_conv.inner = (void*)(this_arg & (~1));
43274         this_arg_conv.is_owned = false;
43275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43276         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
43277         uint32_t ret_ref = 0;
43278         if ((uintptr_t)ret_var.inner > 4096) {
43279                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43280                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43281         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43282                 ret_ref = (uintptr_t)ret_var.inner;
43283                 if (ret_var.is_owned) {
43284                         ret_ref |= 1;
43285                 }
43286         }
43287         return ret_ref;
43288 }
43289
43290 int8_tArray  __attribute__((export_name("TS_Invoice_recover_payee_pub_key"))) TS_Invoice_recover_payee_pub_key(uint32_t this_arg) {
43291         LDKInvoice this_arg_conv;
43292         this_arg_conv.inner = (void*)(this_arg & (~1));
43293         this_arg_conv.is_owned = false;
43294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43295         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
43296         memcpy(ret_arr->elems, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form, 33);
43297         return ret_arr;
43298 }
43299
43300 int64_t  __attribute__((export_name("TS_Invoice_expiry_time"))) TS_Invoice_expiry_time(uint32_t this_arg) {
43301         LDKInvoice this_arg_conv;
43302         this_arg_conv.inner = (void*)(this_arg & (~1));
43303         this_arg_conv.is_owned = false;
43304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43305         int64_t ret_conv = Invoice_expiry_time(&this_arg_conv);
43306         return ret_conv;
43307 }
43308
43309 jboolean  __attribute__((export_name("TS_Invoice_would_expire"))) TS_Invoice_would_expire(uint32_t this_arg, int64_t at_time) {
43310         LDKInvoice this_arg_conv;
43311         this_arg_conv.inner = (void*)(this_arg & (~1));
43312         this_arg_conv.is_owned = false;
43313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43314         jboolean ret_conv = Invoice_would_expire(&this_arg_conv, at_time);
43315         return ret_conv;
43316 }
43317
43318 int64_t  __attribute__((export_name("TS_Invoice_min_final_cltv_expiry"))) TS_Invoice_min_final_cltv_expiry(uint32_t this_arg) {
43319         LDKInvoice this_arg_conv;
43320         this_arg_conv.inner = (void*)(this_arg & (~1));
43321         this_arg_conv.is_owned = false;
43322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43323         int64_t ret_conv = Invoice_min_final_cltv_expiry(&this_arg_conv);
43324         return ret_conv;
43325 }
43326
43327 uint32_tArray  __attribute__((export_name("TS_Invoice_private_routes"))) TS_Invoice_private_routes(uint32_t this_arg) {
43328         LDKInvoice this_arg_conv;
43329         this_arg_conv.inner = (void*)(this_arg & (~1));
43330         this_arg_conv.is_owned = false;
43331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43332         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
43333         uint32_tArray ret_arr = NULL;
43334         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
43335         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
43336         for (size_t o = 0; o < ret_var.datalen; o++) {
43337                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
43338                 uint32_t ret_conv_14_ref = 0;
43339                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43340                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43341                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
43342                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
43343                 if (ret_conv_14_var.is_owned) {
43344                         ret_conv_14_ref |= 1;
43345                 }
43346                 ret_arr_ptr[o] = ret_conv_14_ref;
43347         }
43348         
43349         FREE(ret_var.data);
43350         return ret_arr;
43351 }
43352
43353 uint32_tArray  __attribute__((export_name("TS_Invoice_route_hints"))) TS_Invoice_route_hints(uint32_t this_arg) {
43354         LDKInvoice this_arg_conv;
43355         this_arg_conv.inner = (void*)(this_arg & (~1));
43356         this_arg_conv.is_owned = false;
43357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43358         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
43359         uint32_tArray ret_arr = NULL;
43360         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
43361         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
43362         for (size_t l = 0; l < ret_var.datalen; l++) {
43363                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
43364                 uint32_t ret_conv_11_ref = 0;
43365                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43366                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43367                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
43368                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
43369                 if (ret_conv_11_var.is_owned) {
43370                         ret_conv_11_ref |= 1;
43371                 }
43372                 ret_arr_ptr[l] = ret_conv_11_ref;
43373         }
43374         
43375         FREE(ret_var.data);
43376         return ret_arr;
43377 }
43378
43379 uint32_t  __attribute__((export_name("TS_Invoice_currency"))) TS_Invoice_currency(uint32_t this_arg) {
43380         LDKInvoice this_arg_conv;
43381         this_arg_conv.inner = (void*)(this_arg & (~1));
43382         this_arg_conv.is_owned = false;
43383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43384         uint32_t ret_conv = LDKCurrency_to_js(Invoice_currency(&this_arg_conv));
43385         return ret_conv;
43386 }
43387
43388 uint32_t  __attribute__((export_name("TS_Invoice_amount_milli_satoshis"))) TS_Invoice_amount_milli_satoshis(uint32_t this_arg) {
43389         LDKInvoice this_arg_conv;
43390         this_arg_conv.inner = (void*)(this_arg & (~1));
43391         this_arg_conv.is_owned = false;
43392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43393         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
43394         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
43395         uint32_t ret_ref = (uintptr_t)ret_copy;
43396         return ret_ref;
43397 }
43398
43399 uint32_t  __attribute__((export_name("TS_Description_new"))) TS_Description_new(jstring description) {
43400         LDKStr description_conv = str_ref_to_owned_c(description);
43401         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
43402         *ret_conv = Description_new(description_conv);
43403         return (uint32_t)ret_conv;
43404 }
43405
43406 jstring  __attribute__((export_name("TS_Description_into_inner"))) TS_Description_into_inner(uint32_t this_arg) {
43407         LDKDescription this_arg_conv;
43408         this_arg_conv.inner = (void*)(this_arg & (~1));
43409         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
43410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43411         this_arg_conv = Description_clone(&this_arg_conv);
43412         LDKStr ret_str = Description_into_inner(this_arg_conv);
43413         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
43414         Str_free(ret_str);
43415         return ret_conv;
43416 }
43417
43418 uint32_t  __attribute__((export_name("TS_ExpiryTime_from_seconds"))) TS_ExpiryTime_from_seconds(int64_t seconds) {
43419         LDKExpiryTime ret_var = ExpiryTime_from_seconds(seconds);
43420         uint32_t ret_ref = 0;
43421         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43422         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43423         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43424         ret_ref = (uintptr_t)ret_var.inner;
43425         if (ret_var.is_owned) {
43426                 ret_ref |= 1;
43427         }
43428         return ret_ref;
43429 }
43430
43431 uint32_t  __attribute__((export_name("TS_ExpiryTime_from_duration"))) TS_ExpiryTime_from_duration(int64_t duration) {
43432         LDKExpiryTime ret_var = ExpiryTime_from_duration(duration);
43433         uint32_t ret_ref = 0;
43434         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43435         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43436         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43437         ret_ref = (uintptr_t)ret_var.inner;
43438         if (ret_var.is_owned) {
43439                 ret_ref |= 1;
43440         }
43441         return ret_ref;
43442 }
43443
43444 int64_t  __attribute__((export_name("TS_ExpiryTime_as_seconds"))) TS_ExpiryTime_as_seconds(uint32_t this_arg) {
43445         LDKExpiryTime this_arg_conv;
43446         this_arg_conv.inner = (void*)(this_arg & (~1));
43447         this_arg_conv.is_owned = false;
43448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43449         int64_t ret_conv = ExpiryTime_as_seconds(&this_arg_conv);
43450         return ret_conv;
43451 }
43452
43453 int64_t  __attribute__((export_name("TS_ExpiryTime_as_duration"))) TS_ExpiryTime_as_duration(uint32_t this_arg) {
43454         LDKExpiryTime this_arg_conv;
43455         this_arg_conv.inner = (void*)(this_arg & (~1));
43456         this_arg_conv.is_owned = false;
43457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43458         int64_t ret_conv = ExpiryTime_as_duration(&this_arg_conv);
43459         return ret_conv;
43460 }
43461
43462 uint32_t  __attribute__((export_name("TS_PrivateRoute_new"))) TS_PrivateRoute_new(uint32_t hops) {
43463         LDKRouteHint hops_conv;
43464         hops_conv.inner = (void*)(hops & (~1));
43465         hops_conv.is_owned = (hops & 1) || (hops == 0);
43466         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
43467         hops_conv = RouteHint_clone(&hops_conv);
43468         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
43469         *ret_conv = PrivateRoute_new(hops_conv);
43470         return (uint32_t)ret_conv;
43471 }
43472
43473 uint32_t  __attribute__((export_name("TS_PrivateRoute_into_inner"))) TS_PrivateRoute_into_inner(uint32_t this_arg) {
43474         LDKPrivateRoute this_arg_conv;
43475         this_arg_conv.inner = (void*)(this_arg & (~1));
43476         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
43477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43478         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
43479         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
43480         uint32_t ret_ref = 0;
43481         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43482         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43483         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43484         ret_ref = (uintptr_t)ret_var.inner;
43485         if (ret_var.is_owned) {
43486                 ret_ref |= 1;
43487         }
43488         return ret_ref;
43489 }
43490
43491 uint32_t  __attribute__((export_name("TS_CreationError_clone"))) TS_CreationError_clone(uint32_t orig) {
43492         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
43493         uint32_t ret_conv = LDKCreationError_to_js(CreationError_clone(orig_conv));
43494         return ret_conv;
43495 }
43496
43497 uint32_t  __attribute__((export_name("TS_CreationError_description_too_long"))) TS_CreationError_description_too_long() {
43498         uint32_t ret_conv = LDKCreationError_to_js(CreationError_description_too_long());
43499         return ret_conv;
43500 }
43501
43502 uint32_t  __attribute__((export_name("TS_CreationError_route_too_long"))) TS_CreationError_route_too_long() {
43503         uint32_t ret_conv = LDKCreationError_to_js(CreationError_route_too_long());
43504         return ret_conv;
43505 }
43506
43507 uint32_t  __attribute__((export_name("TS_CreationError_timestamp_out_of_bounds"))) TS_CreationError_timestamp_out_of_bounds() {
43508         uint32_t ret_conv = LDKCreationError_to_js(CreationError_timestamp_out_of_bounds());
43509         return ret_conv;
43510 }
43511
43512 uint32_t  __attribute__((export_name("TS_CreationError_invalid_amount"))) TS_CreationError_invalid_amount() {
43513         uint32_t ret_conv = LDKCreationError_to_js(CreationError_invalid_amount());
43514         return ret_conv;
43515 }
43516
43517 uint32_t  __attribute__((export_name("TS_CreationError_missing_route_hints"))) TS_CreationError_missing_route_hints() {
43518         uint32_t ret_conv = LDKCreationError_to_js(CreationError_missing_route_hints());
43519         return ret_conv;
43520 }
43521
43522 jboolean  __attribute__((export_name("TS_CreationError_eq"))) TS_CreationError_eq(uint32_t a, uint32_t b) {
43523         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
43524         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
43525         jboolean ret_conv = CreationError_eq(a_conv, b_conv);
43526         return ret_conv;
43527 }
43528
43529 jstring  __attribute__((export_name("TS_CreationError_to_str"))) TS_CreationError_to_str(uint32_t o) {
43530         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
43531         LDKStr ret_str = CreationError_to_str(o_conv);
43532         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
43533         Str_free(ret_str);
43534         return ret_conv;
43535 }
43536
43537 uint32_t  __attribute__((export_name("TS_SemanticError_clone"))) TS_SemanticError_clone(uint32_t orig) {
43538         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
43539         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_clone(orig_conv));
43540         return ret_conv;
43541 }
43542
43543 uint32_t  __attribute__((export_name("TS_SemanticError_no_payment_hash"))) TS_SemanticError_no_payment_hash() {
43544         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_payment_hash());
43545         return ret_conv;
43546 }
43547
43548 uint32_t  __attribute__((export_name("TS_SemanticError_multiple_payment_hashes"))) TS_SemanticError_multiple_payment_hashes() {
43549         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_hashes());
43550         return ret_conv;
43551 }
43552
43553 uint32_t  __attribute__((export_name("TS_SemanticError_no_description"))) TS_SemanticError_no_description() {
43554         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_description());
43555         return ret_conv;
43556 }
43557
43558 uint32_t  __attribute__((export_name("TS_SemanticError_multiple_descriptions"))) TS_SemanticError_multiple_descriptions() {
43559         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_descriptions());
43560         return ret_conv;
43561 }
43562
43563 uint32_t  __attribute__((export_name("TS_SemanticError_no_payment_secret"))) TS_SemanticError_no_payment_secret() {
43564         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_payment_secret());
43565         return ret_conv;
43566 }
43567
43568 uint32_t  __attribute__((export_name("TS_SemanticError_multiple_payment_secrets"))) TS_SemanticError_multiple_payment_secrets() {
43569         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_secrets());
43570         return ret_conv;
43571 }
43572
43573 uint32_t  __attribute__((export_name("TS_SemanticError_invalid_features"))) TS_SemanticError_invalid_features() {
43574         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_features());
43575         return ret_conv;
43576 }
43577
43578 uint32_t  __attribute__((export_name("TS_SemanticError_invalid_recovery_id"))) TS_SemanticError_invalid_recovery_id() {
43579         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_recovery_id());
43580         return ret_conv;
43581 }
43582
43583 uint32_t  __attribute__((export_name("TS_SemanticError_invalid_signature"))) TS_SemanticError_invalid_signature() {
43584         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_signature());
43585         return ret_conv;
43586 }
43587
43588 uint32_t  __attribute__((export_name("TS_SemanticError_imprecise_amount"))) TS_SemanticError_imprecise_amount() {
43589         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_imprecise_amount());
43590         return ret_conv;
43591 }
43592
43593 jboolean  __attribute__((export_name("TS_SemanticError_eq"))) TS_SemanticError_eq(uint32_t a, uint32_t b) {
43594         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
43595         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
43596         jboolean ret_conv = SemanticError_eq(a_conv, b_conv);
43597         return ret_conv;
43598 }
43599
43600 jstring  __attribute__((export_name("TS_SemanticError_to_str"))) TS_SemanticError_to_str(uint32_t o) {
43601         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
43602         LDKStr ret_str = SemanticError_to_str(o_conv);
43603         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
43604         Str_free(ret_str);
43605         return ret_conv;
43606 }
43607
43608 void  __attribute__((export_name("TS_SignOrCreationError_free"))) TS_SignOrCreationError_free(uint32_t this_ptr) {
43609         if ((this_ptr & 1) != 0) return;
43610         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
43611         CHECK_ACCESS(this_ptr_ptr);
43612         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
43613         FREE((void*)this_ptr);
43614         SignOrCreationError_free(this_ptr_conv);
43615 }
43616
43617 static inline uintptr_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
43618         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
43619         *ret_copy = SignOrCreationError_clone(arg);
43620 uint32_t ret_ref = (uintptr_t)ret_copy;
43621         return ret_ref;
43622 }
43623 uint32_t  __attribute__((export_name("TS_SignOrCreationError_clone_ptr"))) TS_SignOrCreationError_clone_ptr(uint32_t arg) {
43624         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)arg;
43625         uint32_t ret_conv = SignOrCreationError_clone_ptr(arg_conv);
43626         return ret_conv;
43627 }
43628
43629 uint32_t  __attribute__((export_name("TS_SignOrCreationError_clone"))) TS_SignOrCreationError_clone(uint32_t orig) {
43630         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
43631         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
43632         *ret_copy = SignOrCreationError_clone(orig_conv);
43633         uint32_t ret_ref = (uintptr_t)ret_copy;
43634         return ret_ref;
43635 }
43636
43637 uint32_t  __attribute__((export_name("TS_SignOrCreationError_sign_error"))) TS_SignOrCreationError_sign_error() {
43638         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
43639         *ret_copy = SignOrCreationError_sign_error();
43640         uint32_t ret_ref = (uintptr_t)ret_copy;
43641         return ret_ref;
43642 }
43643
43644 uint32_t  __attribute__((export_name("TS_SignOrCreationError_creation_error"))) TS_SignOrCreationError_creation_error(uint32_t a) {
43645         LDKCreationError a_conv = LDKCreationError_from_js(a);
43646         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
43647         *ret_copy = SignOrCreationError_creation_error(a_conv);
43648         uint32_t ret_ref = (uintptr_t)ret_copy;
43649         return ret_ref;
43650 }
43651
43652 jboolean  __attribute__((export_name("TS_SignOrCreationError_eq"))) TS_SignOrCreationError_eq(uint32_t a, uint32_t b) {
43653         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
43654         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
43655         jboolean ret_conv = SignOrCreationError_eq(a_conv, b_conv);
43656         return ret_conv;
43657 }
43658
43659 jstring  __attribute__((export_name("TS_SignOrCreationError_to_str"))) TS_SignOrCreationError_to_str(uint32_t o) {
43660         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
43661         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
43662         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
43663         Str_free(ret_str);
43664         return ret_conv;
43665 }
43666
43667 void  __attribute__((export_name("TS_InvoicePayer_free"))) TS_InvoicePayer_free(uint32_t this_obj) {
43668         LDKInvoicePayer this_obj_conv;
43669         this_obj_conv.inner = (void*)(this_obj & (~1));
43670         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43672         InvoicePayer_free(this_obj_conv);
43673 }
43674
43675 void  __attribute__((export_name("TS_Payer_free"))) TS_Payer_free(uint32_t this_ptr) {
43676         if ((this_ptr & 1) != 0) return;
43677         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
43678         CHECK_ACCESS(this_ptr_ptr);
43679         LDKPayer this_ptr_conv = *(LDKPayer*)(this_ptr_ptr);
43680         FREE((void*)this_ptr);
43681         Payer_free(this_ptr_conv);
43682 }
43683
43684 void  __attribute__((export_name("TS_Router_free"))) TS_Router_free(uint32_t this_ptr) {
43685         if ((this_ptr & 1) != 0) return;
43686         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
43687         CHECK_ACCESS(this_ptr_ptr);
43688         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
43689         FREE((void*)this_ptr);
43690         Router_free(this_ptr_conv);
43691 }
43692
43693 void  __attribute__((export_name("TS_Retry_free"))) TS_Retry_free(uint32_t this_ptr) {
43694         if ((this_ptr & 1) != 0) return;
43695         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
43696         CHECK_ACCESS(this_ptr_ptr);
43697         LDKRetry this_ptr_conv = *(LDKRetry*)(this_ptr_ptr);
43698         FREE((void*)this_ptr);
43699         Retry_free(this_ptr_conv);
43700 }
43701
43702 static inline uintptr_t Retry_clone_ptr(LDKRetry *NONNULL_PTR arg) {
43703         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
43704         *ret_copy = Retry_clone(arg);
43705 uint32_t ret_ref = (uintptr_t)ret_copy;
43706         return ret_ref;
43707 }
43708 uint32_t  __attribute__((export_name("TS_Retry_clone_ptr"))) TS_Retry_clone_ptr(uint32_t arg) {
43709         LDKRetry* arg_conv = (LDKRetry*)arg;
43710         uint32_t ret_conv = Retry_clone_ptr(arg_conv);
43711         return ret_conv;
43712 }
43713
43714 uint32_t  __attribute__((export_name("TS_Retry_clone"))) TS_Retry_clone(uint32_t orig) {
43715         LDKRetry* orig_conv = (LDKRetry*)orig;
43716         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
43717         *ret_copy = Retry_clone(orig_conv);
43718         uint32_t ret_ref = (uintptr_t)ret_copy;
43719         return ret_ref;
43720 }
43721
43722 uint32_t  __attribute__((export_name("TS_Retry_attempts"))) TS_Retry_attempts(uint32_t a) {
43723         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
43724         *ret_copy = Retry_attempts(a);
43725         uint32_t ret_ref = (uintptr_t)ret_copy;
43726         return ret_ref;
43727 }
43728
43729 jboolean  __attribute__((export_name("TS_Retry_eq"))) TS_Retry_eq(uint32_t a, uint32_t b) {
43730         LDKRetry* a_conv = (LDKRetry*)a;
43731         LDKRetry* b_conv = (LDKRetry*)b;
43732         jboolean ret_conv = Retry_eq(a_conv, b_conv);
43733         return ret_conv;
43734 }
43735
43736 int64_t  __attribute__((export_name("TS_Retry_hash"))) TS_Retry_hash(uint32_t o) {
43737         LDKRetry* o_conv = (LDKRetry*)o;
43738         int64_t ret_conv = Retry_hash(o_conv);
43739         return ret_conv;
43740 }
43741
43742 void  __attribute__((export_name("TS_PaymentError_free"))) TS_PaymentError_free(uint32_t this_ptr) {
43743         if ((this_ptr & 1) != 0) return;
43744         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
43745         CHECK_ACCESS(this_ptr_ptr);
43746         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
43747         FREE((void*)this_ptr);
43748         PaymentError_free(this_ptr_conv);
43749 }
43750
43751 static inline uintptr_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
43752         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
43753         *ret_copy = PaymentError_clone(arg);
43754 uint32_t ret_ref = (uintptr_t)ret_copy;
43755         return ret_ref;
43756 }
43757 uint32_t  __attribute__((export_name("TS_PaymentError_clone_ptr"))) TS_PaymentError_clone_ptr(uint32_t arg) {
43758         LDKPaymentError* arg_conv = (LDKPaymentError*)arg;
43759         uint32_t ret_conv = PaymentError_clone_ptr(arg_conv);
43760         return ret_conv;
43761 }
43762
43763 uint32_t  __attribute__((export_name("TS_PaymentError_clone"))) TS_PaymentError_clone(uint32_t orig) {
43764         LDKPaymentError* orig_conv = (LDKPaymentError*)orig;
43765         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
43766         *ret_copy = PaymentError_clone(orig_conv);
43767         uint32_t ret_ref = (uintptr_t)ret_copy;
43768         return ret_ref;
43769 }
43770
43771 uint32_t  __attribute__((export_name("TS_PaymentError_invoice"))) TS_PaymentError_invoice(jstring a) {
43772         LDKStr a_conv = str_ref_to_owned_c(a);
43773         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
43774         *ret_copy = PaymentError_invoice(a_conv);
43775         uint32_t ret_ref = (uintptr_t)ret_copy;
43776         return ret_ref;
43777 }
43778
43779 uint32_t  __attribute__((export_name("TS_PaymentError_routing"))) TS_PaymentError_routing(uint32_t a) {
43780         LDKLightningError a_conv;
43781         a_conv.inner = (void*)(a & (~1));
43782         a_conv.is_owned = (a & 1) || (a == 0);
43783         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43784         a_conv = LightningError_clone(&a_conv);
43785         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
43786         *ret_copy = PaymentError_routing(a_conv);
43787         uint32_t ret_ref = (uintptr_t)ret_copy;
43788         return ret_ref;
43789 }
43790
43791 uint32_t  __attribute__((export_name("TS_PaymentError_sending"))) TS_PaymentError_sending(uint32_t a) {
43792         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
43793         CHECK_ACCESS(a_ptr);
43794         LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
43795         a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)a) & ~1));
43796         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
43797         *ret_copy = PaymentError_sending(a_conv);
43798         uint32_t ret_ref = (uintptr_t)ret_copy;
43799         return ret_ref;
43800 }
43801
43802 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) {
43803         void* payer_ptr = (void*)(((uintptr_t)payer) & ~1);
43804         CHECK_ACCESS(payer_ptr);
43805         LDKPayer payer_conv = *(LDKPayer*)(payer_ptr);
43806         if (payer_conv.free == LDKPayer_JCalls_free) {
43807                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43808                 LDKPayer_JCalls_cloned(&payer_conv);
43809         }
43810         void* router_ptr = (void*)(((uintptr_t)router) & ~1);
43811         CHECK_ACCESS(router_ptr);
43812         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
43813         if (router_conv.free == LDKRouter_JCalls_free) {
43814                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43815                 LDKRouter_JCalls_cloned(&router_conv);
43816         }
43817         LDKMultiThreadedLockableScore scorer_conv;
43818         scorer_conv.inner = (void*)(scorer & (~1));
43819         scorer_conv.is_owned = false;
43820         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
43821         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
43822         CHECK_ACCESS(logger_ptr);
43823         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
43824         if (logger_conv.free == LDKLogger_JCalls_free) {
43825                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43826                 LDKLogger_JCalls_cloned(&logger_conv);
43827         }
43828         void* event_handler_ptr = (void*)(((uintptr_t)event_handler) & ~1);
43829         CHECK_ACCESS(event_handler_ptr);
43830         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
43831         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
43832                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43833                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
43834         }
43835         void* retry_ptr = (void*)(((uintptr_t)retry) & ~1);
43836         CHECK_ACCESS(retry_ptr);
43837         LDKRetry retry_conv = *(LDKRetry*)(retry_ptr);
43838         retry_conv = Retry_clone((LDKRetry*)(((uintptr_t)retry) & ~1));
43839         LDKInvoicePayer ret_var = InvoicePayer_new(payer_conv, router_conv, &scorer_conv, logger_conv, event_handler_conv, retry_conv);
43840         uint32_t ret_ref = 0;
43841         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43842         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43843         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43844         ret_ref = (uintptr_t)ret_var.inner;
43845         if (ret_var.is_owned) {
43846                 ret_ref |= 1;
43847         }
43848         return ret_ref;
43849 }
43850
43851 uint32_t  __attribute__((export_name("TS_InvoicePayer_pay_invoice"))) TS_InvoicePayer_pay_invoice(uint32_t this_arg, uint32_t invoice) {
43852         LDKInvoicePayer this_arg_conv;
43853         this_arg_conv.inner = (void*)(this_arg & (~1));
43854         this_arg_conv.is_owned = false;
43855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43856         LDKInvoice invoice_conv;
43857         invoice_conv.inner = (void*)(invoice & (~1));
43858         invoice_conv.is_owned = false;
43859         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
43860         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
43861         *ret_conv = InvoicePayer_pay_invoice(&this_arg_conv, &invoice_conv);
43862         return (uint32_t)ret_conv;
43863 }
43864
43865 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) {
43866         LDKInvoicePayer this_arg_conv;
43867         this_arg_conv.inner = (void*)(this_arg & (~1));
43868         this_arg_conv.is_owned = false;
43869         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43870         LDKInvoice invoice_conv;
43871         invoice_conv.inner = (void*)(invoice & (~1));
43872         invoice_conv.is_owned = false;
43873         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
43874         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
43875         *ret_conv = InvoicePayer_pay_zero_value_invoice(&this_arg_conv, &invoice_conv, amount_msats);
43876         return (uint32_t)ret_conv;
43877 }
43878
43879 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) {
43880         LDKInvoicePayer this_arg_conv;
43881         this_arg_conv.inner = (void*)(this_arg & (~1));
43882         this_arg_conv.is_owned = false;
43883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43884         LDKPublicKey pubkey_ref;
43885         CHECK(pubkey->arr_len == 33);
43886         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
43887         LDKThirtyTwoBytes payment_preimage_ref;
43888         CHECK(payment_preimage->arr_len == 32);
43889         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
43890         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
43891         *ret_conv = InvoicePayer_pay_pubkey(&this_arg_conv, pubkey_ref, payment_preimage_ref, amount_msats, final_cltv_expiry_delta);
43892         return (uint32_t)ret_conv;
43893 }
43894
43895 void  __attribute__((export_name("TS_InvoicePayer_remove_cached_payment"))) TS_InvoicePayer_remove_cached_payment(uint32_t this_arg, int8_tArray payment_hash) {
43896         LDKInvoicePayer this_arg_conv;
43897         this_arg_conv.inner = (void*)(this_arg & (~1));
43898         this_arg_conv.is_owned = false;
43899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43900         unsigned char payment_hash_arr[32];
43901         CHECK(payment_hash->arr_len == 32);
43902         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
43903         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
43904         InvoicePayer_remove_cached_payment(&this_arg_conv, payment_hash_ref);
43905 }
43906
43907 uint32_t  __attribute__((export_name("TS_InvoicePayer_as_EventHandler"))) TS_InvoicePayer_as_EventHandler(uint32_t this_arg) {
43908         LDKInvoicePayer this_arg_conv;
43909         this_arg_conv.inner = (void*)(this_arg & (~1));
43910         this_arg_conv.is_owned = false;
43911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43912         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
43913         *ret_ret = InvoicePayer_as_EventHandler(&this_arg_conv);
43914         return (uint32_t)ret_ret;
43915 }
43916
43917 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) {
43918         LDKChannelManager channelmanager_conv;
43919         channelmanager_conv.inner = (void*)(channelmanager & (~1));
43920         channelmanager_conv.is_owned = false;
43921         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
43922         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
43923         CHECK_ACCESS(keys_manager_ptr);
43924         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
43925         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
43926                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43927                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
43928         }
43929         LDKCurrency network_conv = LDKCurrency_from_js(network);
43930         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
43931         CHECK_ACCESS(amt_msat_ptr);
43932         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
43933         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
43934         LDKSha256 description_hash_conv;
43935         description_hash_conv.inner = (void*)(description_hash & (~1));
43936         description_hash_conv.is_owned = (description_hash & 1) || (description_hash == 0);
43937         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
43938         description_hash_conv = Sha256_clone(&description_hash_conv);
43939         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
43940         *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);
43941         return (uint32_t)ret_conv;
43942 }
43943
43944 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) {
43945         LDKChannelManager channelmanager_conv;
43946         channelmanager_conv.inner = (void*)(channelmanager & (~1));
43947         channelmanager_conv.is_owned = false;
43948         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
43949         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
43950         CHECK_ACCESS(keys_manager_ptr);
43951         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
43952         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
43953                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43954                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
43955         }
43956         LDKCurrency network_conv = LDKCurrency_from_js(network);
43957         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
43958         CHECK_ACCESS(amt_msat_ptr);
43959         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
43960         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
43961         LDKStr description_conv = str_ref_to_owned_c(description);
43962         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
43963         *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);
43964         return (uint32_t)ret_conv;
43965 }
43966
43967 void  __attribute__((export_name("TS_DefaultRouter_free"))) TS_DefaultRouter_free(uint32_t this_obj) {
43968         LDKDefaultRouter this_obj_conv;
43969         this_obj_conv.inner = (void*)(this_obj & (~1));
43970         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
43971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43972         DefaultRouter_free(this_obj_conv);
43973 }
43974
43975 uint32_t  __attribute__((export_name("TS_DefaultRouter_new"))) TS_DefaultRouter_new(uint32_t network_graph, uint32_t logger, int8_tArray random_seed_bytes) {
43976         LDKNetworkGraph network_graph_conv;
43977         network_graph_conv.inner = (void*)(network_graph & (~1));
43978         network_graph_conv.is_owned = false;
43979         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
43980         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
43981         CHECK_ACCESS(logger_ptr);
43982         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
43983         if (logger_conv.free == LDKLogger_JCalls_free) {
43984                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43985                 LDKLogger_JCalls_cloned(&logger_conv);
43986         }
43987         LDKThirtyTwoBytes random_seed_bytes_ref;
43988         CHECK(random_seed_bytes->arr_len == 32);
43989         memcpy(random_seed_bytes_ref.data, random_seed_bytes->elems, 32); FREE(random_seed_bytes);
43990         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv, random_seed_bytes_ref);
43991         uint32_t ret_ref = 0;
43992         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
43993         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
43994         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43995         ret_ref = (uintptr_t)ret_var.inner;
43996         if (ret_var.is_owned) {
43997                 ret_ref |= 1;
43998         }
43999         return ret_ref;
44000 }
44001
44002 uint32_t  __attribute__((export_name("TS_DefaultRouter_as_Router"))) TS_DefaultRouter_as_Router(uint32_t this_arg) {
44003         LDKDefaultRouter this_arg_conv;
44004         this_arg_conv.inner = (void*)(this_arg & (~1));
44005         this_arg_conv.is_owned = false;
44006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44007         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
44008         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
44009         return (uint32_t)ret_ret;
44010 }
44011
44012 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Payer"))) TS_ChannelManager_as_Payer(uint32_t this_arg) {
44013         LDKChannelManager this_arg_conv;
44014         this_arg_conv.inner = (void*)(this_arg & (~1));
44015         this_arg_conv.is_owned = false;
44016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44017         LDKPayer* ret_ret = MALLOC(sizeof(LDKPayer), "LDKPayer");
44018         *ret_ret = ChannelManager_as_Payer(&this_arg_conv);
44019         return (uint32_t)ret_ret;
44020 }
44021
44022 uint32_t  __attribute__((export_name("TS_SiPrefix_from_str"))) TS_SiPrefix_from_str(jstring s) {
44023         LDKStr s_conv = str_ref_to_owned_c(s);
44024         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
44025         *ret_conv = SiPrefix_from_str(s_conv);
44026         return (uint32_t)ret_conv;
44027 }
44028
44029 uint32_t  __attribute__((export_name("TS_Invoice_from_str"))) TS_Invoice_from_str(jstring s) {
44030         LDKStr s_conv = str_ref_to_owned_c(s);
44031         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
44032         *ret_conv = Invoice_from_str(s_conv);
44033         return (uint32_t)ret_conv;
44034 }
44035
44036 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_from_str"))) TS_SignedRawInvoice_from_str(jstring s) {
44037         LDKStr s_conv = str_ref_to_owned_c(s);
44038         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
44039         *ret_conv = SignedRawInvoice_from_str(s_conv);
44040         return (uint32_t)ret_conv;
44041 }
44042
44043 jstring  __attribute__((export_name("TS_ParseError_to_str"))) TS_ParseError_to_str(uint32_t o) {
44044         LDKParseError* o_conv = (LDKParseError*)o;
44045         LDKStr ret_str = ParseError_to_str(o_conv);
44046         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
44047         Str_free(ret_str);
44048         return ret_conv;
44049 }
44050
44051 jstring  __attribute__((export_name("TS_ParseOrSemanticError_to_str"))) TS_ParseOrSemanticError_to_str(uint32_t o) {
44052         LDKParseOrSemanticError* o_conv = (LDKParseOrSemanticError*)o;
44053         LDKStr ret_str = ParseOrSemanticError_to_str(o_conv);
44054         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
44055         Str_free(ret_str);
44056         return ret_conv;
44057 }
44058
44059 jstring  __attribute__((export_name("TS_Invoice_to_str"))) TS_Invoice_to_str(uint32_t o) {
44060         LDKInvoice o_conv;
44061         o_conv.inner = (void*)(o & (~1));
44062         o_conv.is_owned = false;
44063         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44064         LDKStr ret_str = Invoice_to_str(&o_conv);
44065         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
44066         Str_free(ret_str);
44067         return ret_conv;
44068 }
44069
44070 jstring  __attribute__((export_name("TS_SignedRawInvoice_to_str"))) TS_SignedRawInvoice_to_str(uint32_t o) {
44071         LDKSignedRawInvoice o_conv;
44072         o_conv.inner = (void*)(o & (~1));
44073         o_conv.is_owned = false;
44074         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44075         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
44076         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
44077         Str_free(ret_str);
44078         return ret_conv;
44079 }
44080
44081 jstring  __attribute__((export_name("TS_Currency_to_str"))) TS_Currency_to_str(uint32_t o) {
44082         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
44083         LDKStr ret_str = Currency_to_str(o_conv);
44084         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
44085         Str_free(ret_str);
44086         return ret_conv;
44087 }
44088
44089 jstring  __attribute__((export_name("TS_SiPrefix_to_str"))) TS_SiPrefix_to_str(uint32_t o) {
44090         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
44091         LDKStr ret_str = SiPrefix_to_str(o_conv);
44092         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
44093         Str_free(ret_str);
44094         return ret_conv;
44095 }
44096