[TS] Update auto-generated bindings
[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 LDKLevel LDKLevel_from_js(int32_t ord) {
194         switch (ord) {
195                 case 0: return LDKLevel_Gossip;
196                 case 1: return LDKLevel_Trace;
197                 case 2: return LDKLevel_Debug;
198                 case 3: return LDKLevel_Info;
199                 case 4: return LDKLevel_Warn;
200                 case 5: return LDKLevel_Error;
201         }
202         abort();
203 }
204 static inline int32_t LDKLevel_to_js(LDKLevel val) {
205         switch (val) {
206                 case LDKLevel_Gossip: return 0;
207                 case LDKLevel_Trace: return 1;
208                 case LDKLevel_Debug: return 2;
209                 case LDKLevel_Info: return 3;
210                 case LDKLevel_Warn: return 4;
211                 case LDKLevel_Error: return 5;
212                 default: abort();
213         }
214 }
215 static inline LDKNetwork LDKNetwork_from_js(int32_t ord) {
216         switch (ord) {
217                 case 0: return LDKNetwork_Bitcoin;
218                 case 1: return LDKNetwork_Testnet;
219                 case 2: return LDKNetwork_Regtest;
220                 case 3: return LDKNetwork_Signet;
221         }
222         abort();
223 }
224 static inline int32_t LDKNetwork_to_js(LDKNetwork val) {
225         switch (val) {
226                 case LDKNetwork_Bitcoin: return 0;
227                 case LDKNetwork_Testnet: return 1;
228                 case LDKNetwork_Regtest: return 2;
229                 case LDKNetwork_Signet: return 3;
230                 default: abort();
231         }
232 }
233 static inline LDKRecipient LDKRecipient_from_js(int32_t ord) {
234         switch (ord) {
235                 case 0: return LDKRecipient_Node;
236                 case 1: return LDKRecipient_PhantomNode;
237         }
238         abort();
239 }
240 static inline int32_t LDKRecipient_to_js(LDKRecipient val) {
241         switch (val) {
242                 case LDKRecipient_Node: return 0;
243                 case LDKRecipient_PhantomNode: return 1;
244                 default: abort();
245         }
246 }
247 static inline LDKSecp256k1Error LDKSecp256k1Error_from_js(int32_t ord) {
248         switch (ord) {
249                 case 0: return LDKSecp256k1Error_IncorrectSignature;
250                 case 1: return LDKSecp256k1Error_InvalidMessage;
251                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
252                 case 3: return LDKSecp256k1Error_InvalidSignature;
253                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
254                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
255                 case 6: return LDKSecp256k1Error_InvalidTweak;
256                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
257                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
258         }
259         abort();
260 }
261 static inline int32_t LDKSecp256k1Error_to_js(LDKSecp256k1Error val) {
262         switch (val) {
263                 case LDKSecp256k1Error_IncorrectSignature: return 0;
264                 case LDKSecp256k1Error_InvalidMessage: return 1;
265                 case LDKSecp256k1Error_InvalidPublicKey: return 2;
266                 case LDKSecp256k1Error_InvalidSignature: return 3;
267                 case LDKSecp256k1Error_InvalidSecretKey: return 4;
268                 case LDKSecp256k1Error_InvalidRecoveryId: return 5;
269                 case LDKSecp256k1Error_InvalidTweak: return 6;
270                 case LDKSecp256k1Error_TweakCheckFailed: return 7;
271                 case LDKSecp256k1Error_NotEnoughMemory: return 8;
272                 default: abort();
273         }
274 }
275 static inline LDKSemanticError LDKSemanticError_from_js(int32_t ord) {
276         switch (ord) {
277                 case 0: return LDKSemanticError_NoPaymentHash;
278                 case 1: return LDKSemanticError_MultiplePaymentHashes;
279                 case 2: return LDKSemanticError_NoDescription;
280                 case 3: return LDKSemanticError_MultipleDescriptions;
281                 case 4: return LDKSemanticError_NoPaymentSecret;
282                 case 5: return LDKSemanticError_MultiplePaymentSecrets;
283                 case 6: return LDKSemanticError_InvalidFeatures;
284                 case 7: return LDKSemanticError_InvalidRecoveryId;
285                 case 8: return LDKSemanticError_InvalidSignature;
286                 case 9: return LDKSemanticError_ImpreciseAmount;
287         }
288         abort();
289 }
290 static inline int32_t LDKSemanticError_to_js(LDKSemanticError val) {
291         switch (val) {
292                 case LDKSemanticError_NoPaymentHash: return 0;
293                 case LDKSemanticError_MultiplePaymentHashes: return 1;
294                 case LDKSemanticError_NoDescription: return 2;
295                 case LDKSemanticError_MultipleDescriptions: return 3;
296                 case LDKSemanticError_NoPaymentSecret: return 4;
297                 case LDKSemanticError_MultiplePaymentSecrets: return 5;
298                 case LDKSemanticError_InvalidFeatures: return 6;
299                 case LDKSemanticError_InvalidRecoveryId: return 7;
300                 case LDKSemanticError_InvalidSignature: return 8;
301                 case LDKSemanticError_ImpreciseAmount: return 9;
302                 default: abort();
303         }
304 }
305 static inline LDKSiPrefix LDKSiPrefix_from_js(int32_t ord) {
306         switch (ord) {
307                 case 0: return LDKSiPrefix_Milli;
308                 case 1: return LDKSiPrefix_Micro;
309                 case 2: return LDKSiPrefix_Nano;
310                 case 3: return LDKSiPrefix_Pico;
311         }
312         abort();
313 }
314 static inline int32_t LDKSiPrefix_to_js(LDKSiPrefix val) {
315         switch (val) {
316                 case LDKSiPrefix_Milli: return 0;
317                 case LDKSiPrefix_Micro: return 1;
318                 case LDKSiPrefix_Nano: return 2;
319                 case LDKSiPrefix_Pico: return 3;
320                 default: abort();
321         }
322 }
323 uint32_t __attribute__((export_name("TS_LDKBech32Error_ty_from_ptr"))) TS_LDKBech32Error_ty_from_ptr(uint32_t ptr) {
324         LDKBech32Error *obj = (LDKBech32Error*)(ptr & ~1);
325         switch(obj->tag) {
326                 case LDKBech32Error_MissingSeparator: return 0;
327                 case LDKBech32Error_InvalidChecksum: return 1;
328                 case LDKBech32Error_InvalidLength: return 2;
329                 case LDKBech32Error_InvalidChar: return 3;
330                 case LDKBech32Error_InvalidData: return 4;
331                 case LDKBech32Error_InvalidPadding: return 5;
332                 case LDKBech32Error_MixedCase: return 6;
333                 default: abort();
334         }
335 }
336 int32_t __attribute__((export_name("TS_LDKBech32Error_InvalidChar_get_invalid_char"))) TS_LDKBech32Error_InvalidChar_get_invalid_char(uint32_t ptr) {
337         LDKBech32Error *obj = (LDKBech32Error*)(ptr & ~1);
338         assert(obj->tag == LDKBech32Error_InvalidChar);
339                         int32_t invalid_char_conv = obj->invalid_char;
340         return invalid_char_conv;
341 }
342 int8_t __attribute__((export_name("TS_LDKBech32Error_InvalidData_get_invalid_data"))) TS_LDKBech32Error_InvalidData_get_invalid_data(uint32_t ptr) {
343         LDKBech32Error *obj = (LDKBech32Error*)(ptr & ~1);
344         assert(obj->tag == LDKBech32Error_InvalidData);
345                         int8_t invalid_data_conv = obj->invalid_data;
346         return invalid_data_conv;
347 }
348 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
349         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
350         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
351         return ret;
352 }
353 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) {
354         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
355         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
356         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
357         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
358         CVec_u8Z_free(ret_var);
359         return ret_arr;
360 }
361
362 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) {
363         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
364         int64_t ret_conv = TxOut_get_value(thing_conv);
365         return ret_conv;
366 }
367
368 static inline void CResult_NoneNoneZ_get_ok(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
369 CHECK(owner->result_ok);
370         return *owner->contents.result;
371 }
372 void  __attribute__((export_name("TS_CResult_NoneNoneZ_get_ok"))) TS_CResult_NoneNoneZ_get_ok(uint32_t owner) {
373         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
374         CResult_NoneNoneZ_get_ok(owner_conv);
375 }
376
377 static inline void CResult_NoneNoneZ_get_err(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
378 CHECK(!owner->result_ok);
379         return *owner->contents.err;
380 }
381 void  __attribute__((export_name("TS_CResult_NoneNoneZ_get_err"))) TS_CResult_NoneNoneZ_get_err(uint32_t owner) {
382         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
383         CResult_NoneNoneZ_get_err(owner_conv);
384 }
385
386 static inline struct LDKCounterpartyCommitmentSecrets CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
387 CHECK(owner->result_ok);
388         return CounterpartyCommitmentSecrets_clone(&*owner->contents.result);
389 }
390 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(uint32_t owner) {
391         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(owner & ~1);
392         LDKCounterpartyCommitmentSecrets ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(owner_conv);
393         uint32_t ret_ref = 0;
394         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
395         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
396         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
397         ret_ref = (uintptr_t)ret_var.inner;
398         if (ret_var.is_owned) {
399                 ret_ref |= 1;
400         }
401         return ret_ref;
402 }
403
404 static inline struct LDKDecodeError CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
405 CHECK(!owner->result_ok);
406         return DecodeError_clone(&*owner->contents.err);
407 }
408 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(uint32_t owner) {
409         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(owner & ~1);
410         LDKDecodeError ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(owner_conv);
411         uint32_t ret_ref = 0;
412         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
413         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
414         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
415         ret_ref = (uintptr_t)ret_var.inner;
416         if (ret_var.is_owned) {
417                 ret_ref |= 1;
418         }
419         return ret_ref;
420 }
421
422 static inline struct LDKSecretKey CResult_SecretKeyErrorZ_get_ok(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
423 CHECK(owner->result_ok);
424         return *owner->contents.result;
425 }
426 int8_tArray  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_get_ok"))) TS_CResult_SecretKeyErrorZ_get_ok(uint32_t owner) {
427         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
428         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
429         memcpy(ret_arr->elems, CResult_SecretKeyErrorZ_get_ok(owner_conv).bytes, 32);
430         return ret_arr;
431 }
432
433 static inline enum LDKSecp256k1Error CResult_SecretKeyErrorZ_get_err(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
434 CHECK(!owner->result_ok);
435         return *owner->contents.err;
436 }
437 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_get_err"))) TS_CResult_SecretKeyErrorZ_get_err(uint32_t owner) {
438         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
439         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_SecretKeyErrorZ_get_err(owner_conv));
440         return ret_conv;
441 }
442
443 static inline struct LDKPublicKey CResult_PublicKeyErrorZ_get_ok(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
444 CHECK(owner->result_ok);
445         return *owner->contents.result;
446 }
447 int8_tArray  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_get_ok"))) TS_CResult_PublicKeyErrorZ_get_ok(uint32_t owner) {
448         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
449         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
450         memcpy(ret_arr->elems, CResult_PublicKeyErrorZ_get_ok(owner_conv).compressed_form, 33);
451         return ret_arr;
452 }
453
454 static inline enum LDKSecp256k1Error CResult_PublicKeyErrorZ_get_err(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
455 CHECK(!owner->result_ok);
456         return *owner->contents.err;
457 }
458 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_get_err"))) TS_CResult_PublicKeyErrorZ_get_err(uint32_t owner) {
459         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
460         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_PublicKeyErrorZ_get_err(owner_conv));
461         return ret_conv;
462 }
463
464 static inline struct LDKTxCreationKeys CResult_TxCreationKeysDecodeErrorZ_get_ok(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
465 CHECK(owner->result_ok);
466         return TxCreationKeys_clone(&*owner->contents.result);
467 }
468 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_get_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_get_ok(uint32_t owner) {
469         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
470         LDKTxCreationKeys ret_var = CResult_TxCreationKeysDecodeErrorZ_get_ok(owner_conv);
471         uint32_t ret_ref = 0;
472         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
473         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
474         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
475         ret_ref = (uintptr_t)ret_var.inner;
476         if (ret_var.is_owned) {
477                 ret_ref |= 1;
478         }
479         return ret_ref;
480 }
481
482 static inline struct LDKDecodeError CResult_TxCreationKeysDecodeErrorZ_get_err(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
483 CHECK(!owner->result_ok);
484         return DecodeError_clone(&*owner->contents.err);
485 }
486 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_get_err"))) TS_CResult_TxCreationKeysDecodeErrorZ_get_err(uint32_t owner) {
487         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
488         LDKDecodeError ret_var = CResult_TxCreationKeysDecodeErrorZ_get_err(owner_conv);
489         uint32_t ret_ref = 0;
490         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
491         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
492         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
493         ret_ref = (uintptr_t)ret_var.inner;
494         if (ret_var.is_owned) {
495                 ret_ref |= 1;
496         }
497         return ret_ref;
498 }
499
500 static inline struct LDKChannelPublicKeys CResult_ChannelPublicKeysDecodeErrorZ_get_ok(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
501 CHECK(owner->result_ok);
502         return ChannelPublicKeys_clone(&*owner->contents.result);
503 }
504 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_get_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_get_ok(uint32_t owner) {
505         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
506         LDKChannelPublicKeys ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_ok(owner_conv);
507         uint32_t ret_ref = 0;
508         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
509         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
510         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
511         ret_ref = (uintptr_t)ret_var.inner;
512         if (ret_var.is_owned) {
513                 ret_ref |= 1;
514         }
515         return ret_ref;
516 }
517
518 static inline struct LDKDecodeError CResult_ChannelPublicKeysDecodeErrorZ_get_err(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
519 CHECK(!owner->result_ok);
520         return DecodeError_clone(&*owner->contents.err);
521 }
522 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_get_err"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_get_err(uint32_t owner) {
523         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
524         LDKDecodeError ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_err(owner_conv);
525         uint32_t ret_ref = 0;
526         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
527         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
528         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
529         ret_ref = (uintptr_t)ret_var.inner;
530         if (ret_var.is_owned) {
531                 ret_ref |= 1;
532         }
533         return ret_ref;
534 }
535
536 static inline struct LDKTxCreationKeys CResult_TxCreationKeysErrorZ_get_ok(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
537 CHECK(owner->result_ok);
538         return TxCreationKeys_clone(&*owner->contents.result);
539 }
540 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_get_ok"))) TS_CResult_TxCreationKeysErrorZ_get_ok(uint32_t owner) {
541         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
542         LDKTxCreationKeys ret_var = CResult_TxCreationKeysErrorZ_get_ok(owner_conv);
543         uint32_t ret_ref = 0;
544         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
545         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
546         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
547         ret_ref = (uintptr_t)ret_var.inner;
548         if (ret_var.is_owned) {
549                 ret_ref |= 1;
550         }
551         return ret_ref;
552 }
553
554 static inline enum LDKSecp256k1Error CResult_TxCreationKeysErrorZ_get_err(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
555 CHECK(!owner->result_ok);
556         return *owner->contents.err;
557 }
558 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_get_err"))) TS_CResult_TxCreationKeysErrorZ_get_err(uint32_t owner) {
559         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
560         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_TxCreationKeysErrorZ_get_err(owner_conv));
561         return ret_conv;
562 }
563
564 uint32_t __attribute__((export_name("TS_LDKCOption_u32Z_ty_from_ptr"))) TS_LDKCOption_u32Z_ty_from_ptr(uint32_t ptr) {
565         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
566         switch(obj->tag) {
567                 case LDKCOption_u32Z_Some: return 0;
568                 case LDKCOption_u32Z_None: return 1;
569                 default: abort();
570         }
571 }
572 int32_t __attribute__((export_name("TS_LDKCOption_u32Z_Some_get_some"))) TS_LDKCOption_u32Z_Some_get_some(uint32_t ptr) {
573         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
574         assert(obj->tag == LDKCOption_u32Z_Some);
575                         int32_t some_conv = obj->some;
576         return some_conv;
577 }
578 static inline struct LDKHTLCOutputInCommitment CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
579 CHECK(owner->result_ok);
580         return HTLCOutputInCommitment_clone(&*owner->contents.result);
581 }
582 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(uint32_t owner) {
583         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
584         LDKHTLCOutputInCommitment ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(owner_conv);
585         uint32_t ret_ref = 0;
586         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
587         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
588         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
589         ret_ref = (uintptr_t)ret_var.inner;
590         if (ret_var.is_owned) {
591                 ret_ref |= 1;
592         }
593         return ret_ref;
594 }
595
596 static inline struct LDKDecodeError CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
597 CHECK(!owner->result_ok);
598         return DecodeError_clone(&*owner->contents.err);
599 }
600 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(uint32_t owner) {
601         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
602         LDKDecodeError ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(owner_conv);
603         uint32_t ret_ref = 0;
604         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
605         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
606         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
607         ret_ref = (uintptr_t)ret_var.inner;
608         if (ret_var.is_owned) {
609                 ret_ref |= 1;
610         }
611         return ret_ref;
612 }
613
614 static inline struct LDKCounterpartyChannelTransactionParameters CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
615 CHECK(owner->result_ok);
616         return CounterpartyChannelTransactionParameters_clone(&*owner->contents.result);
617 }
618 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t owner) {
619         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
620         LDKCounterpartyChannelTransactionParameters ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
621         uint32_t ret_ref = 0;
622         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
623         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
624         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
625         ret_ref = (uintptr_t)ret_var.inner;
626         if (ret_var.is_owned) {
627                 ret_ref |= 1;
628         }
629         return ret_ref;
630 }
631
632 static inline struct LDKDecodeError CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
633 CHECK(!owner->result_ok);
634         return DecodeError_clone(&*owner->contents.err);
635 }
636 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(uint32_t owner) {
637         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
638         LDKDecodeError ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
639         uint32_t ret_ref = 0;
640         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
641         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
642         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
643         ret_ref = (uintptr_t)ret_var.inner;
644         if (ret_var.is_owned) {
645                 ret_ref |= 1;
646         }
647         return ret_ref;
648 }
649
650 static inline struct LDKChannelTransactionParameters CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
651 CHECK(owner->result_ok);
652         return ChannelTransactionParameters_clone(&*owner->contents.result);
653 }
654 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t owner) {
655         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
656         LDKChannelTransactionParameters ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
657         uint32_t ret_ref = 0;
658         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
659         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
660         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
661         ret_ref = (uintptr_t)ret_var.inner;
662         if (ret_var.is_owned) {
663                 ret_ref |= 1;
664         }
665         return ret_ref;
666 }
667
668 static inline struct LDKDecodeError CResult_ChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
669 CHECK(!owner->result_ok);
670         return DecodeError_clone(&*owner->contents.err);
671 }
672 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_err"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_err(uint32_t owner) {
673         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
674         LDKDecodeError ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
675         uint32_t ret_ref = 0;
676         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
677         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
678         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
679         ret_ref = (uintptr_t)ret_var.inner;
680         if (ret_var.is_owned) {
681                 ret_ref |= 1;
682         }
683         return ret_ref;
684 }
685
686 static inline struct LDKHolderCommitmentTransaction CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
687 CHECK(owner->result_ok);
688         return HolderCommitmentTransaction_clone(&*owner->contents.result);
689 }
690 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(uint32_t owner) {
691         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
692         LDKHolderCommitmentTransaction ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
693         uint32_t ret_ref = 0;
694         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
695         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
696         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
697         ret_ref = (uintptr_t)ret_var.inner;
698         if (ret_var.is_owned) {
699                 ret_ref |= 1;
700         }
701         return ret_ref;
702 }
703
704 static inline struct LDKDecodeError CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
705 CHECK(!owner->result_ok);
706         return DecodeError_clone(&*owner->contents.err);
707 }
708 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(uint32_t owner) {
709         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
710         LDKDecodeError ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
711         uint32_t ret_ref = 0;
712         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
713         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
714         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
715         ret_ref = (uintptr_t)ret_var.inner;
716         if (ret_var.is_owned) {
717                 ret_ref |= 1;
718         }
719         return ret_ref;
720 }
721
722 static inline struct LDKBuiltCommitmentTransaction CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
723 CHECK(owner->result_ok);
724         return BuiltCommitmentTransaction_clone(&*owner->contents.result);
725 }
726 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(uint32_t owner) {
727         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
728         LDKBuiltCommitmentTransaction ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
729         uint32_t ret_ref = 0;
730         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
731         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
732         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
733         ret_ref = (uintptr_t)ret_var.inner;
734         if (ret_var.is_owned) {
735                 ret_ref |= 1;
736         }
737         return ret_ref;
738 }
739
740 static inline struct LDKDecodeError CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
741 CHECK(!owner->result_ok);
742         return DecodeError_clone(&*owner->contents.err);
743 }
744 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(uint32_t owner) {
745         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
746         LDKDecodeError ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
747         uint32_t ret_ref = 0;
748         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
749         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
750         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
751         ret_ref = (uintptr_t)ret_var.inner;
752         if (ret_var.is_owned) {
753                 ret_ref |= 1;
754         }
755         return ret_ref;
756 }
757
758 static inline struct LDKTrustedClosingTransaction *CResult_TrustedClosingTransactionNoneZ_get_ok(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
759 CHECK(owner->result_ok);
760         return &*owner->contents.result;
761 }
762 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_get_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_get_ok(uint32_t owner) {
763         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
764         LDKTrustedClosingTransaction ret_var = *CResult_TrustedClosingTransactionNoneZ_get_ok(owner_conv);
765         uint32_t ret_ref = 0;
766         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
767         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
768         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
769         ret_ref = (uintptr_t)ret_var.inner & ~1;
770         return ret_ref;
771 }
772
773 static inline void CResult_TrustedClosingTransactionNoneZ_get_err(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
774 CHECK(!owner->result_ok);
775         return *owner->contents.err;
776 }
777 void  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_get_err"))) TS_CResult_TrustedClosingTransactionNoneZ_get_err(uint32_t owner) {
778         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
779         CResult_TrustedClosingTransactionNoneZ_get_err(owner_conv);
780 }
781
782 static inline struct LDKCommitmentTransaction CResult_CommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
783 CHECK(owner->result_ok);
784         return CommitmentTransaction_clone(&*owner->contents.result);
785 }
786 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_get_ok(uint32_t owner) {
787         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
788         LDKCommitmentTransaction ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
789         uint32_t ret_ref = 0;
790         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
791         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
792         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
793         ret_ref = (uintptr_t)ret_var.inner;
794         if (ret_var.is_owned) {
795                 ret_ref |= 1;
796         }
797         return ret_ref;
798 }
799
800 static inline struct LDKDecodeError CResult_CommitmentTransactionDecodeErrorZ_get_err(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
801 CHECK(!owner->result_ok);
802         return DecodeError_clone(&*owner->contents.err);
803 }
804 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_CommitmentTransactionDecodeErrorZ_get_err(uint32_t owner) {
805         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
806         LDKDecodeError ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_err(owner_conv);
807         uint32_t ret_ref = 0;
808         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
809         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
810         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
811         ret_ref = (uintptr_t)ret_var.inner;
812         if (ret_var.is_owned) {
813                 ret_ref |= 1;
814         }
815         return ret_ref;
816 }
817
818 static inline struct LDKTrustedCommitmentTransaction *CResult_TrustedCommitmentTransactionNoneZ_get_ok(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
819 CHECK(owner->result_ok);
820         return &*owner->contents.result;
821 }
822 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_get_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_get_ok(uint32_t owner) {
823         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
824         LDKTrustedCommitmentTransaction ret_var = *CResult_TrustedCommitmentTransactionNoneZ_get_ok(owner_conv);
825         uint32_t ret_ref = 0;
826         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
827         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
828         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
829         ret_ref = (uintptr_t)ret_var.inner & ~1;
830         return ret_ref;
831 }
832
833 static inline void CResult_TrustedCommitmentTransactionNoneZ_get_err(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
834 CHECK(!owner->result_ok);
835         return *owner->contents.err;
836 }
837 void  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_get_err"))) TS_CResult_TrustedCommitmentTransactionNoneZ_get_err(uint32_t owner) {
838         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
839         CResult_TrustedCommitmentTransactionNoneZ_get_err(owner_conv);
840 }
841
842 static inline struct LDKCVec_SignatureZ CResult_CVec_SignatureZNoneZ_get_ok(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
843 CHECK(owner->result_ok);
844         return *owner->contents.result;
845 }
846 ptrArray  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_get_ok"))) TS_CResult_CVec_SignatureZNoneZ_get_ok(uint32_t owner) {
847         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
848         LDKCVec_SignatureZ ret_var = CResult_CVec_SignatureZNoneZ_get_ok(owner_conv);
849         ptrArray ret_arr = NULL;
850         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
851         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
852         for (size_t m = 0; m < ret_var.datalen; m++) {
853                 int8_tArray ret_conv_12_arr = init_int8_tArray(64, __LINE__);
854                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compact_form, 64);
855                 ret_arr_ptr[m] = ret_conv_12_arr;
856         }
857         
858         return ret_arr;
859 }
860
861 static inline void CResult_CVec_SignatureZNoneZ_get_err(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
862 CHECK(!owner->result_ok);
863         return *owner->contents.err;
864 }
865 void  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_get_err"))) TS_CResult_CVec_SignatureZNoneZ_get_err(uint32_t owner) {
866         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
867         CResult_CVec_SignatureZNoneZ_get_err(owner_conv);
868 }
869
870 static inline struct LDKShutdownScript CResult_ShutdownScriptDecodeErrorZ_get_ok(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
871 CHECK(owner->result_ok);
872         return ShutdownScript_clone(&*owner->contents.result);
873 }
874 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_get_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_get_ok(uint32_t owner) {
875         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
876         LDKShutdownScript ret_var = CResult_ShutdownScriptDecodeErrorZ_get_ok(owner_conv);
877         uint32_t ret_ref = 0;
878         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
879         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
880         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
881         ret_ref = (uintptr_t)ret_var.inner;
882         if (ret_var.is_owned) {
883                 ret_ref |= 1;
884         }
885         return ret_ref;
886 }
887
888 static inline struct LDKDecodeError CResult_ShutdownScriptDecodeErrorZ_get_err(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
889 CHECK(!owner->result_ok);
890         return DecodeError_clone(&*owner->contents.err);
891 }
892 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_get_err"))) TS_CResult_ShutdownScriptDecodeErrorZ_get_err(uint32_t owner) {
893         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
894         LDKDecodeError ret_var = CResult_ShutdownScriptDecodeErrorZ_get_err(owner_conv);
895         uint32_t ret_ref = 0;
896         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
897         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
898         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
899         ret_ref = (uintptr_t)ret_var.inner;
900         if (ret_var.is_owned) {
901                 ret_ref |= 1;
902         }
903         return ret_ref;
904 }
905
906 static inline struct LDKShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
907 CHECK(owner->result_ok);
908         return ShutdownScript_clone(&*owner->contents.result);
909 }
910 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(uint32_t owner) {
911         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
912         LDKShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(owner_conv);
913         uint32_t ret_ref = 0;
914         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
915         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
916         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
917         ret_ref = (uintptr_t)ret_var.inner;
918         if (ret_var.is_owned) {
919                 ret_ref |= 1;
920         }
921         return ret_ref;
922 }
923
924 static inline struct LDKInvalidShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
925 CHECK(!owner->result_ok);
926         return InvalidShutdownScript_clone(&*owner->contents.err);
927 }
928 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_err"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(uint32_t owner) {
929         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
930         LDKInvalidShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(owner_conv);
931         uint32_t ret_ref = 0;
932         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
933         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
934         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
935         ret_ref = (uintptr_t)ret_var.inner;
936         if (ret_var.is_owned) {
937                 ret_ref |= 1;
938         }
939         return ret_ref;
940 }
941
942 static inline struct LDKRouteHop CResult_RouteHopDecodeErrorZ_get_ok(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
943 CHECK(owner->result_ok);
944         return RouteHop_clone(&*owner->contents.result);
945 }
946 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_get_ok"))) TS_CResult_RouteHopDecodeErrorZ_get_ok(uint32_t owner) {
947         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
948         LDKRouteHop ret_var = CResult_RouteHopDecodeErrorZ_get_ok(owner_conv);
949         uint32_t ret_ref = 0;
950         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
951         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
952         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
953         ret_ref = (uintptr_t)ret_var.inner;
954         if (ret_var.is_owned) {
955                 ret_ref |= 1;
956         }
957         return ret_ref;
958 }
959
960 static inline struct LDKDecodeError CResult_RouteHopDecodeErrorZ_get_err(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
961 CHECK(!owner->result_ok);
962         return DecodeError_clone(&*owner->contents.err);
963 }
964 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_get_err"))) TS_CResult_RouteHopDecodeErrorZ_get_err(uint32_t owner) {
965         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
966         LDKDecodeError ret_var = CResult_RouteHopDecodeErrorZ_get_err(owner_conv);
967         uint32_t ret_ref = 0;
968         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
969         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
970         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
971         ret_ref = (uintptr_t)ret_var.inner;
972         if (ret_var.is_owned) {
973                 ret_ref |= 1;
974         }
975         return ret_ref;
976 }
977
978 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
979         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
980         for (size_t i = 0; i < ret.datalen; i++) {
981                 ret.data[i] = RouteHop_clone(&orig->data[i]);
982         }
983         return ret;
984 }
985 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
986         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
987         for (size_t i = 0; i < ret.datalen; i++) {
988                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
989         }
990         return ret;
991 }
992 static inline struct LDKRoute CResult_RouteDecodeErrorZ_get_ok(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
993 CHECK(owner->result_ok);
994         return Route_clone(&*owner->contents.result);
995 }
996 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_get_ok"))) TS_CResult_RouteDecodeErrorZ_get_ok(uint32_t owner) {
997         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
998         LDKRoute ret_var = CResult_RouteDecodeErrorZ_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_RouteDecodeErrorZ_get_err(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
1011 CHECK(!owner->result_ok);
1012         return DecodeError_clone(&*owner->contents.err);
1013 }
1014 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_get_err"))) TS_CResult_RouteDecodeErrorZ_get_err(uint32_t owner) {
1015         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
1016         LDKDecodeError ret_var = CResult_RouteDecodeErrorZ_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 struct LDKRouteParameters CResult_RouteParametersDecodeErrorZ_get_ok(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1029 CHECK(owner->result_ok);
1030         return RouteParameters_clone(&*owner->contents.result);
1031 }
1032 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_get_ok"))) TS_CResult_RouteParametersDecodeErrorZ_get_ok(uint32_t owner) {
1033         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
1034         LDKRouteParameters ret_var = CResult_RouteParametersDecodeErrorZ_get_ok(owner_conv);
1035         uint32_t ret_ref = 0;
1036         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1037         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1038         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1039         ret_ref = (uintptr_t)ret_var.inner;
1040         if (ret_var.is_owned) {
1041                 ret_ref |= 1;
1042         }
1043         return ret_ref;
1044 }
1045
1046 static inline struct LDKDecodeError CResult_RouteParametersDecodeErrorZ_get_err(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1047 CHECK(!owner->result_ok);
1048         return DecodeError_clone(&*owner->contents.err);
1049 }
1050 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_get_err"))) TS_CResult_RouteParametersDecodeErrorZ_get_err(uint32_t owner) {
1051         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
1052         LDKDecodeError ret_var = CResult_RouteParametersDecodeErrorZ_get_err(owner_conv);
1053         uint32_t ret_ref = 0;
1054         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1055         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1056         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1057         ret_ref = (uintptr_t)ret_var.inner;
1058         if (ret_var.is_owned) {
1059                 ret_ref |= 1;
1060         }
1061         return ret_ref;
1062 }
1063
1064 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
1065         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
1066         for (size_t i = 0; i < ret.datalen; i++) {
1067                 ret.data[i] = RouteHint_clone(&orig->data[i]);
1068         }
1069         return ret;
1070 }
1071 uint32_t __attribute__((export_name("TS_LDKCOption_u64Z_ty_from_ptr"))) TS_LDKCOption_u64Z_ty_from_ptr(uint32_t ptr) {
1072         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1073         switch(obj->tag) {
1074                 case LDKCOption_u64Z_Some: return 0;
1075                 case LDKCOption_u64Z_None: return 1;
1076                 default: abort();
1077         }
1078 }
1079 int64_t __attribute__((export_name("TS_LDKCOption_u64Z_Some_get_some"))) TS_LDKCOption_u64Z_Some_get_some(uint32_t ptr) {
1080         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1081         assert(obj->tag == LDKCOption_u64Z_Some);
1082                         int64_t some_conv = obj->some;
1083         return some_conv;
1084 }
1085 static inline struct LDKPaymentParameters CResult_PaymentParametersDecodeErrorZ_get_ok(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1086 CHECK(owner->result_ok);
1087         return PaymentParameters_clone(&*owner->contents.result);
1088 }
1089 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_get_ok"))) TS_CResult_PaymentParametersDecodeErrorZ_get_ok(uint32_t owner) {
1090         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1091         LDKPaymentParameters ret_var = CResult_PaymentParametersDecodeErrorZ_get_ok(owner_conv);
1092         uint32_t ret_ref = 0;
1093         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1094         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1095         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1096         ret_ref = (uintptr_t)ret_var.inner;
1097         if (ret_var.is_owned) {
1098                 ret_ref |= 1;
1099         }
1100         return ret_ref;
1101 }
1102
1103 static inline struct LDKDecodeError CResult_PaymentParametersDecodeErrorZ_get_err(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1104 CHECK(!owner->result_ok);
1105         return DecodeError_clone(&*owner->contents.err);
1106 }
1107 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_get_err"))) TS_CResult_PaymentParametersDecodeErrorZ_get_err(uint32_t owner) {
1108         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1109         LDKDecodeError ret_var = CResult_PaymentParametersDecodeErrorZ_get_err(owner_conv);
1110         uint32_t ret_ref = 0;
1111         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1112         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1113         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1114         ret_ref = (uintptr_t)ret_var.inner;
1115         if (ret_var.is_owned) {
1116                 ret_ref |= 1;
1117         }
1118         return ret_ref;
1119 }
1120
1121 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
1122         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
1123         for (size_t i = 0; i < ret.datalen; i++) {
1124                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
1125         }
1126         return ret;
1127 }
1128 static inline struct LDKRouteHint CResult_RouteHintDecodeErrorZ_get_ok(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1129 CHECK(owner->result_ok);
1130         return RouteHint_clone(&*owner->contents.result);
1131 }
1132 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_get_ok"))) TS_CResult_RouteHintDecodeErrorZ_get_ok(uint32_t owner) {
1133         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1134         LDKRouteHint ret_var = CResult_RouteHintDecodeErrorZ_get_ok(owner_conv);
1135         uint32_t ret_ref = 0;
1136         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1137         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1138         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1139         ret_ref = (uintptr_t)ret_var.inner;
1140         if (ret_var.is_owned) {
1141                 ret_ref |= 1;
1142         }
1143         return ret_ref;
1144 }
1145
1146 static inline struct LDKDecodeError CResult_RouteHintDecodeErrorZ_get_err(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1147 CHECK(!owner->result_ok);
1148         return DecodeError_clone(&*owner->contents.err);
1149 }
1150 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_get_err"))) TS_CResult_RouteHintDecodeErrorZ_get_err(uint32_t owner) {
1151         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1152         LDKDecodeError ret_var = CResult_RouteHintDecodeErrorZ_get_err(owner_conv);
1153         uint32_t ret_ref = 0;
1154         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1155         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1156         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1157         ret_ref = (uintptr_t)ret_var.inner;
1158         if (ret_var.is_owned) {
1159                 ret_ref |= 1;
1160         }
1161         return ret_ref;
1162 }
1163
1164 static inline struct LDKRouteHintHop CResult_RouteHintHopDecodeErrorZ_get_ok(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1165 CHECK(owner->result_ok);
1166         return RouteHintHop_clone(&*owner->contents.result);
1167 }
1168 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_get_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_get_ok(uint32_t owner) {
1169         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1170         LDKRouteHintHop ret_var = CResult_RouteHintHopDecodeErrorZ_get_ok(owner_conv);
1171         uint32_t ret_ref = 0;
1172         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1173         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1174         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1175         ret_ref = (uintptr_t)ret_var.inner;
1176         if (ret_var.is_owned) {
1177                 ret_ref |= 1;
1178         }
1179         return ret_ref;
1180 }
1181
1182 static inline struct LDKDecodeError CResult_RouteHintHopDecodeErrorZ_get_err(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1183 CHECK(!owner->result_ok);
1184         return DecodeError_clone(&*owner->contents.err);
1185 }
1186 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_get_err"))) TS_CResult_RouteHintHopDecodeErrorZ_get_err(uint32_t owner) {
1187         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1188         LDKDecodeError ret_var = CResult_RouteHintHopDecodeErrorZ_get_err(owner_conv);
1189         uint32_t ret_ref = 0;
1190         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1191         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1192         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1193         ret_ref = (uintptr_t)ret_var.inner;
1194         if (ret_var.is_owned) {
1195                 ret_ref |= 1;
1196         }
1197         return ret_ref;
1198 }
1199
1200 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1201         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1202         for (size_t i = 0; i < ret.datalen; i++) {
1203                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1204         }
1205         return ret;
1206 }
1207 static inline struct LDKRoute CResult_RouteLightningErrorZ_get_ok(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1208 CHECK(owner->result_ok);
1209         return Route_clone(&*owner->contents.result);
1210 }
1211 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_get_ok"))) TS_CResult_RouteLightningErrorZ_get_ok(uint32_t owner) {
1212         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1213         LDKRoute ret_var = CResult_RouteLightningErrorZ_get_ok(owner_conv);
1214         uint32_t ret_ref = 0;
1215         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1216         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1217         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1218         ret_ref = (uintptr_t)ret_var.inner;
1219         if (ret_var.is_owned) {
1220                 ret_ref |= 1;
1221         }
1222         return ret_ref;
1223 }
1224
1225 static inline struct LDKLightningError CResult_RouteLightningErrorZ_get_err(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1226 CHECK(!owner->result_ok);
1227         return LightningError_clone(&*owner->contents.err);
1228 }
1229 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_get_err"))) TS_CResult_RouteLightningErrorZ_get_err(uint32_t owner) {
1230         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1231         LDKLightningError ret_var = CResult_RouteLightningErrorZ_get_err(owner_conv);
1232         uint32_t ret_ref = 0;
1233         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1234         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1235         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1236         ret_ref = (uintptr_t)ret_var.inner;
1237         if (ret_var.is_owned) {
1238                 ret_ref |= 1;
1239         }
1240         return ret_ref;
1241 }
1242
1243 static inline struct LDKTxOut CResult_TxOutAccessErrorZ_get_ok(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
1244 CHECK(owner->result_ok);
1245         return TxOut_clone(&*owner->contents.result);
1246 }
1247 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_get_ok"))) TS_CResult_TxOutAccessErrorZ_get_ok(uint32_t owner) {
1248         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
1249         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
1250         *ret_ref = CResult_TxOutAccessErrorZ_get_ok(owner_conv);
1251         return (uint32_t)ret_ref;
1252 }
1253
1254 static inline enum LDKAccessError CResult_TxOutAccessErrorZ_get_err(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
1255 CHECK(!owner->result_ok);
1256         return AccessError_clone(&*owner->contents.err);
1257 }
1258 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_get_err"))) TS_CResult_TxOutAccessErrorZ_get_err(uint32_t owner) {
1259         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
1260         uint32_t ret_conv = LDKAccessError_to_js(CResult_TxOutAccessErrorZ_get_err(owner_conv));
1261         return ret_conv;
1262 }
1263
1264 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
1265         return owner->a;
1266 }
1267 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_get_a"))) TS_C2Tuple_usizeTransactionZ_get_a(uint32_t owner) {
1268         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
1269         uint32_t ret_conv = C2Tuple_usizeTransactionZ_get_a(owner_conv);
1270         return ret_conv;
1271 }
1272
1273 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
1274         return owner->b;
1275 }
1276 int8_tArray  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_get_b"))) TS_C2Tuple_usizeTransactionZ_get_b(uint32_t owner) {
1277         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
1278         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(owner_conv);
1279         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
1280         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
1281         return ret_arr;
1282 }
1283
1284 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
1285         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
1286         for (size_t i = 0; i < ret.datalen; i++) {
1287                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
1288         }
1289         return ret;
1290 }
1291 static inline LDKCVec_TxidZ CVec_TxidZ_clone(const LDKCVec_TxidZ *orig) {
1292         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
1293         for (size_t i = 0; i < ret.datalen; i++) {
1294                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
1295         }
1296         return ret;
1297 }
1298 static inline void CResult_NoneChannelMonitorUpdateErrZ_get_ok(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
1299 CHECK(owner->result_ok);
1300         return *owner->contents.result;
1301 }
1302 void  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_get_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_get_ok(uint32_t owner) {
1303         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
1304         CResult_NoneChannelMonitorUpdateErrZ_get_ok(owner_conv);
1305 }
1306
1307 static inline enum LDKChannelMonitorUpdateErr CResult_NoneChannelMonitorUpdateErrZ_get_err(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
1308 CHECK(!owner->result_ok);
1309         return ChannelMonitorUpdateErr_clone(&*owner->contents.err);
1310 }
1311 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_get_err"))) TS_CResult_NoneChannelMonitorUpdateErrZ_get_err(uint32_t owner) {
1312         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
1313         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(CResult_NoneChannelMonitorUpdateErrZ_get_err(owner_conv));
1314         return ret_conv;
1315 }
1316
1317 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_ty_from_ptr"))) TS_LDKMonitorEvent_ty_from_ptr(uint32_t ptr) {
1318         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1319         switch(obj->tag) {
1320                 case LDKMonitorEvent_HTLCEvent: return 0;
1321                 case LDKMonitorEvent_CommitmentTxConfirmed: return 1;
1322                 case LDKMonitorEvent_UpdateCompleted: return 2;
1323                 case LDKMonitorEvent_UpdateFailed: return 3;
1324                 default: abort();
1325         }
1326 }
1327 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_HTLCEvent_get_htlc_event"))) TS_LDKMonitorEvent_HTLCEvent_get_htlc_event(uint32_t ptr) {
1328         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1329         assert(obj->tag == LDKMonitorEvent_HTLCEvent);
1330                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
1331                         uint32_t htlc_event_ref = 0;
1332                         CHECK((((uintptr_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1333                         CHECK((((uintptr_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1334                         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
1335                         htlc_event_ref = (uintptr_t)htlc_event_var.inner & ~1;
1336         return htlc_event_ref;
1337 }
1338 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_CommitmentTxConfirmed_get_commitment_tx_confirmed"))) TS_LDKMonitorEvent_CommitmentTxConfirmed_get_commitment_tx_confirmed(uint32_t ptr) {
1339         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1340         assert(obj->tag == LDKMonitorEvent_CommitmentTxConfirmed);
1341                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
1342                         uint32_t commitment_tx_confirmed_ref = 0;
1343                         CHECK((((uintptr_t)commitment_tx_confirmed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1344                         CHECK((((uintptr_t)&commitment_tx_confirmed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1345                         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_confirmed_var);
1346                         commitment_tx_confirmed_ref = (uintptr_t)commitment_tx_confirmed_var.inner & ~1;
1347         return commitment_tx_confirmed_ref;
1348 }
1349 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateCompleted_get_funding_txo"))) TS_LDKMonitorEvent_UpdateCompleted_get_funding_txo(uint32_t ptr) {
1350         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1351         assert(obj->tag == LDKMonitorEvent_UpdateCompleted);
1352                         LDKOutPoint funding_txo_var = obj->update_completed.funding_txo;
1353                         uint32_t funding_txo_ref = 0;
1354                         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1355                         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1356                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
1357                         funding_txo_ref = (uintptr_t)funding_txo_var.inner & ~1;
1358         return funding_txo_ref;
1359 }
1360 int64_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateCompleted_get_monitor_update_id"))) TS_LDKMonitorEvent_UpdateCompleted_get_monitor_update_id(uint32_t ptr) {
1361         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1362         assert(obj->tag == LDKMonitorEvent_UpdateCompleted);
1363                         int64_t monitor_update_id_conv = obj->update_completed.monitor_update_id;
1364         return monitor_update_id_conv;
1365 }
1366 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateFailed_get_update_failed"))) TS_LDKMonitorEvent_UpdateFailed_get_update_failed(uint32_t ptr) {
1367         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1368         assert(obj->tag == LDKMonitorEvent_UpdateFailed);
1369                         LDKOutPoint update_failed_var = obj->update_failed;
1370                         uint32_t update_failed_ref = 0;
1371                         CHECK((((uintptr_t)update_failed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1372                         CHECK((((uintptr_t)&update_failed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1373                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_failed_var);
1374                         update_failed_ref = (uintptr_t)update_failed_var.inner & ~1;
1375         return update_failed_ref;
1376 }
1377 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
1378         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
1379         for (size_t i = 0; i < ret.datalen; i++) {
1380                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
1381         }
1382         return ret;
1383 }
1384 uint32_t __attribute__((export_name("TS_LDKCOption_C2Tuple_usizeTransactionZZ_ty_from_ptr"))) TS_LDKCOption_C2Tuple_usizeTransactionZZ_ty_from_ptr(uint32_t ptr) {
1385         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
1386         switch(obj->tag) {
1387                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: return 0;
1388                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: return 1;
1389                 default: abort();
1390         }
1391 }
1392 uint32_t __attribute__((export_name("TS_LDKCOption_C2Tuple_usizeTransactionZZ_Some_get_some"))) TS_LDKCOption_C2Tuple_usizeTransactionZZ_Some_get_some(uint32_t ptr) {
1393         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
1394         assert(obj->tag == LDKCOption_C2Tuple_usizeTransactionZZ_Some);
1395                         LDKC2Tuple_usizeTransactionZ* some_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
1396                         *some_conv = obj->some;
1397                         *some_conv = C2Tuple_usizeTransactionZ_clone(some_conv);
1398         return ((uint32_t)some_conv);
1399 }
1400 uint32_t __attribute__((export_name("TS_LDKClosureReason_ty_from_ptr"))) TS_LDKClosureReason_ty_from_ptr(uint32_t ptr) {
1401         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1402         switch(obj->tag) {
1403                 case LDKClosureReason_CounterpartyForceClosed: return 0;
1404                 case LDKClosureReason_HolderForceClosed: return 1;
1405                 case LDKClosureReason_CooperativeClosure: return 2;
1406                 case LDKClosureReason_CommitmentTxConfirmed: return 3;
1407                 case LDKClosureReason_FundingTimedOut: return 4;
1408                 case LDKClosureReason_ProcessingError: return 5;
1409                 case LDKClosureReason_DisconnectedPeer: return 6;
1410                 case LDKClosureReason_OutdatedChannelManager: return 7;
1411                 default: abort();
1412         }
1413 }
1414 jstring __attribute__((export_name("TS_LDKClosureReason_CounterpartyForceClosed_get_peer_msg"))) TS_LDKClosureReason_CounterpartyForceClosed_get_peer_msg(uint32_t ptr) {
1415         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1416         assert(obj->tag == LDKClosureReason_CounterpartyForceClosed);
1417                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
1418                         jstring peer_msg_conv = str_ref_to_ts(peer_msg_str.chars, peer_msg_str.len);
1419         return peer_msg_conv;
1420 }
1421 jstring __attribute__((export_name("TS_LDKClosureReason_ProcessingError_get_err"))) TS_LDKClosureReason_ProcessingError_get_err(uint32_t ptr) {
1422         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1423         assert(obj->tag == LDKClosureReason_ProcessingError);
1424                         LDKStr err_str = obj->processing_error.err;
1425                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
1426         return err_conv;
1427 }
1428 uint32_t __attribute__((export_name("TS_LDKCOption_ClosureReasonZ_ty_from_ptr"))) TS_LDKCOption_ClosureReasonZ_ty_from_ptr(uint32_t ptr) {
1429         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
1430         switch(obj->tag) {
1431                 case LDKCOption_ClosureReasonZ_Some: return 0;
1432                 case LDKCOption_ClosureReasonZ_None: return 1;
1433                 default: abort();
1434         }
1435 }
1436 uint32_t __attribute__((export_name("TS_LDKCOption_ClosureReasonZ_Some_get_some"))) TS_LDKCOption_ClosureReasonZ_Some_get_some(uint32_t ptr) {
1437         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
1438         assert(obj->tag == LDKCOption_ClosureReasonZ_Some);
1439                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
1440         return some_ref;
1441 }
1442 static inline struct LDKCOption_ClosureReasonZ CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
1443 CHECK(owner->result_ok);
1444         return COption_ClosureReasonZ_clone(&*owner->contents.result);
1445 }
1446 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(uint32_t owner) {
1447         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
1448         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
1449         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(owner_conv);
1450         uint32_t ret_ref = (uintptr_t)ret_copy;
1451         return ret_ref;
1452 }
1453
1454 static inline struct LDKDecodeError CResult_COption_ClosureReasonZDecodeErrorZ_get_err(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
1455 CHECK(!owner->result_ok);
1456         return DecodeError_clone(&*owner->contents.err);
1457 }
1458 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_err"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_err(uint32_t owner) {
1459         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
1460         LDKDecodeError ret_var = CResult_COption_ClosureReasonZDecodeErrorZ_get_err(owner_conv);
1461         uint32_t ret_ref = 0;
1462         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1463         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1464         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1465         ret_ref = (uintptr_t)ret_var.inner;
1466         if (ret_var.is_owned) {
1467                 ret_ref |= 1;
1468         }
1469         return ret_ref;
1470 }
1471
1472 uint32_t __attribute__((export_name("TS_LDKNetworkUpdate_ty_from_ptr"))) TS_LDKNetworkUpdate_ty_from_ptr(uint32_t ptr) {
1473         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1474         switch(obj->tag) {
1475                 case LDKNetworkUpdate_ChannelUpdateMessage: return 0;
1476                 case LDKNetworkUpdate_ChannelClosed: return 1;
1477                 case LDKNetworkUpdate_NodeFailure: return 2;
1478                 default: abort();
1479         }
1480 }
1481 uint32_t __attribute__((export_name("TS_LDKNetworkUpdate_ChannelUpdateMessage_get_msg"))) TS_LDKNetworkUpdate_ChannelUpdateMessage_get_msg(uint32_t ptr) {
1482         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1483         assert(obj->tag == LDKNetworkUpdate_ChannelUpdateMessage);
1484                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
1485                         uint32_t msg_ref = 0;
1486                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1487                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1488                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1489                         msg_ref = (uintptr_t)msg_var.inner & ~1;
1490         return msg_ref;
1491 }
1492 int64_t __attribute__((export_name("TS_LDKNetworkUpdate_ChannelClosed_get_short_channel_id"))) TS_LDKNetworkUpdate_ChannelClosed_get_short_channel_id(uint32_t ptr) {
1493         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1494         assert(obj->tag == LDKNetworkUpdate_ChannelClosed);
1495                         int64_t short_channel_id_conv = obj->channel_closed.short_channel_id;
1496         return short_channel_id_conv;
1497 }
1498 jboolean __attribute__((export_name("TS_LDKNetworkUpdate_ChannelClosed_get_is_permanent"))) TS_LDKNetworkUpdate_ChannelClosed_get_is_permanent(uint32_t ptr) {
1499         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1500         assert(obj->tag == LDKNetworkUpdate_ChannelClosed);
1501                         jboolean is_permanent_conv = obj->channel_closed.is_permanent;
1502         return is_permanent_conv;
1503 }
1504 int8_tArray __attribute__((export_name("TS_LDKNetworkUpdate_NodeFailure_get_node_id"))) TS_LDKNetworkUpdate_NodeFailure_get_node_id(uint32_t ptr) {
1505         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1506         assert(obj->tag == LDKNetworkUpdate_NodeFailure);
1507                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
1508                         memcpy(node_id_arr->elems, obj->node_failure.node_id.compressed_form, 33);
1509         return node_id_arr;
1510 }
1511 jboolean __attribute__((export_name("TS_LDKNetworkUpdate_NodeFailure_get_is_permanent"))) TS_LDKNetworkUpdate_NodeFailure_get_is_permanent(uint32_t ptr) {
1512         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1513         assert(obj->tag == LDKNetworkUpdate_NodeFailure);
1514                         jboolean is_permanent_conv = obj->node_failure.is_permanent;
1515         return is_permanent_conv;
1516 }
1517 uint32_t __attribute__((export_name("TS_LDKCOption_NetworkUpdateZ_ty_from_ptr"))) TS_LDKCOption_NetworkUpdateZ_ty_from_ptr(uint32_t ptr) {
1518         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
1519         switch(obj->tag) {
1520                 case LDKCOption_NetworkUpdateZ_Some: return 0;
1521                 case LDKCOption_NetworkUpdateZ_None: return 1;
1522                 default: abort();
1523         }
1524 }
1525 uint32_t __attribute__((export_name("TS_LDKCOption_NetworkUpdateZ_Some_get_some"))) TS_LDKCOption_NetworkUpdateZ_Some_get_some(uint32_t ptr) {
1526         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
1527         assert(obj->tag == LDKCOption_NetworkUpdateZ_Some);
1528                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
1529         return some_ref;
1530 }
1531 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_ty_from_ptr"))) TS_LDKSpendableOutputDescriptor_ty_from_ptr(uint32_t ptr) {
1532         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1533         switch(obj->tag) {
1534                 case LDKSpendableOutputDescriptor_StaticOutput: return 0;
1535                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: return 1;
1536                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: return 2;
1537                 default: abort();
1538         }
1539 }
1540 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticOutput_get_outpoint"))) TS_LDKSpendableOutputDescriptor_StaticOutput_get_outpoint(uint32_t ptr) {
1541         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1542         assert(obj->tag == LDKSpendableOutputDescriptor_StaticOutput);
1543                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1544                         uint32_t outpoint_ref = 0;
1545                         CHECK((((uintptr_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1546                         CHECK((((uintptr_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1547                         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
1548                         outpoint_ref = (uintptr_t)outpoint_var.inner & ~1;
1549         return outpoint_ref;
1550 }
1551 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticOutput_get_output"))) TS_LDKSpendableOutputDescriptor_StaticOutput_get_output(uint32_t ptr) {
1552         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1553         assert(obj->tag == LDKSpendableOutputDescriptor_StaticOutput);
1554                         uint32_t output_ref = ((uintptr_t)&obj->static_output.output) | 1;
1555         return (uint32_t)output_ref;
1556 }
1557 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_DelayedPaymentOutput_get_delayed_payment_output"))) TS_LDKSpendableOutputDescriptor_DelayedPaymentOutput_get_delayed_payment_output(uint32_t ptr) {
1558         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1559         assert(obj->tag == LDKSpendableOutputDescriptor_DelayedPaymentOutput);
1560                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
1561                         uint32_t delayed_payment_output_ref = 0;
1562                         CHECK((((uintptr_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1563                         CHECK((((uintptr_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1564                         CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
1565                         delayed_payment_output_ref = (uintptr_t)delayed_payment_output_var.inner & ~1;
1566         return delayed_payment_output_ref;
1567 }
1568 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticPaymentOutput_get_static_payment_output"))) TS_LDKSpendableOutputDescriptor_StaticPaymentOutput_get_static_payment_output(uint32_t ptr) {
1569         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1570         assert(obj->tag == LDKSpendableOutputDescriptor_StaticPaymentOutput);
1571                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
1572                         uint32_t static_payment_output_ref = 0;
1573                         CHECK((((uintptr_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1574                         CHECK((((uintptr_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1575                         CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
1576                         static_payment_output_ref = (uintptr_t)static_payment_output_var.inner & ~1;
1577         return static_payment_output_ref;
1578 }
1579 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1580         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1581         for (size_t i = 0; i < ret.datalen; i++) {
1582                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1583         }
1584         return ret;
1585 }
1586 uint32_t __attribute__((export_name("TS_LDKPaymentPurpose_ty_from_ptr"))) TS_LDKPaymentPurpose_ty_from_ptr(uint32_t ptr) {
1587         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1588         switch(obj->tag) {
1589                 case LDKPaymentPurpose_InvoicePayment: return 0;
1590                 case LDKPaymentPurpose_SpontaneousPayment: return 1;
1591                 default: abort();
1592         }
1593 }
1594 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_InvoicePayment_get_payment_preimage"))) TS_LDKPaymentPurpose_InvoicePayment_get_payment_preimage(uint32_t ptr) {
1595         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1596         assert(obj->tag == LDKPaymentPurpose_InvoicePayment);
1597                         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
1598                         memcpy(payment_preimage_arr->elems, obj->invoice_payment.payment_preimage.data, 32);
1599         return payment_preimage_arr;
1600 }
1601 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_InvoicePayment_get_payment_secret"))) TS_LDKPaymentPurpose_InvoicePayment_get_payment_secret(uint32_t ptr) {
1602         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1603         assert(obj->tag == LDKPaymentPurpose_InvoicePayment);
1604                         int8_tArray payment_secret_arr = init_int8_tArray(32, __LINE__);
1605                         memcpy(payment_secret_arr->elems, obj->invoice_payment.payment_secret.data, 32);
1606         return payment_secret_arr;
1607 }
1608 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_SpontaneousPayment_get_spontaneous_payment"))) TS_LDKPaymentPurpose_SpontaneousPayment_get_spontaneous_payment(uint32_t ptr) {
1609         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1610         assert(obj->tag == LDKPaymentPurpose_SpontaneousPayment);
1611                         int8_tArray spontaneous_payment_arr = init_int8_tArray(32, __LINE__);
1612                         memcpy(spontaneous_payment_arr->elems, obj->spontaneous_payment.data, 32);
1613         return spontaneous_payment_arr;
1614 }
1615 uint32_t __attribute__((export_name("TS_LDKEvent_ty_from_ptr"))) TS_LDKEvent_ty_from_ptr(uint32_t ptr) {
1616         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1617         switch(obj->tag) {
1618                 case LDKEvent_FundingGenerationReady: return 0;
1619                 case LDKEvent_PaymentReceived: return 1;
1620                 case LDKEvent_PaymentSent: return 2;
1621                 case LDKEvent_PaymentPathFailed: return 3;
1622                 case LDKEvent_PaymentFailed: return 4;
1623                 case LDKEvent_PendingHTLCsForwardable: return 5;
1624                 case LDKEvent_SpendableOutputs: return 6;
1625                 case LDKEvent_PaymentForwarded: return 7;
1626                 case LDKEvent_ChannelClosed: return 8;
1627                 case LDKEvent_DiscardFunding: return 9;
1628                 case LDKEvent_PaymentPathSuccessful: return 10;
1629                 case LDKEvent_OpenChannelRequest: return 11;
1630                 default: abort();
1631         }
1632 }
1633 int8_tArray __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_temporary_channel_id"))) TS_LDKEvent_FundingGenerationReady_get_temporary_channel_id(uint32_t ptr) {
1634         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1635         assert(obj->tag == LDKEvent_FundingGenerationReady);
1636                         int8_tArray temporary_channel_id_arr = init_int8_tArray(32, __LINE__);
1637                         memcpy(temporary_channel_id_arr->elems, obj->funding_generation_ready.temporary_channel_id.data, 32);
1638         return temporary_channel_id_arr;
1639 }
1640 int64_t __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_channel_value_satoshis"))) TS_LDKEvent_FundingGenerationReady_get_channel_value_satoshis(uint32_t ptr) {
1641         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1642         assert(obj->tag == LDKEvent_FundingGenerationReady);
1643                         int64_t channel_value_satoshis_conv = obj->funding_generation_ready.channel_value_satoshis;
1644         return channel_value_satoshis_conv;
1645 }
1646 int8_tArray __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_output_script"))) TS_LDKEvent_FundingGenerationReady_get_output_script(uint32_t ptr) {
1647         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1648         assert(obj->tag == LDKEvent_FundingGenerationReady);
1649                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
1650                         int8_tArray output_script_arr = init_int8_tArray(output_script_var.datalen, __LINE__);
1651                         memcpy(output_script_arr->elems, output_script_var.data, output_script_var.datalen);
1652         return output_script_arr;
1653 }
1654 int64_t __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_user_channel_id"))) TS_LDKEvent_FundingGenerationReady_get_user_channel_id(uint32_t ptr) {
1655         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1656         assert(obj->tag == LDKEvent_FundingGenerationReady);
1657                         int64_t user_channel_id_conv = obj->funding_generation_ready.user_channel_id;
1658         return user_channel_id_conv;
1659 }
1660 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_payment_hash"))) TS_LDKEvent_PaymentReceived_get_payment_hash(uint32_t ptr) {
1661         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1662         assert(obj->tag == LDKEvent_PaymentReceived);
1663                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1664                         memcpy(payment_hash_arr->elems, obj->payment_received.payment_hash.data, 32);
1665         return payment_hash_arr;
1666 }
1667 int64_t __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_amt"))) TS_LDKEvent_PaymentReceived_get_amt(uint32_t ptr) {
1668         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1669         assert(obj->tag == LDKEvent_PaymentReceived);
1670                         int64_t amt_conv = obj->payment_received.amt;
1671         return amt_conv;
1672 }
1673 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_purpose"))) TS_LDKEvent_PaymentReceived_get_purpose(uint32_t ptr) {
1674         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1675         assert(obj->tag == LDKEvent_PaymentReceived);
1676                         uint32_t purpose_ref = ((uintptr_t)&obj->payment_received.purpose) | 1;
1677         return purpose_ref;
1678 }
1679 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_id"))) TS_LDKEvent_PaymentSent_get_payment_id(uint32_t ptr) {
1680         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1681         assert(obj->tag == LDKEvent_PaymentSent);
1682                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1683                         memcpy(payment_id_arr->elems, obj->payment_sent.payment_id.data, 32);
1684         return payment_id_arr;
1685 }
1686 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_preimage"))) TS_LDKEvent_PaymentSent_get_payment_preimage(uint32_t ptr) {
1687         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1688         assert(obj->tag == LDKEvent_PaymentSent);
1689                         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
1690                         memcpy(payment_preimage_arr->elems, obj->payment_sent.payment_preimage.data, 32);
1691         return payment_preimage_arr;
1692 }
1693 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_hash"))) TS_LDKEvent_PaymentSent_get_payment_hash(uint32_t ptr) {
1694         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1695         assert(obj->tag == LDKEvent_PaymentSent);
1696                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1697                         memcpy(payment_hash_arr->elems, obj->payment_sent.payment_hash.data, 32);
1698         return payment_hash_arr;
1699 }
1700 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentSent_get_fee_paid_msat"))) TS_LDKEvent_PaymentSent_get_fee_paid_msat(uint32_t ptr) {
1701         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1702         assert(obj->tag == LDKEvent_PaymentSent);
1703                         uint32_t fee_paid_msat_ref = ((uintptr_t)&obj->payment_sent.fee_paid_msat) | 1;
1704         return fee_paid_msat_ref;
1705 }
1706 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_payment_id"))) TS_LDKEvent_PaymentPathFailed_get_payment_id(uint32_t ptr) {
1707         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1708         assert(obj->tag == LDKEvent_PaymentPathFailed);
1709                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1710                         memcpy(payment_id_arr->elems, obj->payment_path_failed.payment_id.data, 32);
1711         return payment_id_arr;
1712 }
1713 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_payment_hash"))) TS_LDKEvent_PaymentPathFailed_get_payment_hash(uint32_t ptr) {
1714         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1715         assert(obj->tag == LDKEvent_PaymentPathFailed);
1716                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1717                         memcpy(payment_hash_arr->elems, obj->payment_path_failed.payment_hash.data, 32);
1718         return payment_hash_arr;
1719 }
1720 jboolean __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_rejected_by_dest"))) TS_LDKEvent_PaymentPathFailed_get_rejected_by_dest(uint32_t ptr) {
1721         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1722         assert(obj->tag == LDKEvent_PaymentPathFailed);
1723                         jboolean rejected_by_dest_conv = obj->payment_path_failed.rejected_by_dest;
1724         return rejected_by_dest_conv;
1725 }
1726 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_network_update"))) TS_LDKEvent_PaymentPathFailed_get_network_update(uint32_t ptr) {
1727         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1728         assert(obj->tag == LDKEvent_PaymentPathFailed);
1729                         uint32_t network_update_ref = ((uintptr_t)&obj->payment_path_failed.network_update) | 1;
1730         return network_update_ref;
1731 }
1732 jboolean __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_all_paths_failed"))) TS_LDKEvent_PaymentPathFailed_get_all_paths_failed(uint32_t ptr) {
1733         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1734         assert(obj->tag == LDKEvent_PaymentPathFailed);
1735                         jboolean all_paths_failed_conv = obj->payment_path_failed.all_paths_failed;
1736         return all_paths_failed_conv;
1737 }
1738 uint32_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_path"))) TS_LDKEvent_PaymentPathFailed_get_path(uint32_t ptr) {
1739         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1740         assert(obj->tag == LDKEvent_PaymentPathFailed);
1741                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
1742                         uint32_tArray path_arr = NULL;
1743                         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
1744                         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
1745                         for (size_t k = 0; k < path_var.datalen; k++) {
1746                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1747                                 uint32_t path_conv_10_ref = 0;
1748                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1749                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1750                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1751                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
1752                                 path_arr_ptr[k] = path_conv_10_ref;
1753                         }
1754                         
1755         return path_arr;
1756 }
1757 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_short_channel_id"))) TS_LDKEvent_PaymentPathFailed_get_short_channel_id(uint32_t ptr) {
1758         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1759         assert(obj->tag == LDKEvent_PaymentPathFailed);
1760                         uint32_t short_channel_id_ref = ((uintptr_t)&obj->payment_path_failed.short_channel_id) | 1;
1761         return short_channel_id_ref;
1762 }
1763 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_retry"))) TS_LDKEvent_PaymentPathFailed_get_retry(uint32_t ptr) {
1764         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1765         assert(obj->tag == LDKEvent_PaymentPathFailed);
1766                         LDKRouteParameters retry_var = obj->payment_path_failed.retry;
1767                         uint32_t retry_ref = 0;
1768                         if ((uintptr_t)retry_var.inner > 4096) {
1769                                 CHECK((((uintptr_t)retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1770                                 CHECK((((uintptr_t)&retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1771                         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_var);
1772                                 retry_ref = (uintptr_t)retry_var.inner & ~1;
1773                         }
1774         return retry_ref;
1775 }
1776 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentFailed_get_payment_id"))) TS_LDKEvent_PaymentFailed_get_payment_id(uint32_t ptr) {
1777         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1778         assert(obj->tag == LDKEvent_PaymentFailed);
1779                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1780                         memcpy(payment_id_arr->elems, obj->payment_failed.payment_id.data, 32);
1781         return payment_id_arr;
1782 }
1783 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentFailed_get_payment_hash"))) TS_LDKEvent_PaymentFailed_get_payment_hash(uint32_t ptr) {
1784         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1785         assert(obj->tag == LDKEvent_PaymentFailed);
1786                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1787                         memcpy(payment_hash_arr->elems, obj->payment_failed.payment_hash.data, 32);
1788         return payment_hash_arr;
1789 }
1790 int64_t __attribute__((export_name("TS_LDKEvent_PendingHTLCsForwardable_get_time_forwardable"))) TS_LDKEvent_PendingHTLCsForwardable_get_time_forwardable(uint32_t ptr) {
1791         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1792         assert(obj->tag == LDKEvent_PendingHTLCsForwardable);
1793                         int64_t time_forwardable_conv = obj->pending_htl_cs_forwardable.time_forwardable;
1794         return time_forwardable_conv;
1795 }
1796 uint32_tArray __attribute__((export_name("TS_LDKEvent_SpendableOutputs_get_outputs"))) TS_LDKEvent_SpendableOutputs_get_outputs(uint32_t ptr) {
1797         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1798         assert(obj->tag == LDKEvent_SpendableOutputs);
1799                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
1800                         uint32_tArray outputs_arr = NULL;
1801                         outputs_arr = init_uint32_tArray(outputs_var.datalen, __LINE__);
1802                         uint32_t *outputs_arr_ptr = (uint32_t*)(((uint8_t*)outputs_arr) + 4);
1803                         for (size_t b = 0; b < outputs_var.datalen; b++) {
1804                                 uint32_t outputs_conv_27_ref = ((uintptr_t)&outputs_var.data[b]) | 1;
1805                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
1806                         }
1807                         
1808         return outputs_arr;
1809 }
1810 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_fee_earned_msat"))) TS_LDKEvent_PaymentForwarded_get_fee_earned_msat(uint32_t ptr) {
1811         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1812         assert(obj->tag == LDKEvent_PaymentForwarded);
1813                         uint32_t fee_earned_msat_ref = ((uintptr_t)&obj->payment_forwarded.fee_earned_msat) | 1;
1814         return fee_earned_msat_ref;
1815 }
1816 jboolean __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_claim_from_onchain_tx"))) TS_LDKEvent_PaymentForwarded_get_claim_from_onchain_tx(uint32_t ptr) {
1817         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1818         assert(obj->tag == LDKEvent_PaymentForwarded);
1819                         jboolean claim_from_onchain_tx_conv = obj->payment_forwarded.claim_from_onchain_tx;
1820         return claim_from_onchain_tx_conv;
1821 }
1822 int8_tArray __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_channel_id"))) TS_LDKEvent_ChannelClosed_get_channel_id(uint32_t ptr) {
1823         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1824         assert(obj->tag == LDKEvent_ChannelClosed);
1825                         int8_tArray channel_id_arr = init_int8_tArray(32, __LINE__);
1826                         memcpy(channel_id_arr->elems, obj->channel_closed.channel_id.data, 32);
1827         return channel_id_arr;
1828 }
1829 int64_t __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_user_channel_id"))) TS_LDKEvent_ChannelClosed_get_user_channel_id(uint32_t ptr) {
1830         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1831         assert(obj->tag == LDKEvent_ChannelClosed);
1832                         int64_t user_channel_id_conv = obj->channel_closed.user_channel_id;
1833         return user_channel_id_conv;
1834 }
1835 uint32_t __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_reason"))) TS_LDKEvent_ChannelClosed_get_reason(uint32_t ptr) {
1836         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1837         assert(obj->tag == LDKEvent_ChannelClosed);
1838                         uint32_t reason_ref = ((uintptr_t)&obj->channel_closed.reason) | 1;
1839         return reason_ref;
1840 }
1841 int8_tArray __attribute__((export_name("TS_LDKEvent_DiscardFunding_get_channel_id"))) TS_LDKEvent_DiscardFunding_get_channel_id(uint32_t ptr) {
1842         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1843         assert(obj->tag == LDKEvent_DiscardFunding);
1844                         int8_tArray channel_id_arr = init_int8_tArray(32, __LINE__);
1845                         memcpy(channel_id_arr->elems, obj->discard_funding.channel_id.data, 32);
1846         return channel_id_arr;
1847 }
1848 int8_tArray __attribute__((export_name("TS_LDKEvent_DiscardFunding_get_transaction"))) TS_LDKEvent_DiscardFunding_get_transaction(uint32_t ptr) {
1849         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1850         assert(obj->tag == LDKEvent_DiscardFunding);
1851                         LDKTransaction transaction_var = obj->discard_funding.transaction;
1852                         int8_tArray transaction_arr = init_int8_tArray(transaction_var.datalen, __LINE__);
1853                         memcpy(transaction_arr->elems, transaction_var.data, transaction_var.datalen);
1854         return transaction_arr;
1855 }
1856 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_payment_id"))) TS_LDKEvent_PaymentPathSuccessful_get_payment_id(uint32_t ptr) {
1857         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1858         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1859                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1860                         memcpy(payment_id_arr->elems, obj->payment_path_successful.payment_id.data, 32);
1861         return payment_id_arr;
1862 }
1863 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_payment_hash"))) TS_LDKEvent_PaymentPathSuccessful_get_payment_hash(uint32_t ptr) {
1864         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1865         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1866                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1867                         memcpy(payment_hash_arr->elems, obj->payment_path_successful.payment_hash.data, 32);
1868         return payment_hash_arr;
1869 }
1870 uint32_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_path"))) TS_LDKEvent_PaymentPathSuccessful_get_path(uint32_t ptr) {
1871         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1872         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1873                         LDKCVec_RouteHopZ path_var = obj->payment_path_successful.path;
1874                         uint32_tArray path_arr = NULL;
1875                         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
1876                         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
1877                         for (size_t k = 0; k < path_var.datalen; k++) {
1878                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1879                                 uint32_t path_conv_10_ref = 0;
1880                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1881                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1882                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1883                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
1884                                 path_arr_ptr[k] = path_conv_10_ref;
1885                         }
1886                         
1887         return path_arr;
1888 }
1889 int8_tArray __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_temporary_channel_id"))) TS_LDKEvent_OpenChannelRequest_get_temporary_channel_id(uint32_t ptr) {
1890         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1891         assert(obj->tag == LDKEvent_OpenChannelRequest);
1892                         int8_tArray temporary_channel_id_arr = init_int8_tArray(32, __LINE__);
1893                         memcpy(temporary_channel_id_arr->elems, obj->open_channel_request.temporary_channel_id.data, 32);
1894         return temporary_channel_id_arr;
1895 }
1896 int8_tArray __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_counterparty_node_id"))) TS_LDKEvent_OpenChannelRequest_get_counterparty_node_id(uint32_t ptr) {
1897         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1898         assert(obj->tag == LDKEvent_OpenChannelRequest);
1899                         int8_tArray counterparty_node_id_arr = init_int8_tArray(33, __LINE__);
1900                         memcpy(counterparty_node_id_arr->elems, obj->open_channel_request.counterparty_node_id.compressed_form, 33);
1901         return counterparty_node_id_arr;
1902 }
1903 int64_t __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_funding_satoshis"))) TS_LDKEvent_OpenChannelRequest_get_funding_satoshis(uint32_t ptr) {
1904         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1905         assert(obj->tag == LDKEvent_OpenChannelRequest);
1906                         int64_t funding_satoshis_conv = obj->open_channel_request.funding_satoshis;
1907         return funding_satoshis_conv;
1908 }
1909 int64_t __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_push_msat"))) TS_LDKEvent_OpenChannelRequest_get_push_msat(uint32_t ptr) {
1910         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1911         assert(obj->tag == LDKEvent_OpenChannelRequest);
1912                         int64_t push_msat_conv = obj->open_channel_request.push_msat;
1913         return push_msat_conv;
1914 }
1915 uint32_t __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_channel_type"))) TS_LDKEvent_OpenChannelRequest_get_channel_type(uint32_t ptr) {
1916         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1917         assert(obj->tag == LDKEvent_OpenChannelRequest);
1918                         LDKChannelTypeFeatures channel_type_var = obj->open_channel_request.channel_type;
1919                         uint32_t channel_type_ref = 0;
1920                         CHECK((((uintptr_t)channel_type_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1921                         CHECK((((uintptr_t)&channel_type_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1922                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_var);
1923                         channel_type_ref = (uintptr_t)channel_type_var.inner & ~1;
1924         return channel_type_ref;
1925 }
1926 uint32_t __attribute__((export_name("TS_LDKCOption_EventZ_ty_from_ptr"))) TS_LDKCOption_EventZ_ty_from_ptr(uint32_t ptr) {
1927         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
1928         switch(obj->tag) {
1929                 case LDKCOption_EventZ_Some: return 0;
1930                 case LDKCOption_EventZ_None: return 1;
1931                 default: abort();
1932         }
1933 }
1934 uint32_t __attribute__((export_name("TS_LDKCOption_EventZ_Some_get_some"))) TS_LDKCOption_EventZ_Some_get_some(uint32_t ptr) {
1935         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
1936         assert(obj->tag == LDKCOption_EventZ_Some);
1937                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
1938         return some_ref;
1939 }
1940 static inline struct LDKCOption_EventZ CResult_COption_EventZDecodeErrorZ_get_ok(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
1941 CHECK(owner->result_ok);
1942         return COption_EventZ_clone(&*owner->contents.result);
1943 }
1944 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_get_ok"))) TS_CResult_COption_EventZDecodeErrorZ_get_ok(uint32_t owner) {
1945         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
1946         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
1947         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_ok(owner_conv);
1948         uint32_t ret_ref = (uintptr_t)ret_copy;
1949         return ret_ref;
1950 }
1951
1952 static inline struct LDKDecodeError CResult_COption_EventZDecodeErrorZ_get_err(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
1953 CHECK(!owner->result_ok);
1954         return DecodeError_clone(&*owner->contents.err);
1955 }
1956 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_get_err"))) TS_CResult_COption_EventZDecodeErrorZ_get_err(uint32_t owner) {
1957         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
1958         LDKDecodeError ret_var = CResult_COption_EventZDecodeErrorZ_get_err(owner_conv);
1959         uint32_t ret_ref = 0;
1960         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1961         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1962         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1963         ret_ref = (uintptr_t)ret_var.inner;
1964         if (ret_var.is_owned) {
1965                 ret_ref |= 1;
1966         }
1967         return ret_ref;
1968 }
1969
1970 uint32_t __attribute__((export_name("TS_LDKErrorAction_ty_from_ptr"))) TS_LDKErrorAction_ty_from_ptr(uint32_t ptr) {
1971         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1972         switch(obj->tag) {
1973                 case LDKErrorAction_DisconnectPeer: return 0;
1974                 case LDKErrorAction_IgnoreError: return 1;
1975                 case LDKErrorAction_IgnoreAndLog: return 2;
1976                 case LDKErrorAction_IgnoreDuplicateGossip: return 3;
1977                 case LDKErrorAction_SendErrorMessage: return 4;
1978                 case LDKErrorAction_SendWarningMessage: return 5;
1979                 default: abort();
1980         }
1981 }
1982 uint32_t __attribute__((export_name("TS_LDKErrorAction_DisconnectPeer_get_msg"))) TS_LDKErrorAction_DisconnectPeer_get_msg(uint32_t ptr) {
1983         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1984         assert(obj->tag == LDKErrorAction_DisconnectPeer);
1985                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
1986                         uint32_t msg_ref = 0;
1987                         if ((uintptr_t)msg_var.inner > 4096) {
1988                                 CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1989                                 CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1990                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1991                                 msg_ref = (uintptr_t)msg_var.inner & ~1;
1992                         }
1993         return msg_ref;
1994 }
1995 uint32_t __attribute__((export_name("TS_LDKErrorAction_IgnoreAndLog_get_ignore_and_log"))) TS_LDKErrorAction_IgnoreAndLog_get_ignore_and_log(uint32_t ptr) {
1996         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1997         assert(obj->tag == LDKErrorAction_IgnoreAndLog);
1998                         uint32_t ignore_and_log_conv = LDKLevel_to_js(obj->ignore_and_log);
1999         return ignore_and_log_conv;
2000 }
2001 uint32_t __attribute__((export_name("TS_LDKErrorAction_SendErrorMessage_get_msg"))) TS_LDKErrorAction_SendErrorMessage_get_msg(uint32_t ptr) {
2002         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2003         assert(obj->tag == LDKErrorAction_SendErrorMessage);
2004                         LDKErrorMessage msg_var = obj->send_error_message.msg;
2005                         uint32_t msg_ref = 0;
2006                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2007                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2008                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2009                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2010         return msg_ref;
2011 }
2012 uint32_t __attribute__((export_name("TS_LDKErrorAction_SendWarningMessage_get_msg"))) TS_LDKErrorAction_SendWarningMessage_get_msg(uint32_t ptr) {
2013         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2014         assert(obj->tag == LDKErrorAction_SendWarningMessage);
2015                         LDKWarningMessage msg_var = obj->send_warning_message.msg;
2016                         uint32_t msg_ref = 0;
2017                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2018                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2019                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2020                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2021         return msg_ref;
2022 }
2023 uint32_t __attribute__((export_name("TS_LDKErrorAction_SendWarningMessage_get_log_level"))) TS_LDKErrorAction_SendWarningMessage_get_log_level(uint32_t ptr) {
2024         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2025         assert(obj->tag == LDKErrorAction_SendWarningMessage);
2026                         uint32_t log_level_conv = LDKLevel_to_js(obj->send_warning_message.log_level);
2027         return log_level_conv;
2028 }
2029 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_ty_from_ptr"))) TS_LDKMessageSendEvent_ty_from_ptr(uint32_t ptr) {
2030         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2031         switch(obj->tag) {
2032                 case LDKMessageSendEvent_SendAcceptChannel: return 0;
2033                 case LDKMessageSendEvent_SendOpenChannel: return 1;
2034                 case LDKMessageSendEvent_SendFundingCreated: return 2;
2035                 case LDKMessageSendEvent_SendFundingSigned: return 3;
2036                 case LDKMessageSendEvent_SendFundingLocked: return 4;
2037                 case LDKMessageSendEvent_SendAnnouncementSignatures: return 5;
2038                 case LDKMessageSendEvent_UpdateHTLCs: return 6;
2039                 case LDKMessageSendEvent_SendRevokeAndACK: return 7;
2040                 case LDKMessageSendEvent_SendClosingSigned: return 8;
2041                 case LDKMessageSendEvent_SendShutdown: return 9;
2042                 case LDKMessageSendEvent_SendChannelReestablish: return 10;
2043                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: return 11;
2044                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: return 12;
2045                 case LDKMessageSendEvent_BroadcastChannelUpdate: return 13;
2046                 case LDKMessageSendEvent_SendChannelUpdate: return 14;
2047                 case LDKMessageSendEvent_HandleError: return 15;
2048                 case LDKMessageSendEvent_SendChannelRangeQuery: return 16;
2049                 case LDKMessageSendEvent_SendShortIdsQuery: return 17;
2050                 case LDKMessageSendEvent_SendReplyChannelRange: return 18;
2051                 case LDKMessageSendEvent_SendGossipTimestampFilter: return 19;
2052                 default: abort();
2053         }
2054 }
2055 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendAcceptChannel_get_node_id"))) TS_LDKMessageSendEvent_SendAcceptChannel_get_node_id(uint32_t ptr) {
2056         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2057         assert(obj->tag == LDKMessageSendEvent_SendAcceptChannel);
2058                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2059                         memcpy(node_id_arr->elems, obj->send_accept_channel.node_id.compressed_form, 33);
2060         return node_id_arr;
2061 }
2062 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendAcceptChannel_get_msg"))) TS_LDKMessageSendEvent_SendAcceptChannel_get_msg(uint32_t ptr) {
2063         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2064         assert(obj->tag == LDKMessageSendEvent_SendAcceptChannel);
2065                         LDKAcceptChannel msg_var = obj->send_accept_channel.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_SendOpenChannel_get_node_id"))) TS_LDKMessageSendEvent_SendOpenChannel_get_node_id(uint32_t ptr) {
2074         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2075         assert(obj->tag == LDKMessageSendEvent_SendOpenChannel);
2076                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2077                         memcpy(node_id_arr->elems, obj->send_open_channel.node_id.compressed_form, 33);
2078         return node_id_arr;
2079 }
2080 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendOpenChannel_get_msg"))) TS_LDKMessageSendEvent_SendOpenChannel_get_msg(uint32_t ptr) {
2081         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2082         assert(obj->tag == LDKMessageSendEvent_SendOpenChannel);
2083                         LDKOpenChannel msg_var = obj->send_open_channel.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_SendFundingCreated_get_node_id"))) TS_LDKMessageSendEvent_SendFundingCreated_get_node_id(uint32_t ptr) {
2092         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2093         assert(obj->tag == LDKMessageSendEvent_SendFundingCreated);
2094                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2095                         memcpy(node_id_arr->elems, obj->send_funding_created.node_id.compressed_form, 33);
2096         return node_id_arr;
2097 }
2098 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingCreated_get_msg"))) TS_LDKMessageSendEvent_SendFundingCreated_get_msg(uint32_t ptr) {
2099         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2100         assert(obj->tag == LDKMessageSendEvent_SendFundingCreated);
2101                         LDKFundingCreated msg_var = obj->send_funding_created.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_SendFundingSigned_get_node_id"))) TS_LDKMessageSendEvent_SendFundingSigned_get_node_id(uint32_t ptr) {
2110         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2111         assert(obj->tag == LDKMessageSendEvent_SendFundingSigned);
2112                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2113                         memcpy(node_id_arr->elems, obj->send_funding_signed.node_id.compressed_form, 33);
2114         return node_id_arr;
2115 }
2116 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingSigned_get_msg"))) TS_LDKMessageSendEvent_SendFundingSigned_get_msg(uint32_t ptr) {
2117         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2118         assert(obj->tag == LDKMessageSendEvent_SendFundingSigned);
2119                         LDKFundingSigned msg_var = obj->send_funding_signed.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_SendFundingLocked_get_node_id"))) TS_LDKMessageSendEvent_SendFundingLocked_get_node_id(uint32_t ptr) {
2128         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2129         assert(obj->tag == LDKMessageSendEvent_SendFundingLocked);
2130                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2131                         memcpy(node_id_arr->elems, obj->send_funding_locked.node_id.compressed_form, 33);
2132         return node_id_arr;
2133 }
2134 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingLocked_get_msg"))) TS_LDKMessageSendEvent_SendFundingLocked_get_msg(uint32_t ptr) {
2135         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2136         assert(obj->tag == LDKMessageSendEvent_SendFundingLocked);
2137                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
2138                         uint32_t msg_ref = 0;
2139                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2140                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2141                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2142                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2143         return msg_ref;
2144 }
2145 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_node_id"))) TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_node_id(uint32_t ptr) {
2146         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2147         assert(obj->tag == LDKMessageSendEvent_SendAnnouncementSignatures);
2148                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2149                         memcpy(node_id_arr->elems, obj->send_announcement_signatures.node_id.compressed_form, 33);
2150         return node_id_arr;
2151 }
2152 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_msg"))) TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_msg(uint32_t ptr) {
2153         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2154         assert(obj->tag == LDKMessageSendEvent_SendAnnouncementSignatures);
2155                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.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_UpdateHTLCs_get_node_id"))) TS_LDKMessageSendEvent_UpdateHTLCs_get_node_id(uint32_t ptr) {
2164         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2165         assert(obj->tag == LDKMessageSendEvent_UpdateHTLCs);
2166                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2167                         memcpy(node_id_arr->elems, obj->update_htl_cs.node_id.compressed_form, 33);
2168         return node_id_arr;
2169 }
2170 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_UpdateHTLCs_get_updates"))) TS_LDKMessageSendEvent_UpdateHTLCs_get_updates(uint32_t ptr) {
2171         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2172         assert(obj->tag == LDKMessageSendEvent_UpdateHTLCs);
2173                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
2174                         uint32_t updates_ref = 0;
2175                         CHECK((((uintptr_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2176                         CHECK((((uintptr_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2177                         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
2178                         updates_ref = (uintptr_t)updates_var.inner & ~1;
2179         return updates_ref;
2180 }
2181 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendRevokeAndACK_get_node_id"))) TS_LDKMessageSendEvent_SendRevokeAndACK_get_node_id(uint32_t ptr) {
2182         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2183         assert(obj->tag == LDKMessageSendEvent_SendRevokeAndACK);
2184                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2185                         memcpy(node_id_arr->elems, obj->send_revoke_and_ack.node_id.compressed_form, 33);
2186         return node_id_arr;
2187 }
2188 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendRevokeAndACK_get_msg"))) TS_LDKMessageSendEvent_SendRevokeAndACK_get_msg(uint32_t ptr) {
2189         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2190         assert(obj->tag == LDKMessageSendEvent_SendRevokeAndACK);
2191                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.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_SendClosingSigned_get_node_id"))) TS_LDKMessageSendEvent_SendClosingSigned_get_node_id(uint32_t ptr) {
2200         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2201         assert(obj->tag == LDKMessageSendEvent_SendClosingSigned);
2202                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2203                         memcpy(node_id_arr->elems, obj->send_closing_signed.node_id.compressed_form, 33);
2204         return node_id_arr;
2205 }
2206 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendClosingSigned_get_msg"))) TS_LDKMessageSendEvent_SendClosingSigned_get_msg(uint32_t ptr) {
2207         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2208         assert(obj->tag == LDKMessageSendEvent_SendClosingSigned);
2209                         LDKClosingSigned msg_var = obj->send_closing_signed.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 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendShutdown_get_node_id"))) TS_LDKMessageSendEvent_SendShutdown_get_node_id(uint32_t ptr) {
2218         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2219         assert(obj->tag == LDKMessageSendEvent_SendShutdown);
2220                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2221                         memcpy(node_id_arr->elems, obj->send_shutdown.node_id.compressed_form, 33);
2222         return node_id_arr;
2223 }
2224 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendShutdown_get_msg"))) TS_LDKMessageSendEvent_SendShutdown_get_msg(uint32_t ptr) {
2225         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2226         assert(obj->tag == LDKMessageSendEvent_SendShutdown);
2227                         LDKShutdown msg_var = obj->send_shutdown.msg;
2228                         uint32_t msg_ref = 0;
2229                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2230                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2231                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2232                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2233         return msg_ref;
2234 }
2235 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReestablish_get_node_id"))) TS_LDKMessageSendEvent_SendChannelReestablish_get_node_id(uint32_t ptr) {
2236         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2237         assert(obj->tag == LDKMessageSendEvent_SendChannelReestablish);
2238                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2239                         memcpy(node_id_arr->elems, obj->send_channel_reestablish.node_id.compressed_form, 33);
2240         return node_id_arr;
2241 }
2242 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReestablish_get_msg"))) TS_LDKMessageSendEvent_SendChannelReestablish_get_msg(uint32_t ptr) {
2243         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2244         assert(obj->tag == LDKMessageSendEvent_SendChannelReestablish);
2245                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
2246                         uint32_t msg_ref = 0;
2247                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2248                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2249                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2250                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2251         return msg_ref;
2252 }
2253 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_msg"))) TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_msg(uint32_t ptr) {
2254         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2255         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelAnnouncement);
2256                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
2257                         uint32_t msg_ref = 0;
2258                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2259                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2260                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2261                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2262         return msg_ref;
2263 }
2264 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_update_msg"))) TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_update_msg(uint32_t ptr) {
2265         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2266         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelAnnouncement);
2267                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
2268                         uint32_t update_msg_ref = 0;
2269                         CHECK((((uintptr_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2270                         CHECK((((uintptr_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2271                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
2272                         update_msg_ref = (uintptr_t)update_msg_var.inner & ~1;
2273         return update_msg_ref;
2274 }
2275 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastNodeAnnouncement_get_msg"))) TS_LDKMessageSendEvent_BroadcastNodeAnnouncement_get_msg(uint32_t ptr) {
2276         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2277         assert(obj->tag == LDKMessageSendEvent_BroadcastNodeAnnouncement);
2278                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
2279                         uint32_t msg_ref = 0;
2280                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2281                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2282                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2283                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2284         return msg_ref;
2285 }
2286 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelUpdate_get_msg"))) TS_LDKMessageSendEvent_BroadcastChannelUpdate_get_msg(uint32_t ptr) {
2287         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2288         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelUpdate);
2289                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
2290                         uint32_t msg_ref = 0;
2291                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2292                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2293                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2294                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2295         return msg_ref;
2296 }
2297 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelUpdate_get_node_id"))) TS_LDKMessageSendEvent_SendChannelUpdate_get_node_id(uint32_t ptr) {
2298         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2299         assert(obj->tag == LDKMessageSendEvent_SendChannelUpdate);
2300                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2301                         memcpy(node_id_arr->elems, obj->send_channel_update.node_id.compressed_form, 33);
2302         return node_id_arr;
2303 }
2304 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelUpdate_get_msg"))) TS_LDKMessageSendEvent_SendChannelUpdate_get_msg(uint32_t ptr) {
2305         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2306         assert(obj->tag == LDKMessageSendEvent_SendChannelUpdate);
2307                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
2308                         uint32_t msg_ref = 0;
2309                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2310                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2311                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2312                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2313         return msg_ref;
2314 }
2315 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_HandleError_get_node_id"))) TS_LDKMessageSendEvent_HandleError_get_node_id(uint32_t ptr) {
2316         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2317         assert(obj->tag == LDKMessageSendEvent_HandleError);
2318                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2319                         memcpy(node_id_arr->elems, obj->handle_error.node_id.compressed_form, 33);
2320         return node_id_arr;
2321 }
2322 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_HandleError_get_action"))) TS_LDKMessageSendEvent_HandleError_get_action(uint32_t ptr) {
2323         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2324         assert(obj->tag == LDKMessageSendEvent_HandleError);
2325                         uint32_t action_ref = ((uintptr_t)&obj->handle_error.action) | 1;
2326         return action_ref;
2327 }
2328 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelRangeQuery_get_node_id"))) TS_LDKMessageSendEvent_SendChannelRangeQuery_get_node_id(uint32_t ptr) {
2329         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2330         assert(obj->tag == LDKMessageSendEvent_SendChannelRangeQuery);
2331                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2332                         memcpy(node_id_arr->elems, obj->send_channel_range_query.node_id.compressed_form, 33);
2333         return node_id_arr;
2334 }
2335 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelRangeQuery_get_msg"))) TS_LDKMessageSendEvent_SendChannelRangeQuery_get_msg(uint32_t ptr) {
2336         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2337         assert(obj->tag == LDKMessageSendEvent_SendChannelRangeQuery);
2338                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.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_SendShortIdsQuery_get_node_id"))) TS_LDKMessageSendEvent_SendShortIdsQuery_get_node_id(uint32_t ptr) {
2347         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2348         assert(obj->tag == LDKMessageSendEvent_SendShortIdsQuery);
2349                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2350                         memcpy(node_id_arr->elems, obj->send_short_ids_query.node_id.compressed_form, 33);
2351         return node_id_arr;
2352 }
2353 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendShortIdsQuery_get_msg"))) TS_LDKMessageSendEvent_SendShortIdsQuery_get_msg(uint32_t ptr) {
2354         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2355         assert(obj->tag == LDKMessageSendEvent_SendShortIdsQuery);
2356                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.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 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendReplyChannelRange_get_node_id"))) TS_LDKMessageSendEvent_SendReplyChannelRange_get_node_id(uint32_t ptr) {
2365         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2366         assert(obj->tag == LDKMessageSendEvent_SendReplyChannelRange);
2367                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2368                         memcpy(node_id_arr->elems, obj->send_reply_channel_range.node_id.compressed_form, 33);
2369         return node_id_arr;
2370 }
2371 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendReplyChannelRange_get_msg"))) TS_LDKMessageSendEvent_SendReplyChannelRange_get_msg(uint32_t ptr) {
2372         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2373         assert(obj->tag == LDKMessageSendEvent_SendReplyChannelRange);
2374                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
2375                         uint32_t msg_ref = 0;
2376                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2377                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2378                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2379                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2380         return msg_ref;
2381 }
2382 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendGossipTimestampFilter_get_node_id"))) TS_LDKMessageSendEvent_SendGossipTimestampFilter_get_node_id(uint32_t ptr) {
2383         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2384         assert(obj->tag == LDKMessageSendEvent_SendGossipTimestampFilter);
2385                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2386                         memcpy(node_id_arr->elems, obj->send_gossip_timestamp_filter.node_id.compressed_form, 33);
2387         return node_id_arr;
2388 }
2389 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendGossipTimestampFilter_get_msg"))) TS_LDKMessageSendEvent_SendGossipTimestampFilter_get_msg(uint32_t ptr) {
2390         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2391         assert(obj->tag == LDKMessageSendEvent_SendGossipTimestampFilter);
2392                         LDKGossipTimestampFilter msg_var = obj->send_gossip_timestamp_filter.msg;
2393                         uint32_t msg_ref = 0;
2394                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2395                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2396                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2397                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2398         return msg_ref;
2399 }
2400 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
2401         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
2402         for (size_t i = 0; i < ret.datalen; i++) {
2403                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
2404         }
2405         return ret;
2406 }
2407 static inline struct LDKFixedPenaltyScorer CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
2408 CHECK(owner->result_ok);
2409         return FixedPenaltyScorer_clone(&*owner->contents.result);
2410 }
2411 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_ok"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(uint32_t owner) {
2412         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
2413         LDKFixedPenaltyScorer ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(owner_conv);
2414         uint32_t ret_ref = 0;
2415         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2416         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2417         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2418         ret_ref = (uintptr_t)ret_var.inner;
2419         if (ret_var.is_owned) {
2420                 ret_ref |= 1;
2421         }
2422         return ret_ref;
2423 }
2424
2425 static inline struct LDKDecodeError CResult_FixedPenaltyScorerDecodeErrorZ_get_err(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
2426 CHECK(!owner->result_ok);
2427         return DecodeError_clone(&*owner->contents.err);
2428 }
2429 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_err"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_err(uint32_t owner) {
2430         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
2431         LDKDecodeError ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_err(owner_conv);
2432         uint32_t ret_ref = 0;
2433         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2434         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2435         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2436         ret_ref = (uintptr_t)ret_var.inner;
2437         if (ret_var.is_owned) {
2438                 ret_ref |= 1;
2439         }
2440         return ret_ref;
2441 }
2442
2443 static inline struct LDKScoringParameters CResult_ScoringParametersDecodeErrorZ_get_ok(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR owner){
2444 CHECK(owner->result_ok);
2445         return ScoringParameters_clone(&*owner->contents.result);
2446 }
2447 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_get_ok"))) TS_CResult_ScoringParametersDecodeErrorZ_get_ok(uint32_t owner) {
2448         LDKCResult_ScoringParametersDecodeErrorZ* owner_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(owner & ~1);
2449         LDKScoringParameters ret_var = CResult_ScoringParametersDecodeErrorZ_get_ok(owner_conv);
2450         uint32_t ret_ref = 0;
2451         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2452         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2453         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2454         ret_ref = (uintptr_t)ret_var.inner;
2455         if (ret_var.is_owned) {
2456                 ret_ref |= 1;
2457         }
2458         return ret_ref;
2459 }
2460
2461 static inline struct LDKDecodeError CResult_ScoringParametersDecodeErrorZ_get_err(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR owner){
2462 CHECK(!owner->result_ok);
2463         return DecodeError_clone(&*owner->contents.err);
2464 }
2465 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_get_err"))) TS_CResult_ScoringParametersDecodeErrorZ_get_err(uint32_t owner) {
2466         LDKCResult_ScoringParametersDecodeErrorZ* owner_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(owner & ~1);
2467         LDKDecodeError ret_var = CResult_ScoringParametersDecodeErrorZ_get_err(owner_conv);
2468         uint32_t ret_ref = 0;
2469         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2470         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2471         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2472         ret_ref = (uintptr_t)ret_var.inner;
2473         if (ret_var.is_owned) {
2474                 ret_ref |= 1;
2475         }
2476         return ret_ref;
2477 }
2478
2479 static inline struct LDKScorer *CResult_ScorerDecodeErrorZ_get_ok(LDKCResult_ScorerDecodeErrorZ *NONNULL_PTR owner){
2480 CHECK(owner->result_ok);
2481         return &*owner->contents.result;
2482 }
2483 uint32_t  __attribute__((export_name("TS_CResult_ScorerDecodeErrorZ_get_ok"))) TS_CResult_ScorerDecodeErrorZ_get_ok(uint32_t owner) {
2484         LDKCResult_ScorerDecodeErrorZ* owner_conv = (LDKCResult_ScorerDecodeErrorZ*)(owner & ~1);
2485         LDKScorer ret_var = *CResult_ScorerDecodeErrorZ_get_ok(owner_conv);
2486         uint32_t ret_ref = 0;
2487         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2488         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2489         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2490         ret_ref = (uintptr_t)ret_var.inner & ~1;
2491         return ret_ref;
2492 }
2493
2494 static inline struct LDKDecodeError CResult_ScorerDecodeErrorZ_get_err(LDKCResult_ScorerDecodeErrorZ *NONNULL_PTR owner){
2495 CHECK(!owner->result_ok);
2496         return DecodeError_clone(&*owner->contents.err);
2497 }
2498 uint32_t  __attribute__((export_name("TS_CResult_ScorerDecodeErrorZ_get_err"))) TS_CResult_ScorerDecodeErrorZ_get_err(uint32_t owner) {
2499         LDKCResult_ScorerDecodeErrorZ* owner_conv = (LDKCResult_ScorerDecodeErrorZ*)(owner & ~1);
2500         LDKDecodeError ret_var = CResult_ScorerDecodeErrorZ_get_err(owner_conv);
2501         uint32_t ret_ref = 0;
2502         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2503         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2504         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2505         ret_ref = (uintptr_t)ret_var.inner;
2506         if (ret_var.is_owned) {
2507                 ret_ref |= 1;
2508         }
2509         return ret_ref;
2510 }
2511
2512 static inline struct LDKProbabilisticScorer *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
2513 CHECK(owner->result_ok);
2514         return &*owner->contents.result;
2515 }
2516 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_get_ok"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_get_ok(uint32_t owner) {
2517         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(owner & ~1);
2518         LDKProbabilisticScorer ret_var = *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(owner_conv);
2519         uint32_t ret_ref = 0;
2520         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2521         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2522         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2523         ret_ref = (uintptr_t)ret_var.inner & ~1;
2524         return ret_ref;
2525 }
2526
2527 static inline struct LDKDecodeError CResult_ProbabilisticScorerDecodeErrorZ_get_err(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
2528 CHECK(!owner->result_ok);
2529         return DecodeError_clone(&*owner->contents.err);
2530 }
2531 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_get_err"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_get_err(uint32_t owner) {
2532         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(owner & ~1);
2533         LDKDecodeError ret_var = CResult_ProbabilisticScorerDecodeErrorZ_get_err(owner_conv);
2534         uint32_t ret_ref = 0;
2535         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2536         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2537         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2538         ret_ref = (uintptr_t)ret_var.inner;
2539         if (ret_var.is_owned) {
2540                 ret_ref |= 1;
2541         }
2542         return ret_ref;
2543 }
2544
2545 static inline struct LDKInitFeatures CResult_InitFeaturesDecodeErrorZ_get_ok(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
2546 CHECK(owner->result_ok);
2547         return InitFeatures_clone(&*owner->contents.result);
2548 }
2549 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_get_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2550         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
2551         LDKInitFeatures ret_var = CResult_InitFeaturesDecodeErrorZ_get_ok(owner_conv);
2552         uint32_t ret_ref = 0;
2553         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2554         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2555         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2556         ret_ref = (uintptr_t)ret_var.inner;
2557         if (ret_var.is_owned) {
2558                 ret_ref |= 1;
2559         }
2560         return ret_ref;
2561 }
2562
2563 static inline struct LDKDecodeError CResult_InitFeaturesDecodeErrorZ_get_err(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
2564 CHECK(!owner->result_ok);
2565         return DecodeError_clone(&*owner->contents.err);
2566 }
2567 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_get_err"))) TS_CResult_InitFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2568         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
2569         LDKDecodeError ret_var = CResult_InitFeaturesDecodeErrorZ_get_err(owner_conv);
2570         uint32_t ret_ref = 0;
2571         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2572         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2573         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2574         ret_ref = (uintptr_t)ret_var.inner;
2575         if (ret_var.is_owned) {
2576                 ret_ref |= 1;
2577         }
2578         return ret_ref;
2579 }
2580
2581 static inline struct LDKChannelFeatures CResult_ChannelFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
2582 CHECK(owner->result_ok);
2583         return ChannelFeatures_clone(&*owner->contents.result);
2584 }
2585 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_get_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2586         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
2587         LDKChannelFeatures ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_ok(owner_conv);
2588         uint32_t ret_ref = 0;
2589         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2590         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2591         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2592         ret_ref = (uintptr_t)ret_var.inner;
2593         if (ret_var.is_owned) {
2594                 ret_ref |= 1;
2595         }
2596         return ret_ref;
2597 }
2598
2599 static inline struct LDKDecodeError CResult_ChannelFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
2600 CHECK(!owner->result_ok);
2601         return DecodeError_clone(&*owner->contents.err);
2602 }
2603 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_get_err"))) TS_CResult_ChannelFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2604         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
2605         LDKDecodeError ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_err(owner_conv);
2606         uint32_t ret_ref = 0;
2607         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2608         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2609         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2610         ret_ref = (uintptr_t)ret_var.inner;
2611         if (ret_var.is_owned) {
2612                 ret_ref |= 1;
2613         }
2614         return ret_ref;
2615 }
2616
2617 static inline struct LDKNodeFeatures CResult_NodeFeaturesDecodeErrorZ_get_ok(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2618 CHECK(owner->result_ok);
2619         return NodeFeatures_clone(&*owner->contents.result);
2620 }
2621 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_get_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2622         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
2623         LDKNodeFeatures ret_var = CResult_NodeFeaturesDecodeErrorZ_get_ok(owner_conv);
2624         uint32_t ret_ref = 0;
2625         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2626         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2627         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2628         ret_ref = (uintptr_t)ret_var.inner;
2629         if (ret_var.is_owned) {
2630                 ret_ref |= 1;
2631         }
2632         return ret_ref;
2633 }
2634
2635 static inline struct LDKDecodeError CResult_NodeFeaturesDecodeErrorZ_get_err(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2636 CHECK(!owner->result_ok);
2637         return DecodeError_clone(&*owner->contents.err);
2638 }
2639 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_get_err"))) TS_CResult_NodeFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2640         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
2641         LDKDecodeError ret_var = CResult_NodeFeaturesDecodeErrorZ_get_err(owner_conv);
2642         uint32_t ret_ref = 0;
2643         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2644         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2645         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2646         ret_ref = (uintptr_t)ret_var.inner;
2647         if (ret_var.is_owned) {
2648                 ret_ref |= 1;
2649         }
2650         return ret_ref;
2651 }
2652
2653 static inline struct LDKInvoiceFeatures CResult_InvoiceFeaturesDecodeErrorZ_get_ok(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
2654 CHECK(owner->result_ok);
2655         return InvoiceFeatures_clone(&*owner->contents.result);
2656 }
2657 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_get_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2658         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
2659         LDKInvoiceFeatures ret_var = CResult_InvoiceFeaturesDecodeErrorZ_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;
2665         if (ret_var.is_owned) {
2666                 ret_ref |= 1;
2667         }
2668         return ret_ref;
2669 }
2670
2671 static inline struct LDKDecodeError CResult_InvoiceFeaturesDecodeErrorZ_get_err(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
2672 CHECK(!owner->result_ok);
2673         return DecodeError_clone(&*owner->contents.err);
2674 }
2675 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_get_err"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2676         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
2677         LDKDecodeError ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_err(owner_conv);
2678         uint32_t ret_ref = 0;
2679         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2680         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2681         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2682         ret_ref = (uintptr_t)ret_var.inner;
2683         if (ret_var.is_owned) {
2684                 ret_ref |= 1;
2685         }
2686         return ret_ref;
2687 }
2688
2689 static inline struct LDKChannelTypeFeatures CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2690 CHECK(owner->result_ok);
2691         return ChannelTypeFeatures_clone(&*owner->contents.result);
2692 }
2693 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2694         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
2695         LDKChannelTypeFeatures ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(owner_conv);
2696         uint32_t ret_ref = 0;
2697         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2698         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2699         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2700         ret_ref = (uintptr_t)ret_var.inner;
2701         if (ret_var.is_owned) {
2702                 ret_ref |= 1;
2703         }
2704         return ret_ref;
2705 }
2706
2707 static inline struct LDKDecodeError CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2708 CHECK(!owner->result_ok);
2709         return DecodeError_clone(&*owner->contents.err);
2710 }
2711 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_err"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2712         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
2713         LDKDecodeError ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(owner_conv);
2714         uint32_t ret_ref = 0;
2715         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2716         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2717         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2718         ret_ref = (uintptr_t)ret_var.inner;
2719         if (ret_var.is_owned) {
2720                 ret_ref |= 1;
2721         }
2722         return ret_ref;
2723 }
2724
2725 static inline struct LDKDelayedPaymentOutputDescriptor CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
2726 CHECK(owner->result_ok);
2727         return DelayedPaymentOutputDescriptor_clone(&*owner->contents.result);
2728 }
2729 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
2730         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
2731         LDKDelayedPaymentOutputDescriptor ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
2732         uint32_t ret_ref = 0;
2733         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2734         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2735         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2736         ret_ref = (uintptr_t)ret_var.inner;
2737         if (ret_var.is_owned) {
2738                 ret_ref |= 1;
2739         }
2740         return ret_ref;
2741 }
2742
2743 static inline struct LDKDecodeError CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
2744 CHECK(!owner->result_ok);
2745         return DecodeError_clone(&*owner->contents.err);
2746 }
2747 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
2748         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
2749         LDKDecodeError ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
2750         uint32_t ret_ref = 0;
2751         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2752         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2753         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2754         ret_ref = (uintptr_t)ret_var.inner;
2755         if (ret_var.is_owned) {
2756                 ret_ref |= 1;
2757         }
2758         return ret_ref;
2759 }
2760
2761 static inline struct LDKStaticPaymentOutputDescriptor CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
2762 CHECK(owner->result_ok);
2763         return StaticPaymentOutputDescriptor_clone(&*owner->contents.result);
2764 }
2765 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
2766         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
2767         LDKStaticPaymentOutputDescriptor ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
2768         uint32_t ret_ref = 0;
2769         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2770         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2771         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2772         ret_ref = (uintptr_t)ret_var.inner;
2773         if (ret_var.is_owned) {
2774                 ret_ref |= 1;
2775         }
2776         return ret_ref;
2777 }
2778
2779 static inline struct LDKDecodeError CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
2780 CHECK(!owner->result_ok);
2781         return DecodeError_clone(&*owner->contents.err);
2782 }
2783 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
2784         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
2785         LDKDecodeError ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
2786         uint32_t ret_ref = 0;
2787         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2788         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2789         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2790         ret_ref = (uintptr_t)ret_var.inner;
2791         if (ret_var.is_owned) {
2792                 ret_ref |= 1;
2793         }
2794         return ret_ref;
2795 }
2796
2797 static inline struct LDKSpendableOutputDescriptor CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
2798 CHECK(owner->result_ok);
2799         return SpendableOutputDescriptor_clone(&*owner->contents.result);
2800 }
2801 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
2802         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
2803         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
2804         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
2805         uint32_t ret_ref = (uintptr_t)ret_copy;
2806         return ret_ref;
2807 }
2808
2809 static inline struct LDKDecodeError CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
2810 CHECK(!owner->result_ok);
2811         return DecodeError_clone(&*owner->contents.err);
2812 }
2813 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
2814         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
2815         LDKDecodeError ret_var = CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(owner_conv);
2816         uint32_t ret_ref = 0;
2817         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2818         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2819         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2820         ret_ref = (uintptr_t)ret_var.inner;
2821         if (ret_var.is_owned) {
2822                 ret_ref |= 1;
2823         }
2824         return ret_ref;
2825 }
2826
2827 static inline LDKCVec_PaymentPreimageZ CVec_PaymentPreimageZ_clone(const LDKCVec_PaymentPreimageZ *orig) {
2828         LDKCVec_PaymentPreimageZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_PaymentPreimageZ clone bytes"), .datalen = orig->datalen };
2829         for (size_t i = 0; i < ret.datalen; i++) {
2830                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
2831         }
2832         return ret;
2833 }
2834 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
2835         return owner->a;
2836 }
2837 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_get_a"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_a(uint32_t owner) {
2838         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
2839         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
2840         memcpy(ret_arr->elems, C2Tuple_SignatureCVec_SignatureZZ_get_a(owner_conv).compact_form, 64);
2841         return ret_arr;
2842 }
2843
2844 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
2845         return owner->b;
2846 }
2847 ptrArray  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_get_b"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_b(uint32_t owner) {
2848         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
2849         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(owner_conv);
2850         ptrArray ret_arr = NULL;
2851         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
2852         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
2853         for (size_t m = 0; m < ret_var.datalen; m++) {
2854                 int8_tArray ret_conv_12_arr = init_int8_tArray(64, __LINE__);
2855                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compact_form, 64);
2856                 ret_arr_ptr[m] = ret_conv_12_arr;
2857         }
2858         
2859         return ret_arr;
2860 }
2861
2862 static inline struct LDKC2Tuple_SignatureCVec_SignatureZZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
2863 CHECK(owner->result_ok);
2864         return C2Tuple_SignatureCVec_SignatureZZ_clone(&*owner->contents.result);
2865 }
2866 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(uint32_t owner) {
2867         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
2868         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
2869         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(owner_conv);
2870         return ((uint32_t)ret_conv);
2871 }
2872
2873 static inline void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
2874 CHECK(!owner->result_ok);
2875         return *owner->contents.err;
2876 }
2877 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(uint32_t owner) {
2878         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
2879         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(owner_conv);
2880 }
2881
2882 static inline struct LDKSignature CResult_SignatureNoneZ_get_ok(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
2883 CHECK(owner->result_ok);
2884         return *owner->contents.result;
2885 }
2886 int8_tArray  __attribute__((export_name("TS_CResult_SignatureNoneZ_get_ok"))) TS_CResult_SignatureNoneZ_get_ok(uint32_t owner) {
2887         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
2888         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
2889         memcpy(ret_arr->elems, CResult_SignatureNoneZ_get_ok(owner_conv).compact_form, 64);
2890         return ret_arr;
2891 }
2892
2893 static inline void CResult_SignatureNoneZ_get_err(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
2894 CHECK(!owner->result_ok);
2895         return *owner->contents.err;
2896 }
2897 void  __attribute__((export_name("TS_CResult_SignatureNoneZ_get_err"))) TS_CResult_SignatureNoneZ_get_err(uint32_t owner) {
2898         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
2899         CResult_SignatureNoneZ_get_err(owner_conv);
2900 }
2901
2902 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_a(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
2903         return owner->a;
2904 }
2905 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_get_a"))) TS_C2Tuple_SignatureSignatureZ_get_a(uint32_t owner) {
2906         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
2907         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
2908         memcpy(ret_arr->elems, C2Tuple_SignatureSignatureZ_get_a(owner_conv).compact_form, 64);
2909         return ret_arr;
2910 }
2911
2912 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_b(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
2913         return owner->b;
2914 }
2915 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_get_b"))) TS_C2Tuple_SignatureSignatureZ_get_b(uint32_t owner) {
2916         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
2917         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
2918         memcpy(ret_arr->elems, C2Tuple_SignatureSignatureZ_get_b(owner_conv).compact_form, 64);
2919         return ret_arr;
2920 }
2921
2922 static inline struct LDKC2Tuple_SignatureSignatureZ CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
2923 CHECK(owner->result_ok);
2924         return C2Tuple_SignatureSignatureZ_clone(&*owner->contents.result);
2925 }
2926 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(uint32_t owner) {
2927         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
2928         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
2929         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(owner_conv);
2930         return ((uint32_t)ret_conv);
2931 }
2932
2933 static inline void CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
2934 CHECK(!owner->result_ok);
2935         return *owner->contents.err;
2936 }
2937 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_err"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(uint32_t owner) {
2938         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
2939         CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(owner_conv);
2940 }
2941
2942 static inline struct LDKSecretKey CResult_SecretKeyNoneZ_get_ok(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
2943 CHECK(owner->result_ok);
2944         return *owner->contents.result;
2945 }
2946 int8_tArray  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_get_ok"))) TS_CResult_SecretKeyNoneZ_get_ok(uint32_t owner) {
2947         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
2948         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
2949         memcpy(ret_arr->elems, CResult_SecretKeyNoneZ_get_ok(owner_conv).bytes, 32);
2950         return ret_arr;
2951 }
2952
2953 static inline void CResult_SecretKeyNoneZ_get_err(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
2954 CHECK(!owner->result_ok);
2955         return *owner->contents.err;
2956 }
2957 void  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_get_err"))) TS_CResult_SecretKeyNoneZ_get_err(uint32_t owner) {
2958         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
2959         CResult_SecretKeyNoneZ_get_err(owner_conv);
2960 }
2961
2962 typedef struct LDKBaseSign_JCalls {
2963         atomic_size_t refcnt;
2964         uint32_t instance_ptr;
2965 } LDKBaseSign_JCalls;
2966 static void LDKBaseSign_JCalls_free(void* this_arg) {
2967         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2968         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2969                 FREE(j_calls);
2970         }
2971 }
2972 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2973         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2974         int64_t idx_conv = idx;
2975         int8_tArray ret = (int8_tArray)js_invoke_function_1(j_calls->instance_ptr, 0, (uint32_t)idx_conv);
2976         LDKPublicKey ret_ref;
2977         CHECK(ret->arr_len == 33);
2978         memcpy(ret_ref.compressed_form, ret->elems, 33); FREE(ret);
2979         return ret_ref;
2980 }
2981 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2982         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2983         int64_t idx_conv = idx;
2984         int8_tArray ret = (int8_tArray)js_invoke_function_1(j_calls->instance_ptr, 1, (uint32_t)idx_conv);
2985         LDKThirtyTwoBytes ret_ref;
2986         CHECK(ret->arr_len == 32);
2987         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
2988         return ret_ref;
2989 }
2990 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx, LDKCVec_PaymentPreimageZ preimages) {
2991         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2992         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
2993         uint32_t holder_tx_ref = 0;
2994         holder_tx_var = HolderCommitmentTransaction_clone(&holder_tx_var);
2995         CHECK((((uintptr_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2996         CHECK((((uintptr_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2997         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
2998         holder_tx_ref = (uintptr_t)holder_tx_var.inner;
2999         if (holder_tx_var.is_owned) {
3000                 holder_tx_ref |= 1;
3001         }
3002         LDKCVec_PaymentPreimageZ preimages_var = preimages;
3003         ptrArray preimages_arr = NULL;
3004         preimages_arr = init_ptrArray(preimages_var.datalen, __LINE__);
3005         int8_tArray *preimages_arr_ptr = (int8_tArray*)(((uint8_t*)preimages_arr) + 4);
3006         for (size_t m = 0; m < preimages_var.datalen; m++) {
3007                 int8_tArray preimages_conv_12_arr = init_int8_tArray(32, __LINE__);
3008                 memcpy(preimages_conv_12_arr->elems, preimages_var.data[m].data, 32);
3009                 preimages_arr_ptr[m] = preimages_conv_12_arr;
3010         }
3011         
3012         FREE(preimages_var.data);
3013         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 2, (uint32_t)holder_tx_ref, (uint32_t)preimages_arr);
3014         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3015         CHECK_ACCESS(ret_ptr);
3016         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
3017         FREE((void*)ret);
3018         return ret_conv;
3019 }
3020 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
3021         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3022         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 3);
3023         LDKThirtyTwoBytes ret_ref;
3024         CHECK(ret->arr_len == 32);
3025         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
3026         return ret_ref;
3027 }
3028 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx, LDKCVec_PaymentPreimageZ preimages) {
3029         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3030         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
3031         uint32_t commitment_tx_ref = 0;
3032         commitment_tx_var = CommitmentTransaction_clone(&commitment_tx_var);
3033         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3034         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3035         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
3036         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
3037         if (commitment_tx_var.is_owned) {
3038                 commitment_tx_ref |= 1;
3039         }
3040         LDKCVec_PaymentPreimageZ preimages_var = preimages;
3041         ptrArray preimages_arr = NULL;
3042         preimages_arr = init_ptrArray(preimages_var.datalen, __LINE__);
3043         int8_tArray *preimages_arr_ptr = (int8_tArray*)(((uint8_t*)preimages_arr) + 4);
3044         for (size_t m = 0; m < preimages_var.datalen; m++) {
3045                 int8_tArray preimages_conv_12_arr = init_int8_tArray(32, __LINE__);
3046                 memcpy(preimages_conv_12_arr->elems, preimages_var.data[m].data, 32);
3047                 preimages_arr_ptr[m] = preimages_conv_12_arr;
3048         }
3049         
3050         FREE(preimages_var.data);
3051         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 4, (uint32_t)commitment_tx_ref, (uint32_t)preimages_arr);
3052         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3053         CHECK_ACCESS(ret_ptr);
3054         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
3055         FREE((void*)ret);
3056         return ret_conv;
3057 }
3058 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
3059         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3060         int64_t idx_conv = idx;
3061         int8_tArray secret_arr = init_int8_tArray(32, __LINE__);
3062         memcpy(secret_arr->elems, *secret, 32);
3063         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 5, (uint32_t)idx_conv, (uint32_t)secret_arr);
3064         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3065         CHECK_ACCESS(ret_ptr);
3066         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
3067         FREE((void*)ret);
3068         return ret_conv;
3069 }
3070 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
3071         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3072         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
3073         uint32_t commitment_tx_ref = 0;
3074         commitment_tx_var = HolderCommitmentTransaction_clone(&commitment_tx_var);
3075         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3076         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3077         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
3078         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
3079         if (commitment_tx_var.is_owned) {
3080                 commitment_tx_ref |= 1;
3081         }
3082         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 6, (uint32_t)commitment_tx_ref);
3083         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3084         CHECK_ACCESS(ret_ptr);
3085         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
3086         FREE((void*)ret);
3087         return ret_conv;
3088 }
3089 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]) {
3090         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3091         LDKTransaction justice_tx_var = justice_tx;
3092         int8_tArray justice_tx_arr = init_int8_tArray(justice_tx_var.datalen, __LINE__);
3093         memcpy(justice_tx_arr->elems, justice_tx_var.data, justice_tx_var.datalen);
3094         Transaction_free(justice_tx_var);
3095         uint32_t input_conv = input;
3096         int64_t amount_conv = amount;
3097         int8_tArray per_commitment_key_arr = init_int8_tArray(32, __LINE__);
3098         memcpy(per_commitment_key_arr->elems, *per_commitment_key, 32);
3099         uint32_t ret = js_invoke_function_4(j_calls->instance_ptr, 7, (uint32_t)justice_tx_arr, (uint32_t)input_conv, (uint32_t)amount_conv, (uint32_t)per_commitment_key_arr);
3100         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3101         CHECK_ACCESS(ret_ptr);
3102         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3103         FREE((void*)ret);
3104         return ret_conv;
3105 }
3106 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) {
3107         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3108         LDKTransaction justice_tx_var = justice_tx;
3109         int8_tArray justice_tx_arr = init_int8_tArray(justice_tx_var.datalen, __LINE__);
3110         memcpy(justice_tx_arr->elems, justice_tx_var.data, justice_tx_var.datalen);
3111         Transaction_free(justice_tx_var);
3112         uint32_t input_conv = input;
3113         int64_t amount_conv = amount;
3114         int8_tArray per_commitment_key_arr = init_int8_tArray(32, __LINE__);
3115         memcpy(per_commitment_key_arr->elems, *per_commitment_key, 32);
3116         LDKHTLCOutputInCommitment htlc_var = *htlc;
3117         uint32_t htlc_ref = 0;
3118         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
3119         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3120         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3121         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
3122         htlc_ref = (uintptr_t)htlc_var.inner;
3123         if (htlc_var.is_owned) {
3124                 htlc_ref |= 1;
3125         }
3126         uint32_t ret = js_invoke_function_5(j_calls->instance_ptr, 8, (uint32_t)justice_tx_arr, (uint32_t)input_conv, (uint32_t)amount_conv, (uint32_t)per_commitment_key_arr, (uint32_t)htlc_ref);
3127         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3128         CHECK_ACCESS(ret_ptr);
3129         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3130         FREE((void*)ret);
3131         return ret_conv;
3132 }
3133 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) {
3134         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3135         LDKTransaction htlc_tx_var = htlc_tx;
3136         int8_tArray htlc_tx_arr = init_int8_tArray(htlc_tx_var.datalen, __LINE__);
3137         memcpy(htlc_tx_arr->elems, htlc_tx_var.data, htlc_tx_var.datalen);
3138         Transaction_free(htlc_tx_var);
3139         uint32_t input_conv = input;
3140         int64_t amount_conv = amount;
3141         int8_tArray per_commitment_point_arr = init_int8_tArray(33, __LINE__);
3142         memcpy(per_commitment_point_arr->elems, per_commitment_point.compressed_form, 33);
3143         LDKHTLCOutputInCommitment htlc_var = *htlc;
3144         uint32_t htlc_ref = 0;
3145         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
3146         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3147         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3148         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
3149         htlc_ref = (uintptr_t)htlc_var.inner;
3150         if (htlc_var.is_owned) {
3151                 htlc_ref |= 1;
3152         }
3153         uint32_t ret = js_invoke_function_5(j_calls->instance_ptr, 9, (uint32_t)htlc_tx_arr, (uint32_t)input_conv, (uint32_t)amount_conv, (uint32_t)per_commitment_point_arr, (uint32_t)htlc_ref);
3154         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3155         CHECK_ACCESS(ret_ptr);
3156         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3157         FREE((void*)ret);
3158         return ret_conv;
3159 }
3160 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
3161         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3162         LDKClosingTransaction closing_tx_var = *closing_tx;
3163         uint32_t closing_tx_ref = 0;
3164         closing_tx_var = ClosingTransaction_clone(&closing_tx_var);
3165         CHECK((((uintptr_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3166         CHECK((((uintptr_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3167         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
3168         closing_tx_ref = (uintptr_t)closing_tx_var.inner;
3169         if (closing_tx_var.is_owned) {
3170                 closing_tx_ref |= 1;
3171         }
3172         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 10, (uint32_t)closing_tx_ref);
3173         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3174         CHECK_ACCESS(ret_ptr);
3175         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3176         FREE((void*)ret);
3177         return ret_conv;
3178 }
3179 LDKCResult_C2Tuple_SignatureSignatureZNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
3180         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3181         LDKUnsignedChannelAnnouncement msg_var = *msg;
3182         uint32_t msg_ref = 0;
3183         msg_var = UnsignedChannelAnnouncement_clone(&msg_var);
3184         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3185         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3186         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3187         msg_ref = (uintptr_t)msg_var.inner;
3188         if (msg_var.is_owned) {
3189                 msg_ref |= 1;
3190         }
3191         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 11, (uint32_t)msg_ref);
3192         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3193         CHECK_ACCESS(ret_ptr);
3194         LDKCResult_C2Tuple_SignatureSignatureZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(ret_ptr);
3195         FREE((void*)ret);
3196         return ret_conv;
3197 }
3198 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
3199         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3200         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
3201         uint32_t channel_parameters_ref = 0;
3202         channel_parameters_var = ChannelTransactionParameters_clone(&channel_parameters_var);
3203         CHECK((((uintptr_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3204         CHECK((((uintptr_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3205         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
3206         channel_parameters_ref = (uintptr_t)channel_parameters_var.inner;
3207         if (channel_parameters_var.is_owned) {
3208                 channel_parameters_ref |= 1;
3209         }
3210         js_invoke_function_1(j_calls->instance_ptr, 12, (uint32_t)channel_parameters_ref);
3211 }
3212 static void LDKBaseSign_JCalls_cloned(LDKBaseSign* new_obj) {
3213         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) new_obj->this_arg;
3214         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3215 }
3216 static inline LDKBaseSign LDKBaseSign_init (JSValue o, uint32_t pubkeys) {
3217         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
3218         atomic_init(&calls->refcnt, 1);
3219         calls->instance_ptr = o;
3220
3221         LDKChannelPublicKeys pubkeys_conv;
3222         pubkeys_conv.inner = (void*)(pubkeys & (~1));
3223         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
3224         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
3225
3226         LDKBaseSign ret = {
3227                 .this_arg = (void*) calls,
3228                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
3229                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
3230                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
3231                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
3232                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
3233                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
3234                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
3235                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
3236                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
3237                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
3238                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
3239                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
3240                 .ready_channel = ready_channel_LDKBaseSign_jcall,
3241                 .free = LDKBaseSign_JCalls_free,
3242                 .pubkeys = pubkeys_conv,
3243                 .set_pubkeys = NULL,
3244         };
3245         return ret;
3246 }
3247 long  __attribute__((export_name("TS_LDKBaseSign_new"))) TS_LDKBaseSign_new(JSValue o, uint32_t pubkeys) {
3248         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
3249         *res_ptr = LDKBaseSign_init(o, pubkeys);
3250         return (long)res_ptr;
3251 }
3252 int8_tArray  __attribute__((export_name("TS_BaseSign_get_per_commitment_point"))) TS_BaseSign_get_per_commitment_point(uint32_t this_arg, int64_t idx) {
3253         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3254         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3255         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3256         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
3257         memcpy(ret_arr->elems, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form, 33);
3258         return ret_arr;
3259 }
3260
3261 int8_tArray  __attribute__((export_name("TS_BaseSign_release_commitment_secret"))) TS_BaseSign_release_commitment_secret(uint32_t this_arg, int64_t idx) {
3262         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3263         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3264         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3265         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3266         memcpy(ret_arr->elems, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data, 32);
3267         return ret_arr;
3268 }
3269
3270 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) {
3271         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3272         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3273         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3274         LDKHolderCommitmentTransaction holder_tx_conv;
3275         holder_tx_conv.inner = (void*)(holder_tx & (~1));
3276         holder_tx_conv.is_owned = false;
3277         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
3278         LDKCVec_PaymentPreimageZ preimages_constr;
3279         preimages_constr.datalen = preimages->arr_len;
3280         if (preimages_constr.datalen > 0)
3281                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
3282         else
3283                 preimages_constr.data = NULL;
3284         int8_tArray* preimages_vals = (void*) preimages->elems /* XXX preimages leaks */;
3285         for (size_t m = 0; m < preimages_constr.datalen; m++) {
3286                 int8_tArray preimages_conv_12 = preimages_vals[m];
3287                 LDKThirtyTwoBytes preimages_conv_12_ref;
3288                 CHECK(preimages_conv_12->arr_len == 32);
3289                 memcpy(preimages_conv_12_ref.data, preimages_conv_12->elems, 32); FREE(preimages_conv_12);
3290                 preimages_constr.data[m] = preimages_conv_12_ref;
3291         }
3292         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
3293         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv, preimages_constr);
3294         return (uint32_t)ret_conv;
3295 }
3296
3297 int8_tArray  __attribute__((export_name("TS_BaseSign_channel_keys_id"))) TS_BaseSign_channel_keys_id(uint32_t this_arg) {
3298         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3299         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3300         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3301         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3302         memcpy(ret_arr->elems, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data, 32);
3303         return ret_arr;
3304 }
3305
3306 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) {
3307         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3308         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3309         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3310         LDKCommitmentTransaction commitment_tx_conv;
3311         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
3312         commitment_tx_conv.is_owned = false;
3313         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
3314         LDKCVec_PaymentPreimageZ preimages_constr;
3315         preimages_constr.datalen = preimages->arr_len;
3316         if (preimages_constr.datalen > 0)
3317                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
3318         else
3319                 preimages_constr.data = NULL;
3320         int8_tArray* preimages_vals = (void*) preimages->elems /* XXX preimages leaks */;
3321         for (size_t m = 0; m < preimages_constr.datalen; m++) {
3322                 int8_tArray preimages_conv_12 = preimages_vals[m];
3323                 LDKThirtyTwoBytes preimages_conv_12_ref;
3324                 CHECK(preimages_conv_12->arr_len == 32);
3325                 memcpy(preimages_conv_12_ref.data, preimages_conv_12->elems, 32); FREE(preimages_conv_12);
3326                 preimages_constr.data[m] = preimages_conv_12_ref;
3327         }
3328         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
3329         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv, preimages_constr);
3330         return (uint32_t)ret_conv;
3331 }
3332
3333 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) {
3334         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3335         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3336         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3337         unsigned char secret_arr[32];
3338         CHECK(secret->arr_len == 32);
3339         memcpy(secret_arr, secret->elems, 32); FREE(secret);
3340         unsigned char (*secret_ref)[32] = &secret_arr;
3341         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
3342         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
3343         return (uint32_t)ret_conv;
3344 }
3345
3346 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) {
3347         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3348         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3349         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3350         LDKHolderCommitmentTransaction commitment_tx_conv;
3351         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
3352         commitment_tx_conv.is_owned = false;
3353         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
3354         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
3355         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
3356         return (uint32_t)ret_conv;
3357 }
3358
3359 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) {
3360         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3361         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3362         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3363         LDKTransaction justice_tx_ref;
3364         justice_tx_ref.datalen = justice_tx->arr_len;
3365         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
3366         memcpy(justice_tx_ref.data, justice_tx->elems, justice_tx_ref.datalen); FREE(justice_tx);
3367         justice_tx_ref.data_is_owned = true;
3368         unsigned char per_commitment_key_arr[32];
3369         CHECK(per_commitment_key->arr_len == 32);
3370         memcpy(per_commitment_key_arr, per_commitment_key->elems, 32); FREE(per_commitment_key);
3371         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
3372         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3373         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
3374         return (uint32_t)ret_conv;
3375 }
3376
3377 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) {
3378         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3379         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3380         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3381         LDKTransaction justice_tx_ref;
3382         justice_tx_ref.datalen = justice_tx->arr_len;
3383         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
3384         memcpy(justice_tx_ref.data, justice_tx->elems, justice_tx_ref.datalen); FREE(justice_tx);
3385         justice_tx_ref.data_is_owned = true;
3386         unsigned char per_commitment_key_arr[32];
3387         CHECK(per_commitment_key->arr_len == 32);
3388         memcpy(per_commitment_key_arr, per_commitment_key->elems, 32); FREE(per_commitment_key);
3389         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
3390         LDKHTLCOutputInCommitment htlc_conv;
3391         htlc_conv.inner = (void*)(htlc & (~1));
3392         htlc_conv.is_owned = false;
3393         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
3394         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3395         *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);
3396         return (uint32_t)ret_conv;
3397 }
3398
3399 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) {
3400         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3401         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3402         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3403         LDKTransaction htlc_tx_ref;
3404         htlc_tx_ref.datalen = htlc_tx->arr_len;
3405         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
3406         memcpy(htlc_tx_ref.data, htlc_tx->elems, htlc_tx_ref.datalen); FREE(htlc_tx);
3407         htlc_tx_ref.data_is_owned = true;
3408         LDKPublicKey per_commitment_point_ref;
3409         CHECK(per_commitment_point->arr_len == 33);
3410         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
3411         LDKHTLCOutputInCommitment htlc_conv;
3412         htlc_conv.inner = (void*)(htlc & (~1));
3413         htlc_conv.is_owned = false;
3414         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
3415         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3416         *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);
3417         return (uint32_t)ret_conv;
3418 }
3419
3420 uint32_t  __attribute__((export_name("TS_BaseSign_sign_closing_transaction"))) TS_BaseSign_sign_closing_transaction(uint32_t this_arg, uint32_t closing_tx) {
3421         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3422         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3423         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3424         LDKClosingTransaction closing_tx_conv;
3425         closing_tx_conv.inner = (void*)(closing_tx & (~1));
3426         closing_tx_conv.is_owned = false;
3427         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
3428         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3429         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
3430         return (uint32_t)ret_conv;
3431 }
3432
3433 uint32_t  __attribute__((export_name("TS_BaseSign_sign_channel_announcement"))) TS_BaseSign_sign_channel_announcement(uint32_t this_arg, uint32_t msg) {
3434         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3435         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3436         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3437         LDKUnsignedChannelAnnouncement msg_conv;
3438         msg_conv.inner = (void*)(msg & (~1));
3439         msg_conv.is_owned = false;
3440         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
3441         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
3442         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
3443         return (uint32_t)ret_conv;
3444 }
3445
3446 void  __attribute__((export_name("TS_BaseSign_ready_channel"))) TS_BaseSign_ready_channel(uint32_t this_arg, uint32_t channel_parameters) {
3447         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3448         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3449         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3450         LDKChannelTransactionParameters channel_parameters_conv;
3451         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
3452         channel_parameters_conv.is_owned = false;
3453         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
3454         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
3455 }
3456
3457 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
3458         if (this_arg->set_pubkeys != NULL)
3459                 this_arg->set_pubkeys(this_arg);
3460         return this_arg->pubkeys;
3461 }
3462 uint32_t  __attribute__((export_name("TS_BaseSign_get_pubkeys"))) TS_BaseSign_get_pubkeys(uint32_t this_arg) {
3463         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3464         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3465         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3466         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
3467         uint32_t ret_ref = 0;
3468         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3469         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3470         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3471         ret_ref = (uintptr_t)ret_var.inner;
3472         if (ret_var.is_owned) {
3473                 ret_ref |= 1;
3474         }
3475         return ret_ref;
3476 }
3477
3478 typedef struct LDKSign_JCalls {
3479         atomic_size_t refcnt;
3480         uint32_t instance_ptr;
3481         LDKBaseSign_JCalls* BaseSign;
3482 } LDKSign_JCalls;
3483 static void LDKSign_JCalls_free(void* this_arg) {
3484         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
3485         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3486                 FREE(j_calls);
3487         }
3488 }
3489 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
3490         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
3491         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 13);
3492         LDKCVec_u8Z ret_ref;
3493         ret_ref.datalen = ret->arr_len;
3494         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
3495         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
3496         return ret_ref;
3497 }
3498 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
3499         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
3500         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3501         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
3502 }
3503 static inline LDKSign LDKSign_init (JSValue o, JSValue BaseSign, uint32_t pubkeys) {
3504         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
3505         atomic_init(&calls->refcnt, 1);
3506         calls->instance_ptr = o;
3507
3508         LDKChannelPublicKeys pubkeys_conv;
3509         pubkeys_conv.inner = (void*)(pubkeys & (~1));
3510         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
3511         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
3512
3513         LDKSign ret = {
3514                 .this_arg = (void*) calls,
3515                 .write = write_LDKSign_jcall,
3516                 .cloned = LDKSign_JCalls_cloned,
3517                 .free = LDKSign_JCalls_free,
3518                 .BaseSign = LDKBaseSign_init(BaseSign, pubkeys),
3519         };
3520         calls->BaseSign = ret.BaseSign.this_arg;
3521         return ret;
3522 }
3523 long  __attribute__((export_name("TS_LDKSign_new"))) TS_LDKSign_new(JSValue o, JSValue BaseSign, uint32_t pubkeys) {
3524         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
3525         *res_ptr = LDKSign_init(o, BaseSign, pubkeys);
3526         return (long)res_ptr;
3527 }
3528 int8_tArray  __attribute__((export_name("TS_Sign_write"))) TS_Sign_write(uint32_t this_arg) {
3529         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3530         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3531         LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
3532         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
3533         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
3534         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
3535         CVec_u8Z_free(ret_var);
3536         return ret_arr;
3537 }
3538
3539 static inline struct LDKSign CResult_SignDecodeErrorZ_get_ok(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
3540 CHECK(owner->result_ok);
3541         return Sign_clone(&*owner->contents.result);
3542 }
3543 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_get_ok"))) TS_CResult_SignDecodeErrorZ_get_ok(uint32_t owner) {
3544         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
3545         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
3546         *ret_ret = CResult_SignDecodeErrorZ_get_ok(owner_conv);
3547         return (uint32_t)ret_ret;
3548 }
3549
3550 static inline struct LDKDecodeError CResult_SignDecodeErrorZ_get_err(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
3551 CHECK(!owner->result_ok);
3552         return DecodeError_clone(&*owner->contents.err);
3553 }
3554 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_get_err"))) TS_CResult_SignDecodeErrorZ_get_err(uint32_t owner) {
3555         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
3556         LDKDecodeError ret_var = CResult_SignDecodeErrorZ_get_err(owner_conv);
3557         uint32_t ret_ref = 0;
3558         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3559         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3560         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3561         ret_ref = (uintptr_t)ret_var.inner;
3562         if (ret_var.is_owned) {
3563                 ret_ref |= 1;
3564         }
3565         return ret_ref;
3566 }
3567
3568 static inline struct LDKRecoverableSignature CResult_RecoverableSignatureNoneZ_get_ok(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
3569 CHECK(owner->result_ok);
3570         return *owner->contents.result;
3571 }
3572 int8_tArray  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_get_ok"))) TS_CResult_RecoverableSignatureNoneZ_get_ok(uint32_t owner) {
3573         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
3574         int8_tArray ret_arr = init_int8_tArray(68, __LINE__);
3575         memcpy(ret_arr->elems, CResult_RecoverableSignatureNoneZ_get_ok(owner_conv).serialized_form, 68);
3576         return ret_arr;
3577 }
3578
3579 static inline void CResult_RecoverableSignatureNoneZ_get_err(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
3580 CHECK(!owner->result_ok);
3581         return *owner->contents.err;
3582 }
3583 void  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_get_err"))) TS_CResult_RecoverableSignatureNoneZ_get_err(uint32_t owner) {
3584         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
3585         CResult_RecoverableSignatureNoneZ_get_err(owner_conv);
3586 }
3587
3588 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
3589         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
3590         for (size_t i = 0; i < ret.datalen; i++) {
3591                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
3592         }
3593         return ret;
3594 }
3595 static inline struct LDKCVec_CVec_u8ZZ CResult_CVec_CVec_u8ZZNoneZ_get_ok(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
3596 CHECK(owner->result_ok);
3597         return CVec_CVec_u8ZZ_clone(&*owner->contents.result);
3598 }
3599 ptrArray  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_get_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_get_ok(uint32_t owner) {
3600         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
3601         LDKCVec_CVec_u8ZZ ret_var = CResult_CVec_CVec_u8ZZNoneZ_get_ok(owner_conv);
3602         ptrArray ret_arr = NULL;
3603         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
3604         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
3605         for (size_t m = 0; m < ret_var.datalen; m++) {
3606                 LDKCVec_u8Z ret_conv_12_var = ret_var.data[m];
3607                 int8_tArray ret_conv_12_arr = init_int8_tArray(ret_conv_12_var.datalen, __LINE__);
3608                 memcpy(ret_conv_12_arr->elems, ret_conv_12_var.data, ret_conv_12_var.datalen);
3609                 CVec_u8Z_free(ret_conv_12_var);
3610                 ret_arr_ptr[m] = ret_conv_12_arr;
3611         }
3612         
3613         FREE(ret_var.data);
3614         return ret_arr;
3615 }
3616
3617 static inline void CResult_CVec_CVec_u8ZZNoneZ_get_err(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
3618 CHECK(!owner->result_ok);
3619         return *owner->contents.err;
3620 }
3621 void  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_get_err"))) TS_CResult_CVec_CVec_u8ZZNoneZ_get_err(uint32_t owner) {
3622         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
3623         CResult_CVec_CVec_u8ZZNoneZ_get_err(owner_conv);
3624 }
3625
3626 static inline struct LDKInMemorySigner CResult_InMemorySignerDecodeErrorZ_get_ok(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
3627 CHECK(owner->result_ok);
3628         return InMemorySigner_clone(&*owner->contents.result);
3629 }
3630 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_get_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_get_ok(uint32_t owner) {
3631         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
3632         LDKInMemorySigner ret_var = CResult_InMemorySignerDecodeErrorZ_get_ok(owner_conv);
3633         uint32_t ret_ref = 0;
3634         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3635         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3636         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3637         ret_ref = (uintptr_t)ret_var.inner;
3638         if (ret_var.is_owned) {
3639                 ret_ref |= 1;
3640         }
3641         return ret_ref;
3642 }
3643
3644 static inline struct LDKDecodeError CResult_InMemorySignerDecodeErrorZ_get_err(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
3645 CHECK(!owner->result_ok);
3646         return DecodeError_clone(&*owner->contents.err);
3647 }
3648 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_get_err"))) TS_CResult_InMemorySignerDecodeErrorZ_get_err(uint32_t owner) {
3649         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
3650         LDKDecodeError ret_var = CResult_InMemorySignerDecodeErrorZ_get_err(owner_conv);
3651         uint32_t ret_ref = 0;
3652         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3653         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3654         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3655         ret_ref = (uintptr_t)ret_var.inner;
3656         if (ret_var.is_owned) {
3657                 ret_ref |= 1;
3658         }
3659         return ret_ref;
3660 }
3661
3662 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
3663         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
3664         for (size_t i = 0; i < ret.datalen; i++) {
3665                 ret.data[i] = TxOut_clone(&orig->data[i]);
3666         }
3667         return ret;
3668 }
3669 static inline struct LDKTransaction CResult_TransactionNoneZ_get_ok(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
3670 CHECK(owner->result_ok);
3671         return *owner->contents.result;
3672 }
3673 int8_tArray  __attribute__((export_name("TS_CResult_TransactionNoneZ_get_ok"))) TS_CResult_TransactionNoneZ_get_ok(uint32_t owner) {
3674         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
3675         LDKTransaction ret_var = CResult_TransactionNoneZ_get_ok(owner_conv);
3676         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
3677         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
3678         return ret_arr;
3679 }
3680
3681 static inline void CResult_TransactionNoneZ_get_err(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
3682 CHECK(!owner->result_ok);
3683         return *owner->contents.err;
3684 }
3685 void  __attribute__((export_name("TS_CResult_TransactionNoneZ_get_err"))) TS_CResult_TransactionNoneZ_get_err(uint32_t owner) {
3686         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
3687         CResult_TransactionNoneZ_get_err(owner_conv);
3688 }
3689
3690 uint32_t __attribute__((export_name("TS_LDKCOption_u16Z_ty_from_ptr"))) TS_LDKCOption_u16Z_ty_from_ptr(uint32_t ptr) {
3691         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
3692         switch(obj->tag) {
3693                 case LDKCOption_u16Z_Some: return 0;
3694                 case LDKCOption_u16Z_None: return 1;
3695                 default: abort();
3696         }
3697 }
3698 int16_t __attribute__((export_name("TS_LDKCOption_u16Z_Some_get_some"))) TS_LDKCOption_u16Z_Some_get_some(uint32_t ptr) {
3699         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
3700         assert(obj->tag == LDKCOption_u16Z_Some);
3701                         int16_t some_conv = obj->some;
3702         return some_conv;
3703 }
3704 uint32_t __attribute__((export_name("TS_LDKAPIError_ty_from_ptr"))) TS_LDKAPIError_ty_from_ptr(uint32_t ptr) {
3705         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3706         switch(obj->tag) {
3707                 case LDKAPIError_APIMisuseError: return 0;
3708                 case LDKAPIError_FeeRateTooHigh: return 1;
3709                 case LDKAPIError_RouteError: return 2;
3710                 case LDKAPIError_ChannelUnavailable: return 3;
3711                 case LDKAPIError_MonitorUpdateFailed: return 4;
3712                 case LDKAPIError_IncompatibleShutdownScript: return 5;
3713                 default: abort();
3714         }
3715 }
3716 jstring __attribute__((export_name("TS_LDKAPIError_APIMisuseError_get_err"))) TS_LDKAPIError_APIMisuseError_get_err(uint32_t ptr) {
3717         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3718         assert(obj->tag == LDKAPIError_APIMisuseError);
3719                         LDKStr err_str = obj->api_misuse_error.err;
3720                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
3721         return err_conv;
3722 }
3723 jstring __attribute__((export_name("TS_LDKAPIError_FeeRateTooHigh_get_err"))) TS_LDKAPIError_FeeRateTooHigh_get_err(uint32_t ptr) {
3724         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3725         assert(obj->tag == LDKAPIError_FeeRateTooHigh);
3726                         LDKStr err_str = obj->fee_rate_too_high.err;
3727                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
3728         return err_conv;
3729 }
3730 int32_t __attribute__((export_name("TS_LDKAPIError_FeeRateTooHigh_get_feerate"))) TS_LDKAPIError_FeeRateTooHigh_get_feerate(uint32_t ptr) {
3731         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3732         assert(obj->tag == LDKAPIError_FeeRateTooHigh);
3733                         int32_t feerate_conv = obj->fee_rate_too_high.feerate;
3734         return feerate_conv;
3735 }
3736 jstring __attribute__((export_name("TS_LDKAPIError_RouteError_get_err"))) TS_LDKAPIError_RouteError_get_err(uint32_t ptr) {
3737         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3738         assert(obj->tag == LDKAPIError_RouteError);
3739                         LDKStr err_str = obj->route_error.err;
3740                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
3741         return err_conv;
3742 }
3743 jstring __attribute__((export_name("TS_LDKAPIError_ChannelUnavailable_get_err"))) TS_LDKAPIError_ChannelUnavailable_get_err(uint32_t ptr) {
3744         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3745         assert(obj->tag == LDKAPIError_ChannelUnavailable);
3746                         LDKStr err_str = obj->channel_unavailable.err;
3747                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
3748         return err_conv;
3749 }
3750 uint32_t __attribute__((export_name("TS_LDKAPIError_IncompatibleShutdownScript_get_script"))) TS_LDKAPIError_IncompatibleShutdownScript_get_script(uint32_t ptr) {
3751         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3752         assert(obj->tag == LDKAPIError_IncompatibleShutdownScript);
3753                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
3754                         uint32_t script_ref = 0;
3755                         CHECK((((uintptr_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3756                         CHECK((((uintptr_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3757                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
3758                         script_ref = (uintptr_t)script_var.inner & ~1;
3759         return script_ref;
3760 }
3761 static inline void CResult_NoneAPIErrorZ_get_ok(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
3762 CHECK(owner->result_ok);
3763         return *owner->contents.result;
3764 }
3765 void  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_get_ok"))) TS_CResult_NoneAPIErrorZ_get_ok(uint32_t owner) {
3766         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
3767         CResult_NoneAPIErrorZ_get_ok(owner_conv);
3768 }
3769
3770 static inline struct LDKAPIError CResult_NoneAPIErrorZ_get_err(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
3771 CHECK(!owner->result_ok);
3772         return APIError_clone(&*owner->contents.err);
3773 }
3774 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_get_err"))) TS_CResult_NoneAPIErrorZ_get_err(uint32_t owner) {
3775         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
3776         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
3777         *ret_copy = CResult_NoneAPIErrorZ_get_err(owner_conv);
3778         uint32_t ret_ref = (uintptr_t)ret_copy;
3779         return ret_ref;
3780 }
3781
3782 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
3783         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
3784         for (size_t i = 0; i < ret.datalen; i++) {
3785                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
3786         }
3787         return ret;
3788 }
3789 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
3790         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
3791         for (size_t i = 0; i < ret.datalen; i++) {
3792                 ret.data[i] = APIError_clone(&orig->data[i]);
3793         }
3794         return ret;
3795 }
3796 static inline struct LDKThirtyTwoBytes CResult__u832APIErrorZ_get_ok(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
3797 CHECK(owner->result_ok);
3798         return ThirtyTwoBytes_clone(&*owner->contents.result);
3799 }
3800 int8_tArray  __attribute__((export_name("TS_CResult__u832APIErrorZ_get_ok"))) TS_CResult__u832APIErrorZ_get_ok(uint32_t owner) {
3801         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
3802         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3803         memcpy(ret_arr->elems, CResult__u832APIErrorZ_get_ok(owner_conv).data, 32);
3804         return ret_arr;
3805 }
3806
3807 static inline struct LDKAPIError CResult__u832APIErrorZ_get_err(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
3808 CHECK(!owner->result_ok);
3809         return APIError_clone(&*owner->contents.err);
3810 }
3811 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_get_err"))) TS_CResult__u832APIErrorZ_get_err(uint32_t owner) {
3812         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
3813         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
3814         *ret_copy = CResult__u832APIErrorZ_get_err(owner_conv);
3815         uint32_t ret_ref = (uintptr_t)ret_copy;
3816         return ret_ref;
3817 }
3818
3819 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_ty_from_ptr"))) TS_LDKPaymentSendFailure_ty_from_ptr(uint32_t ptr) {
3820         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3821         switch(obj->tag) {
3822                 case LDKPaymentSendFailure_ParameterError: return 0;
3823                 case LDKPaymentSendFailure_PathParameterError: return 1;
3824                 case LDKPaymentSendFailure_AllFailedRetrySafe: return 2;
3825                 case LDKPaymentSendFailure_PartialFailure: return 3;
3826                 default: abort();
3827         }
3828 }
3829 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_ParameterError_get_parameter_error"))) TS_LDKPaymentSendFailure_ParameterError_get_parameter_error(uint32_t ptr) {
3830         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3831         assert(obj->tag == LDKPaymentSendFailure_ParameterError);
3832                         uint32_t parameter_error_ref = ((uintptr_t)&obj->parameter_error) | 1;
3833         return parameter_error_ref;
3834 }
3835 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PathParameterError_get_path_parameter_error"))) TS_LDKPaymentSendFailure_PathParameterError_get_path_parameter_error(uint32_t ptr) {
3836         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3837         assert(obj->tag == LDKPaymentSendFailure_PathParameterError);
3838                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
3839                         uint32_tArray path_parameter_error_arr = NULL;
3840                         path_parameter_error_arr = init_uint32_tArray(path_parameter_error_var.datalen, __LINE__);
3841                         uint32_t *path_parameter_error_arr_ptr = (uint32_t*)(((uint8_t*)path_parameter_error_arr) + 4);
3842                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
3843                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3844                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
3845                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
3846                                 path_parameter_error_arr_ptr[w] = (uint32_t)path_parameter_error_conv_22_conv;
3847                         }
3848                         
3849         return path_parameter_error_arr;
3850 }
3851 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_AllFailedRetrySafe_get_all_failed_retry_safe"))) TS_LDKPaymentSendFailure_AllFailedRetrySafe_get_all_failed_retry_safe(uint32_t ptr) {
3852         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3853         assert(obj->tag == LDKPaymentSendFailure_AllFailedRetrySafe);
3854                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
3855                         uint32_tArray all_failed_retry_safe_arr = NULL;
3856                         all_failed_retry_safe_arr = init_uint32_tArray(all_failed_retry_safe_var.datalen, __LINE__);
3857                         uint32_t *all_failed_retry_safe_arr_ptr = (uint32_t*)(((uint8_t*)all_failed_retry_safe_arr) + 4);
3858                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
3859                                 uint32_t all_failed_retry_safe_conv_10_ref = ((uintptr_t)&all_failed_retry_safe_var.data[k]) | 1;
3860                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
3861                         }
3862                         
3863         return all_failed_retry_safe_arr;
3864 }
3865 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_results"))) TS_LDKPaymentSendFailure_PartialFailure_get_results(uint32_t ptr) {
3866         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3867         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
3868                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
3869                         uint32_tArray results_arr = NULL;
3870                         results_arr = init_uint32_tArray(results_var.datalen, __LINE__);
3871                         uint32_t *results_arr_ptr = (uint32_t*)(((uint8_t*)results_arr) + 4);
3872                         for (size_t w = 0; w < results_var.datalen; w++) {
3873                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3874                                 *results_conv_22_conv = results_var.data[w];
3875                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
3876                                 results_arr_ptr[w] = (uint32_t)results_conv_22_conv;
3877                         }
3878                         
3879         return results_arr;
3880 }
3881 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_failed_paths_retry"))) TS_LDKPaymentSendFailure_PartialFailure_get_failed_paths_retry(uint32_t ptr) {
3882         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3883         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
3884                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
3885                         uint32_t failed_paths_retry_ref = 0;
3886                         if ((uintptr_t)failed_paths_retry_var.inner > 4096) {
3887                                 CHECK((((uintptr_t)failed_paths_retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3888                                 CHECK((((uintptr_t)&failed_paths_retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3889                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
3890                                 failed_paths_retry_ref = (uintptr_t)failed_paths_retry_var.inner & ~1;
3891                         }
3892         return failed_paths_retry_ref;
3893 }
3894 int8_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_payment_id"))) TS_LDKPaymentSendFailure_PartialFailure_get_payment_id(uint32_t ptr) {
3895         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3896         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
3897                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
3898                         memcpy(payment_id_arr->elems, obj->partial_failure.payment_id.data, 32);
3899         return payment_id_arr;
3900 }
3901 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentSendFailureZ_get_ok(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
3902 CHECK(owner->result_ok);
3903         return ThirtyTwoBytes_clone(&*owner->contents.result);
3904 }
3905 int8_tArray  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_get_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_get_ok(uint32_t owner) {
3906         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
3907         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3908         memcpy(ret_arr->elems, CResult_PaymentIdPaymentSendFailureZ_get_ok(owner_conv).data, 32);
3909         return ret_arr;
3910 }
3911
3912 static inline struct LDKPaymentSendFailure CResult_PaymentIdPaymentSendFailureZ_get_err(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
3913 CHECK(!owner->result_ok);
3914         return PaymentSendFailure_clone(&*owner->contents.err);
3915 }
3916 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_get_err"))) TS_CResult_PaymentIdPaymentSendFailureZ_get_err(uint32_t owner) {
3917         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
3918         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
3919         *ret_copy = CResult_PaymentIdPaymentSendFailureZ_get_err(owner_conv);
3920         uint32_t ret_ref = (uintptr_t)ret_copy;
3921         return ret_ref;
3922 }
3923
3924 static inline void CResult_NonePaymentSendFailureZ_get_ok(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
3925 CHECK(owner->result_ok);
3926         return *owner->contents.result;
3927 }
3928 void  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_get_ok"))) TS_CResult_NonePaymentSendFailureZ_get_ok(uint32_t owner) {
3929         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
3930         CResult_NonePaymentSendFailureZ_get_ok(owner_conv);
3931 }
3932
3933 static inline struct LDKPaymentSendFailure CResult_NonePaymentSendFailureZ_get_err(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
3934 CHECK(!owner->result_ok);
3935         return PaymentSendFailure_clone(&*owner->contents.err);
3936 }
3937 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_get_err"))) TS_CResult_NonePaymentSendFailureZ_get_err(uint32_t owner) {
3938         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
3939         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
3940         *ret_copy = CResult_NonePaymentSendFailureZ_get_err(owner_conv);
3941         uint32_t ret_ref = (uintptr_t)ret_copy;
3942         return ret_ref;
3943 }
3944
3945 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
3946         return ThirtyTwoBytes_clone(&owner->a);
3947 }
3948 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_get_a"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_a(uint32_t owner) {
3949         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
3950         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3951         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentIdZ_get_a(owner_conv).data, 32);
3952         return ret_arr;
3953 }
3954
3955 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
3956         return ThirtyTwoBytes_clone(&owner->b);
3957 }
3958 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_get_b"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_b(uint32_t owner) {
3959         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
3960         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3961         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentIdZ_get_b(owner_conv).data, 32);
3962         return ret_arr;
3963 }
3964
3965 static inline struct LDKC2Tuple_PaymentHashPaymentIdZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
3966 CHECK(owner->result_ok);
3967         return C2Tuple_PaymentHashPaymentIdZ_clone(&*owner->contents.result);
3968 }
3969 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(uint32_t owner) {
3970         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
3971         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
3972         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(owner_conv);
3973         return ((uint32_t)ret_conv);
3974 }
3975
3976 static inline struct LDKPaymentSendFailure CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
3977 CHECK(!owner->result_ok);
3978         return PaymentSendFailure_clone(&*owner->contents.err);
3979 }
3980 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(uint32_t owner) {
3981         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
3982         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
3983         *ret_copy = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(owner_conv);
3984         uint32_t ret_ref = (uintptr_t)ret_copy;
3985         return ret_ref;
3986 }
3987
3988 uint32_t __attribute__((export_name("TS_LDKNetAddress_ty_from_ptr"))) TS_LDKNetAddress_ty_from_ptr(uint32_t ptr) {
3989         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3990         switch(obj->tag) {
3991                 case LDKNetAddress_IPv4: return 0;
3992                 case LDKNetAddress_IPv6: return 1;
3993                 case LDKNetAddress_OnionV2: return 2;
3994                 case LDKNetAddress_OnionV3: return 3;
3995                 default: abort();
3996         }
3997 }
3998 int8_tArray __attribute__((export_name("TS_LDKNetAddress_IPv4_get_addr"))) TS_LDKNetAddress_IPv4_get_addr(uint32_t ptr) {
3999         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
4000         assert(obj->tag == LDKNetAddress_IPv4);
4001                         int8_tArray addr_arr = init_int8_tArray(4, __LINE__);
4002                         memcpy(addr_arr->elems, obj->i_pv4.addr.data, 4);
4003         return addr_arr;
4004 }
4005 int16_t __attribute__((export_name("TS_LDKNetAddress_IPv4_get_port"))) TS_LDKNetAddress_IPv4_get_port(uint32_t ptr) {
4006         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
4007         assert(obj->tag == LDKNetAddress_IPv4);
4008                         int16_t port_conv = obj->i_pv4.port;
4009         return port_conv;
4010 }
4011 int8_tArray __attribute__((export_name("TS_LDKNetAddress_IPv6_get_addr"))) TS_LDKNetAddress_IPv6_get_addr(uint32_t ptr) {
4012         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
4013         assert(obj->tag == LDKNetAddress_IPv6);
4014                         int8_tArray addr_arr = init_int8_tArray(16, __LINE__);
4015                         memcpy(addr_arr->elems, obj->i_pv6.addr.data, 16);
4016         return addr_arr;
4017 }
4018 int16_t __attribute__((export_name("TS_LDKNetAddress_IPv6_get_port"))) TS_LDKNetAddress_IPv6_get_port(uint32_t ptr) {
4019         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
4020         assert(obj->tag == LDKNetAddress_IPv6);
4021                         int16_t port_conv = obj->i_pv6.port;
4022         return port_conv;
4023 }
4024 int8_tArray __attribute__((export_name("TS_LDKNetAddress_OnionV2_get_onion_v2"))) TS_LDKNetAddress_OnionV2_get_onion_v2(uint32_t ptr) {
4025         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
4026         assert(obj->tag == LDKNetAddress_OnionV2);
4027                         int8_tArray onion_v2_arr = init_int8_tArray(12, __LINE__);
4028                         memcpy(onion_v2_arr->elems, obj->onion_v2.data, 12);
4029         return onion_v2_arr;
4030 }
4031 int8_tArray __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_ed25519_pubkey"))) TS_LDKNetAddress_OnionV3_get_ed25519_pubkey(uint32_t ptr) {
4032         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
4033         assert(obj->tag == LDKNetAddress_OnionV3);
4034                         int8_tArray ed25519_pubkey_arr = init_int8_tArray(32, __LINE__);
4035                         memcpy(ed25519_pubkey_arr->elems, obj->onion_v3.ed25519_pubkey.data, 32);
4036         return ed25519_pubkey_arr;
4037 }
4038 int16_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_checksum"))) TS_LDKNetAddress_OnionV3_get_checksum(uint32_t ptr) {
4039         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
4040         assert(obj->tag == LDKNetAddress_OnionV3);
4041                         int16_t checksum_conv = obj->onion_v3.checksum;
4042         return checksum_conv;
4043 }
4044 int8_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_version"))) TS_LDKNetAddress_OnionV3_get_version(uint32_t ptr) {
4045         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
4046         assert(obj->tag == LDKNetAddress_OnionV3);
4047                         int8_t version_conv = obj->onion_v3.version;
4048         return version_conv;
4049 }
4050 int16_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_port"))) TS_LDKNetAddress_OnionV3_get_port(uint32_t ptr) {
4051         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
4052         assert(obj->tag == LDKNetAddress_OnionV3);
4053                         int16_t port_conv = obj->onion_v3.port;
4054         return port_conv;
4055 }
4056 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
4057         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
4058         for (size_t i = 0; i < ret.datalen; i++) {
4059                 ret.data[i] = NetAddress_clone(&orig->data[i]);
4060         }
4061         return ret;
4062 }
4063 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
4064         return ThirtyTwoBytes_clone(&owner->a);
4065 }
4066 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_get_a"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_a(uint32_t owner) {
4067         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
4068         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4069         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentSecretZ_get_a(owner_conv).data, 32);
4070         return ret_arr;
4071 }
4072
4073 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
4074         return ThirtyTwoBytes_clone(&owner->b);
4075 }
4076 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_get_b"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_b(uint32_t owner) {
4077         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
4078         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4079         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentSecretZ_get_b(owner_conv).data, 32);
4080         return ret_arr;
4081 }
4082
4083 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
4084 CHECK(owner->result_ok);
4085         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
4086 }
4087 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(uint32_t owner) {
4088         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
4089         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
4090         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(owner_conv);
4091         return ((uint32_t)ret_conv);
4092 }
4093
4094 static inline void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
4095 CHECK(!owner->result_ok);
4096         return *owner->contents.err;
4097 }
4098 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(uint32_t owner) {
4099         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
4100         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(owner_conv);
4101 }
4102
4103 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
4104 CHECK(owner->result_ok);
4105         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
4106 }
4107 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(uint32_t owner) {
4108         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
4109         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
4110         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(owner_conv);
4111         return ((uint32_t)ret_conv);
4112 }
4113
4114 static inline struct LDKAPIError CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
4115 CHECK(!owner->result_ok);
4116         return APIError_clone(&*owner->contents.err);
4117 }
4118 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(uint32_t owner) {
4119         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
4120         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4121         *ret_copy = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(owner_conv);
4122         uint32_t ret_ref = (uintptr_t)ret_copy;
4123         return ret_ref;
4124 }
4125
4126 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretNoneZ_get_ok(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
4127 CHECK(owner->result_ok);
4128         return ThirtyTwoBytes_clone(&*owner->contents.result);
4129 }
4130 int8_tArray  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_get_ok"))) TS_CResult_PaymentSecretNoneZ_get_ok(uint32_t owner) {
4131         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
4132         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4133         memcpy(ret_arr->elems, CResult_PaymentSecretNoneZ_get_ok(owner_conv).data, 32);
4134         return ret_arr;
4135 }
4136
4137 static inline void CResult_PaymentSecretNoneZ_get_err(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
4138 CHECK(!owner->result_ok);
4139         return *owner->contents.err;
4140 }
4141 void  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_get_err"))) TS_CResult_PaymentSecretNoneZ_get_err(uint32_t owner) {
4142         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
4143         CResult_PaymentSecretNoneZ_get_err(owner_conv);
4144 }
4145
4146 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretAPIErrorZ_get_ok(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
4147 CHECK(owner->result_ok);
4148         return ThirtyTwoBytes_clone(&*owner->contents.result);
4149 }
4150 int8_tArray  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_get_ok"))) TS_CResult_PaymentSecretAPIErrorZ_get_ok(uint32_t owner) {
4151         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
4152         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4153         memcpy(ret_arr->elems, CResult_PaymentSecretAPIErrorZ_get_ok(owner_conv).data, 32);
4154         return ret_arr;
4155 }
4156
4157 static inline struct LDKAPIError CResult_PaymentSecretAPIErrorZ_get_err(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
4158 CHECK(!owner->result_ok);
4159         return APIError_clone(&*owner->contents.err);
4160 }
4161 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_get_err"))) TS_CResult_PaymentSecretAPIErrorZ_get_err(uint32_t owner) {
4162         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
4163         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4164         *ret_copy = CResult_PaymentSecretAPIErrorZ_get_err(owner_conv);
4165         uint32_t ret_ref = (uintptr_t)ret_copy;
4166         return ret_ref;
4167 }
4168
4169 static inline struct LDKThirtyTwoBytes CResult_PaymentPreimageAPIErrorZ_get_ok(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
4170 CHECK(owner->result_ok);
4171         return ThirtyTwoBytes_clone(&*owner->contents.result);
4172 }
4173 int8_tArray  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_get_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_get_ok(uint32_t owner) {
4174         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
4175         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4176         memcpy(ret_arr->elems, CResult_PaymentPreimageAPIErrorZ_get_ok(owner_conv).data, 32);
4177         return ret_arr;
4178 }
4179
4180 static inline struct LDKAPIError CResult_PaymentPreimageAPIErrorZ_get_err(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
4181 CHECK(!owner->result_ok);
4182         return APIError_clone(&*owner->contents.err);
4183 }
4184 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_get_err"))) TS_CResult_PaymentPreimageAPIErrorZ_get_err(uint32_t owner) {
4185         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
4186         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4187         *ret_copy = CResult_PaymentPreimageAPIErrorZ_get_err(owner_conv);
4188         uint32_t ret_ref = (uintptr_t)ret_copy;
4189         return ret_ref;
4190 }
4191
4192 static inline struct LDKCounterpartyForwardingInfo CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
4193 CHECK(owner->result_ok);
4194         return CounterpartyForwardingInfo_clone(&*owner->contents.result);
4195 }
4196 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(uint32_t owner) {
4197         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
4198         LDKCounterpartyForwardingInfo ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(owner_conv);
4199         uint32_t ret_ref = 0;
4200         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4201         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4202         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4203         ret_ref = (uintptr_t)ret_var.inner;
4204         if (ret_var.is_owned) {
4205                 ret_ref |= 1;
4206         }
4207         return ret_ref;
4208 }
4209
4210 static inline struct LDKDecodeError CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
4211 CHECK(!owner->result_ok);
4212         return DecodeError_clone(&*owner->contents.err);
4213 }
4214 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(uint32_t owner) {
4215         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
4216         LDKDecodeError ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(owner_conv);
4217         uint32_t ret_ref = 0;
4218         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4219         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4220         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4221         ret_ref = (uintptr_t)ret_var.inner;
4222         if (ret_var.is_owned) {
4223                 ret_ref |= 1;
4224         }
4225         return ret_ref;
4226 }
4227
4228 static inline struct LDKChannelCounterparty CResult_ChannelCounterpartyDecodeErrorZ_get_ok(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
4229 CHECK(owner->result_ok);
4230         return ChannelCounterparty_clone(&*owner->contents.result);
4231 }
4232 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_get_ok"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_get_ok(uint32_t owner) {
4233         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
4234         LDKChannelCounterparty ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_ok(owner_conv);
4235         uint32_t ret_ref = 0;
4236         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4237         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4238         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4239         ret_ref = (uintptr_t)ret_var.inner;
4240         if (ret_var.is_owned) {
4241                 ret_ref |= 1;
4242         }
4243         return ret_ref;
4244 }
4245
4246 static inline struct LDKDecodeError CResult_ChannelCounterpartyDecodeErrorZ_get_err(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
4247 CHECK(!owner->result_ok);
4248         return DecodeError_clone(&*owner->contents.err);
4249 }
4250 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_get_err"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_get_err(uint32_t owner) {
4251         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
4252         LDKDecodeError ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_err(owner_conv);
4253         uint32_t ret_ref = 0;
4254         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4255         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4256         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4257         ret_ref = (uintptr_t)ret_var.inner;
4258         if (ret_var.is_owned) {
4259                 ret_ref |= 1;
4260         }
4261         return ret_ref;
4262 }
4263
4264 static inline struct LDKChannelDetails CResult_ChannelDetailsDecodeErrorZ_get_ok(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
4265 CHECK(owner->result_ok);
4266         return ChannelDetails_clone(&*owner->contents.result);
4267 }
4268 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_get_ok"))) TS_CResult_ChannelDetailsDecodeErrorZ_get_ok(uint32_t owner) {
4269         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
4270         LDKChannelDetails ret_var = CResult_ChannelDetailsDecodeErrorZ_get_ok(owner_conv);
4271         uint32_t ret_ref = 0;
4272         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4273         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4274         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4275         ret_ref = (uintptr_t)ret_var.inner;
4276         if (ret_var.is_owned) {
4277                 ret_ref |= 1;
4278         }
4279         return ret_ref;
4280 }
4281
4282 static inline struct LDKDecodeError CResult_ChannelDetailsDecodeErrorZ_get_err(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
4283 CHECK(!owner->result_ok);
4284         return DecodeError_clone(&*owner->contents.err);
4285 }
4286 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_get_err"))) TS_CResult_ChannelDetailsDecodeErrorZ_get_err(uint32_t owner) {
4287         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
4288         LDKDecodeError ret_var = CResult_ChannelDetailsDecodeErrorZ_get_err(owner_conv);
4289         uint32_t ret_ref = 0;
4290         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4291         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4292         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4293         ret_ref = (uintptr_t)ret_var.inner;
4294         if (ret_var.is_owned) {
4295                 ret_ref |= 1;
4296         }
4297         return ret_ref;
4298 }
4299
4300 static inline struct LDKPhantomRouteHints CResult_PhantomRouteHintsDecodeErrorZ_get_ok(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
4301 CHECK(owner->result_ok);
4302         return PhantomRouteHints_clone(&*owner->contents.result);
4303 }
4304 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_get_ok"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_get_ok(uint32_t owner) {
4305         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
4306         LDKPhantomRouteHints ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_ok(owner_conv);
4307         uint32_t ret_ref = 0;
4308         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4309         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4310         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4311         ret_ref = (uintptr_t)ret_var.inner;
4312         if (ret_var.is_owned) {
4313                 ret_ref |= 1;
4314         }
4315         return ret_ref;
4316 }
4317
4318 static inline struct LDKDecodeError CResult_PhantomRouteHintsDecodeErrorZ_get_err(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
4319 CHECK(!owner->result_ok);
4320         return DecodeError_clone(&*owner->contents.err);
4321 }
4322 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_get_err"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_get_err(uint32_t owner) {
4323         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
4324         LDKDecodeError ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_err(owner_conv);
4325         uint32_t ret_ref = 0;
4326         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4327         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4328         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4329         ret_ref = (uintptr_t)ret_var.inner;
4330         if (ret_var.is_owned) {
4331                 ret_ref |= 1;
4332         }
4333         return ret_ref;
4334 }
4335
4336 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
4337         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
4338         for (size_t i = 0; i < ret.datalen; i++) {
4339                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
4340         }
4341         return ret;
4342 }
4343 typedef struct LDKWatch_JCalls {
4344         atomic_size_t refcnt;
4345         uint32_t instance_ptr;
4346 } LDKWatch_JCalls;
4347 static void LDKWatch_JCalls_free(void* this_arg) {
4348         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4349         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4350                 FREE(j_calls);
4351         }
4352 }
4353 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
4354         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4355         LDKOutPoint funding_txo_var = funding_txo;
4356         uint32_t funding_txo_ref = 0;
4357         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4358         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4359         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
4360         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
4361         if (funding_txo_var.is_owned) {
4362                 funding_txo_ref |= 1;
4363         }
4364         LDKChannelMonitor monitor_var = monitor;
4365         uint32_t monitor_ref = 0;
4366         CHECK((((uintptr_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4367         CHECK((((uintptr_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4368         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
4369         monitor_ref = (uintptr_t)monitor_var.inner;
4370         if (monitor_var.is_owned) {
4371                 monitor_ref |= 1;
4372         }
4373         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 14, (uint32_t)funding_txo_ref, (uint32_t)monitor_ref);
4374         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4375         CHECK_ACCESS(ret_ptr);
4376         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
4377         FREE((void*)ret);
4378         return ret_conv;
4379 }
4380 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
4381         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4382         LDKOutPoint funding_txo_var = funding_txo;
4383         uint32_t funding_txo_ref = 0;
4384         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4385         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4386         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
4387         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
4388         if (funding_txo_var.is_owned) {
4389                 funding_txo_ref |= 1;
4390         }
4391         LDKChannelMonitorUpdate update_var = update;
4392         uint32_t update_ref = 0;
4393         CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4394         CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4395         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
4396         update_ref = (uintptr_t)update_var.inner;
4397         if (update_var.is_owned) {
4398                 update_ref |= 1;
4399         }
4400         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 15, (uint32_t)funding_txo_ref, (uint32_t)update_ref);
4401         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4402         CHECK_ACCESS(ret_ptr);
4403         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
4404         FREE((void*)ret);
4405         return ret_conv;
4406 }
4407 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
4408         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4409         uint32_tArray ret = (uint32_tArray)js_invoke_function_0(j_calls->instance_ptr, 16);
4410         LDKCVec_MonitorEventZ ret_constr;
4411         ret_constr.datalen = ret->arr_len;
4412         if (ret_constr.datalen > 0)
4413                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
4414         else
4415                 ret_constr.data = NULL;
4416         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
4417         for (size_t o = 0; o < ret_constr.datalen; o++) {
4418                 uint32_t ret_conv_14 = ret_vals[o];
4419                 void* ret_conv_14_ptr = (void*)(((uintptr_t)ret_conv_14) & ~1);
4420                 CHECK_ACCESS(ret_conv_14_ptr);
4421                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(ret_conv_14_ptr);
4422                 FREE((void*)ret_conv_14);
4423                 ret_constr.data[o] = ret_conv_14_conv;
4424         }
4425         return ret_constr;
4426 }
4427 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
4428         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
4429         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4430 }
4431 static inline LDKWatch LDKWatch_init (JSValue o) {
4432         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
4433         atomic_init(&calls->refcnt, 1);
4434         calls->instance_ptr = o;
4435
4436         LDKWatch ret = {
4437                 .this_arg = (void*) calls,
4438                 .watch_channel = watch_channel_LDKWatch_jcall,
4439                 .update_channel = update_channel_LDKWatch_jcall,
4440                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
4441                 .free = LDKWatch_JCalls_free,
4442         };
4443         return ret;
4444 }
4445 long  __attribute__((export_name("TS_LDKWatch_new"))) TS_LDKWatch_new(JSValue o) {
4446         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
4447         *res_ptr = LDKWatch_init(o);
4448         return (long)res_ptr;
4449 }
4450 uint32_t  __attribute__((export_name("TS_Watch_watch_channel"))) TS_Watch_watch_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t monitor) {
4451         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4452         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4453         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
4454         LDKOutPoint funding_txo_conv;
4455         funding_txo_conv.inner = (void*)(funding_txo & (~1));
4456         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
4457         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
4458         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
4459         LDKChannelMonitor monitor_conv;
4460         monitor_conv.inner = (void*)(monitor & (~1));
4461         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
4462         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
4463         monitor_conv = ChannelMonitor_clone(&monitor_conv);
4464         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4465         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
4466         return (uint32_t)ret_conv;
4467 }
4468
4469 uint32_t  __attribute__((export_name("TS_Watch_update_channel"))) TS_Watch_update_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t update) {
4470         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4471         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4472         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
4473         LDKOutPoint funding_txo_conv;
4474         funding_txo_conv.inner = (void*)(funding_txo & (~1));
4475         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
4476         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
4477         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
4478         LDKChannelMonitorUpdate update_conv;
4479         update_conv.inner = (void*)(update & (~1));
4480         update_conv.is_owned = (update & 1) || (update == 0);
4481         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
4482         update_conv = ChannelMonitorUpdate_clone(&update_conv);
4483         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4484         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
4485         return (uint32_t)ret_conv;
4486 }
4487
4488 uint32_tArray  __attribute__((export_name("TS_Watch_release_pending_monitor_events"))) TS_Watch_release_pending_monitor_events(uint32_t this_arg) {
4489         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4490         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4491         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
4492         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
4493         uint32_tArray ret_arr = NULL;
4494         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
4495         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
4496         for (size_t o = 0; o < ret_var.datalen; o++) {
4497                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
4498                 *ret_conv_14_copy = ret_var.data[o];
4499                 uint32_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
4500                 ret_arr_ptr[o] = ret_conv_14_ref;
4501         }
4502         
4503         FREE(ret_var.data);
4504         return ret_arr;
4505 }
4506
4507 typedef struct LDKBroadcasterInterface_JCalls {
4508         atomic_size_t refcnt;
4509         uint32_t instance_ptr;
4510 } LDKBroadcasterInterface_JCalls;
4511 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
4512         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
4513         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4514                 FREE(j_calls);
4515         }
4516 }
4517 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
4518         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
4519         LDKTransaction tx_var = tx;
4520         int8_tArray tx_arr = init_int8_tArray(tx_var.datalen, __LINE__);
4521         memcpy(tx_arr->elems, tx_var.data, tx_var.datalen);
4522         Transaction_free(tx_var);
4523         js_invoke_function_1(j_calls->instance_ptr, 17, (uint32_t)tx_arr);
4524 }
4525 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
4526         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
4527         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4528 }
4529 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JSValue o) {
4530         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
4531         atomic_init(&calls->refcnt, 1);
4532         calls->instance_ptr = o;
4533
4534         LDKBroadcasterInterface ret = {
4535                 .this_arg = (void*) calls,
4536                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
4537                 .free = LDKBroadcasterInterface_JCalls_free,
4538         };
4539         return ret;
4540 }
4541 long  __attribute__((export_name("TS_LDKBroadcasterInterface_new"))) TS_LDKBroadcasterInterface_new(JSValue o) {
4542         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
4543         *res_ptr = LDKBroadcasterInterface_init(o);
4544         return (long)res_ptr;
4545 }
4546 void  __attribute__((export_name("TS_BroadcasterInterface_broadcast_transaction"))) TS_BroadcasterInterface_broadcast_transaction(uint32_t this_arg, int8_tArray tx) {
4547         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4548         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4549         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
4550         LDKTransaction tx_ref;
4551         tx_ref.datalen = tx->arr_len;
4552         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
4553         memcpy(tx_ref.data, tx->elems, tx_ref.datalen); FREE(tx);
4554         tx_ref.data_is_owned = true;
4555         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
4556 }
4557
4558 typedef struct LDKKeysInterface_JCalls {
4559         atomic_size_t refcnt;
4560         uint32_t instance_ptr;
4561 } LDKKeysInterface_JCalls;
4562 static void LDKKeysInterface_JCalls_free(void* this_arg) {
4563         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4564         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4565                 FREE(j_calls);
4566         }
4567 }
4568 LDKCResult_SecretKeyNoneZ get_node_secret_LDKKeysInterface_jcall(const void* this_arg, LDKRecipient recipient) {
4569         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4570         uint32_t recipient_conv = LDKRecipient_to_js(recipient);
4571         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 18, (uint32_t)recipient_conv);
4572         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4573         CHECK_ACCESS(ret_ptr);
4574         LDKCResult_SecretKeyNoneZ ret_conv = *(LDKCResult_SecretKeyNoneZ*)(ret_ptr);
4575         FREE((void*)ret);
4576         return ret_conv;
4577 }
4578 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
4579         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4580         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 19);
4581         LDKCVec_u8Z ret_ref;
4582         ret_ref.datalen = ret->arr_len;
4583         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
4584         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
4585         return ret_ref;
4586 }
4587 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
4588         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4589         uint32_t ret = js_invoke_function_0(j_calls->instance_ptr, 20);
4590         LDKShutdownScript ret_conv;
4591         ret_conv.inner = (void*)(ret & (~1));
4592         ret_conv.is_owned = (ret & 1) || (ret == 0);
4593         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
4594         return ret_conv;
4595 }
4596 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
4597         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4598         jboolean inbound_conv = inbound;
4599         int64_t channel_value_satoshis_conv = channel_value_satoshis;
4600         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 21, (uint32_t)inbound_conv, (uint32_t)channel_value_satoshis_conv);
4601         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4602         CHECK_ACCESS(ret_ptr);
4603         LDKSign ret_conv = *(LDKSign*)(ret_ptr);
4604         FREE((void*)ret);
4605         return ret_conv;
4606 }
4607 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
4608         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4609         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 22);
4610         LDKThirtyTwoBytes ret_ref;
4611         CHECK(ret->arr_len == 32);
4612         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
4613         return ret_ref;
4614 }
4615 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
4616         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4617         LDKu8slice reader_var = reader;
4618         int8_tArray reader_arr = init_int8_tArray(reader_var.datalen, __LINE__);
4619         memcpy(reader_arr->elems, reader_var.data, reader_var.datalen);
4620         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 23, (uint32_t)reader_arr);
4621         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4622         CHECK_ACCESS(ret_ptr);
4623         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
4624         FREE((void*)ret);
4625         return ret_conv;
4626 }
4627 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice hrp_bytes, LDKCVec_u5Z invoice_data, LDKRecipient receipient) {
4628         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4629         LDKu8slice hrp_bytes_var = hrp_bytes;
4630         int8_tArray hrp_bytes_arr = init_int8_tArray(hrp_bytes_var.datalen, __LINE__);
4631         memcpy(hrp_bytes_arr->elems, hrp_bytes_var.data, hrp_bytes_var.datalen);
4632         LDKCVec_u5Z invoice_data_var = invoice_data;
4633         ptrArray invoice_data_arr = NULL;
4634         invoice_data_arr = init_ptrArray(invoice_data_var.datalen, __LINE__);
4635         int8_t *invoice_data_arr_ptr = (int8_t*)(((uint8_t*)invoice_data_arr) + 4);
4636         for (size_t h = 0; h < invoice_data_var.datalen; h++) {
4637                 uint8_t invoice_data_conv_7_val = invoice_data_var.data[h]._0;
4638                 invoice_data_arr_ptr[h] = invoice_data_conv_7_val;
4639         }
4640         
4641         FREE(invoice_data_var.data);
4642         uint32_t receipient_conv = LDKRecipient_to_js(receipient);
4643         uint32_t ret = js_invoke_function_3(j_calls->instance_ptr, 24, (uint32_t)hrp_bytes_arr, (uint32_t)invoice_data_arr, (uint32_t)receipient_conv);
4644         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4645         CHECK_ACCESS(ret_ptr);
4646         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
4647         FREE((void*)ret);
4648         return ret_conv;
4649 }
4650 LDKThirtyTwoBytes get_inbound_payment_key_material_LDKKeysInterface_jcall(const void* this_arg) {
4651         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4652         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 25);
4653         LDKThirtyTwoBytes ret_ref;
4654         CHECK(ret->arr_len == 32);
4655         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
4656         return ret_ref;
4657 }
4658 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
4659         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
4660         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4661 }
4662 static inline LDKKeysInterface LDKKeysInterface_init (JSValue o) {
4663         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
4664         atomic_init(&calls->refcnt, 1);
4665         calls->instance_ptr = o;
4666
4667         LDKKeysInterface ret = {
4668                 .this_arg = (void*) calls,
4669                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
4670                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
4671                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
4672                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
4673                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
4674                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
4675                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
4676                 .get_inbound_payment_key_material = get_inbound_payment_key_material_LDKKeysInterface_jcall,
4677                 .free = LDKKeysInterface_JCalls_free,
4678         };
4679         return ret;
4680 }
4681 long  __attribute__((export_name("TS_LDKKeysInterface_new"))) TS_LDKKeysInterface_new(JSValue o) {
4682         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
4683         *res_ptr = LDKKeysInterface_init(o);
4684         return (long)res_ptr;
4685 }
4686 uint32_t  __attribute__((export_name("TS_KeysInterface_get_node_secret"))) TS_KeysInterface_get_node_secret(uint32_t this_arg, uint32_t recipient) {
4687         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4688         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4689         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4690         LDKRecipient recipient_conv = LDKRecipient_from_js(recipient);
4691         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
4692         *ret_conv = (this_arg_conv->get_node_secret)(this_arg_conv->this_arg, recipient_conv);
4693         return (uint32_t)ret_conv;
4694 }
4695
4696 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_destination_script"))) TS_KeysInterface_get_destination_script(uint32_t this_arg) {
4697         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4698         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4699         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4700         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
4701         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
4702         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
4703         CVec_u8Z_free(ret_var);
4704         return ret_arr;
4705 }
4706
4707 uint32_t  __attribute__((export_name("TS_KeysInterface_get_shutdown_scriptpubkey"))) TS_KeysInterface_get_shutdown_scriptpubkey(uint32_t this_arg) {
4708         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4709         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4710         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4711         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
4712         uint32_t ret_ref = 0;
4713         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4714         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4715         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4716         ret_ref = (uintptr_t)ret_var.inner;
4717         if (ret_var.is_owned) {
4718                 ret_ref |= 1;
4719         }
4720         return ret_ref;
4721 }
4722
4723 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) {
4724         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4725         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4726         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4727         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
4728         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
4729         return (uint32_t)ret_ret;
4730 }
4731
4732 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_secure_random_bytes"))) TS_KeysInterface_get_secure_random_bytes(uint32_t this_arg) {
4733         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4734         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4735         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4736         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4737         memcpy(ret_arr->elems, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data, 32);
4738         return ret_arr;
4739 }
4740
4741 uint32_t  __attribute__((export_name("TS_KeysInterface_read_chan_signer"))) TS_KeysInterface_read_chan_signer(uint32_t this_arg, int8_tArray reader) {
4742         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4743         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4744         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4745         LDKu8slice reader_ref;
4746         reader_ref.datalen = reader->arr_len;
4747         reader_ref.data = reader->elems /* XXX reader leaks */;
4748         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
4749         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
4750         return (uint32_t)ret_conv;
4751 }
4752
4753 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) {
4754         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4755         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4756         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4757         LDKu8slice hrp_bytes_ref;
4758         hrp_bytes_ref.datalen = hrp_bytes->arr_len;
4759         hrp_bytes_ref.data = hrp_bytes->elems /* XXX hrp_bytes leaks */;
4760         LDKCVec_u5Z invoice_data_constr;
4761         invoice_data_constr.datalen = invoice_data->arr_len;
4762         if (invoice_data_constr.datalen > 0)
4763                 invoice_data_constr.data = MALLOC(invoice_data_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
4764         else
4765                 invoice_data_constr.data = NULL;
4766         int8_t* invoice_data_vals = (void*) invoice_data->elems /* XXX invoice_data leaks */;
4767         for (size_t h = 0; h < invoice_data_constr.datalen; h++) {
4768                 int8_t invoice_data_conv_7 = invoice_data_vals[h];
4769                 
4770                 invoice_data_constr.data[h] = (LDKu5){ ._0 = invoice_data_conv_7 };
4771         }
4772         LDKRecipient receipient_conv = LDKRecipient_from_js(receipient);
4773         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
4774         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, hrp_bytes_ref, invoice_data_constr, receipient_conv);
4775         return (uint32_t)ret_conv;
4776 }
4777
4778 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_inbound_payment_key_material"))) TS_KeysInterface_get_inbound_payment_key_material(uint32_t this_arg) {
4779         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4780         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4781         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4782         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4783         memcpy(ret_arr->elems, (this_arg_conv->get_inbound_payment_key_material)(this_arg_conv->this_arg).data, 32);
4784         return ret_arr;
4785 }
4786
4787 typedef struct LDKFeeEstimator_JCalls {
4788         atomic_size_t refcnt;
4789         uint32_t instance_ptr;
4790 } LDKFeeEstimator_JCalls;
4791 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
4792         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
4793         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4794                 FREE(j_calls);
4795         }
4796 }
4797 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
4798         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
4799         uint32_t confirmation_target_conv = LDKConfirmationTarget_to_js(confirmation_target);
4800         return js_invoke_function_1(j_calls->instance_ptr, 26, (uint32_t)confirmation_target_conv);
4801 }
4802 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
4803         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
4804         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4805 }
4806 static inline LDKFeeEstimator LDKFeeEstimator_init (JSValue o) {
4807         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
4808         atomic_init(&calls->refcnt, 1);
4809         calls->instance_ptr = o;
4810
4811         LDKFeeEstimator ret = {
4812                 .this_arg = (void*) calls,
4813                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
4814                 .free = LDKFeeEstimator_JCalls_free,
4815         };
4816         return ret;
4817 }
4818 long  __attribute__((export_name("TS_LDKFeeEstimator_new"))) TS_LDKFeeEstimator_new(JSValue o) {
4819         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
4820         *res_ptr = LDKFeeEstimator_init(o);
4821         return (long)res_ptr;
4822 }
4823 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) {
4824         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4825         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4826         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
4827         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_js(confirmation_target);
4828         int32_t ret_conv = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
4829         return ret_conv;
4830 }
4831
4832 typedef struct LDKLogger_JCalls {
4833         atomic_size_t refcnt;
4834         uint32_t instance_ptr;
4835 } LDKLogger_JCalls;
4836 static void LDKLogger_JCalls_free(void* this_arg) {
4837         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4838         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4839                 FREE(j_calls);
4840         }
4841 }
4842 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
4843         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4844         LDKRecord record_var = *record;
4845         uint32_t record_ref = 0;
4846         record_var = Record_clone(&record_var);
4847         CHECK((((uintptr_t)record_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4848         CHECK((((uintptr_t)&record_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4849         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
4850         record_ref = (uintptr_t)record_var.inner;
4851         if (record_var.is_owned) {
4852                 record_ref |= 1;
4853         }
4854         js_invoke_function_1(j_calls->instance_ptr, 27, (uint32_t)record_ref);
4855 }
4856 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
4857         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
4858         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4859 }
4860 static inline LDKLogger LDKLogger_init (JSValue o) {
4861         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
4862         atomic_init(&calls->refcnt, 1);
4863         calls->instance_ptr = o;
4864
4865         LDKLogger ret = {
4866                 .this_arg = (void*) calls,
4867                 .log = log_LDKLogger_jcall,
4868                 .free = LDKLogger_JCalls_free,
4869         };
4870         return ret;
4871 }
4872 long  __attribute__((export_name("TS_LDKLogger_new"))) TS_LDKLogger_new(JSValue o) {
4873         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
4874         *res_ptr = LDKLogger_init(o);
4875         return (long)res_ptr;
4876 }
4877 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
4878         return ThirtyTwoBytes_clone(&owner->a);
4879 }
4880 int8_tArray  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_get_a"))) TS_C2Tuple_BlockHashChannelManagerZ_get_a(uint32_t owner) {
4881         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
4882         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4883         memcpy(ret_arr->elems, C2Tuple_BlockHashChannelManagerZ_get_a(owner_conv).data, 32);
4884         return ret_arr;
4885 }
4886
4887 static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
4888         return &owner->b;
4889 }
4890 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_get_b"))) TS_C2Tuple_BlockHashChannelManagerZ_get_b(uint32_t owner) {
4891         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
4892         LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(owner_conv);
4893         uint32_t ret_ref = 0;
4894         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4895         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4896         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4897         ret_ref = (uintptr_t)ret_var.inner & ~1;
4898         return ret_ref;
4899 }
4900
4901 static inline struct LDKC2Tuple_BlockHashChannelManagerZ *CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
4902 CHECK(owner->result_ok);
4903         return &*owner->contents.result;
4904 }
4905 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(uint32_t owner) {
4906         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
4907         uint32_t ret_ret = (uintptr_t)CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(owner_conv) | 1;
4908         return ret_ret;
4909 }
4910
4911 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
4912 CHECK(!owner->result_ok);
4913         return DecodeError_clone(&*owner->contents.err);
4914 }
4915 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(uint32_t owner) {
4916         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
4917         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(owner_conv);
4918         uint32_t ret_ref = 0;
4919         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4920         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4921         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4922         ret_ref = (uintptr_t)ret_var.inner;
4923         if (ret_var.is_owned) {
4924                 ret_ref |= 1;
4925         }
4926         return ret_ref;
4927 }
4928
4929 static inline struct LDKChannelConfig CResult_ChannelConfigDecodeErrorZ_get_ok(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
4930 CHECK(owner->result_ok);
4931         return ChannelConfig_clone(&*owner->contents.result);
4932 }
4933 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_get_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_get_ok(uint32_t owner) {
4934         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
4935         LDKChannelConfig ret_var = CResult_ChannelConfigDecodeErrorZ_get_ok(owner_conv);
4936         uint32_t ret_ref = 0;
4937         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4938         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4939         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4940         ret_ref = (uintptr_t)ret_var.inner;
4941         if (ret_var.is_owned) {
4942                 ret_ref |= 1;
4943         }
4944         return ret_ref;
4945 }
4946
4947 static inline struct LDKDecodeError CResult_ChannelConfigDecodeErrorZ_get_err(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
4948 CHECK(!owner->result_ok);
4949         return DecodeError_clone(&*owner->contents.err);
4950 }
4951 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_get_err"))) TS_CResult_ChannelConfigDecodeErrorZ_get_err(uint32_t owner) {
4952         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
4953         LDKDecodeError ret_var = CResult_ChannelConfigDecodeErrorZ_get_err(owner_conv);
4954         uint32_t ret_ref = 0;
4955         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4956         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4957         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4958         ret_ref = (uintptr_t)ret_var.inner;
4959         if (ret_var.is_owned) {
4960                 ret_ref |= 1;
4961         }
4962         return ret_ref;
4963 }
4964
4965 static inline struct LDKOutPoint CResult_OutPointDecodeErrorZ_get_ok(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
4966 CHECK(owner->result_ok);
4967         return OutPoint_clone(&*owner->contents.result);
4968 }
4969 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_get_ok"))) TS_CResult_OutPointDecodeErrorZ_get_ok(uint32_t owner) {
4970         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
4971         LDKOutPoint ret_var = CResult_OutPointDecodeErrorZ_get_ok(owner_conv);
4972         uint32_t ret_ref = 0;
4973         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4974         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4975         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4976         ret_ref = (uintptr_t)ret_var.inner;
4977         if (ret_var.is_owned) {
4978                 ret_ref |= 1;
4979         }
4980         return ret_ref;
4981 }
4982
4983 static inline struct LDKDecodeError CResult_OutPointDecodeErrorZ_get_err(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
4984 CHECK(!owner->result_ok);
4985         return DecodeError_clone(&*owner->contents.err);
4986 }
4987 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_get_err"))) TS_CResult_OutPointDecodeErrorZ_get_err(uint32_t owner) {
4988         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
4989         LDKDecodeError ret_var = CResult_OutPointDecodeErrorZ_get_err(owner_conv);
4990         uint32_t ret_ref = 0;
4991         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4992         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4993         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4994         ret_ref = (uintptr_t)ret_var.inner;
4995         if (ret_var.is_owned) {
4996                 ret_ref |= 1;
4997         }
4998         return ret_ref;
4999 }
5000
5001 typedef struct LDKType_JCalls {
5002         atomic_size_t refcnt;
5003         uint32_t instance_ptr;
5004 } LDKType_JCalls;
5005 static void LDKType_JCalls_free(void* this_arg) {
5006         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5007         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5008                 FREE(j_calls);
5009         }
5010 }
5011 uint16_t type_id_LDKType_jcall(const void* this_arg) {
5012         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5013         return js_invoke_function_0(j_calls->instance_ptr, 28);
5014 }
5015 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
5016         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5017         jstring ret = (jstring)js_invoke_function_0(j_calls->instance_ptr, 29);
5018         LDKStr ret_conv = str_ref_to_owned_c(ret);
5019         return ret_conv;
5020 }
5021 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
5022         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5023         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 30);
5024         LDKCVec_u8Z ret_ref;
5025         ret_ref.datalen = ret->arr_len;
5026         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
5027         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
5028         return ret_ref;
5029 }
5030 static void LDKType_JCalls_cloned(LDKType* new_obj) {
5031         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
5032         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5033 }
5034 static inline LDKType LDKType_init (JSValue o) {
5035         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
5036         atomic_init(&calls->refcnt, 1);
5037         calls->instance_ptr = o;
5038
5039         LDKType ret = {
5040                 .this_arg = (void*) calls,
5041                 .type_id = type_id_LDKType_jcall,
5042                 .debug_str = debug_str_LDKType_jcall,
5043                 .write = write_LDKType_jcall,
5044                 .cloned = LDKType_JCalls_cloned,
5045                 .free = LDKType_JCalls_free,
5046         };
5047         return ret;
5048 }
5049 long  __attribute__((export_name("TS_LDKType_new"))) TS_LDKType_new(JSValue o) {
5050         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
5051         *res_ptr = LDKType_init(o);
5052         return (long)res_ptr;
5053 }
5054 int16_t  __attribute__((export_name("TS_Type_type_id"))) TS_Type_type_id(uint32_t this_arg) {
5055         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5056         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5057         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5058         int16_t ret_conv = (this_arg_conv->type_id)(this_arg_conv->this_arg);
5059         return ret_conv;
5060 }
5061
5062 jstring  __attribute__((export_name("TS_Type_debug_str"))) TS_Type_debug_str(uint32_t this_arg) {
5063         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5064         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5065         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5066         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
5067         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
5068         Str_free(ret_str);
5069         return ret_conv;
5070 }
5071
5072 int8_tArray  __attribute__((export_name("TS_Type_write"))) TS_Type_write(uint32_t this_arg) {
5073         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5074         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5075         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5076         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
5077         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
5078         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
5079         CVec_u8Z_free(ret_var);
5080         return ret_arr;
5081 }
5082
5083 uint32_t __attribute__((export_name("TS_LDKCOption_TypeZ_ty_from_ptr"))) TS_LDKCOption_TypeZ_ty_from_ptr(uint32_t ptr) {
5084         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
5085         switch(obj->tag) {
5086                 case LDKCOption_TypeZ_Some: return 0;
5087                 case LDKCOption_TypeZ_None: return 1;
5088                 default: abort();
5089         }
5090 }
5091 uint32_t __attribute__((export_name("TS_LDKCOption_TypeZ_Some_get_some"))) TS_LDKCOption_TypeZ_Some_get_some(uint32_t ptr) {
5092         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
5093         assert(obj->tag == LDKCOption_TypeZ_Some);
5094                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
5095                         *some_ret = Type_clone(&obj->some);
5096         return (uint32_t)some_ret;
5097 }
5098 static inline struct LDKCOption_TypeZ CResult_COption_TypeZDecodeErrorZ_get_ok(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
5099 CHECK(owner->result_ok);
5100         return COption_TypeZ_clone(&*owner->contents.result);
5101 }
5102 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_get_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_get_ok(uint32_t owner) {
5103         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
5104         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
5105         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_ok(owner_conv);
5106         uint32_t ret_ref = (uintptr_t)ret_copy;
5107         return ret_ref;
5108 }
5109
5110 static inline struct LDKDecodeError CResult_COption_TypeZDecodeErrorZ_get_err(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
5111 CHECK(!owner->result_ok);
5112         return DecodeError_clone(&*owner->contents.err);
5113 }
5114 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_get_err"))) TS_CResult_COption_TypeZDecodeErrorZ_get_err(uint32_t owner) {
5115         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
5116         LDKDecodeError ret_var = CResult_COption_TypeZDecodeErrorZ_get_err(owner_conv);
5117         uint32_t ret_ref = 0;
5118         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5119         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5120         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5121         ret_ref = (uintptr_t)ret_var.inner;
5122         if (ret_var.is_owned) {
5123                 ret_ref |= 1;
5124         }
5125         return ret_ref;
5126 }
5127
5128 uint32_t __attribute__((export_name("TS_LDKPaymentError_ty_from_ptr"))) TS_LDKPaymentError_ty_from_ptr(uint32_t ptr) {
5129         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
5130         switch(obj->tag) {
5131                 case LDKPaymentError_Invoice: return 0;
5132                 case LDKPaymentError_Routing: return 1;
5133                 case LDKPaymentError_Sending: return 2;
5134                 default: abort();
5135         }
5136 }
5137 jstring __attribute__((export_name("TS_LDKPaymentError_Invoice_get_invoice"))) TS_LDKPaymentError_Invoice_get_invoice(uint32_t ptr) {
5138         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
5139         assert(obj->tag == LDKPaymentError_Invoice);
5140                         LDKStr invoice_str = obj->invoice;
5141                         jstring invoice_conv = str_ref_to_ts(invoice_str.chars, invoice_str.len);
5142         return invoice_conv;
5143 }
5144 uint32_t __attribute__((export_name("TS_LDKPaymentError_Routing_get_routing"))) TS_LDKPaymentError_Routing_get_routing(uint32_t ptr) {
5145         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
5146         assert(obj->tag == LDKPaymentError_Routing);
5147                         LDKLightningError routing_var = obj->routing;
5148                         uint32_t routing_ref = 0;
5149                         CHECK((((uintptr_t)routing_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5150                         CHECK((((uintptr_t)&routing_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5151                         CHECK_INNER_FIELD_ACCESS_OR_NULL(routing_var);
5152                         routing_ref = (uintptr_t)routing_var.inner & ~1;
5153         return routing_ref;
5154 }
5155 uint32_t __attribute__((export_name("TS_LDKPaymentError_Sending_get_sending"))) TS_LDKPaymentError_Sending_get_sending(uint32_t ptr) {
5156         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
5157         assert(obj->tag == LDKPaymentError_Sending);
5158                         uint32_t sending_ref = ((uintptr_t)&obj->sending) | 1;
5159         return sending_ref;
5160 }
5161 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentErrorZ_get_ok(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
5162 CHECK(owner->result_ok);
5163         return ThirtyTwoBytes_clone(&*owner->contents.result);
5164 }
5165 int8_tArray  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_get_ok"))) TS_CResult_PaymentIdPaymentErrorZ_get_ok(uint32_t owner) {
5166         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
5167         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5168         memcpy(ret_arr->elems, CResult_PaymentIdPaymentErrorZ_get_ok(owner_conv).data, 32);
5169         return ret_arr;
5170 }
5171
5172 static inline struct LDKPaymentError CResult_PaymentIdPaymentErrorZ_get_err(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
5173 CHECK(!owner->result_ok);
5174         return PaymentError_clone(&*owner->contents.err);
5175 }
5176 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_get_err"))) TS_CResult_PaymentIdPaymentErrorZ_get_err(uint32_t owner) {
5177         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
5178         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
5179         *ret_copy = CResult_PaymentIdPaymentErrorZ_get_err(owner_conv);
5180         uint32_t ret_ref = (uintptr_t)ret_copy;
5181         return ret_ref;
5182 }
5183
5184 uint32_t __attribute__((export_name("TS_LDKParseError_ty_from_ptr"))) TS_LDKParseError_ty_from_ptr(uint32_t ptr) {
5185         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
5186         switch(obj->tag) {
5187                 case LDKParseError_Bech32Error: return 0;
5188                 case LDKParseError_ParseAmountError: return 1;
5189                 case LDKParseError_MalformedSignature: return 2;
5190                 case LDKParseError_BadPrefix: return 3;
5191                 case LDKParseError_UnknownCurrency: return 4;
5192                 case LDKParseError_UnknownSiPrefix: return 5;
5193                 case LDKParseError_MalformedHRP: return 6;
5194                 case LDKParseError_TooShortDataPart: return 7;
5195                 case LDKParseError_UnexpectedEndOfTaggedFields: return 8;
5196                 case LDKParseError_DescriptionDecodeError: return 9;
5197                 case LDKParseError_PaddingError: return 10;
5198                 case LDKParseError_IntegerOverflowError: return 11;
5199                 case LDKParseError_InvalidSegWitProgramLength: return 12;
5200                 case LDKParseError_InvalidPubKeyHashLength: return 13;
5201                 case LDKParseError_InvalidScriptHashLength: return 14;
5202                 case LDKParseError_InvalidRecoveryId: return 15;
5203                 case LDKParseError_InvalidSliceLength: return 16;
5204                 case LDKParseError_Skip: return 17;
5205                 default: abort();
5206         }
5207 }
5208 uint32_t __attribute__((export_name("TS_LDKParseError_Bech32Error_get_bech32_error"))) TS_LDKParseError_Bech32Error_get_bech32_error(uint32_t ptr) {
5209         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
5210         assert(obj->tag == LDKParseError_Bech32Error);
5211                         uint32_t bech32_error_ref = ((uintptr_t)&obj->bech32_error) | 1;
5212         return bech32_error_ref;
5213 }
5214 int32_t __attribute__((export_name("TS_LDKParseError_ParseAmountError_get_parse_amount_error"))) TS_LDKParseError_ParseAmountError_get_parse_amount_error(uint32_t ptr) {
5215         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
5216         assert(obj->tag == LDKParseError_ParseAmountError);
5217                         /*obj->parse_amount_error*/
5218         return 0;
5219 }
5220 uint32_t __attribute__((export_name("TS_LDKParseError_MalformedSignature_get_malformed_signature"))) TS_LDKParseError_MalformedSignature_get_malformed_signature(uint32_t ptr) {
5221         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
5222         assert(obj->tag == LDKParseError_MalformedSignature);
5223                         uint32_t malformed_signature_conv = LDKSecp256k1Error_to_js(obj->malformed_signature);
5224         return malformed_signature_conv;
5225 }
5226 int32_t __attribute__((export_name("TS_LDKParseError_DescriptionDecodeError_get_description_decode_error"))) TS_LDKParseError_DescriptionDecodeError_get_description_decode_error(uint32_t ptr) {
5227         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
5228         assert(obj->tag == LDKParseError_DescriptionDecodeError);
5229                         /*obj->description_decode_error*/
5230         return 0;
5231 }
5232 jstring __attribute__((export_name("TS_LDKParseError_InvalidSliceLength_get_invalid_slice_length"))) TS_LDKParseError_InvalidSliceLength_get_invalid_slice_length(uint32_t ptr) {
5233         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
5234         assert(obj->tag == LDKParseError_InvalidSliceLength);
5235                         LDKStr invalid_slice_length_str = obj->invalid_slice_length;
5236                         jstring invalid_slice_length_conv = str_ref_to_ts(invalid_slice_length_str.chars, invalid_slice_length_str.len);
5237         return invalid_slice_length_conv;
5238 }
5239 static inline enum LDKSiPrefix CResult_SiPrefixParseErrorZ_get_ok(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
5240 CHECK(owner->result_ok);
5241         return SiPrefix_clone(&*owner->contents.result);
5242 }
5243 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_get_ok"))) TS_CResult_SiPrefixParseErrorZ_get_ok(uint32_t owner) {
5244         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)(owner & ~1);
5245         uint32_t ret_conv = LDKSiPrefix_to_js(CResult_SiPrefixParseErrorZ_get_ok(owner_conv));
5246         return ret_conv;
5247 }
5248
5249 static inline struct LDKParseError CResult_SiPrefixParseErrorZ_get_err(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
5250 CHECK(!owner->result_ok);
5251         return ParseError_clone(&*owner->contents.err);
5252 }
5253 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_get_err"))) TS_CResult_SiPrefixParseErrorZ_get_err(uint32_t owner) {
5254         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)(owner & ~1);
5255         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
5256         *ret_copy = CResult_SiPrefixParseErrorZ_get_err(owner_conv);
5257         uint32_t ret_ref = (uintptr_t)ret_copy;
5258         return ret_ref;
5259 }
5260
5261 uint32_t __attribute__((export_name("TS_LDKParseOrSemanticError_ty_from_ptr"))) TS_LDKParseOrSemanticError_ty_from_ptr(uint32_t ptr) {
5262         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)(ptr & ~1);
5263         switch(obj->tag) {
5264                 case LDKParseOrSemanticError_ParseError: return 0;
5265                 case LDKParseOrSemanticError_SemanticError: return 1;
5266                 default: abort();
5267         }
5268 }
5269 uint32_t __attribute__((export_name("TS_LDKParseOrSemanticError_ParseError_get_parse_error"))) TS_LDKParseOrSemanticError_ParseError_get_parse_error(uint32_t ptr) {
5270         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)(ptr & ~1);
5271         assert(obj->tag == LDKParseOrSemanticError_ParseError);
5272                         uint32_t parse_error_ref = ((uintptr_t)&obj->parse_error) | 1;
5273         return parse_error_ref;
5274 }
5275 uint32_t __attribute__((export_name("TS_LDKParseOrSemanticError_SemanticError_get_semantic_error"))) TS_LDKParseOrSemanticError_SemanticError_get_semantic_error(uint32_t ptr) {
5276         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)(ptr & ~1);
5277         assert(obj->tag == LDKParseOrSemanticError_SemanticError);
5278                         uint32_t semantic_error_conv = LDKSemanticError_to_js(obj->semantic_error);
5279         return semantic_error_conv;
5280 }
5281 static inline struct LDKInvoice CResult_InvoiceParseOrSemanticErrorZ_get_ok(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
5282 CHECK(owner->result_ok);
5283         return Invoice_clone(&*owner->contents.result);
5284 }
5285 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_get_ok"))) TS_CResult_InvoiceParseOrSemanticErrorZ_get_ok(uint32_t owner) {
5286         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(owner & ~1);
5287         LDKInvoice ret_var = CResult_InvoiceParseOrSemanticErrorZ_get_ok(owner_conv);
5288         uint32_t ret_ref = 0;
5289         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5290         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5291         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5292         ret_ref = (uintptr_t)ret_var.inner;
5293         if (ret_var.is_owned) {
5294                 ret_ref |= 1;
5295         }
5296         return ret_ref;
5297 }
5298
5299 static inline struct LDKParseOrSemanticError CResult_InvoiceParseOrSemanticErrorZ_get_err(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
5300 CHECK(!owner->result_ok);
5301         return ParseOrSemanticError_clone(&*owner->contents.err);
5302 }
5303 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_get_err"))) TS_CResult_InvoiceParseOrSemanticErrorZ_get_err(uint32_t owner) {
5304         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(owner & ~1);
5305         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
5306         *ret_copy = CResult_InvoiceParseOrSemanticErrorZ_get_err(owner_conv);
5307         uint32_t ret_ref = (uintptr_t)ret_copy;
5308         return ret_ref;
5309 }
5310
5311 static inline struct LDKSignedRawInvoice CResult_SignedRawInvoiceParseErrorZ_get_ok(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
5312 CHECK(owner->result_ok);
5313         return SignedRawInvoice_clone(&*owner->contents.result);
5314 }
5315 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_get_ok"))) TS_CResult_SignedRawInvoiceParseErrorZ_get_ok(uint32_t owner) {
5316         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(owner & ~1);
5317         LDKSignedRawInvoice ret_var = CResult_SignedRawInvoiceParseErrorZ_get_ok(owner_conv);
5318         uint32_t ret_ref = 0;
5319         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5320         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5321         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5322         ret_ref = (uintptr_t)ret_var.inner;
5323         if (ret_var.is_owned) {
5324                 ret_ref |= 1;
5325         }
5326         return ret_ref;
5327 }
5328
5329 static inline struct LDKParseError CResult_SignedRawInvoiceParseErrorZ_get_err(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
5330 CHECK(!owner->result_ok);
5331         return ParseError_clone(&*owner->contents.err);
5332 }
5333 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_get_err"))) TS_CResult_SignedRawInvoiceParseErrorZ_get_err(uint32_t owner) {
5334         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(owner & ~1);
5335         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
5336         *ret_copy = CResult_SignedRawInvoiceParseErrorZ_get_err(owner_conv);
5337         uint32_t ret_ref = (uintptr_t)ret_copy;
5338         return ret_ref;
5339 }
5340
5341 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
5342         return RawInvoice_clone(&owner->a);
5343 }
5344 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(uint32_t owner) {
5345         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
5346         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(owner_conv);
5347         uint32_t ret_ref = 0;
5348         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5349         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5350         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5351         ret_ref = (uintptr_t)ret_var.inner;
5352         if (ret_var.is_owned) {
5353                 ret_ref |= 1;
5354         }
5355         return ret_ref;
5356 }
5357
5358 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
5359         return ThirtyTwoBytes_clone(&owner->b);
5360 }
5361 int8_tArray  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(uint32_t owner) {
5362         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
5363         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5364         memcpy(ret_arr->elems, C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(owner_conv).data, 32);
5365         return ret_arr;
5366 }
5367
5368 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
5369         return InvoiceSignature_clone(&owner->c);
5370 }
5371 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(uint32_t owner) {
5372         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
5373         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(owner_conv);
5374         uint32_t ret_ref = 0;
5375         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5376         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5377         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5378         ret_ref = (uintptr_t)ret_var.inner;
5379         if (ret_var.is_owned) {
5380                 ret_ref |= 1;
5381         }
5382         return ret_ref;
5383 }
5384
5385 static inline struct LDKPayeePubKey CResult_PayeePubKeyErrorZ_get_ok(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
5386 CHECK(owner->result_ok);
5387         return PayeePubKey_clone(&*owner->contents.result);
5388 }
5389 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_get_ok"))) TS_CResult_PayeePubKeyErrorZ_get_ok(uint32_t owner) {
5390         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
5391         LDKPayeePubKey ret_var = CResult_PayeePubKeyErrorZ_get_ok(owner_conv);
5392         uint32_t ret_ref = 0;
5393         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5394         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5395         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5396         ret_ref = (uintptr_t)ret_var.inner;
5397         if (ret_var.is_owned) {
5398                 ret_ref |= 1;
5399         }
5400         return ret_ref;
5401 }
5402
5403 static inline enum LDKSecp256k1Error CResult_PayeePubKeyErrorZ_get_err(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
5404 CHECK(!owner->result_ok);
5405         return *owner->contents.err;
5406 }
5407 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_get_err"))) TS_CResult_PayeePubKeyErrorZ_get_err(uint32_t owner) {
5408         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
5409         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_PayeePubKeyErrorZ_get_err(owner_conv));
5410         return ret_conv;
5411 }
5412
5413 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
5414         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
5415         for (size_t i = 0; i < ret.datalen; i++) {
5416                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
5417         }
5418         return ret;
5419 }
5420 static inline struct LDKPositiveTimestamp CResult_PositiveTimestampCreationErrorZ_get_ok(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
5421 CHECK(owner->result_ok);
5422         return PositiveTimestamp_clone(&*owner->contents.result);
5423 }
5424 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_get_ok"))) TS_CResult_PositiveTimestampCreationErrorZ_get_ok(uint32_t owner) {
5425         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
5426         LDKPositiveTimestamp ret_var = CResult_PositiveTimestampCreationErrorZ_get_ok(owner_conv);
5427         uint32_t ret_ref = 0;
5428         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5429         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5430         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5431         ret_ref = (uintptr_t)ret_var.inner;
5432         if (ret_var.is_owned) {
5433                 ret_ref |= 1;
5434         }
5435         return ret_ref;
5436 }
5437
5438 static inline enum LDKCreationError CResult_PositiveTimestampCreationErrorZ_get_err(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
5439 CHECK(!owner->result_ok);
5440         return CreationError_clone(&*owner->contents.err);
5441 }
5442 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_get_err"))) TS_CResult_PositiveTimestampCreationErrorZ_get_err(uint32_t owner) {
5443         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
5444         uint32_t ret_conv = LDKCreationError_to_js(CResult_PositiveTimestampCreationErrorZ_get_err(owner_conv));
5445         return ret_conv;
5446 }
5447
5448 static inline void CResult_NoneSemanticErrorZ_get_ok(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
5449 CHECK(owner->result_ok);
5450         return *owner->contents.result;
5451 }
5452 void  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_get_ok"))) TS_CResult_NoneSemanticErrorZ_get_ok(uint32_t owner) {
5453         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
5454         CResult_NoneSemanticErrorZ_get_ok(owner_conv);
5455 }
5456
5457 static inline enum LDKSemanticError CResult_NoneSemanticErrorZ_get_err(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
5458 CHECK(!owner->result_ok);
5459         return SemanticError_clone(&*owner->contents.err);
5460 }
5461 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_get_err"))) TS_CResult_NoneSemanticErrorZ_get_err(uint32_t owner) {
5462         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
5463         uint32_t ret_conv = LDKSemanticError_to_js(CResult_NoneSemanticErrorZ_get_err(owner_conv));
5464         return ret_conv;
5465 }
5466
5467 static inline struct LDKInvoice CResult_InvoiceSemanticErrorZ_get_ok(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
5468 CHECK(owner->result_ok);
5469         return Invoice_clone(&*owner->contents.result);
5470 }
5471 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_get_ok"))) TS_CResult_InvoiceSemanticErrorZ_get_ok(uint32_t owner) {
5472         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
5473         LDKInvoice ret_var = CResult_InvoiceSemanticErrorZ_get_ok(owner_conv);
5474         uint32_t ret_ref = 0;
5475         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5476         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5477         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5478         ret_ref = (uintptr_t)ret_var.inner;
5479         if (ret_var.is_owned) {
5480                 ret_ref |= 1;
5481         }
5482         return ret_ref;
5483 }
5484
5485 static inline enum LDKSemanticError CResult_InvoiceSemanticErrorZ_get_err(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
5486 CHECK(!owner->result_ok);
5487         return SemanticError_clone(&*owner->contents.err);
5488 }
5489 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_get_err"))) TS_CResult_InvoiceSemanticErrorZ_get_err(uint32_t owner) {
5490         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
5491         uint32_t ret_conv = LDKSemanticError_to_js(CResult_InvoiceSemanticErrorZ_get_err(owner_conv));
5492         return ret_conv;
5493 }
5494
5495 static inline struct LDKDescription CResult_DescriptionCreationErrorZ_get_ok(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
5496 CHECK(owner->result_ok);
5497         return Description_clone(&*owner->contents.result);
5498 }
5499 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_get_ok"))) TS_CResult_DescriptionCreationErrorZ_get_ok(uint32_t owner) {
5500         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
5501         LDKDescription ret_var = CResult_DescriptionCreationErrorZ_get_ok(owner_conv);
5502         uint32_t ret_ref = 0;
5503         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5504         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5505         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5506         ret_ref = (uintptr_t)ret_var.inner;
5507         if (ret_var.is_owned) {
5508                 ret_ref |= 1;
5509         }
5510         return ret_ref;
5511 }
5512
5513 static inline enum LDKCreationError CResult_DescriptionCreationErrorZ_get_err(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
5514 CHECK(!owner->result_ok);
5515         return CreationError_clone(&*owner->contents.err);
5516 }
5517 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_get_err"))) TS_CResult_DescriptionCreationErrorZ_get_err(uint32_t owner) {
5518         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
5519         uint32_t ret_conv = LDKCreationError_to_js(CResult_DescriptionCreationErrorZ_get_err(owner_conv));
5520         return ret_conv;
5521 }
5522
5523 static inline struct LDKPrivateRoute CResult_PrivateRouteCreationErrorZ_get_ok(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
5524 CHECK(owner->result_ok);
5525         return PrivateRoute_clone(&*owner->contents.result);
5526 }
5527 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_get_ok"))) TS_CResult_PrivateRouteCreationErrorZ_get_ok(uint32_t owner) {
5528         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
5529         LDKPrivateRoute ret_var = CResult_PrivateRouteCreationErrorZ_get_ok(owner_conv);
5530         uint32_t ret_ref = 0;
5531         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5532         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5533         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5534         ret_ref = (uintptr_t)ret_var.inner;
5535         if (ret_var.is_owned) {
5536                 ret_ref |= 1;
5537         }
5538         return ret_ref;
5539 }
5540
5541 static inline enum LDKCreationError CResult_PrivateRouteCreationErrorZ_get_err(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
5542 CHECK(!owner->result_ok);
5543         return CreationError_clone(&*owner->contents.err);
5544 }
5545 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_get_err"))) TS_CResult_PrivateRouteCreationErrorZ_get_err(uint32_t owner) {
5546         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
5547         uint32_t ret_conv = LDKCreationError_to_js(CResult_PrivateRouteCreationErrorZ_get_err(owner_conv));
5548         return ret_conv;
5549 }
5550
5551 static inline struct LDKStr CResult_StringErrorZ_get_ok(LDKCResult_StringErrorZ *NONNULL_PTR owner){
5552 CHECK(owner->result_ok);
5553         return *owner->contents.result;
5554 }
5555 jstring  __attribute__((export_name("TS_CResult_StringErrorZ_get_ok"))) TS_CResult_StringErrorZ_get_ok(uint32_t owner) {
5556         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
5557         LDKStr ret_str = CResult_StringErrorZ_get_ok(owner_conv);
5558         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
5559         return ret_conv;
5560 }
5561
5562 static inline enum LDKSecp256k1Error CResult_StringErrorZ_get_err(LDKCResult_StringErrorZ *NONNULL_PTR owner){
5563 CHECK(!owner->result_ok);
5564         return *owner->contents.err;
5565 }
5566 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_get_err"))) TS_CResult_StringErrorZ_get_err(uint32_t owner) {
5567         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
5568         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_StringErrorZ_get_err(owner_conv));
5569         return ret_conv;
5570 }
5571
5572 static inline struct LDKChannelMonitorUpdate CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
5573 CHECK(owner->result_ok);
5574         return ChannelMonitorUpdate_clone(&*owner->contents.result);
5575 }
5576 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(uint32_t owner) {
5577         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
5578         LDKChannelMonitorUpdate ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(owner_conv);
5579         uint32_t ret_ref = 0;
5580         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5581         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5582         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5583         ret_ref = (uintptr_t)ret_var.inner;
5584         if (ret_var.is_owned) {
5585                 ret_ref |= 1;
5586         }
5587         return ret_ref;
5588 }
5589
5590 static inline struct LDKDecodeError CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
5591 CHECK(!owner->result_ok);
5592         return DecodeError_clone(&*owner->contents.err);
5593 }
5594 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_err"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(uint32_t owner) {
5595         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
5596         LDKDecodeError ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(owner_conv);
5597         uint32_t ret_ref = 0;
5598         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5599         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5600         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5601         ret_ref = (uintptr_t)ret_var.inner;
5602         if (ret_var.is_owned) {
5603                 ret_ref |= 1;
5604         }
5605         return ret_ref;
5606 }
5607
5608 uint32_t __attribute__((export_name("TS_LDKCOption_MonitorEventZ_ty_from_ptr"))) TS_LDKCOption_MonitorEventZ_ty_from_ptr(uint32_t ptr) {
5609         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
5610         switch(obj->tag) {
5611                 case LDKCOption_MonitorEventZ_Some: return 0;
5612                 case LDKCOption_MonitorEventZ_None: return 1;
5613                 default: abort();
5614         }
5615 }
5616 uint32_t __attribute__((export_name("TS_LDKCOption_MonitorEventZ_Some_get_some"))) TS_LDKCOption_MonitorEventZ_Some_get_some(uint32_t ptr) {
5617         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
5618         assert(obj->tag == LDKCOption_MonitorEventZ_Some);
5619                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
5620         return some_ref;
5621 }
5622 static inline struct LDKCOption_MonitorEventZ CResult_COption_MonitorEventZDecodeErrorZ_get_ok(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
5623 CHECK(owner->result_ok);
5624         return COption_MonitorEventZ_clone(&*owner->contents.result);
5625 }
5626 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_get_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_get_ok(uint32_t owner) {
5627         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
5628         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
5629         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_ok(owner_conv);
5630         uint32_t ret_ref = (uintptr_t)ret_copy;
5631         return ret_ref;
5632 }
5633
5634 static inline struct LDKDecodeError CResult_COption_MonitorEventZDecodeErrorZ_get_err(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
5635 CHECK(!owner->result_ok);
5636         return DecodeError_clone(&*owner->contents.err);
5637 }
5638 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_get_err"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_get_err(uint32_t owner) {
5639         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
5640         LDKDecodeError ret_var = CResult_COption_MonitorEventZDecodeErrorZ_get_err(owner_conv);
5641         uint32_t ret_ref = 0;
5642         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5643         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5644         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5645         ret_ref = (uintptr_t)ret_var.inner;
5646         if (ret_var.is_owned) {
5647                 ret_ref |= 1;
5648         }
5649         return ret_ref;
5650 }
5651
5652 static inline struct LDKHTLCUpdate CResult_HTLCUpdateDecodeErrorZ_get_ok(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
5653 CHECK(owner->result_ok);
5654         return HTLCUpdate_clone(&*owner->contents.result);
5655 }
5656 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_get_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_get_ok(uint32_t owner) {
5657         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
5658         LDKHTLCUpdate ret_var = CResult_HTLCUpdateDecodeErrorZ_get_ok(owner_conv);
5659         uint32_t ret_ref = 0;
5660         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5661         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5662         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5663         ret_ref = (uintptr_t)ret_var.inner;
5664         if (ret_var.is_owned) {
5665                 ret_ref |= 1;
5666         }
5667         return ret_ref;
5668 }
5669
5670 static inline struct LDKDecodeError CResult_HTLCUpdateDecodeErrorZ_get_err(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
5671 CHECK(!owner->result_ok);
5672         return DecodeError_clone(&*owner->contents.err);
5673 }
5674 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_get_err"))) TS_CResult_HTLCUpdateDecodeErrorZ_get_err(uint32_t owner) {
5675         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
5676         LDKDecodeError ret_var = CResult_HTLCUpdateDecodeErrorZ_get_err(owner_conv);
5677         uint32_t ret_ref = 0;
5678         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5679         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5680         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5681         ret_ref = (uintptr_t)ret_var.inner;
5682         if (ret_var.is_owned) {
5683                 ret_ref |= 1;
5684         }
5685         return ret_ref;
5686 }
5687
5688 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
5689         return OutPoint_clone(&owner->a);
5690 }
5691 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_get_a"))) TS_C2Tuple_OutPointScriptZ_get_a(uint32_t owner) {
5692         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
5693         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(owner_conv);
5694         uint32_t ret_ref = 0;
5695         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5696         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5697         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5698         ret_ref = (uintptr_t)ret_var.inner;
5699         if (ret_var.is_owned) {
5700                 ret_ref |= 1;
5701         }
5702         return ret_ref;
5703 }
5704
5705 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
5706         return CVec_u8Z_clone(&owner->b);
5707 }
5708 int8_tArray  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_get_b"))) TS_C2Tuple_OutPointScriptZ_get_b(uint32_t owner) {
5709         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
5710         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(owner_conv);
5711         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
5712         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
5713         CVec_u8Z_free(ret_var);
5714         return ret_arr;
5715 }
5716
5717 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
5718         return owner->a;
5719 }
5720 int32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_get_a"))) TS_C2Tuple_u32ScriptZ_get_a(uint32_t owner) {
5721         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
5722         int32_t ret_conv = C2Tuple_u32ScriptZ_get_a(owner_conv);
5723         return ret_conv;
5724 }
5725
5726 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
5727         return CVec_u8Z_clone(&owner->b);
5728 }
5729 int8_tArray  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_get_b"))) TS_C2Tuple_u32ScriptZ_get_b(uint32_t owner) {
5730         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
5731         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(owner_conv);
5732         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
5733         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
5734         CVec_u8Z_free(ret_var);
5735         return ret_arr;
5736 }
5737
5738 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
5739         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
5740         for (size_t i = 0; i < ret.datalen; i++) {
5741                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
5742         }
5743         return ret;
5744 }
5745 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
5746         return ThirtyTwoBytes_clone(&owner->a);
5747 }
5748 int8_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(uint32_t owner) {
5749         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
5750         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5751         memcpy(ret_arr->elems, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(owner_conv).data, 32);
5752         return ret_arr;
5753 }
5754
5755 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
5756         return CVec_C2Tuple_u32ScriptZZ_clone(&owner->b);
5757 }
5758 uint32_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(uint32_t owner) {
5759         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
5760         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(owner_conv);
5761         uint32_tArray ret_arr = NULL;
5762         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
5763         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
5764         for (size_t v = 0; v < ret_var.datalen; v++) {
5765                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
5766                 *ret_conv_21_conv = ret_var.data[v];
5767                 ret_arr_ptr[v] = ((uint32_t)ret_conv_21_conv);
5768         }
5769         
5770         FREE(ret_var.data);
5771         return ret_arr;
5772 }
5773
5774 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
5775         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 };
5776         for (size_t i = 0; i < ret.datalen; i++) {
5777                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
5778         }
5779         return ret;
5780 }
5781 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
5782         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
5783         for (size_t i = 0; i < ret.datalen; i++) {
5784                 ret.data[i] = Event_clone(&orig->data[i]);
5785         }
5786         return ret;
5787 }
5788 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
5789         return owner->a;
5790 }
5791 int32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_get_a"))) TS_C2Tuple_u32TxOutZ_get_a(uint32_t owner) {
5792         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
5793         int32_t ret_conv = C2Tuple_u32TxOutZ_get_a(owner_conv);
5794         return ret_conv;
5795 }
5796
5797 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
5798         return TxOut_clone(&owner->b);
5799 }
5800 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_get_b"))) TS_C2Tuple_u32TxOutZ_get_b(uint32_t owner) {
5801         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
5802         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
5803         *ret_ref = C2Tuple_u32TxOutZ_get_b(owner_conv);
5804         return (uint32_t)ret_ref;
5805 }
5806
5807 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
5808         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
5809         for (size_t i = 0; i < ret.datalen; i++) {
5810                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
5811         }
5812         return ret;
5813 }
5814 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
5815         return ThirtyTwoBytes_clone(&owner->a);
5816 }
5817 int8_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(uint32_t owner) {
5818         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
5819         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5820         memcpy(ret_arr->elems, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(owner_conv).data, 32);
5821         return ret_arr;
5822 }
5823
5824 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
5825         return CVec_C2Tuple_u32TxOutZZ_clone(&owner->b);
5826 }
5827 uint32_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(uint32_t owner) {
5828         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
5829         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(owner_conv);
5830         uint32_tArray ret_arr = NULL;
5831         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
5832         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
5833         for (size_t u = 0; u < ret_var.datalen; u++) {
5834                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
5835                 *ret_conv_20_conv = ret_var.data[u];
5836                 ret_arr_ptr[u] = ((uint32_t)ret_conv_20_conv);
5837         }
5838         
5839         FREE(ret_var.data);
5840         return ret_arr;
5841 }
5842
5843 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
5844         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 };
5845         for (size_t i = 0; i < ret.datalen; i++) {
5846                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
5847         }
5848         return ret;
5849 }
5850 uint32_t __attribute__((export_name("TS_LDKBalance_ty_from_ptr"))) TS_LDKBalance_ty_from_ptr(uint32_t ptr) {
5851         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5852         switch(obj->tag) {
5853                 case LDKBalance_ClaimableOnChannelClose: return 0;
5854                 case LDKBalance_ClaimableAwaitingConfirmations: return 1;
5855                 case LDKBalance_ContentiousClaimable: return 2;
5856                 case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: return 3;
5857                 default: abort();
5858         }
5859 }
5860 int64_t __attribute__((export_name("TS_LDKBalance_ClaimableOnChannelClose_get_claimable_amount_satoshis"))) TS_LDKBalance_ClaimableOnChannelClose_get_claimable_amount_satoshis(uint32_t ptr) {
5861         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5862         assert(obj->tag == LDKBalance_ClaimableOnChannelClose);
5863                         int64_t claimable_amount_satoshis_conv = obj->claimable_on_channel_close.claimable_amount_satoshis;
5864         return claimable_amount_satoshis_conv;
5865 }
5866 int64_t __attribute__((export_name("TS_LDKBalance_ClaimableAwaitingConfirmations_get_claimable_amount_satoshis"))) TS_LDKBalance_ClaimableAwaitingConfirmations_get_claimable_amount_satoshis(uint32_t ptr) {
5867         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5868         assert(obj->tag == LDKBalance_ClaimableAwaitingConfirmations);
5869                         int64_t claimable_amount_satoshis_conv = obj->claimable_awaiting_confirmations.claimable_amount_satoshis;
5870         return claimable_amount_satoshis_conv;
5871 }
5872 int32_t __attribute__((export_name("TS_LDKBalance_ClaimableAwaitingConfirmations_get_confirmation_height"))) TS_LDKBalance_ClaimableAwaitingConfirmations_get_confirmation_height(uint32_t ptr) {
5873         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5874         assert(obj->tag == LDKBalance_ClaimableAwaitingConfirmations);
5875                         int32_t confirmation_height_conv = obj->claimable_awaiting_confirmations.confirmation_height;
5876         return confirmation_height_conv;
5877 }
5878 int64_t __attribute__((export_name("TS_LDKBalance_ContentiousClaimable_get_claimable_amount_satoshis"))) TS_LDKBalance_ContentiousClaimable_get_claimable_amount_satoshis(uint32_t ptr) {
5879         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5880         assert(obj->tag == LDKBalance_ContentiousClaimable);
5881                         int64_t claimable_amount_satoshis_conv = obj->contentious_claimable.claimable_amount_satoshis;
5882         return claimable_amount_satoshis_conv;
5883 }
5884 int32_t __attribute__((export_name("TS_LDKBalance_ContentiousClaimable_get_timeout_height"))) TS_LDKBalance_ContentiousClaimable_get_timeout_height(uint32_t ptr) {
5885         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5886         assert(obj->tag == LDKBalance_ContentiousClaimable);
5887                         int32_t timeout_height_conv = obj->contentious_claimable.timeout_height;
5888         return timeout_height_conv;
5889 }
5890 int64_t __attribute__((export_name("TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_amount_satoshis"))) TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_amount_satoshis(uint32_t ptr) {
5891         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5892         assert(obj->tag == LDKBalance_MaybeClaimableHTLCAwaitingTimeout);
5893                         int64_t claimable_amount_satoshis_conv = obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis;
5894         return claimable_amount_satoshis_conv;
5895 }
5896 int32_t __attribute__((export_name("TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_height"))) TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_height(uint32_t ptr) {
5897         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5898         assert(obj->tag == LDKBalance_MaybeClaimableHTLCAwaitingTimeout);
5899                         int32_t claimable_height_conv = obj->maybe_claimable_htlc_awaiting_timeout.claimable_height;
5900         return claimable_height_conv;
5901 }
5902 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
5903         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
5904         for (size_t i = 0; i < ret.datalen; i++) {
5905                 ret.data[i] = Balance_clone(&orig->data[i]);
5906         }
5907         return ret;
5908 }
5909 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
5910         return ThirtyTwoBytes_clone(&owner->a);
5911 }
5912 int8_tArray  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_get_a"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_a(uint32_t owner) {
5913         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
5914         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5915         memcpy(ret_arr->elems, C2Tuple_BlockHashChannelMonitorZ_get_a(owner_conv).data, 32);
5916         return ret_arr;
5917 }
5918
5919 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
5920         return ChannelMonitor_clone(&owner->b);
5921 }
5922 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_get_b"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_b(uint32_t owner) {
5923         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
5924         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(owner_conv);
5925         uint32_t ret_ref = 0;
5926         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5927         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5928         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5929         ret_ref = (uintptr_t)ret_var.inner;
5930         if (ret_var.is_owned) {
5931                 ret_ref |= 1;
5932         }
5933         return ret_ref;
5934 }
5935
5936 static inline struct LDKC2Tuple_BlockHashChannelMonitorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
5937 CHECK(owner->result_ok);
5938         return C2Tuple_BlockHashChannelMonitorZ_clone(&*owner->contents.result);
5939 }
5940 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(uint32_t owner) {
5941         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
5942         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
5943         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(owner_conv);
5944         return ((uint32_t)ret_conv);
5945 }
5946
5947 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
5948 CHECK(!owner->result_ok);
5949         return DecodeError_clone(&*owner->contents.err);
5950 }
5951 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(uint32_t owner) {
5952         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
5953         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(owner_conv);
5954         uint32_t ret_ref = 0;
5955         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5956         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5957         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5958         ret_ref = (uintptr_t)ret_var.inner;
5959         if (ret_var.is_owned) {
5960                 ret_ref |= 1;
5961         }
5962         return ret_ref;
5963 }
5964
5965 static inline void CResult_NoneLightningErrorZ_get_ok(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
5966 CHECK(owner->result_ok);
5967         return *owner->contents.result;
5968 }
5969 void  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_get_ok"))) TS_CResult_NoneLightningErrorZ_get_ok(uint32_t owner) {
5970         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
5971         CResult_NoneLightningErrorZ_get_ok(owner_conv);
5972 }
5973
5974 static inline struct LDKLightningError CResult_NoneLightningErrorZ_get_err(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
5975 CHECK(!owner->result_ok);
5976         return LightningError_clone(&*owner->contents.err);
5977 }
5978 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_get_err"))) TS_CResult_NoneLightningErrorZ_get_err(uint32_t owner) {
5979         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
5980         LDKLightningError ret_var = CResult_NoneLightningErrorZ_get_err(owner_conv);
5981         uint32_t ret_ref = 0;
5982         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5983         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5984         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5985         ret_ref = (uintptr_t)ret_var.inner;
5986         if (ret_var.is_owned) {
5987                 ret_ref |= 1;
5988         }
5989         return ret_ref;
5990 }
5991
5992 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
5993         return owner->a;
5994 }
5995 int8_tArray  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_get_a"))) TS_C2Tuple_PublicKeyTypeZ_get_a(uint32_t owner) {
5996         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
5997         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
5998         memcpy(ret_arr->elems, C2Tuple_PublicKeyTypeZ_get_a(owner_conv).compressed_form, 33);
5999         return ret_arr;
6000 }
6001
6002 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
6003         return Type_clone(&owner->b);
6004 }
6005 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_get_b"))) TS_C2Tuple_PublicKeyTypeZ_get_b(uint32_t owner) {
6006         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
6007         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
6008         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(owner_conv);
6009         return (uint32_t)ret_ret;
6010 }
6011
6012 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
6013         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
6014         for (size_t i = 0; i < ret.datalen; i++) {
6015                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
6016         }
6017         return ret;
6018 }
6019 static inline bool CResult_boolLightningErrorZ_get_ok(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
6020 CHECK(owner->result_ok);
6021         return *owner->contents.result;
6022 }
6023 jboolean  __attribute__((export_name("TS_CResult_boolLightningErrorZ_get_ok"))) TS_CResult_boolLightningErrorZ_get_ok(uint32_t owner) {
6024         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
6025         jboolean ret_conv = CResult_boolLightningErrorZ_get_ok(owner_conv);
6026         return ret_conv;
6027 }
6028
6029 static inline struct LDKLightningError CResult_boolLightningErrorZ_get_err(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
6030 CHECK(!owner->result_ok);
6031         return LightningError_clone(&*owner->contents.err);
6032 }
6033 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_get_err"))) TS_CResult_boolLightningErrorZ_get_err(uint32_t owner) {
6034         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
6035         LDKLightningError ret_var = CResult_boolLightningErrorZ_get_err(owner_conv);
6036         uint32_t ret_ref = 0;
6037         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6038         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6039         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6040         ret_ref = (uintptr_t)ret_var.inner;
6041         if (ret_var.is_owned) {
6042                 ret_ref |= 1;
6043         }
6044         return ret_ref;
6045 }
6046
6047 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
6048         return ChannelAnnouncement_clone(&owner->a);
6049 }
6050 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(uint32_t owner) {
6051         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
6052         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(owner_conv);
6053         uint32_t ret_ref = 0;
6054         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6055         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6056         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6057         ret_ref = (uintptr_t)ret_var.inner;
6058         if (ret_var.is_owned) {
6059                 ret_ref |= 1;
6060         }
6061         return ret_ref;
6062 }
6063
6064 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
6065         return ChannelUpdate_clone(&owner->b);
6066 }
6067 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(uint32_t owner) {
6068         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
6069         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(owner_conv);
6070         uint32_t ret_ref = 0;
6071         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6072         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6073         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6074         ret_ref = (uintptr_t)ret_var.inner;
6075         if (ret_var.is_owned) {
6076                 ret_ref |= 1;
6077         }
6078         return ret_ref;
6079 }
6080
6081 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
6082         return ChannelUpdate_clone(&owner->c);
6083 }
6084 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(uint32_t owner) {
6085         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
6086         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(owner_conv);
6087         uint32_t ret_ref = 0;
6088         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6089         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6090         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6091         ret_ref = (uintptr_t)ret_var.inner;
6092         if (ret_var.is_owned) {
6093                 ret_ref |= 1;
6094         }
6095         return ret_ref;
6096 }
6097
6098 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
6099         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
6100         for (size_t i = 0; i < ret.datalen; i++) {
6101                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
6102         }
6103         return ret;
6104 }
6105 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
6106         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
6107         for (size_t i = 0; i < ret.datalen; i++) {
6108                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
6109         }
6110         return ret;
6111 }
6112 uint32_t __attribute__((export_name("TS_LDKCOption_NetAddressZ_ty_from_ptr"))) TS_LDKCOption_NetAddressZ_ty_from_ptr(uint32_t ptr) {
6113         LDKCOption_NetAddressZ *obj = (LDKCOption_NetAddressZ*)(ptr & ~1);
6114         switch(obj->tag) {
6115                 case LDKCOption_NetAddressZ_Some: return 0;
6116                 case LDKCOption_NetAddressZ_None: return 1;
6117                 default: abort();
6118         }
6119 }
6120 uint32_t __attribute__((export_name("TS_LDKCOption_NetAddressZ_Some_get_some"))) TS_LDKCOption_NetAddressZ_Some_get_some(uint32_t ptr) {
6121         LDKCOption_NetAddressZ *obj = (LDKCOption_NetAddressZ*)(ptr & ~1);
6122         assert(obj->tag == LDKCOption_NetAddressZ_Some);
6123                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
6124         return some_ref;
6125 }
6126 static inline struct LDKCVec_u8Z CResult_CVec_u8ZPeerHandleErrorZ_get_ok(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
6127 CHECK(owner->result_ok);
6128         return CVec_u8Z_clone(&*owner->contents.result);
6129 }
6130 int8_tArray  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_get_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_get_ok(uint32_t owner) {
6131         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
6132         LDKCVec_u8Z ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_ok(owner_conv);
6133         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
6134         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
6135         CVec_u8Z_free(ret_var);
6136         return ret_arr;
6137 }
6138
6139 static inline struct LDKPeerHandleError CResult_CVec_u8ZPeerHandleErrorZ_get_err(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
6140 CHECK(!owner->result_ok);
6141         return PeerHandleError_clone(&*owner->contents.err);
6142 }
6143 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_get_err"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_get_err(uint32_t owner) {
6144         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
6145         LDKPeerHandleError ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_err(owner_conv);
6146         uint32_t ret_ref = 0;
6147         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6148         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6149         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6150         ret_ref = (uintptr_t)ret_var.inner;
6151         if (ret_var.is_owned) {
6152                 ret_ref |= 1;
6153         }
6154         return ret_ref;
6155 }
6156
6157 static inline void CResult_NonePeerHandleErrorZ_get_ok(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
6158 CHECK(owner->result_ok);
6159         return *owner->contents.result;
6160 }
6161 void  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_get_ok"))) TS_CResult_NonePeerHandleErrorZ_get_ok(uint32_t owner) {
6162         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
6163         CResult_NonePeerHandleErrorZ_get_ok(owner_conv);
6164 }
6165
6166 static inline struct LDKPeerHandleError CResult_NonePeerHandleErrorZ_get_err(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
6167 CHECK(!owner->result_ok);
6168         return PeerHandleError_clone(&*owner->contents.err);
6169 }
6170 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_get_err"))) TS_CResult_NonePeerHandleErrorZ_get_err(uint32_t owner) {
6171         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
6172         LDKPeerHandleError ret_var = CResult_NonePeerHandleErrorZ_get_err(owner_conv);
6173         uint32_t ret_ref = 0;
6174         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6175         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6176         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6177         ret_ref = (uintptr_t)ret_var.inner;
6178         if (ret_var.is_owned) {
6179                 ret_ref |= 1;
6180         }
6181         return ret_ref;
6182 }
6183
6184 static inline bool CResult_boolPeerHandleErrorZ_get_ok(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
6185 CHECK(owner->result_ok);
6186         return *owner->contents.result;
6187 }
6188 jboolean  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_get_ok"))) TS_CResult_boolPeerHandleErrorZ_get_ok(uint32_t owner) {
6189         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
6190         jboolean ret_conv = CResult_boolPeerHandleErrorZ_get_ok(owner_conv);
6191         return ret_conv;
6192 }
6193
6194 static inline struct LDKPeerHandleError CResult_boolPeerHandleErrorZ_get_err(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
6195 CHECK(!owner->result_ok);
6196         return PeerHandleError_clone(&*owner->contents.err);
6197 }
6198 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_get_err"))) TS_CResult_boolPeerHandleErrorZ_get_err(uint32_t owner) {
6199         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
6200         LDKPeerHandleError ret_var = CResult_boolPeerHandleErrorZ_get_err(owner_conv);
6201         uint32_t ret_ref = 0;
6202         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6203         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6204         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6205         ret_ref = (uintptr_t)ret_var.inner;
6206         if (ret_var.is_owned) {
6207                 ret_ref |= 1;
6208         }
6209         return ret_ref;
6210 }
6211
6212 static inline struct LDKNodeId CResult_NodeIdDecodeErrorZ_get_ok(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
6213 CHECK(owner->result_ok);
6214         return NodeId_clone(&*owner->contents.result);
6215 }
6216 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_get_ok"))) TS_CResult_NodeIdDecodeErrorZ_get_ok(uint32_t owner) {
6217         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
6218         LDKNodeId ret_var = CResult_NodeIdDecodeErrorZ_get_ok(owner_conv);
6219         uint32_t ret_ref = 0;
6220         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6221         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6222         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6223         ret_ref = (uintptr_t)ret_var.inner;
6224         if (ret_var.is_owned) {
6225                 ret_ref |= 1;
6226         }
6227         return ret_ref;
6228 }
6229
6230 static inline struct LDKDecodeError CResult_NodeIdDecodeErrorZ_get_err(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
6231 CHECK(!owner->result_ok);
6232         return DecodeError_clone(&*owner->contents.err);
6233 }
6234 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_get_err"))) TS_CResult_NodeIdDecodeErrorZ_get_err(uint32_t owner) {
6235         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
6236         LDKDecodeError ret_var = CResult_NodeIdDecodeErrorZ_get_err(owner_conv);
6237         uint32_t ret_ref = 0;
6238         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6239         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6240         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6241         ret_ref = (uintptr_t)ret_var.inner;
6242         if (ret_var.is_owned) {
6243                 ret_ref |= 1;
6244         }
6245         return ret_ref;
6246 }
6247
6248 static inline struct LDKCOption_NetworkUpdateZ CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
6249 CHECK(owner->result_ok);
6250         return COption_NetworkUpdateZ_clone(&*owner->contents.result);
6251 }
6252 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(uint32_t owner) {
6253         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
6254         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
6255         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(owner_conv);
6256         uint32_t ret_ref = (uintptr_t)ret_copy;
6257         return ret_ref;
6258 }
6259
6260 static inline struct LDKDecodeError CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
6261 CHECK(!owner->result_ok);
6262         return DecodeError_clone(&*owner->contents.err);
6263 }
6264 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_err"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(uint32_t owner) {
6265         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
6266         LDKDecodeError ret_var = CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(owner_conv);
6267         uint32_t ret_ref = 0;
6268         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6269         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6270         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6271         ret_ref = (uintptr_t)ret_var.inner;
6272         if (ret_var.is_owned) {
6273                 ret_ref |= 1;
6274         }
6275         return ret_ref;
6276 }
6277
6278 typedef struct LDKAccess_JCalls {
6279         atomic_size_t refcnt;
6280         uint32_t instance_ptr;
6281 } LDKAccess_JCalls;
6282 static void LDKAccess_JCalls_free(void* this_arg) {
6283         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6284         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6285                 FREE(j_calls);
6286         }
6287 }
6288 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
6289         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6290         int8_tArray genesis_hash_arr = init_int8_tArray(32, __LINE__);
6291         memcpy(genesis_hash_arr->elems, *genesis_hash, 32);
6292         int64_t short_channel_id_conv = short_channel_id;
6293         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 31, (uint32_t)genesis_hash_arr, (uint32_t)short_channel_id_conv);
6294         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6295         CHECK_ACCESS(ret_ptr);
6296         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
6297         FREE((void*)ret);
6298         return ret_conv;
6299 }
6300 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
6301         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
6302         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6303 }
6304 static inline LDKAccess LDKAccess_init (JSValue o) {
6305         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
6306         atomic_init(&calls->refcnt, 1);
6307         calls->instance_ptr = o;
6308
6309         LDKAccess ret = {
6310                 .this_arg = (void*) calls,
6311                 .get_utxo = get_utxo_LDKAccess_jcall,
6312                 .free = LDKAccess_JCalls_free,
6313         };
6314         return ret;
6315 }
6316 long  __attribute__((export_name("TS_LDKAccess_new"))) TS_LDKAccess_new(JSValue o) {
6317         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
6318         *res_ptr = LDKAccess_init(o);
6319         return (long)res_ptr;
6320 }
6321 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) {
6322         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6323         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6324         LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
6325         unsigned char genesis_hash_arr[32];
6326         CHECK(genesis_hash->arr_len == 32);
6327         memcpy(genesis_hash_arr, genesis_hash->elems, 32); FREE(genesis_hash);
6328         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
6329         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
6330         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
6331         return (uint32_t)ret_conv;
6332 }
6333
6334 uint32_t __attribute__((export_name("TS_LDKCOption_AccessZ_ty_from_ptr"))) TS_LDKCOption_AccessZ_ty_from_ptr(uint32_t ptr) {
6335         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
6336         switch(obj->tag) {
6337                 case LDKCOption_AccessZ_Some: return 0;
6338                 case LDKCOption_AccessZ_None: return 1;
6339                 default: abort();
6340         }
6341 }
6342 uint32_t __attribute__((export_name("TS_LDKCOption_AccessZ_Some_get_some"))) TS_LDKCOption_AccessZ_Some_get_some(uint32_t ptr) {
6343         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
6344         assert(obj->tag == LDKCOption_AccessZ_Some);
6345                         LDKAccess* some_ret = MALLOC(sizeof(LDKAccess), "LDKAccess");
6346                         *some_ret = obj->some;
6347                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
6348                         if ((*some_ret).free == LDKAccess_JCalls_free) {
6349                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6350                                 LDKAccess_JCalls_cloned(&(*some_ret));
6351                         }
6352         return (uint32_t)some_ret;
6353 }
6354 static inline struct LDKChannelUpdateInfo CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
6355 CHECK(owner->result_ok);
6356         return ChannelUpdateInfo_clone(&*owner->contents.result);
6357 }
6358 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_ok"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(uint32_t owner) {
6359         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
6360         LDKChannelUpdateInfo ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(owner_conv);
6361         uint32_t ret_ref = 0;
6362         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6363         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6364         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6365         ret_ref = (uintptr_t)ret_var.inner;
6366         if (ret_var.is_owned) {
6367                 ret_ref |= 1;
6368         }
6369         return ret_ref;
6370 }
6371
6372 static inline struct LDKDecodeError CResult_ChannelUpdateInfoDecodeErrorZ_get_err(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
6373 CHECK(!owner->result_ok);
6374         return DecodeError_clone(&*owner->contents.err);
6375 }
6376 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_err"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_err(uint32_t owner) {
6377         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
6378         LDKDecodeError ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_err(owner_conv);
6379         uint32_t ret_ref = 0;
6380         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6381         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6382         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6383         ret_ref = (uintptr_t)ret_var.inner;
6384         if (ret_var.is_owned) {
6385                 ret_ref |= 1;
6386         }
6387         return ret_ref;
6388 }
6389
6390 static inline struct LDKChannelInfo CResult_ChannelInfoDecodeErrorZ_get_ok(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
6391 CHECK(owner->result_ok);
6392         return ChannelInfo_clone(&*owner->contents.result);
6393 }
6394 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_get_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_get_ok(uint32_t owner) {
6395         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
6396         LDKChannelInfo ret_var = CResult_ChannelInfoDecodeErrorZ_get_ok(owner_conv);
6397         uint32_t ret_ref = 0;
6398         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6399         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6400         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6401         ret_ref = (uintptr_t)ret_var.inner;
6402         if (ret_var.is_owned) {
6403                 ret_ref |= 1;
6404         }
6405         return ret_ref;
6406 }
6407
6408 static inline struct LDKDecodeError CResult_ChannelInfoDecodeErrorZ_get_err(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
6409 CHECK(!owner->result_ok);
6410         return DecodeError_clone(&*owner->contents.err);
6411 }
6412 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_get_err"))) TS_CResult_ChannelInfoDecodeErrorZ_get_err(uint32_t owner) {
6413         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
6414         LDKDecodeError ret_var = CResult_ChannelInfoDecodeErrorZ_get_err(owner_conv);
6415         uint32_t ret_ref = 0;
6416         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6417         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6418         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6419         ret_ref = (uintptr_t)ret_var.inner;
6420         if (ret_var.is_owned) {
6421                 ret_ref |= 1;
6422         }
6423         return ret_ref;
6424 }
6425
6426 static inline struct LDKRoutingFees CResult_RoutingFeesDecodeErrorZ_get_ok(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
6427 CHECK(owner->result_ok);
6428         return RoutingFees_clone(&*owner->contents.result);
6429 }
6430 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_get_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_get_ok(uint32_t owner) {
6431         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
6432         LDKRoutingFees ret_var = CResult_RoutingFeesDecodeErrorZ_get_ok(owner_conv);
6433         uint32_t ret_ref = 0;
6434         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6435         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6436         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6437         ret_ref = (uintptr_t)ret_var.inner;
6438         if (ret_var.is_owned) {
6439                 ret_ref |= 1;
6440         }
6441         return ret_ref;
6442 }
6443
6444 static inline struct LDKDecodeError CResult_RoutingFeesDecodeErrorZ_get_err(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
6445 CHECK(!owner->result_ok);
6446         return DecodeError_clone(&*owner->contents.err);
6447 }
6448 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_get_err"))) TS_CResult_RoutingFeesDecodeErrorZ_get_err(uint32_t owner) {
6449         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
6450         LDKDecodeError ret_var = CResult_RoutingFeesDecodeErrorZ_get_err(owner_conv);
6451         uint32_t ret_ref = 0;
6452         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6453         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6454         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6455         ret_ref = (uintptr_t)ret_var.inner;
6456         if (ret_var.is_owned) {
6457                 ret_ref |= 1;
6458         }
6459         return ret_ref;
6460 }
6461
6462 static inline struct LDKNodeAnnouncementInfo CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
6463 CHECK(owner->result_ok);
6464         return NodeAnnouncementInfo_clone(&*owner->contents.result);
6465 }
6466 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(uint32_t owner) {
6467         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
6468         LDKNodeAnnouncementInfo ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(owner_conv);
6469         uint32_t ret_ref = 0;
6470         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6471         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6472         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6473         ret_ref = (uintptr_t)ret_var.inner;
6474         if (ret_var.is_owned) {
6475                 ret_ref |= 1;
6476         }
6477         return ret_ref;
6478 }
6479
6480 static inline struct LDKDecodeError CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
6481 CHECK(!owner->result_ok);
6482         return DecodeError_clone(&*owner->contents.err);
6483 }
6484 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_err"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(uint32_t owner) {
6485         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
6486         LDKDecodeError ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(owner_conv);
6487         uint32_t ret_ref = 0;
6488         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6489         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6490         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6491         ret_ref = (uintptr_t)ret_var.inner;
6492         if (ret_var.is_owned) {
6493                 ret_ref |= 1;
6494         }
6495         return ret_ref;
6496 }
6497
6498 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
6499         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
6500         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
6501         return ret;
6502 }
6503 static inline struct LDKNodeInfo CResult_NodeInfoDecodeErrorZ_get_ok(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
6504 CHECK(owner->result_ok);
6505         return NodeInfo_clone(&*owner->contents.result);
6506 }
6507 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_get_ok"))) TS_CResult_NodeInfoDecodeErrorZ_get_ok(uint32_t owner) {
6508         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
6509         LDKNodeInfo ret_var = CResult_NodeInfoDecodeErrorZ_get_ok(owner_conv);
6510         uint32_t ret_ref = 0;
6511         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6512         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6513         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6514         ret_ref = (uintptr_t)ret_var.inner;
6515         if (ret_var.is_owned) {
6516                 ret_ref |= 1;
6517         }
6518         return ret_ref;
6519 }
6520
6521 static inline struct LDKDecodeError CResult_NodeInfoDecodeErrorZ_get_err(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
6522 CHECK(!owner->result_ok);
6523         return DecodeError_clone(&*owner->contents.err);
6524 }
6525 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_get_err"))) TS_CResult_NodeInfoDecodeErrorZ_get_err(uint32_t owner) {
6526         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
6527         LDKDecodeError ret_var = CResult_NodeInfoDecodeErrorZ_get_err(owner_conv);
6528         uint32_t ret_ref = 0;
6529         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6530         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6531         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6532         ret_ref = (uintptr_t)ret_var.inner;
6533         if (ret_var.is_owned) {
6534                 ret_ref |= 1;
6535         }
6536         return ret_ref;
6537 }
6538
6539 static inline struct LDKNetworkGraph CResult_NetworkGraphDecodeErrorZ_get_ok(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
6540 CHECK(owner->result_ok);
6541         return NetworkGraph_clone(&*owner->contents.result);
6542 }
6543 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_get_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_get_ok(uint32_t owner) {
6544         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
6545         LDKNetworkGraph ret_var = CResult_NetworkGraphDecodeErrorZ_get_ok(owner_conv);
6546         uint32_t ret_ref = 0;
6547         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6548         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6549         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6550         ret_ref = (uintptr_t)ret_var.inner;
6551         if (ret_var.is_owned) {
6552                 ret_ref |= 1;
6553         }
6554         return ret_ref;
6555 }
6556
6557 static inline struct LDKDecodeError CResult_NetworkGraphDecodeErrorZ_get_err(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
6558 CHECK(!owner->result_ok);
6559         return DecodeError_clone(&*owner->contents.err);
6560 }
6561 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_get_err"))) TS_CResult_NetworkGraphDecodeErrorZ_get_err(uint32_t owner) {
6562         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
6563         LDKDecodeError ret_var = CResult_NetworkGraphDecodeErrorZ_get_err(owner_conv);
6564         uint32_t ret_ref = 0;
6565         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6566         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6567         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6568         ret_ref = (uintptr_t)ret_var.inner;
6569         if (ret_var.is_owned) {
6570                 ret_ref |= 1;
6571         }
6572         return ret_ref;
6573 }
6574
6575 uint32_t __attribute__((export_name("TS_LDKCOption_CVec_NetAddressZZ_ty_from_ptr"))) TS_LDKCOption_CVec_NetAddressZZ_ty_from_ptr(uint32_t ptr) {
6576         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
6577         switch(obj->tag) {
6578                 case LDKCOption_CVec_NetAddressZZ_Some: return 0;
6579                 case LDKCOption_CVec_NetAddressZZ_None: return 1;
6580                 default: abort();
6581         }
6582 }
6583 uint32_tArray __attribute__((export_name("TS_LDKCOption_CVec_NetAddressZZ_Some_get_some"))) TS_LDKCOption_CVec_NetAddressZZ_Some_get_some(uint32_t ptr) {
6584         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
6585         assert(obj->tag == LDKCOption_CVec_NetAddressZZ_Some);
6586                         LDKCVec_NetAddressZ some_var = obj->some;
6587                         uint32_tArray some_arr = NULL;
6588                         some_arr = init_uint32_tArray(some_var.datalen, __LINE__);
6589                         uint32_t *some_arr_ptr = (uint32_t*)(((uint8_t*)some_arr) + 4);
6590                         for (size_t m = 0; m < some_var.datalen; m++) {
6591                                 uint32_t some_conv_12_ref = ((uintptr_t)&some_var.data[m]) | 1;
6592                                 some_arr_ptr[m] = some_conv_12_ref;
6593                         }
6594                         
6595         return some_arr;
6596 }
6597 static inline struct LDKNetAddress CResult_NetAddressDecodeErrorZ_get_ok(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
6598 CHECK(owner->result_ok);
6599         return NetAddress_clone(&*owner->contents.result);
6600 }
6601 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_get_ok"))) TS_CResult_NetAddressDecodeErrorZ_get_ok(uint32_t owner) {
6602         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
6603         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
6604         *ret_copy = CResult_NetAddressDecodeErrorZ_get_ok(owner_conv);
6605         uint32_t ret_ref = (uintptr_t)ret_copy;
6606         return ret_ref;
6607 }
6608
6609 static inline struct LDKDecodeError CResult_NetAddressDecodeErrorZ_get_err(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
6610 CHECK(!owner->result_ok);
6611         return DecodeError_clone(&*owner->contents.err);
6612 }
6613 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_get_err"))) TS_CResult_NetAddressDecodeErrorZ_get_err(uint32_t owner) {
6614         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
6615         LDKDecodeError ret_var = CResult_NetAddressDecodeErrorZ_get_err(owner_conv);
6616         uint32_t ret_ref = 0;
6617         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6618         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6619         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6620         ret_ref = (uintptr_t)ret_var.inner;
6621         if (ret_var.is_owned) {
6622                 ret_ref |= 1;
6623         }
6624         return ret_ref;
6625 }
6626
6627 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
6628         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
6629         for (size_t i = 0; i < ret.datalen; i++) {
6630                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
6631         }
6632         return ret;
6633 }
6634 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
6635         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
6636         for (size_t i = 0; i < ret.datalen; i++) {
6637                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
6638         }
6639         return ret;
6640 }
6641 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
6642         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
6643         for (size_t i = 0; i < ret.datalen; i++) {
6644                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
6645         }
6646         return ret;
6647 }
6648 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
6649         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
6650         for (size_t i = 0; i < ret.datalen; i++) {
6651                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
6652         }
6653         return ret;
6654 }
6655 static inline struct LDKAcceptChannel CResult_AcceptChannelDecodeErrorZ_get_ok(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
6656 CHECK(owner->result_ok);
6657         return AcceptChannel_clone(&*owner->contents.result);
6658 }
6659 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_get_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_get_ok(uint32_t owner) {
6660         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
6661         LDKAcceptChannel ret_var = CResult_AcceptChannelDecodeErrorZ_get_ok(owner_conv);
6662         uint32_t ret_ref = 0;
6663         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6664         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6665         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6666         ret_ref = (uintptr_t)ret_var.inner;
6667         if (ret_var.is_owned) {
6668                 ret_ref |= 1;
6669         }
6670         return ret_ref;
6671 }
6672
6673 static inline struct LDKDecodeError CResult_AcceptChannelDecodeErrorZ_get_err(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
6674 CHECK(!owner->result_ok);
6675         return DecodeError_clone(&*owner->contents.err);
6676 }
6677 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_get_err"))) TS_CResult_AcceptChannelDecodeErrorZ_get_err(uint32_t owner) {
6678         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
6679         LDKDecodeError ret_var = CResult_AcceptChannelDecodeErrorZ_get_err(owner_conv);
6680         uint32_t ret_ref = 0;
6681         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6682         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6683         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6684         ret_ref = (uintptr_t)ret_var.inner;
6685         if (ret_var.is_owned) {
6686                 ret_ref |= 1;
6687         }
6688         return ret_ref;
6689 }
6690
6691 static inline struct LDKAnnouncementSignatures CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
6692 CHECK(owner->result_ok);
6693         return AnnouncementSignatures_clone(&*owner->contents.result);
6694 }
6695 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(uint32_t owner) {
6696         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
6697         LDKAnnouncementSignatures ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(owner_conv);
6698         uint32_t ret_ref = 0;
6699         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6700         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6701         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6702         ret_ref = (uintptr_t)ret_var.inner;
6703         if (ret_var.is_owned) {
6704                 ret_ref |= 1;
6705         }
6706         return ret_ref;
6707 }
6708
6709 static inline struct LDKDecodeError CResult_AnnouncementSignaturesDecodeErrorZ_get_err(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
6710 CHECK(!owner->result_ok);
6711         return DecodeError_clone(&*owner->contents.err);
6712 }
6713 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_err"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_err(uint32_t owner) {
6714         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
6715         LDKDecodeError ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_err(owner_conv);
6716         uint32_t ret_ref = 0;
6717         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6718         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6719         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6720         ret_ref = (uintptr_t)ret_var.inner;
6721         if (ret_var.is_owned) {
6722                 ret_ref |= 1;
6723         }
6724         return ret_ref;
6725 }
6726
6727 static inline struct LDKChannelReestablish CResult_ChannelReestablishDecodeErrorZ_get_ok(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
6728 CHECK(owner->result_ok);
6729         return ChannelReestablish_clone(&*owner->contents.result);
6730 }
6731 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_get_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_get_ok(uint32_t owner) {
6732         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
6733         LDKChannelReestablish ret_var = CResult_ChannelReestablishDecodeErrorZ_get_ok(owner_conv);
6734         uint32_t ret_ref = 0;
6735         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6736         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6737         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6738         ret_ref = (uintptr_t)ret_var.inner;
6739         if (ret_var.is_owned) {
6740                 ret_ref |= 1;
6741         }
6742         return ret_ref;
6743 }
6744
6745 static inline struct LDKDecodeError CResult_ChannelReestablishDecodeErrorZ_get_err(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
6746 CHECK(!owner->result_ok);
6747         return DecodeError_clone(&*owner->contents.err);
6748 }
6749 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_get_err"))) TS_CResult_ChannelReestablishDecodeErrorZ_get_err(uint32_t owner) {
6750         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
6751         LDKDecodeError ret_var = CResult_ChannelReestablishDecodeErrorZ_get_err(owner_conv);
6752         uint32_t ret_ref = 0;
6753         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6754         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6755         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6756         ret_ref = (uintptr_t)ret_var.inner;
6757         if (ret_var.is_owned) {
6758                 ret_ref |= 1;
6759         }
6760         return ret_ref;
6761 }
6762
6763 static inline struct LDKClosingSigned CResult_ClosingSignedDecodeErrorZ_get_ok(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
6764 CHECK(owner->result_ok);
6765         return ClosingSigned_clone(&*owner->contents.result);
6766 }
6767 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_get_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_get_ok(uint32_t owner) {
6768         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
6769         LDKClosingSigned ret_var = CResult_ClosingSignedDecodeErrorZ_get_ok(owner_conv);
6770         uint32_t ret_ref = 0;
6771         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6772         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6773         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6774         ret_ref = (uintptr_t)ret_var.inner;
6775         if (ret_var.is_owned) {
6776                 ret_ref |= 1;
6777         }
6778         return ret_ref;
6779 }
6780
6781 static inline struct LDKDecodeError CResult_ClosingSignedDecodeErrorZ_get_err(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
6782 CHECK(!owner->result_ok);
6783         return DecodeError_clone(&*owner->contents.err);
6784 }
6785 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_get_err"))) TS_CResult_ClosingSignedDecodeErrorZ_get_err(uint32_t owner) {
6786         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
6787         LDKDecodeError ret_var = CResult_ClosingSignedDecodeErrorZ_get_err(owner_conv);
6788         uint32_t ret_ref = 0;
6789         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6790         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6791         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6792         ret_ref = (uintptr_t)ret_var.inner;
6793         if (ret_var.is_owned) {
6794                 ret_ref |= 1;
6795         }
6796         return ret_ref;
6797 }
6798
6799 static inline struct LDKClosingSignedFeeRange CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
6800 CHECK(owner->result_ok);
6801         return ClosingSignedFeeRange_clone(&*owner->contents.result);
6802 }
6803 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(uint32_t owner) {
6804         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
6805         LDKClosingSignedFeeRange ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(owner_conv);
6806         uint32_t ret_ref = 0;
6807         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6808         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6809         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6810         ret_ref = (uintptr_t)ret_var.inner;
6811         if (ret_var.is_owned) {
6812                 ret_ref |= 1;
6813         }
6814         return ret_ref;
6815 }
6816
6817 static inline struct LDKDecodeError CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
6818 CHECK(!owner->result_ok);
6819         return DecodeError_clone(&*owner->contents.err);
6820 }
6821 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(uint32_t owner) {
6822         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
6823         LDKDecodeError ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(owner_conv);
6824         uint32_t ret_ref = 0;
6825         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6826         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6827         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6828         ret_ref = (uintptr_t)ret_var.inner;
6829         if (ret_var.is_owned) {
6830                 ret_ref |= 1;
6831         }
6832         return ret_ref;
6833 }
6834
6835 static inline struct LDKCommitmentSigned CResult_CommitmentSignedDecodeErrorZ_get_ok(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
6836 CHECK(owner->result_ok);
6837         return CommitmentSigned_clone(&*owner->contents.result);
6838 }
6839 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_get_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_get_ok(uint32_t owner) {
6840         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
6841         LDKCommitmentSigned ret_var = CResult_CommitmentSignedDecodeErrorZ_get_ok(owner_conv);
6842         uint32_t ret_ref = 0;
6843         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6844         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6845         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6846         ret_ref = (uintptr_t)ret_var.inner;
6847         if (ret_var.is_owned) {
6848                 ret_ref |= 1;
6849         }
6850         return ret_ref;
6851 }
6852
6853 static inline struct LDKDecodeError CResult_CommitmentSignedDecodeErrorZ_get_err(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
6854 CHECK(!owner->result_ok);
6855         return DecodeError_clone(&*owner->contents.err);
6856 }
6857 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_get_err"))) TS_CResult_CommitmentSignedDecodeErrorZ_get_err(uint32_t owner) {
6858         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
6859         LDKDecodeError ret_var = CResult_CommitmentSignedDecodeErrorZ_get_err(owner_conv);
6860         uint32_t ret_ref = 0;
6861         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6862         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6863         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6864         ret_ref = (uintptr_t)ret_var.inner;
6865         if (ret_var.is_owned) {
6866                 ret_ref |= 1;
6867         }
6868         return ret_ref;
6869 }
6870
6871 static inline struct LDKFundingCreated CResult_FundingCreatedDecodeErrorZ_get_ok(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
6872 CHECK(owner->result_ok);
6873         return FundingCreated_clone(&*owner->contents.result);
6874 }
6875 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_get_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_get_ok(uint32_t owner) {
6876         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
6877         LDKFundingCreated ret_var = CResult_FundingCreatedDecodeErrorZ_get_ok(owner_conv);
6878         uint32_t ret_ref = 0;
6879         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6880         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6881         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6882         ret_ref = (uintptr_t)ret_var.inner;
6883         if (ret_var.is_owned) {
6884                 ret_ref |= 1;
6885         }
6886         return ret_ref;
6887 }
6888
6889 static inline struct LDKDecodeError CResult_FundingCreatedDecodeErrorZ_get_err(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
6890 CHECK(!owner->result_ok);
6891         return DecodeError_clone(&*owner->contents.err);
6892 }
6893 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_get_err"))) TS_CResult_FundingCreatedDecodeErrorZ_get_err(uint32_t owner) {
6894         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
6895         LDKDecodeError ret_var = CResult_FundingCreatedDecodeErrorZ_get_err(owner_conv);
6896         uint32_t ret_ref = 0;
6897         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6898         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6899         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6900         ret_ref = (uintptr_t)ret_var.inner;
6901         if (ret_var.is_owned) {
6902                 ret_ref |= 1;
6903         }
6904         return ret_ref;
6905 }
6906
6907 static inline struct LDKFundingSigned CResult_FundingSignedDecodeErrorZ_get_ok(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
6908 CHECK(owner->result_ok);
6909         return FundingSigned_clone(&*owner->contents.result);
6910 }
6911 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_get_ok"))) TS_CResult_FundingSignedDecodeErrorZ_get_ok(uint32_t owner) {
6912         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
6913         LDKFundingSigned ret_var = CResult_FundingSignedDecodeErrorZ_get_ok(owner_conv);
6914         uint32_t ret_ref = 0;
6915         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6916         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6917         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6918         ret_ref = (uintptr_t)ret_var.inner;
6919         if (ret_var.is_owned) {
6920                 ret_ref |= 1;
6921         }
6922         return ret_ref;
6923 }
6924
6925 static inline struct LDKDecodeError CResult_FundingSignedDecodeErrorZ_get_err(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
6926 CHECK(!owner->result_ok);
6927         return DecodeError_clone(&*owner->contents.err);
6928 }
6929 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_get_err"))) TS_CResult_FundingSignedDecodeErrorZ_get_err(uint32_t owner) {
6930         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
6931         LDKDecodeError ret_var = CResult_FundingSignedDecodeErrorZ_get_err(owner_conv);
6932         uint32_t ret_ref = 0;
6933         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6934         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6935         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6936         ret_ref = (uintptr_t)ret_var.inner;
6937         if (ret_var.is_owned) {
6938                 ret_ref |= 1;
6939         }
6940         return ret_ref;
6941 }
6942
6943 static inline struct LDKFundingLocked CResult_FundingLockedDecodeErrorZ_get_ok(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR owner){
6944 CHECK(owner->result_ok);
6945         return FundingLocked_clone(&*owner->contents.result);
6946 }
6947 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_get_ok"))) TS_CResult_FundingLockedDecodeErrorZ_get_ok(uint32_t owner) {
6948         LDKCResult_FundingLockedDecodeErrorZ* owner_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(owner & ~1);
6949         LDKFundingLocked ret_var = CResult_FundingLockedDecodeErrorZ_get_ok(owner_conv);
6950         uint32_t ret_ref = 0;
6951         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6952         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6953         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6954         ret_ref = (uintptr_t)ret_var.inner;
6955         if (ret_var.is_owned) {
6956                 ret_ref |= 1;
6957         }
6958         return ret_ref;
6959 }
6960
6961 static inline struct LDKDecodeError CResult_FundingLockedDecodeErrorZ_get_err(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR owner){
6962 CHECK(!owner->result_ok);
6963         return DecodeError_clone(&*owner->contents.err);
6964 }
6965 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_get_err"))) TS_CResult_FundingLockedDecodeErrorZ_get_err(uint32_t owner) {
6966         LDKCResult_FundingLockedDecodeErrorZ* owner_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(owner & ~1);
6967         LDKDecodeError ret_var = CResult_FundingLockedDecodeErrorZ_get_err(owner_conv);
6968         uint32_t ret_ref = 0;
6969         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6970         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6971         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6972         ret_ref = (uintptr_t)ret_var.inner;
6973         if (ret_var.is_owned) {
6974                 ret_ref |= 1;
6975         }
6976         return ret_ref;
6977 }
6978
6979 static inline struct LDKInit CResult_InitDecodeErrorZ_get_ok(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
6980 CHECK(owner->result_ok);
6981         return Init_clone(&*owner->contents.result);
6982 }
6983 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_get_ok"))) TS_CResult_InitDecodeErrorZ_get_ok(uint32_t owner) {
6984         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
6985         LDKInit ret_var = CResult_InitDecodeErrorZ_get_ok(owner_conv);
6986         uint32_t ret_ref = 0;
6987         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6988         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6989         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6990         ret_ref = (uintptr_t)ret_var.inner;
6991         if (ret_var.is_owned) {
6992                 ret_ref |= 1;
6993         }
6994         return ret_ref;
6995 }
6996
6997 static inline struct LDKDecodeError CResult_InitDecodeErrorZ_get_err(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
6998 CHECK(!owner->result_ok);
6999         return DecodeError_clone(&*owner->contents.err);
7000 }
7001 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_get_err"))) TS_CResult_InitDecodeErrorZ_get_err(uint32_t owner) {
7002         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
7003         LDKDecodeError ret_var = CResult_InitDecodeErrorZ_get_err(owner_conv);
7004         uint32_t ret_ref = 0;
7005         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7006         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7007         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7008         ret_ref = (uintptr_t)ret_var.inner;
7009         if (ret_var.is_owned) {
7010                 ret_ref |= 1;
7011         }
7012         return ret_ref;
7013 }
7014
7015 static inline struct LDKOpenChannel CResult_OpenChannelDecodeErrorZ_get_ok(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
7016 CHECK(owner->result_ok);
7017         return OpenChannel_clone(&*owner->contents.result);
7018 }
7019 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_get_ok"))) TS_CResult_OpenChannelDecodeErrorZ_get_ok(uint32_t owner) {
7020         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
7021         LDKOpenChannel ret_var = CResult_OpenChannelDecodeErrorZ_get_ok(owner_conv);
7022         uint32_t ret_ref = 0;
7023         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7024         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7025         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7026         ret_ref = (uintptr_t)ret_var.inner;
7027         if (ret_var.is_owned) {
7028                 ret_ref |= 1;
7029         }
7030         return ret_ref;
7031 }
7032
7033 static inline struct LDKDecodeError CResult_OpenChannelDecodeErrorZ_get_err(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
7034 CHECK(!owner->result_ok);
7035         return DecodeError_clone(&*owner->contents.err);
7036 }
7037 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_get_err"))) TS_CResult_OpenChannelDecodeErrorZ_get_err(uint32_t owner) {
7038         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
7039         LDKDecodeError ret_var = CResult_OpenChannelDecodeErrorZ_get_err(owner_conv);
7040         uint32_t ret_ref = 0;
7041         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7042         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7043         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7044         ret_ref = (uintptr_t)ret_var.inner;
7045         if (ret_var.is_owned) {
7046                 ret_ref |= 1;
7047         }
7048         return ret_ref;
7049 }
7050
7051 static inline struct LDKRevokeAndACK CResult_RevokeAndACKDecodeErrorZ_get_ok(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
7052 CHECK(owner->result_ok);
7053         return RevokeAndACK_clone(&*owner->contents.result);
7054 }
7055 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_get_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_get_ok(uint32_t owner) {
7056         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
7057         LDKRevokeAndACK ret_var = CResult_RevokeAndACKDecodeErrorZ_get_ok(owner_conv);
7058         uint32_t ret_ref = 0;
7059         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7060         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7061         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7062         ret_ref = (uintptr_t)ret_var.inner;
7063         if (ret_var.is_owned) {
7064                 ret_ref |= 1;
7065         }
7066         return ret_ref;
7067 }
7068
7069 static inline struct LDKDecodeError CResult_RevokeAndACKDecodeErrorZ_get_err(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
7070 CHECK(!owner->result_ok);
7071         return DecodeError_clone(&*owner->contents.err);
7072 }
7073 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_get_err"))) TS_CResult_RevokeAndACKDecodeErrorZ_get_err(uint32_t owner) {
7074         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
7075         LDKDecodeError ret_var = CResult_RevokeAndACKDecodeErrorZ_get_err(owner_conv);
7076         uint32_t ret_ref = 0;
7077         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7078         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7079         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7080         ret_ref = (uintptr_t)ret_var.inner;
7081         if (ret_var.is_owned) {
7082                 ret_ref |= 1;
7083         }
7084         return ret_ref;
7085 }
7086
7087 static inline struct LDKShutdown CResult_ShutdownDecodeErrorZ_get_ok(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
7088 CHECK(owner->result_ok);
7089         return Shutdown_clone(&*owner->contents.result);
7090 }
7091 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_get_ok"))) TS_CResult_ShutdownDecodeErrorZ_get_ok(uint32_t owner) {
7092         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
7093         LDKShutdown ret_var = CResult_ShutdownDecodeErrorZ_get_ok(owner_conv);
7094         uint32_t ret_ref = 0;
7095         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7096         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7097         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7098         ret_ref = (uintptr_t)ret_var.inner;
7099         if (ret_var.is_owned) {
7100                 ret_ref |= 1;
7101         }
7102         return ret_ref;
7103 }
7104
7105 static inline struct LDKDecodeError CResult_ShutdownDecodeErrorZ_get_err(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
7106 CHECK(!owner->result_ok);
7107         return DecodeError_clone(&*owner->contents.err);
7108 }
7109 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_get_err"))) TS_CResult_ShutdownDecodeErrorZ_get_err(uint32_t owner) {
7110         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
7111         LDKDecodeError ret_var = CResult_ShutdownDecodeErrorZ_get_err(owner_conv);
7112         uint32_t ret_ref = 0;
7113         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7114         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7115         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7116         ret_ref = (uintptr_t)ret_var.inner;
7117         if (ret_var.is_owned) {
7118                 ret_ref |= 1;
7119         }
7120         return ret_ref;
7121 }
7122
7123 static inline struct LDKUpdateFailHTLC CResult_UpdateFailHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
7124 CHECK(owner->result_ok);
7125         return UpdateFailHTLC_clone(&*owner->contents.result);
7126 }
7127 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7128         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
7129         LDKUpdateFailHTLC ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_ok(owner_conv);
7130         uint32_t ret_ref = 0;
7131         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7132         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7133         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7134         ret_ref = (uintptr_t)ret_var.inner;
7135         if (ret_var.is_owned) {
7136                 ret_ref |= 1;
7137         }
7138         return ret_ref;
7139 }
7140
7141 static inline struct LDKDecodeError CResult_UpdateFailHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
7142 CHECK(!owner->result_ok);
7143         return DecodeError_clone(&*owner->contents.err);
7144 }
7145 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_get_err(uint32_t owner) {
7146         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
7147         LDKDecodeError ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_err(owner_conv);
7148         uint32_t ret_ref = 0;
7149         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7150         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7151         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7152         ret_ref = (uintptr_t)ret_var.inner;
7153         if (ret_var.is_owned) {
7154                 ret_ref |= 1;
7155         }
7156         return ret_ref;
7157 }
7158
7159 static inline struct LDKUpdateFailMalformedHTLC CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
7160 CHECK(owner->result_ok);
7161         return UpdateFailMalformedHTLC_clone(&*owner->contents.result);
7162 }
7163 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7164         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
7165         LDKUpdateFailMalformedHTLC ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(owner_conv);
7166         uint32_t ret_ref = 0;
7167         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7168         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7169         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7170         ret_ref = (uintptr_t)ret_var.inner;
7171         if (ret_var.is_owned) {
7172                 ret_ref |= 1;
7173         }
7174         return ret_ref;
7175 }
7176
7177 static inline struct LDKDecodeError CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
7178 CHECK(!owner->result_ok);
7179         return DecodeError_clone(&*owner->contents.err);
7180 }
7181 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(uint32_t owner) {
7182         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
7183         LDKDecodeError ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(owner_conv);
7184         uint32_t ret_ref = 0;
7185         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7186         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7187         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7188         ret_ref = (uintptr_t)ret_var.inner;
7189         if (ret_var.is_owned) {
7190                 ret_ref |= 1;
7191         }
7192         return ret_ref;
7193 }
7194
7195 static inline struct LDKUpdateFee CResult_UpdateFeeDecodeErrorZ_get_ok(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
7196 CHECK(owner->result_ok);
7197         return UpdateFee_clone(&*owner->contents.result);
7198 }
7199 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_get_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_get_ok(uint32_t owner) {
7200         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
7201         LDKUpdateFee ret_var = CResult_UpdateFeeDecodeErrorZ_get_ok(owner_conv);
7202         uint32_t ret_ref = 0;
7203         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7204         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7205         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7206         ret_ref = (uintptr_t)ret_var.inner;
7207         if (ret_var.is_owned) {
7208                 ret_ref |= 1;
7209         }
7210         return ret_ref;
7211 }
7212
7213 static inline struct LDKDecodeError CResult_UpdateFeeDecodeErrorZ_get_err(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
7214 CHECK(!owner->result_ok);
7215         return DecodeError_clone(&*owner->contents.err);
7216 }
7217 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_get_err"))) TS_CResult_UpdateFeeDecodeErrorZ_get_err(uint32_t owner) {
7218         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
7219         LDKDecodeError ret_var = CResult_UpdateFeeDecodeErrorZ_get_err(owner_conv);
7220         uint32_t ret_ref = 0;
7221         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7222         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7223         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7224         ret_ref = (uintptr_t)ret_var.inner;
7225         if (ret_var.is_owned) {
7226                 ret_ref |= 1;
7227         }
7228         return ret_ref;
7229 }
7230
7231 static inline struct LDKUpdateFulfillHTLC CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
7232 CHECK(owner->result_ok);
7233         return UpdateFulfillHTLC_clone(&*owner->contents.result);
7234 }
7235 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7236         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
7237         LDKUpdateFulfillHTLC ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(owner_conv);
7238         uint32_t ret_ref = 0;
7239         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7240         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7241         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7242         ret_ref = (uintptr_t)ret_var.inner;
7243         if (ret_var.is_owned) {
7244                 ret_ref |= 1;
7245         }
7246         return ret_ref;
7247 }
7248
7249 static inline struct LDKDecodeError CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
7250 CHECK(!owner->result_ok);
7251         return DecodeError_clone(&*owner->contents.err);
7252 }
7253 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(uint32_t owner) {
7254         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
7255         LDKDecodeError ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(owner_conv);
7256         uint32_t ret_ref = 0;
7257         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7258         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7259         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7260         ret_ref = (uintptr_t)ret_var.inner;
7261         if (ret_var.is_owned) {
7262                 ret_ref |= 1;
7263         }
7264         return ret_ref;
7265 }
7266
7267 static inline struct LDKUpdateAddHTLC CResult_UpdateAddHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
7268 CHECK(owner->result_ok);
7269         return UpdateAddHTLC_clone(&*owner->contents.result);
7270 }
7271 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7272         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
7273         LDKUpdateAddHTLC ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_ok(owner_conv);
7274         uint32_t ret_ref = 0;
7275         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7276         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7277         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7278         ret_ref = (uintptr_t)ret_var.inner;
7279         if (ret_var.is_owned) {
7280                 ret_ref |= 1;
7281         }
7282         return ret_ref;
7283 }
7284
7285 static inline struct LDKDecodeError CResult_UpdateAddHTLCDecodeErrorZ_get_err(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
7286 CHECK(!owner->result_ok);
7287         return DecodeError_clone(&*owner->contents.err);
7288 }
7289 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_get_err(uint32_t owner) {
7290         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
7291         LDKDecodeError ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_err(owner_conv);
7292         uint32_t ret_ref = 0;
7293         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7294         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7295         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7296         ret_ref = (uintptr_t)ret_var.inner;
7297         if (ret_var.is_owned) {
7298                 ret_ref |= 1;
7299         }
7300         return ret_ref;
7301 }
7302
7303 static inline struct LDKPing CResult_PingDecodeErrorZ_get_ok(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
7304 CHECK(owner->result_ok);
7305         return Ping_clone(&*owner->contents.result);
7306 }
7307 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_get_ok"))) TS_CResult_PingDecodeErrorZ_get_ok(uint32_t owner) {
7308         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
7309         LDKPing ret_var = CResult_PingDecodeErrorZ_get_ok(owner_conv);
7310         uint32_t ret_ref = 0;
7311         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7312         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7313         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7314         ret_ref = (uintptr_t)ret_var.inner;
7315         if (ret_var.is_owned) {
7316                 ret_ref |= 1;
7317         }
7318         return ret_ref;
7319 }
7320
7321 static inline struct LDKDecodeError CResult_PingDecodeErrorZ_get_err(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
7322 CHECK(!owner->result_ok);
7323         return DecodeError_clone(&*owner->contents.err);
7324 }
7325 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_get_err"))) TS_CResult_PingDecodeErrorZ_get_err(uint32_t owner) {
7326         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
7327         LDKDecodeError ret_var = CResult_PingDecodeErrorZ_get_err(owner_conv);
7328         uint32_t ret_ref = 0;
7329         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7330         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7331         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7332         ret_ref = (uintptr_t)ret_var.inner;
7333         if (ret_var.is_owned) {
7334                 ret_ref |= 1;
7335         }
7336         return ret_ref;
7337 }
7338
7339 static inline struct LDKPong CResult_PongDecodeErrorZ_get_ok(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
7340 CHECK(owner->result_ok);
7341         return Pong_clone(&*owner->contents.result);
7342 }
7343 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_get_ok"))) TS_CResult_PongDecodeErrorZ_get_ok(uint32_t owner) {
7344         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
7345         LDKPong ret_var = CResult_PongDecodeErrorZ_get_ok(owner_conv);
7346         uint32_t ret_ref = 0;
7347         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7348         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7349         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7350         ret_ref = (uintptr_t)ret_var.inner;
7351         if (ret_var.is_owned) {
7352                 ret_ref |= 1;
7353         }
7354         return ret_ref;
7355 }
7356
7357 static inline struct LDKDecodeError CResult_PongDecodeErrorZ_get_err(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
7358 CHECK(!owner->result_ok);
7359         return DecodeError_clone(&*owner->contents.err);
7360 }
7361 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_get_err"))) TS_CResult_PongDecodeErrorZ_get_err(uint32_t owner) {
7362         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
7363         LDKDecodeError ret_var = CResult_PongDecodeErrorZ_get_err(owner_conv);
7364         uint32_t ret_ref = 0;
7365         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7366         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7367         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7368         ret_ref = (uintptr_t)ret_var.inner;
7369         if (ret_var.is_owned) {
7370                 ret_ref |= 1;
7371         }
7372         return ret_ref;
7373 }
7374
7375 static inline struct LDKUnsignedChannelAnnouncement CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7376 CHECK(owner->result_ok);
7377         return UnsignedChannelAnnouncement_clone(&*owner->contents.result);
7378 }
7379 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7380         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7381         LDKUnsignedChannelAnnouncement ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
7382         uint32_t ret_ref = 0;
7383         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7384         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7385         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7386         ret_ref = (uintptr_t)ret_var.inner;
7387         if (ret_var.is_owned) {
7388                 ret_ref |= 1;
7389         }
7390         return ret_ref;
7391 }
7392
7393 static inline struct LDKDecodeError CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7394 CHECK(!owner->result_ok);
7395         return DecodeError_clone(&*owner->contents.err);
7396 }
7397 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7398         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7399         LDKDecodeError ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
7400         uint32_t ret_ref = 0;
7401         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7402         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7403         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7404         ret_ref = (uintptr_t)ret_var.inner;
7405         if (ret_var.is_owned) {
7406                 ret_ref |= 1;
7407         }
7408         return ret_ref;
7409 }
7410
7411 static inline struct LDKChannelAnnouncement CResult_ChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7412 CHECK(owner->result_ok);
7413         return ChannelAnnouncement_clone(&*owner->contents.result);
7414 }
7415 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7416         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7417         LDKChannelAnnouncement ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
7418         uint32_t ret_ref = 0;
7419         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7420         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7421         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7422         ret_ref = (uintptr_t)ret_var.inner;
7423         if (ret_var.is_owned) {
7424                 ret_ref |= 1;
7425         }
7426         return ret_ref;
7427 }
7428
7429 static inline struct LDKDecodeError CResult_ChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7430 CHECK(!owner->result_ok);
7431         return DecodeError_clone(&*owner->contents.err);
7432 }
7433 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_get_err"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7434         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7435         LDKDecodeError ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
7436         uint32_t ret_ref = 0;
7437         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7438         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7439         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7440         ret_ref = (uintptr_t)ret_var.inner;
7441         if (ret_var.is_owned) {
7442                 ret_ref |= 1;
7443         }
7444         return ret_ref;
7445 }
7446
7447 static inline struct LDKUnsignedChannelUpdate CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7448 CHECK(owner->result_ok);
7449         return UnsignedChannelUpdate_clone(&*owner->contents.result);
7450 }
7451 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(uint32_t owner) {
7452         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
7453         LDKUnsignedChannelUpdate ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(owner_conv);
7454         uint32_t ret_ref = 0;
7455         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7456         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7457         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7458         ret_ref = (uintptr_t)ret_var.inner;
7459         if (ret_var.is_owned) {
7460                 ret_ref |= 1;
7461         }
7462         return ret_ref;
7463 }
7464
7465 static inline struct LDKDecodeError CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7466 CHECK(!owner->result_ok);
7467         return DecodeError_clone(&*owner->contents.err);
7468 }
7469 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_err"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(uint32_t owner) {
7470         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
7471         LDKDecodeError ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(owner_conv);
7472         uint32_t ret_ref = 0;
7473         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7474         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7475         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7476         ret_ref = (uintptr_t)ret_var.inner;
7477         if (ret_var.is_owned) {
7478                 ret_ref |= 1;
7479         }
7480         return ret_ref;
7481 }
7482
7483 static inline struct LDKChannelUpdate CResult_ChannelUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7484 CHECK(owner->result_ok);
7485         return ChannelUpdate_clone(&*owner->contents.result);
7486 }
7487 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_get_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_get_ok(uint32_t owner) {
7488         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
7489         LDKChannelUpdate ret_var = CResult_ChannelUpdateDecodeErrorZ_get_ok(owner_conv);
7490         uint32_t ret_ref = 0;
7491         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7492         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7493         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7494         ret_ref = (uintptr_t)ret_var.inner;
7495         if (ret_var.is_owned) {
7496                 ret_ref |= 1;
7497         }
7498         return ret_ref;
7499 }
7500
7501 static inline struct LDKDecodeError CResult_ChannelUpdateDecodeErrorZ_get_err(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7502 CHECK(!owner->result_ok);
7503         return DecodeError_clone(&*owner->contents.err);
7504 }
7505 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_get_err"))) TS_CResult_ChannelUpdateDecodeErrorZ_get_err(uint32_t owner) {
7506         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
7507         LDKDecodeError ret_var = CResult_ChannelUpdateDecodeErrorZ_get_err(owner_conv);
7508         uint32_t ret_ref = 0;
7509         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7510         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7511         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7512         ret_ref = (uintptr_t)ret_var.inner;
7513         if (ret_var.is_owned) {
7514                 ret_ref |= 1;
7515         }
7516         return ret_ref;
7517 }
7518
7519 static inline struct LDKErrorMessage CResult_ErrorMessageDecodeErrorZ_get_ok(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
7520 CHECK(owner->result_ok);
7521         return ErrorMessage_clone(&*owner->contents.result);
7522 }
7523 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_get_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_get_ok(uint32_t owner) {
7524         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
7525         LDKErrorMessage ret_var = CResult_ErrorMessageDecodeErrorZ_get_ok(owner_conv);
7526         uint32_t ret_ref = 0;
7527         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7528         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7529         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7530         ret_ref = (uintptr_t)ret_var.inner;
7531         if (ret_var.is_owned) {
7532                 ret_ref |= 1;
7533         }
7534         return ret_ref;
7535 }
7536
7537 static inline struct LDKDecodeError CResult_ErrorMessageDecodeErrorZ_get_err(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
7538 CHECK(!owner->result_ok);
7539         return DecodeError_clone(&*owner->contents.err);
7540 }
7541 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_get_err"))) TS_CResult_ErrorMessageDecodeErrorZ_get_err(uint32_t owner) {
7542         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
7543         LDKDecodeError ret_var = CResult_ErrorMessageDecodeErrorZ_get_err(owner_conv);
7544         uint32_t ret_ref = 0;
7545         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7546         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7547         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7548         ret_ref = (uintptr_t)ret_var.inner;
7549         if (ret_var.is_owned) {
7550                 ret_ref |= 1;
7551         }
7552         return ret_ref;
7553 }
7554
7555 static inline struct LDKWarningMessage CResult_WarningMessageDecodeErrorZ_get_ok(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
7556 CHECK(owner->result_ok);
7557         return WarningMessage_clone(&*owner->contents.result);
7558 }
7559 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_get_ok"))) TS_CResult_WarningMessageDecodeErrorZ_get_ok(uint32_t owner) {
7560         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
7561         LDKWarningMessage ret_var = CResult_WarningMessageDecodeErrorZ_get_ok(owner_conv);
7562         uint32_t ret_ref = 0;
7563         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7564         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7565         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7566         ret_ref = (uintptr_t)ret_var.inner;
7567         if (ret_var.is_owned) {
7568                 ret_ref |= 1;
7569         }
7570         return ret_ref;
7571 }
7572
7573 static inline struct LDKDecodeError CResult_WarningMessageDecodeErrorZ_get_err(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
7574 CHECK(!owner->result_ok);
7575         return DecodeError_clone(&*owner->contents.err);
7576 }
7577 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_get_err"))) TS_CResult_WarningMessageDecodeErrorZ_get_err(uint32_t owner) {
7578         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
7579         LDKDecodeError ret_var = CResult_WarningMessageDecodeErrorZ_get_err(owner_conv);
7580         uint32_t ret_ref = 0;
7581         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7582         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7583         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7584         ret_ref = (uintptr_t)ret_var.inner;
7585         if (ret_var.is_owned) {
7586                 ret_ref |= 1;
7587         }
7588         return ret_ref;
7589 }
7590
7591 static inline struct LDKUnsignedNodeAnnouncement CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7592 CHECK(owner->result_ok);
7593         return UnsignedNodeAnnouncement_clone(&*owner->contents.result);
7594 }
7595 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7596         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
7597         LDKUnsignedNodeAnnouncement ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
7598         uint32_t ret_ref = 0;
7599         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7600         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7601         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7602         ret_ref = (uintptr_t)ret_var.inner;
7603         if (ret_var.is_owned) {
7604                 ret_ref |= 1;
7605         }
7606         return ret_ref;
7607 }
7608
7609 static inline struct LDKDecodeError CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7610 CHECK(!owner->result_ok);
7611         return DecodeError_clone(&*owner->contents.err);
7612 }
7613 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7614         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
7615         LDKDecodeError ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(owner_conv);
7616         uint32_t ret_ref = 0;
7617         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7618         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7619         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7620         ret_ref = (uintptr_t)ret_var.inner;
7621         if (ret_var.is_owned) {
7622                 ret_ref |= 1;
7623         }
7624         return ret_ref;
7625 }
7626
7627 static inline struct LDKNodeAnnouncement CResult_NodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7628 CHECK(owner->result_ok);
7629         return NodeAnnouncement_clone(&*owner->contents.result);
7630 }
7631 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7632         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
7633         LDKNodeAnnouncement ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
7634         uint32_t ret_ref = 0;
7635         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7636         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7637         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7638         ret_ref = (uintptr_t)ret_var.inner;
7639         if (ret_var.is_owned) {
7640                 ret_ref |= 1;
7641         }
7642         return ret_ref;
7643 }
7644
7645 static inline struct LDKDecodeError CResult_NodeAnnouncementDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7646 CHECK(!owner->result_ok);
7647         return DecodeError_clone(&*owner->contents.err);
7648 }
7649 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_get_err"))) TS_CResult_NodeAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7650         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
7651         LDKDecodeError ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_err(owner_conv);
7652         uint32_t ret_ref = 0;
7653         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7654         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7655         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7656         ret_ref = (uintptr_t)ret_var.inner;
7657         if (ret_var.is_owned) {
7658                 ret_ref |= 1;
7659         }
7660         return ret_ref;
7661 }
7662
7663 static inline struct LDKQueryShortChannelIds CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
7664 CHECK(owner->result_ok);
7665         return QueryShortChannelIds_clone(&*owner->contents.result);
7666 }
7667 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(uint32_t owner) {
7668         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
7669         LDKQueryShortChannelIds ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(owner_conv);
7670         uint32_t ret_ref = 0;
7671         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7672         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7673         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7674         ret_ref = (uintptr_t)ret_var.inner;
7675         if (ret_var.is_owned) {
7676                 ret_ref |= 1;
7677         }
7678         return ret_ref;
7679 }
7680
7681 static inline struct LDKDecodeError CResult_QueryShortChannelIdsDecodeErrorZ_get_err(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
7682 CHECK(!owner->result_ok);
7683         return DecodeError_clone(&*owner->contents.err);
7684 }
7685 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_err"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_err(uint32_t owner) {
7686         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
7687         LDKDecodeError ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_err(owner_conv);
7688         uint32_t ret_ref = 0;
7689         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7690         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7691         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7692         ret_ref = (uintptr_t)ret_var.inner;
7693         if (ret_var.is_owned) {
7694                 ret_ref |= 1;
7695         }
7696         return ret_ref;
7697 }
7698
7699 static inline struct LDKReplyShortChannelIdsEnd CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
7700 CHECK(owner->result_ok);
7701         return ReplyShortChannelIdsEnd_clone(&*owner->contents.result);
7702 }
7703 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(uint32_t owner) {
7704         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
7705         LDKReplyShortChannelIdsEnd ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(owner_conv);
7706         uint32_t ret_ref = 0;
7707         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7708         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7709         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7710         ret_ref = (uintptr_t)ret_var.inner;
7711         if (ret_var.is_owned) {
7712                 ret_ref |= 1;
7713         }
7714         return ret_ref;
7715 }
7716
7717 static inline struct LDKDecodeError CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
7718 CHECK(!owner->result_ok);
7719         return DecodeError_clone(&*owner->contents.err);
7720 }
7721 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(uint32_t owner) {
7722         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
7723         LDKDecodeError ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(owner_conv);
7724         uint32_t ret_ref = 0;
7725         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7726         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7727         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7728         ret_ref = (uintptr_t)ret_var.inner;
7729         if (ret_var.is_owned) {
7730                 ret_ref |= 1;
7731         }
7732         return ret_ref;
7733 }
7734
7735 static inline struct LDKQueryChannelRange CResult_QueryChannelRangeDecodeErrorZ_get_ok(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
7736 CHECK(owner->result_ok);
7737         return QueryChannelRange_clone(&*owner->contents.result);
7738 }
7739 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_get_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_get_ok(uint32_t owner) {
7740         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
7741         LDKQueryChannelRange ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_ok(owner_conv);
7742         uint32_t ret_ref = 0;
7743         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7744         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7745         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7746         ret_ref = (uintptr_t)ret_var.inner;
7747         if (ret_var.is_owned) {
7748                 ret_ref |= 1;
7749         }
7750         return ret_ref;
7751 }
7752
7753 static inline struct LDKDecodeError CResult_QueryChannelRangeDecodeErrorZ_get_err(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
7754 CHECK(!owner->result_ok);
7755         return DecodeError_clone(&*owner->contents.err);
7756 }
7757 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_get_err"))) TS_CResult_QueryChannelRangeDecodeErrorZ_get_err(uint32_t owner) {
7758         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
7759         LDKDecodeError ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_err(owner_conv);
7760         uint32_t ret_ref = 0;
7761         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7762         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7763         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7764         ret_ref = (uintptr_t)ret_var.inner;
7765         if (ret_var.is_owned) {
7766                 ret_ref |= 1;
7767         }
7768         return ret_ref;
7769 }
7770
7771 static inline struct LDKReplyChannelRange CResult_ReplyChannelRangeDecodeErrorZ_get_ok(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
7772 CHECK(owner->result_ok);
7773         return ReplyChannelRange_clone(&*owner->contents.result);
7774 }
7775 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_get_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_get_ok(uint32_t owner) {
7776         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
7777         LDKReplyChannelRange ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_ok(owner_conv);
7778         uint32_t ret_ref = 0;
7779         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7780         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7781         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7782         ret_ref = (uintptr_t)ret_var.inner;
7783         if (ret_var.is_owned) {
7784                 ret_ref |= 1;
7785         }
7786         return ret_ref;
7787 }
7788
7789 static inline struct LDKDecodeError CResult_ReplyChannelRangeDecodeErrorZ_get_err(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
7790 CHECK(!owner->result_ok);
7791         return DecodeError_clone(&*owner->contents.err);
7792 }
7793 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_get_err"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_get_err(uint32_t owner) {
7794         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
7795         LDKDecodeError ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_err(owner_conv);
7796         uint32_t ret_ref = 0;
7797         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7798         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7799         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7800         ret_ref = (uintptr_t)ret_var.inner;
7801         if (ret_var.is_owned) {
7802                 ret_ref |= 1;
7803         }
7804         return ret_ref;
7805 }
7806
7807 static inline struct LDKGossipTimestampFilter CResult_GossipTimestampFilterDecodeErrorZ_get_ok(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
7808 CHECK(owner->result_ok);
7809         return GossipTimestampFilter_clone(&*owner->contents.result);
7810 }
7811 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_get_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_get_ok(uint32_t owner) {
7812         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
7813         LDKGossipTimestampFilter ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_ok(owner_conv);
7814         uint32_t ret_ref = 0;
7815         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7816         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7817         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7818         ret_ref = (uintptr_t)ret_var.inner;
7819         if (ret_var.is_owned) {
7820                 ret_ref |= 1;
7821         }
7822         return ret_ref;
7823 }
7824
7825 static inline struct LDKDecodeError CResult_GossipTimestampFilterDecodeErrorZ_get_err(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
7826 CHECK(!owner->result_ok);
7827         return DecodeError_clone(&*owner->contents.err);
7828 }
7829 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_get_err"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_get_err(uint32_t owner) {
7830         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
7831         LDKDecodeError ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_err(owner_conv);
7832         uint32_t ret_ref = 0;
7833         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7834         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7835         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7836         ret_ref = (uintptr_t)ret_var.inner;
7837         if (ret_var.is_owned) {
7838                 ret_ref |= 1;
7839         }
7840         return ret_ref;
7841 }
7842
7843 uint32_t __attribute__((export_name("TS_LDKSignOrCreationError_ty_from_ptr"))) TS_LDKSignOrCreationError_ty_from_ptr(uint32_t ptr) {
7844         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
7845         switch(obj->tag) {
7846                 case LDKSignOrCreationError_SignError: return 0;
7847                 case LDKSignOrCreationError_CreationError: return 1;
7848                 default: abort();
7849         }
7850 }
7851 uint32_t __attribute__((export_name("TS_LDKSignOrCreationError_CreationError_get_creation_error"))) TS_LDKSignOrCreationError_CreationError_get_creation_error(uint32_t ptr) {
7852         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
7853         assert(obj->tag == LDKSignOrCreationError_CreationError);
7854                         uint32_t creation_error_conv = LDKCreationError_to_js(obj->creation_error);
7855         return creation_error_conv;
7856 }
7857 static inline struct LDKInvoice CResult_InvoiceSignOrCreationErrorZ_get_ok(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
7858 CHECK(owner->result_ok);
7859         return Invoice_clone(&*owner->contents.result);
7860 }
7861 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_get_ok"))) TS_CResult_InvoiceSignOrCreationErrorZ_get_ok(uint32_t owner) {
7862         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
7863         LDKInvoice ret_var = CResult_InvoiceSignOrCreationErrorZ_get_ok(owner_conv);
7864         uint32_t ret_ref = 0;
7865         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7866         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7867         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7868         ret_ref = (uintptr_t)ret_var.inner;
7869         if (ret_var.is_owned) {
7870                 ret_ref |= 1;
7871         }
7872         return ret_ref;
7873 }
7874
7875 static inline struct LDKSignOrCreationError CResult_InvoiceSignOrCreationErrorZ_get_err(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
7876 CHECK(!owner->result_ok);
7877         return SignOrCreationError_clone(&*owner->contents.err);
7878 }
7879 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_get_err"))) TS_CResult_InvoiceSignOrCreationErrorZ_get_err(uint32_t owner) {
7880         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
7881         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
7882         *ret_copy = CResult_InvoiceSignOrCreationErrorZ_get_err(owner_conv);
7883         uint32_t ret_ref = (uintptr_t)ret_copy;
7884         return ret_ref;
7885 }
7886
7887 typedef struct LDKFilter_JCalls {
7888         atomic_size_t refcnt;
7889         uint32_t instance_ptr;
7890 } LDKFilter_JCalls;
7891 static void LDKFilter_JCalls_free(void* this_arg) {
7892         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7893         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7894                 FREE(j_calls);
7895         }
7896 }
7897 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
7898         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7899         int8_tArray txid_arr = init_int8_tArray(32, __LINE__);
7900         memcpy(txid_arr->elems, *txid, 32);
7901         LDKu8slice script_pubkey_var = script_pubkey;
7902         int8_tArray script_pubkey_arr = init_int8_tArray(script_pubkey_var.datalen, __LINE__);
7903         memcpy(script_pubkey_arr->elems, script_pubkey_var.data, script_pubkey_var.datalen);
7904         js_invoke_function_2(j_calls->instance_ptr, 32, (uint32_t)txid_arr, (uint32_t)script_pubkey_arr);
7905 }
7906 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
7907         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7908         LDKWatchedOutput output_var = output;
7909         uint32_t output_ref = 0;
7910         CHECK((((uintptr_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7911         CHECK((((uintptr_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7912         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
7913         output_ref = (uintptr_t)output_var.inner;
7914         if (output_var.is_owned) {
7915                 output_ref |= 1;
7916         }
7917         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 33, (uint32_t)output_ref);
7918         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
7919         CHECK_ACCESS(ret_ptr);
7920         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(ret_ptr);
7921         FREE((void*)ret);
7922         return ret_conv;
7923 }
7924 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
7925         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
7926         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7927 }
7928 static inline LDKFilter LDKFilter_init (JSValue o) {
7929         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
7930         atomic_init(&calls->refcnt, 1);
7931         calls->instance_ptr = o;
7932
7933         LDKFilter ret = {
7934                 .this_arg = (void*) calls,
7935                 .register_tx = register_tx_LDKFilter_jcall,
7936                 .register_output = register_output_LDKFilter_jcall,
7937                 .free = LDKFilter_JCalls_free,
7938         };
7939         return ret;
7940 }
7941 long  __attribute__((export_name("TS_LDKFilter_new"))) TS_LDKFilter_new(JSValue o) {
7942         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
7943         *res_ptr = LDKFilter_init(o);
7944         return (long)res_ptr;
7945 }
7946 void  __attribute__((export_name("TS_Filter_register_tx"))) TS_Filter_register_tx(uint32_t this_arg, int8_tArray txid, int8_tArray script_pubkey) {
7947         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7948         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7949         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
7950         unsigned char txid_arr[32];
7951         CHECK(txid->arr_len == 32);
7952         memcpy(txid_arr, txid->elems, 32); FREE(txid);
7953         unsigned char (*txid_ref)[32] = &txid_arr;
7954         LDKu8slice script_pubkey_ref;
7955         script_pubkey_ref.datalen = script_pubkey->arr_len;
7956         script_pubkey_ref.data = script_pubkey->elems /* XXX script_pubkey leaks */;
7957         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
7958 }
7959
7960 uint32_t  __attribute__((export_name("TS_Filter_register_output"))) TS_Filter_register_output(uint32_t this_arg, uint32_t output) {
7961         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7962         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7963         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
7964         LDKWatchedOutput output_conv;
7965         output_conv.inner = (void*)(output & (~1));
7966         output_conv.is_owned = (output & 1) || (output == 0);
7967         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
7968         output_conv = WatchedOutput_clone(&output_conv);
7969         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
7970         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
7971         uint32_t ret_ref = (uintptr_t)ret_copy;
7972         return ret_ref;
7973 }
7974
7975 uint32_t __attribute__((export_name("TS_LDKCOption_FilterZ_ty_from_ptr"))) TS_LDKCOption_FilterZ_ty_from_ptr(uint32_t ptr) {
7976         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
7977         switch(obj->tag) {
7978                 case LDKCOption_FilterZ_Some: return 0;
7979                 case LDKCOption_FilterZ_None: return 1;
7980                 default: abort();
7981         }
7982 }
7983 uint32_t __attribute__((export_name("TS_LDKCOption_FilterZ_Some_get_some"))) TS_LDKCOption_FilterZ_Some_get_some(uint32_t ptr) {
7984         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
7985         assert(obj->tag == LDKCOption_FilterZ_Some);
7986                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
7987                         *some_ret = obj->some;
7988                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
7989                         if ((*some_ret).free == LDKFilter_JCalls_free) {
7990                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7991                                 LDKFilter_JCalls_cloned(&(*some_ret));
7992                         }
7993         return (uint32_t)some_ret;
7994 }
7995 static inline struct LDKLockedChannelMonitor *CResult_LockedChannelMonitorNoneZ_get_ok(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
7996 CHECK(owner->result_ok);
7997         return &*owner->contents.result;
7998 }
7999 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_get_ok"))) TS_CResult_LockedChannelMonitorNoneZ_get_ok(uint32_t owner) {
8000         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
8001         LDKLockedChannelMonitor ret_var = *CResult_LockedChannelMonitorNoneZ_get_ok(owner_conv);
8002         uint32_t ret_ref = 0;
8003         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8004         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8005         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8006         ret_ref = (uintptr_t)ret_var.inner & ~1;
8007         return ret_ref;
8008 }
8009
8010 static inline void CResult_LockedChannelMonitorNoneZ_get_err(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
8011 CHECK(!owner->result_ok);
8012         return *owner->contents.err;
8013 }
8014 void  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_get_err"))) TS_CResult_LockedChannelMonitorNoneZ_get_err(uint32_t owner) {
8015         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
8016         CResult_LockedChannelMonitorNoneZ_get_err(owner_conv);
8017 }
8018
8019 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
8020         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
8021         for (size_t i = 0; i < ret.datalen; i++) {
8022                 ret.data[i] = OutPoint_clone(&orig->data[i]);
8023         }
8024         return ret;
8025 }
8026 typedef struct LDKMessageSendEventsProvider_JCalls {
8027         atomic_size_t refcnt;
8028         uint32_t instance_ptr;
8029 } LDKMessageSendEventsProvider_JCalls;
8030 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
8031         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
8032         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8033                 FREE(j_calls);
8034         }
8035 }
8036 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
8037         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
8038         uint32_tArray ret = (uint32_tArray)js_invoke_function_0(j_calls->instance_ptr, 34);
8039         LDKCVec_MessageSendEventZ ret_constr;
8040         ret_constr.datalen = ret->arr_len;
8041         if (ret_constr.datalen > 0)
8042                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
8043         else
8044                 ret_constr.data = NULL;
8045         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
8046         for (size_t s = 0; s < ret_constr.datalen; s++) {
8047                 uint32_t ret_conv_18 = ret_vals[s];
8048                 void* ret_conv_18_ptr = (void*)(((uintptr_t)ret_conv_18) & ~1);
8049                 CHECK_ACCESS(ret_conv_18_ptr);
8050                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
8051                 FREE((void*)ret_conv_18);
8052                 ret_constr.data[s] = ret_conv_18_conv;
8053         }
8054         return ret_constr;
8055 }
8056 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
8057         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
8058         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8059 }
8060 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JSValue o) {
8061         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
8062         atomic_init(&calls->refcnt, 1);
8063         calls->instance_ptr = o;
8064
8065         LDKMessageSendEventsProvider ret = {
8066                 .this_arg = (void*) calls,
8067                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
8068                 .free = LDKMessageSendEventsProvider_JCalls_free,
8069         };
8070         return ret;
8071 }
8072 long  __attribute__((export_name("TS_LDKMessageSendEventsProvider_new"))) TS_LDKMessageSendEventsProvider_new(JSValue o) {
8073         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
8074         *res_ptr = LDKMessageSendEventsProvider_init(o);
8075         return (long)res_ptr;
8076 }
8077 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) {
8078         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8079         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8080         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
8081         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
8082         uint32_tArray ret_arr = NULL;
8083         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
8084         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
8085         for (size_t s = 0; s < ret_var.datalen; s++) {
8086                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
8087                 *ret_conv_18_copy = ret_var.data[s];
8088                 uint32_t ret_conv_18_ref = (uintptr_t)ret_conv_18_copy;
8089                 ret_arr_ptr[s] = ret_conv_18_ref;
8090         }
8091         
8092         FREE(ret_var.data);
8093         return ret_arr;
8094 }
8095
8096 typedef struct LDKEventHandler_JCalls {
8097         atomic_size_t refcnt;
8098         uint32_t instance_ptr;
8099 } LDKEventHandler_JCalls;
8100 static void LDKEventHandler_JCalls_free(void* this_arg) {
8101         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
8102         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8103                 FREE(j_calls);
8104         }
8105 }
8106 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
8107         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
8108         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
8109         *ret_event = Event_clone(event);
8110         js_invoke_function_1(j_calls->instance_ptr, 35, (uint32_t)(uint32_t)ret_event);
8111 }
8112 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
8113         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
8114         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8115 }
8116 static inline LDKEventHandler LDKEventHandler_init (JSValue o) {
8117         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
8118         atomic_init(&calls->refcnt, 1);
8119         calls->instance_ptr = o;
8120
8121         LDKEventHandler ret = {
8122                 .this_arg = (void*) calls,
8123                 .handle_event = handle_event_LDKEventHandler_jcall,
8124                 .free = LDKEventHandler_JCalls_free,
8125         };
8126         return ret;
8127 }
8128 long  __attribute__((export_name("TS_LDKEventHandler_new"))) TS_LDKEventHandler_new(JSValue o) {
8129         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
8130         *res_ptr = LDKEventHandler_init(o);
8131         return (long)res_ptr;
8132 }
8133 void  __attribute__((export_name("TS_EventHandler_handle_event"))) TS_EventHandler_handle_event(uint32_t this_arg, uint32_t event) {
8134         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8135         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8136         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
8137         LDKEvent* event_conv = (LDKEvent*)event;
8138         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
8139 }
8140
8141 typedef struct LDKEventsProvider_JCalls {
8142         atomic_size_t refcnt;
8143         uint32_t instance_ptr;
8144 } LDKEventsProvider_JCalls;
8145 static void LDKEventsProvider_JCalls_free(void* this_arg) {
8146         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
8147         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8148                 FREE(j_calls);
8149         }
8150 }
8151 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
8152         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
8153         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
8154         *handler_ret = handler;
8155         js_invoke_function_1(j_calls->instance_ptr, 36, (uint32_t)(uint32_t)handler_ret);
8156 }
8157 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
8158         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
8159         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8160 }
8161 static inline LDKEventsProvider LDKEventsProvider_init (JSValue o) {
8162         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
8163         atomic_init(&calls->refcnt, 1);
8164         calls->instance_ptr = o;
8165
8166         LDKEventsProvider ret = {
8167                 .this_arg = (void*) calls,
8168                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
8169                 .free = LDKEventsProvider_JCalls_free,
8170         };
8171         return ret;
8172 }
8173 long  __attribute__((export_name("TS_LDKEventsProvider_new"))) TS_LDKEventsProvider_new(JSValue o) {
8174         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
8175         *res_ptr = LDKEventsProvider_init(o);
8176         return (long)res_ptr;
8177 }
8178 void  __attribute__((export_name("TS_EventsProvider_process_pending_events"))) TS_EventsProvider_process_pending_events(uint32_t this_arg, uint32_t handler) {
8179         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8180         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8181         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
8182         void* handler_ptr = (void*)(((uintptr_t)handler) & ~1);
8183         CHECK_ACCESS(handler_ptr);
8184         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
8185         if (handler_conv.free == LDKEventHandler_JCalls_free) {
8186                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
8187                 LDKEventHandler_JCalls_cloned(&handler_conv);
8188         }
8189         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
8190 }
8191
8192 typedef struct LDKListen_JCalls {
8193         atomic_size_t refcnt;
8194         uint32_t instance_ptr;
8195 } LDKListen_JCalls;
8196 static void LDKListen_JCalls_free(void* this_arg) {
8197         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
8198         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8199                 FREE(j_calls);
8200         }
8201 }
8202 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
8203         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
8204         LDKu8slice block_var = block;
8205         int8_tArray block_arr = init_int8_tArray(block_var.datalen, __LINE__);
8206         memcpy(block_arr->elems, block_var.data, block_var.datalen);
8207         int32_t height_conv = height;
8208         js_invoke_function_2(j_calls->instance_ptr, 37, (uint32_t)block_arr, (uint32_t)height_conv);
8209 }
8210 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
8211         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
8212         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
8213         memcpy(header_arr->elems, *header, 80);
8214         int32_t height_conv = height;
8215         js_invoke_function_2(j_calls->instance_ptr, 38, (uint32_t)header_arr, (uint32_t)height_conv);
8216 }
8217 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
8218         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
8219         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8220 }
8221 static inline LDKListen LDKListen_init (JSValue o) {
8222         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
8223         atomic_init(&calls->refcnt, 1);
8224         calls->instance_ptr = o;
8225
8226         LDKListen ret = {
8227                 .this_arg = (void*) calls,
8228                 .block_connected = block_connected_LDKListen_jcall,
8229                 .block_disconnected = block_disconnected_LDKListen_jcall,
8230                 .free = LDKListen_JCalls_free,
8231         };
8232         return ret;
8233 }
8234 long  __attribute__((export_name("TS_LDKListen_new"))) TS_LDKListen_new(JSValue o) {
8235         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
8236         *res_ptr = LDKListen_init(o);
8237         return (long)res_ptr;
8238 }
8239 void  __attribute__((export_name("TS_Listen_block_connected"))) TS_Listen_block_connected(uint32_t this_arg, int8_tArray block, int32_t height) {
8240         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8241         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8242         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
8243         LDKu8slice block_ref;
8244         block_ref.datalen = block->arr_len;
8245         block_ref.data = block->elems /* XXX block leaks */;
8246         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
8247 }
8248
8249 void  __attribute__((export_name("TS_Listen_block_disconnected"))) TS_Listen_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t height) {
8250         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8251         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8252         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
8253         unsigned char header_arr[80];
8254         CHECK(header->arr_len == 80);
8255         memcpy(header_arr, header->elems, 80); FREE(header);
8256         unsigned char (*header_ref)[80] = &header_arr;
8257         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
8258 }
8259
8260 typedef struct LDKConfirm_JCalls {
8261         atomic_size_t refcnt;
8262         uint32_t instance_ptr;
8263 } LDKConfirm_JCalls;
8264 static void LDKConfirm_JCalls_free(void* this_arg) {
8265         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8266         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8267                 FREE(j_calls);
8268         }
8269 }
8270 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
8271         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8272         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
8273         memcpy(header_arr->elems, *header, 80);
8274         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
8275         uint32_tArray txdata_arr = NULL;
8276         txdata_arr = init_uint32_tArray(txdata_var.datalen, __LINE__);
8277         uint32_t *txdata_arr_ptr = (uint32_t*)(((uint8_t*)txdata_arr) + 4);
8278         for (size_t c = 0; c < txdata_var.datalen; c++) {
8279                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
8280                 *txdata_conv_28_conv = txdata_var.data[c];
8281                 txdata_arr_ptr[c] = ((uint32_t)txdata_conv_28_conv);
8282         }
8283         
8284         FREE(txdata_var.data);
8285         int32_t height_conv = height;
8286         js_invoke_function_3(j_calls->instance_ptr, 39, (uint32_t)header_arr, (uint32_t)txdata_arr, (uint32_t)height_conv);
8287 }
8288 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
8289         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8290         int8_tArray txid_arr = init_int8_tArray(32, __LINE__);
8291         memcpy(txid_arr->elems, *txid, 32);
8292         js_invoke_function_1(j_calls->instance_ptr, 40, (uint32_t)txid_arr);
8293 }
8294 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
8295         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8296         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
8297         memcpy(header_arr->elems, *header, 80);
8298         int32_t height_conv = height;
8299         js_invoke_function_2(j_calls->instance_ptr, 41, (uint32_t)header_arr, (uint32_t)height_conv);
8300 }
8301 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
8302         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8303         ptrArray ret = (ptrArray)js_invoke_function_0(j_calls->instance_ptr, 42);
8304         LDKCVec_TxidZ ret_constr;
8305         ret_constr.datalen = ret->arr_len;
8306         if (ret_constr.datalen > 0)
8307                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
8308         else
8309                 ret_constr.data = NULL;
8310         int8_tArray* ret_vals = (void*) ret->elems /* XXX ret leaks */;
8311         for (size_t m = 0; m < ret_constr.datalen; m++) {
8312                 int8_tArray ret_conv_12 = ret_vals[m];
8313                 LDKThirtyTwoBytes ret_conv_12_ref;
8314                 CHECK(ret_conv_12->arr_len == 32);
8315                 memcpy(ret_conv_12_ref.data, ret_conv_12->elems, 32); FREE(ret_conv_12);
8316                 ret_constr.data[m] = ret_conv_12_ref;
8317         }
8318         return ret_constr;
8319 }
8320 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
8321         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
8322         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8323 }
8324 static inline LDKConfirm LDKConfirm_init (JSValue o) {
8325         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
8326         atomic_init(&calls->refcnt, 1);
8327         calls->instance_ptr = o;
8328
8329         LDKConfirm ret = {
8330                 .this_arg = (void*) calls,
8331                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
8332                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
8333                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
8334                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
8335                 .free = LDKConfirm_JCalls_free,
8336         };
8337         return ret;
8338 }
8339 long  __attribute__((export_name("TS_LDKConfirm_new"))) TS_LDKConfirm_new(JSValue o) {
8340         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
8341         *res_ptr = LDKConfirm_init(o);
8342         return (long)res_ptr;
8343 }
8344 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) {
8345         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8346         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8347         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8348         unsigned char header_arr[80];
8349         CHECK(header->arr_len == 80);
8350         memcpy(header_arr, header->elems, 80); FREE(header);
8351         unsigned char (*header_ref)[80] = &header_arr;
8352         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
8353         txdata_constr.datalen = txdata->arr_len;
8354         if (txdata_constr.datalen > 0)
8355                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
8356         else
8357                 txdata_constr.data = NULL;
8358         uint32_t* txdata_vals = txdata->elems /* XXX txdata leaks */;
8359         for (size_t c = 0; c < txdata_constr.datalen; c++) {
8360                 uint32_t txdata_conv_28 = txdata_vals[c];
8361                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
8362                 CHECK_ACCESS(txdata_conv_28_ptr);
8363                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
8364                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
8365                 txdata_constr.data[c] = txdata_conv_28_conv;
8366         }
8367         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
8368 }
8369
8370 void  __attribute__((export_name("TS_Confirm_transaction_unconfirmed"))) TS_Confirm_transaction_unconfirmed(uint32_t this_arg, int8_tArray txid) {
8371         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8372         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8373         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8374         unsigned char txid_arr[32];
8375         CHECK(txid->arr_len == 32);
8376         memcpy(txid_arr, txid->elems, 32); FREE(txid);
8377         unsigned char (*txid_ref)[32] = &txid_arr;
8378         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
8379 }
8380
8381 void  __attribute__((export_name("TS_Confirm_best_block_updated"))) TS_Confirm_best_block_updated(uint32_t this_arg, int8_tArray header, int32_t height) {
8382         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8383         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8384         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8385         unsigned char header_arr[80];
8386         CHECK(header->arr_len == 80);
8387         memcpy(header_arr, header->elems, 80); FREE(header);
8388         unsigned char (*header_ref)[80] = &header_arr;
8389         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
8390 }
8391
8392 ptrArray  __attribute__((export_name("TS_Confirm_get_relevant_txids"))) TS_Confirm_get_relevant_txids(uint32_t this_arg) {
8393         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8394         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8395         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8396         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
8397         ptrArray ret_arr = NULL;
8398         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
8399         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
8400         for (size_t m = 0; m < ret_var.datalen; m++) {
8401                 int8_tArray ret_conv_12_arr = init_int8_tArray(32, __LINE__);
8402                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].data, 32);
8403                 ret_arr_ptr[m] = ret_conv_12_arr;
8404         }
8405         
8406         FREE(ret_var.data);
8407         return ret_arr;
8408 }
8409
8410 typedef struct LDKPersist_JCalls {
8411         atomic_size_t refcnt;
8412         uint32_t instance_ptr;
8413 } LDKPersist_JCalls;
8414 static void LDKPersist_JCalls_free(void* this_arg) {
8415         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
8416         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8417                 FREE(j_calls);
8418         }
8419 }
8420 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
8421         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
8422         LDKOutPoint channel_id_var = channel_id;
8423         uint32_t channel_id_ref = 0;
8424         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8425         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8426         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
8427         channel_id_ref = (uintptr_t)channel_id_var.inner;
8428         if (channel_id_var.is_owned) {
8429                 channel_id_ref |= 1;
8430         }
8431         LDKChannelMonitor data_var = *data;
8432         uint32_t data_ref = 0;
8433         data_var = ChannelMonitor_clone(&data_var);
8434         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8435         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8436         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
8437         data_ref = (uintptr_t)data_var.inner;
8438         if (data_var.is_owned) {
8439                 data_ref |= 1;
8440         }
8441         LDKMonitorUpdateId update_id_var = update_id;
8442         uint32_t update_id_ref = 0;
8443         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8444         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8445         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
8446         update_id_ref = (uintptr_t)update_id_var.inner;
8447         if (update_id_var.is_owned) {
8448                 update_id_ref |= 1;
8449         }
8450         uint32_t ret = js_invoke_function_3(j_calls->instance_ptr, 43, (uint32_t)channel_id_ref, (uint32_t)data_ref, (uint32_t)update_id_ref);
8451         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8452         CHECK_ACCESS(ret_ptr);
8453         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
8454         FREE((void*)ret);
8455         return ret_conv;
8456 }
8457 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
8458         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
8459         LDKOutPoint channel_id_var = channel_id;
8460         uint32_t channel_id_ref = 0;
8461         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8462         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8463         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
8464         channel_id_ref = (uintptr_t)channel_id_var.inner;
8465         if (channel_id_var.is_owned) {
8466                 channel_id_ref |= 1;
8467         }
8468         LDKChannelMonitorUpdate update_var = *update;
8469         uint32_t update_ref = 0;
8470         if ((uintptr_t)update_var.inner > 4096) {
8471                 update_var = ChannelMonitorUpdate_clone(&update_var);
8472                 CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8473                 CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8474         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
8475                 update_ref = (uintptr_t)update_var.inner;
8476                 if (update_var.is_owned) {
8477                         update_ref |= 1;
8478                 }
8479         }
8480         LDKChannelMonitor data_var = *data;
8481         uint32_t data_ref = 0;
8482         data_var = ChannelMonitor_clone(&data_var);
8483         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8484         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8485         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
8486         data_ref = (uintptr_t)data_var.inner;
8487         if (data_var.is_owned) {
8488                 data_ref |= 1;
8489         }
8490         LDKMonitorUpdateId update_id_var = update_id;
8491         uint32_t update_id_ref = 0;
8492         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8493         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8494         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
8495         update_id_ref = (uintptr_t)update_id_var.inner;
8496         if (update_id_var.is_owned) {
8497                 update_id_ref |= 1;
8498         }
8499         uint32_t ret = js_invoke_function_4(j_calls->instance_ptr, 44, (uint32_t)channel_id_ref, (uint32_t)update_ref, (uint32_t)data_ref, (uint32_t)update_id_ref);
8500         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8501         CHECK_ACCESS(ret_ptr);
8502         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
8503         FREE((void*)ret);
8504         return ret_conv;
8505 }
8506 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
8507         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
8508         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8509 }
8510 static inline LDKPersist LDKPersist_init (JSValue o) {
8511         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
8512         atomic_init(&calls->refcnt, 1);
8513         calls->instance_ptr = o;
8514
8515         LDKPersist ret = {
8516                 .this_arg = (void*) calls,
8517                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
8518                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
8519                 .free = LDKPersist_JCalls_free,
8520         };
8521         return ret;
8522 }
8523 long  __attribute__((export_name("TS_LDKPersist_new"))) TS_LDKPersist_new(JSValue o) {
8524         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
8525         *res_ptr = LDKPersist_init(o);
8526         return (long)res_ptr;
8527 }
8528 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) {
8529         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8530         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8531         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
8532         LDKOutPoint channel_id_conv;
8533         channel_id_conv.inner = (void*)(channel_id & (~1));
8534         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
8535         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
8536         channel_id_conv = OutPoint_clone(&channel_id_conv);
8537         LDKChannelMonitor data_conv;
8538         data_conv.inner = (void*)(data & (~1));
8539         data_conv.is_owned = false;
8540         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
8541         LDKMonitorUpdateId update_id_conv;
8542         update_id_conv.inner = (void*)(update_id & (~1));
8543         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
8544         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
8545         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
8546         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
8547         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv);
8548         return (uint32_t)ret_conv;
8549 }
8550
8551 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) {
8552         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8553         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8554         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
8555         LDKOutPoint channel_id_conv;
8556         channel_id_conv.inner = (void*)(channel_id & (~1));
8557         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
8558         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
8559         channel_id_conv = OutPoint_clone(&channel_id_conv);
8560         LDKChannelMonitorUpdate update_conv;
8561         update_conv.inner = (void*)(update & (~1));
8562         update_conv.is_owned = false;
8563         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
8564         LDKChannelMonitor data_conv;
8565         data_conv.inner = (void*)(data & (~1));
8566         data_conv.is_owned = false;
8567         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
8568         LDKMonitorUpdateId update_id_conv;
8569         update_id_conv.inner = (void*)(update_id & (~1));
8570         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
8571         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
8572         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
8573         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
8574         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv);
8575         return (uint32_t)ret_conv;
8576 }
8577
8578 typedef struct LDKChannelMessageHandler_JCalls {
8579         atomic_size_t refcnt;
8580         uint32_t instance_ptr;
8581         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
8582 } LDKChannelMessageHandler_JCalls;
8583 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
8584         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8585         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8586                 FREE(j_calls);
8587         }
8588 }
8589 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
8590         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8591         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8592         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8593         LDKInitFeatures their_features_var = their_features;
8594         uint32_t their_features_ref = 0;
8595         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8596         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8597         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
8598         their_features_ref = (uintptr_t)their_features_var.inner;
8599         if (their_features_var.is_owned) {
8600                 their_features_ref |= 1;
8601         }
8602         LDKOpenChannel msg_var = *msg;
8603         uint32_t msg_ref = 0;
8604         msg_var = OpenChannel_clone(&msg_var);
8605         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8606         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8607         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8608         msg_ref = (uintptr_t)msg_var.inner;
8609         if (msg_var.is_owned) {
8610                 msg_ref |= 1;
8611         }
8612         js_invoke_function_3(j_calls->instance_ptr, 45, (uint32_t)their_node_id_arr, (uint32_t)their_features_ref, (uint32_t)msg_ref);
8613 }
8614 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
8615         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8616         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8617         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8618         LDKInitFeatures their_features_var = their_features;
8619         uint32_t their_features_ref = 0;
8620         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8621         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8622         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
8623         their_features_ref = (uintptr_t)their_features_var.inner;
8624         if (their_features_var.is_owned) {
8625                 their_features_ref |= 1;
8626         }
8627         LDKAcceptChannel msg_var = *msg;
8628         uint32_t msg_ref = 0;
8629         msg_var = AcceptChannel_clone(&msg_var);
8630         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8631         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8632         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8633         msg_ref = (uintptr_t)msg_var.inner;
8634         if (msg_var.is_owned) {
8635                 msg_ref |= 1;
8636         }
8637         js_invoke_function_3(j_calls->instance_ptr, 46, (uint32_t)their_node_id_arr, (uint32_t)their_features_ref, (uint32_t)msg_ref);
8638 }
8639 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
8640         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8641         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8642         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8643         LDKFundingCreated msg_var = *msg;
8644         uint32_t msg_ref = 0;
8645         msg_var = FundingCreated_clone(&msg_var);
8646         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8647         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8648         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8649         msg_ref = (uintptr_t)msg_var.inner;
8650         if (msg_var.is_owned) {
8651                 msg_ref |= 1;
8652         }
8653         js_invoke_function_2(j_calls->instance_ptr, 47, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8654 }
8655 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
8656         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8657         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8658         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8659         LDKFundingSigned msg_var = *msg;
8660         uint32_t msg_ref = 0;
8661         msg_var = FundingSigned_clone(&msg_var);
8662         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8663         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8664         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8665         msg_ref = (uintptr_t)msg_var.inner;
8666         if (msg_var.is_owned) {
8667                 msg_ref |= 1;
8668         }
8669         js_invoke_function_2(j_calls->instance_ptr, 48, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8670 }
8671 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
8672         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8673         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8674         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8675         LDKFundingLocked msg_var = *msg;
8676         uint32_t msg_ref = 0;
8677         msg_var = FundingLocked_clone(&msg_var);
8678         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8679         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8680         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8681         msg_ref = (uintptr_t)msg_var.inner;
8682         if (msg_var.is_owned) {
8683                 msg_ref |= 1;
8684         }
8685         js_invoke_function_2(j_calls->instance_ptr, 49, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8686 }
8687 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
8688         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8689         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8690         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8691         LDKInitFeatures their_features_var = *their_features;
8692         uint32_t their_features_ref = 0;
8693         their_features_var = InitFeatures_clone(&their_features_var);
8694         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8695         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8696         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
8697         their_features_ref = (uintptr_t)their_features_var.inner;
8698         if (their_features_var.is_owned) {
8699                 their_features_ref |= 1;
8700         }
8701         LDKShutdown msg_var = *msg;
8702         uint32_t msg_ref = 0;
8703         msg_var = Shutdown_clone(&msg_var);
8704         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8705         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8706         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8707         msg_ref = (uintptr_t)msg_var.inner;
8708         if (msg_var.is_owned) {
8709                 msg_ref |= 1;
8710         }
8711         js_invoke_function_3(j_calls->instance_ptr, 50, (uint32_t)their_node_id_arr, (uint32_t)their_features_ref, (uint32_t)msg_ref);
8712 }
8713 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
8714         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8715         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8716         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8717         LDKClosingSigned msg_var = *msg;
8718         uint32_t msg_ref = 0;
8719         msg_var = ClosingSigned_clone(&msg_var);
8720         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8721         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8722         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8723         msg_ref = (uintptr_t)msg_var.inner;
8724         if (msg_var.is_owned) {
8725                 msg_ref |= 1;
8726         }
8727         js_invoke_function_2(j_calls->instance_ptr, 51, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8728 }
8729 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
8730         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8731         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8732         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8733         LDKUpdateAddHTLC msg_var = *msg;
8734         uint32_t msg_ref = 0;
8735         msg_var = UpdateAddHTLC_clone(&msg_var);
8736         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8737         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8738         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8739         msg_ref = (uintptr_t)msg_var.inner;
8740         if (msg_var.is_owned) {
8741                 msg_ref |= 1;
8742         }
8743         js_invoke_function_2(j_calls->instance_ptr, 52, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8744 }
8745 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
8746         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8747         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8748         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8749         LDKUpdateFulfillHTLC msg_var = *msg;
8750         uint32_t msg_ref = 0;
8751         msg_var = UpdateFulfillHTLC_clone(&msg_var);
8752         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8753         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8754         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8755         msg_ref = (uintptr_t)msg_var.inner;
8756         if (msg_var.is_owned) {
8757                 msg_ref |= 1;
8758         }
8759         js_invoke_function_2(j_calls->instance_ptr, 53, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8760 }
8761 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
8762         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8763         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8764         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8765         LDKUpdateFailHTLC msg_var = *msg;
8766         uint32_t msg_ref = 0;
8767         msg_var = UpdateFailHTLC_clone(&msg_var);
8768         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8769         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8770         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8771         msg_ref = (uintptr_t)msg_var.inner;
8772         if (msg_var.is_owned) {
8773                 msg_ref |= 1;
8774         }
8775         js_invoke_function_2(j_calls->instance_ptr, 54, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8776 }
8777 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
8778         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8779         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8780         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8781         LDKUpdateFailMalformedHTLC msg_var = *msg;
8782         uint32_t msg_ref = 0;
8783         msg_var = UpdateFailMalformedHTLC_clone(&msg_var);
8784         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8785         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8786         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8787         msg_ref = (uintptr_t)msg_var.inner;
8788         if (msg_var.is_owned) {
8789                 msg_ref |= 1;
8790         }
8791         js_invoke_function_2(j_calls->instance_ptr, 55, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8792 }
8793 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
8794         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8795         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8796         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8797         LDKCommitmentSigned msg_var = *msg;
8798         uint32_t msg_ref = 0;
8799         msg_var = CommitmentSigned_clone(&msg_var);
8800         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8801         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8802         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8803         msg_ref = (uintptr_t)msg_var.inner;
8804         if (msg_var.is_owned) {
8805                 msg_ref |= 1;
8806         }
8807         js_invoke_function_2(j_calls->instance_ptr, 56, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8808 }
8809 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
8810         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8811         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8812         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8813         LDKRevokeAndACK msg_var = *msg;
8814         uint32_t msg_ref = 0;
8815         msg_var = RevokeAndACK_clone(&msg_var);
8816         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8817         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8818         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8819         msg_ref = (uintptr_t)msg_var.inner;
8820         if (msg_var.is_owned) {
8821                 msg_ref |= 1;
8822         }
8823         js_invoke_function_2(j_calls->instance_ptr, 57, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8824 }
8825 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
8826         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8827         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8828         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8829         LDKUpdateFee msg_var = *msg;
8830         uint32_t msg_ref = 0;
8831         msg_var = UpdateFee_clone(&msg_var);
8832         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8833         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8834         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8835         msg_ref = (uintptr_t)msg_var.inner;
8836         if (msg_var.is_owned) {
8837                 msg_ref |= 1;
8838         }
8839         js_invoke_function_2(j_calls->instance_ptr, 58, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8840 }
8841 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
8842         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8843         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8844         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8845         LDKAnnouncementSignatures msg_var = *msg;
8846         uint32_t msg_ref = 0;
8847         msg_var = AnnouncementSignatures_clone(&msg_var);
8848         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8849         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8850         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8851         msg_ref = (uintptr_t)msg_var.inner;
8852         if (msg_var.is_owned) {
8853                 msg_ref |= 1;
8854         }
8855         js_invoke_function_2(j_calls->instance_ptr, 59, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8856 }
8857 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
8858         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8859         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8860         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8861         jboolean no_connection_possible_conv = no_connection_possible;
8862         js_invoke_function_2(j_calls->instance_ptr, 60, (uint32_t)their_node_id_arr, (uint32_t)no_connection_possible_conv);
8863 }
8864 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
8865         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8866         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8867         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8868         LDKInit msg_var = *msg;
8869         uint32_t msg_ref = 0;
8870         msg_var = Init_clone(&msg_var);
8871         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8872         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8873         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8874         msg_ref = (uintptr_t)msg_var.inner;
8875         if (msg_var.is_owned) {
8876                 msg_ref |= 1;
8877         }
8878         js_invoke_function_2(j_calls->instance_ptr, 61, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8879 }
8880 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
8881         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8882         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8883         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8884         LDKChannelReestablish msg_var = *msg;
8885         uint32_t msg_ref = 0;
8886         msg_var = ChannelReestablish_clone(&msg_var);
8887         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8888         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8889         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8890         msg_ref = (uintptr_t)msg_var.inner;
8891         if (msg_var.is_owned) {
8892                 msg_ref |= 1;
8893         }
8894         js_invoke_function_2(j_calls->instance_ptr, 62, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8895 }
8896 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
8897         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8898         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8899         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8900         LDKChannelUpdate msg_var = *msg;
8901         uint32_t msg_ref = 0;
8902         msg_var = ChannelUpdate_clone(&msg_var);
8903         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8904         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8905         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8906         msg_ref = (uintptr_t)msg_var.inner;
8907         if (msg_var.is_owned) {
8908                 msg_ref |= 1;
8909         }
8910         js_invoke_function_2(j_calls->instance_ptr, 63, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8911 }
8912 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
8913         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8914         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8915         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8916         LDKErrorMessage msg_var = *msg;
8917         uint32_t msg_ref = 0;
8918         msg_var = ErrorMessage_clone(&msg_var);
8919         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8920         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8921         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8922         msg_ref = (uintptr_t)msg_var.inner;
8923         if (msg_var.is_owned) {
8924                 msg_ref |= 1;
8925         }
8926         js_invoke_function_2(j_calls->instance_ptr, 64, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8927 }
8928 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
8929         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
8930         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8931         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
8932 }
8933 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JSValue o, JSValue MessageSendEventsProvider) {
8934         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
8935         atomic_init(&calls->refcnt, 1);
8936         calls->instance_ptr = o;
8937
8938         LDKChannelMessageHandler ret = {
8939                 .this_arg = (void*) calls,
8940                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
8941                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
8942                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
8943                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
8944                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
8945                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
8946                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
8947                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
8948                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
8949                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
8950                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
8951                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
8952                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
8953                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
8954                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
8955                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
8956                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
8957                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
8958                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
8959                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
8960                 .free = LDKChannelMessageHandler_JCalls_free,
8961                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
8962         };
8963         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
8964         return ret;
8965 }
8966 long  __attribute__((export_name("TS_LDKChannelMessageHandler_new"))) TS_LDKChannelMessageHandler_new(JSValue o, JSValue MessageSendEventsProvider) {
8967         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
8968         *res_ptr = LDKChannelMessageHandler_init(o, MessageSendEventsProvider);
8969         return (long)res_ptr;
8970 }
8971 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) {
8972         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8973         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8974         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8975         LDKPublicKey their_node_id_ref;
8976         CHECK(their_node_id->arr_len == 33);
8977         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8978         LDKInitFeatures their_features_conv;
8979         their_features_conv.inner = (void*)(their_features & (~1));
8980         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
8981         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
8982         their_features_conv = InitFeatures_clone(&their_features_conv);
8983         LDKOpenChannel msg_conv;
8984         msg_conv.inner = (void*)(msg & (~1));
8985         msg_conv.is_owned = false;
8986         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8987         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
8988 }
8989
8990 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) {
8991         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8992         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8993         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8994         LDKPublicKey their_node_id_ref;
8995         CHECK(their_node_id->arr_len == 33);
8996         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8997         LDKInitFeatures their_features_conv;
8998         their_features_conv.inner = (void*)(their_features & (~1));
8999         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
9000         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
9001         their_features_conv = InitFeatures_clone(&their_features_conv);
9002         LDKAcceptChannel msg_conv;
9003         msg_conv.inner = (void*)(msg & (~1));
9004         msg_conv.is_owned = false;
9005         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9006         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
9007 }
9008
9009 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) {
9010         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9011         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9012         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9013         LDKPublicKey their_node_id_ref;
9014         CHECK(their_node_id->arr_len == 33);
9015         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9016         LDKFundingCreated msg_conv;
9017         msg_conv.inner = (void*)(msg & (~1));
9018         msg_conv.is_owned = false;
9019         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9020         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9021 }
9022
9023 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) {
9024         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9025         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9026         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9027         LDKPublicKey their_node_id_ref;
9028         CHECK(their_node_id->arr_len == 33);
9029         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9030         LDKFundingSigned msg_conv;
9031         msg_conv.inner = (void*)(msg & (~1));
9032         msg_conv.is_owned = false;
9033         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9034         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9035 }
9036
9037 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_funding_locked"))) TS_ChannelMessageHandler_handle_funding_locked(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
9038         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9039         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9040         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9041         LDKPublicKey their_node_id_ref;
9042         CHECK(their_node_id->arr_len == 33);
9043         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9044         LDKFundingLocked msg_conv;
9045         msg_conv.inner = (void*)(msg & (~1));
9046         msg_conv.is_owned = false;
9047         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9048         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9049 }
9050
9051 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) {
9052         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9053         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9054         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9055         LDKPublicKey their_node_id_ref;
9056         CHECK(their_node_id->arr_len == 33);
9057         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9058         LDKInitFeatures their_features_conv;
9059         their_features_conv.inner = (void*)(their_features & (~1));
9060         their_features_conv.is_owned = false;
9061         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
9062         LDKShutdown msg_conv;
9063         msg_conv.inner = (void*)(msg & (~1));
9064         msg_conv.is_owned = false;
9065         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9066         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
9067 }
9068
9069 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) {
9070         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9071         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9072         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9073         LDKPublicKey their_node_id_ref;
9074         CHECK(their_node_id->arr_len == 33);
9075         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9076         LDKClosingSigned msg_conv;
9077         msg_conv.inner = (void*)(msg & (~1));
9078         msg_conv.is_owned = false;
9079         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9080         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9081 }
9082
9083 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) {
9084         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9085         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9086         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9087         LDKPublicKey their_node_id_ref;
9088         CHECK(their_node_id->arr_len == 33);
9089         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9090         LDKUpdateAddHTLC msg_conv;
9091         msg_conv.inner = (void*)(msg & (~1));
9092         msg_conv.is_owned = false;
9093         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9094         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9095 }
9096
9097 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) {
9098         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9099         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9100         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9101         LDKPublicKey their_node_id_ref;
9102         CHECK(their_node_id->arr_len == 33);
9103         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9104         LDKUpdateFulfillHTLC msg_conv;
9105         msg_conv.inner = (void*)(msg & (~1));
9106         msg_conv.is_owned = false;
9107         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9108         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9109 }
9110
9111 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) {
9112         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9113         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9114         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9115         LDKPublicKey their_node_id_ref;
9116         CHECK(their_node_id->arr_len == 33);
9117         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9118         LDKUpdateFailHTLC msg_conv;
9119         msg_conv.inner = (void*)(msg & (~1));
9120         msg_conv.is_owned = false;
9121         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9122         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9123 }
9124
9125 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) {
9126         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9127         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9128         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9129         LDKPublicKey their_node_id_ref;
9130         CHECK(their_node_id->arr_len == 33);
9131         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9132         LDKUpdateFailMalformedHTLC msg_conv;
9133         msg_conv.inner = (void*)(msg & (~1));
9134         msg_conv.is_owned = false;
9135         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9136         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9137 }
9138
9139 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) {
9140         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9141         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9142         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9143         LDKPublicKey their_node_id_ref;
9144         CHECK(their_node_id->arr_len == 33);
9145         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9146         LDKCommitmentSigned msg_conv;
9147         msg_conv.inner = (void*)(msg & (~1));
9148         msg_conv.is_owned = false;
9149         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9150         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9151 }
9152
9153 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) {
9154         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9155         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9156         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9157         LDKPublicKey their_node_id_ref;
9158         CHECK(their_node_id->arr_len == 33);
9159         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9160         LDKRevokeAndACK msg_conv;
9161         msg_conv.inner = (void*)(msg & (~1));
9162         msg_conv.is_owned = false;
9163         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9164         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9165 }
9166
9167 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) {
9168         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9169         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9170         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9171         LDKPublicKey their_node_id_ref;
9172         CHECK(their_node_id->arr_len == 33);
9173         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9174         LDKUpdateFee msg_conv;
9175         msg_conv.inner = (void*)(msg & (~1));
9176         msg_conv.is_owned = false;
9177         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9178         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9179 }
9180
9181 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) {
9182         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9183         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9184         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9185         LDKPublicKey their_node_id_ref;
9186         CHECK(their_node_id->arr_len == 33);
9187         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9188         LDKAnnouncementSignatures msg_conv;
9189         msg_conv.inner = (void*)(msg & (~1));
9190         msg_conv.is_owned = false;
9191         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9192         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9193 }
9194
9195 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) {
9196         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9197         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9198         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9199         LDKPublicKey their_node_id_ref;
9200         CHECK(their_node_id->arr_len == 33);
9201         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9202         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
9203 }
9204
9205 void  __attribute__((export_name("TS_ChannelMessageHandler_peer_connected"))) TS_ChannelMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
9206         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9207         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9208         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9209         LDKPublicKey their_node_id_ref;
9210         CHECK(their_node_id->arr_len == 33);
9211         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9212         LDKInit msg_conv;
9213         msg_conv.inner = (void*)(msg & (~1));
9214         msg_conv.is_owned = false;
9215         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9216         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9217 }
9218
9219 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) {
9220         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9221         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9222         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9223         LDKPublicKey their_node_id_ref;
9224         CHECK(their_node_id->arr_len == 33);
9225         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9226         LDKChannelReestablish msg_conv;
9227         msg_conv.inner = (void*)(msg & (~1));
9228         msg_conv.is_owned = false;
9229         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9230         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9231 }
9232
9233 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) {
9234         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9235         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9236         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9237         LDKPublicKey their_node_id_ref;
9238         CHECK(their_node_id->arr_len == 33);
9239         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9240         LDKChannelUpdate msg_conv;
9241         msg_conv.inner = (void*)(msg & (~1));
9242         msg_conv.is_owned = false;
9243         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9244         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9245 }
9246
9247 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_error"))) TS_ChannelMessageHandler_handle_error(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
9248         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9249         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9250         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9251         LDKPublicKey their_node_id_ref;
9252         CHECK(their_node_id->arr_len == 33);
9253         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9254         LDKErrorMessage msg_conv;
9255         msg_conv.inner = (void*)(msg & (~1));
9256         msg_conv.is_owned = false;
9257         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9258         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9259 }
9260
9261 typedef struct LDKRoutingMessageHandler_JCalls {
9262         atomic_size_t refcnt;
9263         uint32_t instance_ptr;
9264         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
9265 } LDKRoutingMessageHandler_JCalls;
9266 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
9267         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9268         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9269                 FREE(j_calls);
9270         }
9271 }
9272 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
9273         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9274         LDKNodeAnnouncement msg_var = *msg;
9275         uint32_t msg_ref = 0;
9276         msg_var = NodeAnnouncement_clone(&msg_var);
9277         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9278         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9279         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9280         msg_ref = (uintptr_t)msg_var.inner;
9281         if (msg_var.is_owned) {
9282                 msg_ref |= 1;
9283         }
9284         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 65, (uint32_t)msg_ref);
9285         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9286         CHECK_ACCESS(ret_ptr);
9287         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9288         FREE((void*)ret);
9289         return ret_conv;
9290 }
9291 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
9292         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9293         LDKChannelAnnouncement msg_var = *msg;
9294         uint32_t msg_ref = 0;
9295         msg_var = ChannelAnnouncement_clone(&msg_var);
9296         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9297         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9298         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9299         msg_ref = (uintptr_t)msg_var.inner;
9300         if (msg_var.is_owned) {
9301                 msg_ref |= 1;
9302         }
9303         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 66, (uint32_t)msg_ref);
9304         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9305         CHECK_ACCESS(ret_ptr);
9306         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9307         FREE((void*)ret);
9308         return ret_conv;
9309 }
9310 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
9311         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9312         LDKChannelUpdate msg_var = *msg;
9313         uint32_t msg_ref = 0;
9314         msg_var = ChannelUpdate_clone(&msg_var);
9315         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9316         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9317         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9318         msg_ref = (uintptr_t)msg_var.inner;
9319         if (msg_var.is_owned) {
9320                 msg_ref |= 1;
9321         }
9322         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 67, (uint32_t)msg_ref);
9323         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9324         CHECK_ACCESS(ret_ptr);
9325         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9326         FREE((void*)ret);
9327         return ret_conv;
9328 }
9329 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
9330         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9331         int64_t starting_point_conv = starting_point;
9332         int8_t batch_amount_conv = batch_amount;
9333         uint32_tArray ret = (uint32_tArray)js_invoke_function_2(j_calls->instance_ptr, 68, (uint32_t)starting_point_conv, (uint32_t)batch_amount_conv);
9334         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
9335         ret_constr.datalen = ret->arr_len;
9336         if (ret_constr.datalen > 0)
9337                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
9338         else
9339                 ret_constr.data = NULL;
9340         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
9341         for (size_t h = 0; h < ret_constr.datalen; h++) {
9342                 uint32_t ret_conv_59 = ret_vals[h];
9343                 void* ret_conv_59_ptr = (void*)(((uintptr_t)ret_conv_59) & ~1);
9344                 CHECK_ACCESS(ret_conv_59_ptr);
9345                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ret_conv_59_ptr);
9346                 FREE((void*)ret_conv_59);
9347                 ret_constr.data[h] = ret_conv_59_conv;
9348         }
9349         return ret_constr;
9350 }
9351 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
9352         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9353         int8_tArray starting_point_arr = init_int8_tArray(33, __LINE__);
9354         memcpy(starting_point_arr->elems, starting_point.compressed_form, 33);
9355         int8_t batch_amount_conv = batch_amount;
9356         uint32_tArray ret = (uint32_tArray)js_invoke_function_2(j_calls->instance_ptr, 69, (uint32_t)starting_point_arr, (uint32_t)batch_amount_conv);
9357         LDKCVec_NodeAnnouncementZ ret_constr;
9358         ret_constr.datalen = ret->arr_len;
9359         if (ret_constr.datalen > 0)
9360                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
9361         else
9362                 ret_constr.data = NULL;
9363         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
9364         for (size_t s = 0; s < ret_constr.datalen; s++) {
9365                 uint32_t ret_conv_18 = ret_vals[s];
9366                 LDKNodeAnnouncement ret_conv_18_conv;
9367                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
9368                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
9369                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_conv);
9370                 ret_constr.data[s] = ret_conv_18_conv;
9371         }
9372         return ret_constr;
9373 }
9374 void peer_connected_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
9375         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9376         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9377         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9378         LDKInit init_var = *init;
9379         uint32_t init_ref = 0;
9380         init_var = Init_clone(&init_var);
9381         CHECK((((uintptr_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9382         CHECK((((uintptr_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9383         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
9384         init_ref = (uintptr_t)init_var.inner;
9385         if (init_var.is_owned) {
9386                 init_ref |= 1;
9387         }
9388         js_invoke_function_2(j_calls->instance_ptr, 70, (uint32_t)their_node_id_arr, (uint32_t)init_ref);
9389 }
9390 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
9391         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9392         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9393         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9394         LDKReplyChannelRange msg_var = msg;
9395         uint32_t msg_ref = 0;
9396         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9397         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9398         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9399         msg_ref = (uintptr_t)msg_var.inner;
9400         if (msg_var.is_owned) {
9401                 msg_ref |= 1;
9402         }
9403         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 71, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9404         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9405         CHECK_ACCESS(ret_ptr);
9406         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9407         FREE((void*)ret);
9408         return ret_conv;
9409 }
9410 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
9411         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9412         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9413         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9414         LDKReplyShortChannelIdsEnd msg_var = msg;
9415         uint32_t msg_ref = 0;
9416         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9417         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9418         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9419         msg_ref = (uintptr_t)msg_var.inner;
9420         if (msg_var.is_owned) {
9421                 msg_ref |= 1;
9422         }
9423         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 72, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9424         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9425         CHECK_ACCESS(ret_ptr);
9426         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9427         FREE((void*)ret);
9428         return ret_conv;
9429 }
9430 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
9431         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9432         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9433         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9434         LDKQueryChannelRange msg_var = msg;
9435         uint32_t msg_ref = 0;
9436         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9437         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9438         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9439         msg_ref = (uintptr_t)msg_var.inner;
9440         if (msg_var.is_owned) {
9441                 msg_ref |= 1;
9442         }
9443         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 73, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9444         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9445         CHECK_ACCESS(ret_ptr);
9446         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9447         FREE((void*)ret);
9448         return ret_conv;
9449 }
9450 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
9451         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9452         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9453         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9454         LDKQueryShortChannelIds msg_var = msg;
9455         uint32_t msg_ref = 0;
9456         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9457         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9458         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9459         msg_ref = (uintptr_t)msg_var.inner;
9460         if (msg_var.is_owned) {
9461                 msg_ref |= 1;
9462         }
9463         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 74, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9464         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9465         CHECK_ACCESS(ret_ptr);
9466         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9467         FREE((void*)ret);
9468         return ret_conv;
9469 }
9470 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
9471         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
9472         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9473         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
9474 }
9475 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JSValue o, JSValue MessageSendEventsProvider) {
9476         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
9477         atomic_init(&calls->refcnt, 1);
9478         calls->instance_ptr = o;
9479
9480         LDKRoutingMessageHandler ret = {
9481                 .this_arg = (void*) calls,
9482                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
9483                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
9484                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
9485                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
9486                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
9487                 .peer_connected = peer_connected_LDKRoutingMessageHandler_jcall,
9488                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
9489                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
9490                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
9491                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
9492                 .free = LDKRoutingMessageHandler_JCalls_free,
9493                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
9494         };
9495         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
9496         return ret;
9497 }
9498 long  __attribute__((export_name("TS_LDKRoutingMessageHandler_new"))) TS_LDKRoutingMessageHandler_new(JSValue o, JSValue MessageSendEventsProvider) {
9499         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
9500         *res_ptr = LDKRoutingMessageHandler_init(o, MessageSendEventsProvider);
9501         return (long)res_ptr;
9502 }
9503 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_node_announcement"))) TS_RoutingMessageHandler_handle_node_announcement(uint32_t this_arg, uint32_t msg) {
9504         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9505         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9506         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9507         LDKNodeAnnouncement msg_conv;
9508         msg_conv.inner = (void*)(msg & (~1));
9509         msg_conv.is_owned = false;
9510         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9511         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9512         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
9513         return (uint32_t)ret_conv;
9514 }
9515
9516 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_channel_announcement"))) TS_RoutingMessageHandler_handle_channel_announcement(uint32_t this_arg, uint32_t msg) {
9517         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9518         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9519         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9520         LDKChannelAnnouncement msg_conv;
9521         msg_conv.inner = (void*)(msg & (~1));
9522         msg_conv.is_owned = false;
9523         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9524         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9525         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
9526         return (uint32_t)ret_conv;
9527 }
9528
9529 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_channel_update"))) TS_RoutingMessageHandler_handle_channel_update(uint32_t this_arg, uint32_t msg) {
9530         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9531         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9532         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9533         LDKChannelUpdate msg_conv;
9534         msg_conv.inner = (void*)(msg & (~1));
9535         msg_conv.is_owned = false;
9536         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9537         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9538         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
9539         return (uint32_t)ret_conv;
9540 }
9541
9542 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) {
9543         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9544         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9545         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9546         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
9547         uint32_tArray ret_arr = NULL;
9548         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
9549         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
9550         for (size_t h = 0; h < ret_var.datalen; h++) {
9551                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
9552                 *ret_conv_59_conv = ret_var.data[h];
9553                 ret_arr_ptr[h] = ((uint32_t)ret_conv_59_conv);
9554         }
9555         
9556         FREE(ret_var.data);
9557         return ret_arr;
9558 }
9559
9560 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) {
9561         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9562         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9563         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9564         LDKPublicKey starting_point_ref;
9565         CHECK(starting_point->arr_len == 33);
9566         memcpy(starting_point_ref.compressed_form, starting_point->elems, 33); FREE(starting_point);
9567         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
9568         uint32_tArray ret_arr = NULL;
9569         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
9570         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
9571         for (size_t s = 0; s < ret_var.datalen; s++) {
9572                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
9573                 uint32_t ret_conv_18_ref = 0;
9574                 CHECK((((uintptr_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9575                 CHECK((((uintptr_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9576                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_var);
9577                 ret_conv_18_ref = (uintptr_t)ret_conv_18_var.inner;
9578                 if (ret_conv_18_var.is_owned) {
9579                         ret_conv_18_ref |= 1;
9580                 }
9581                 ret_arr_ptr[s] = ret_conv_18_ref;
9582         }
9583         
9584         FREE(ret_var.data);
9585         return ret_arr;
9586 }
9587
9588 void  __attribute__((export_name("TS_RoutingMessageHandler_peer_connected"))) TS_RoutingMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t init) {
9589         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9590         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9591         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9592         LDKPublicKey their_node_id_ref;
9593         CHECK(their_node_id->arr_len == 33);
9594         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9595         LDKInit init_conv;
9596         init_conv.inner = (void*)(init & (~1));
9597         init_conv.is_owned = false;
9598         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
9599         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
9600 }
9601
9602 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) {
9603         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9604         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9605         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9606         LDKPublicKey their_node_id_ref;
9607         CHECK(their_node_id->arr_len == 33);
9608         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9609         LDKReplyChannelRange msg_conv;
9610         msg_conv.inner = (void*)(msg & (~1));
9611         msg_conv.is_owned = (msg & 1) || (msg == 0);
9612         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9613         msg_conv = ReplyChannelRange_clone(&msg_conv);
9614         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9615         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9616         return (uint32_t)ret_conv;
9617 }
9618
9619 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) {
9620         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9621         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9622         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9623         LDKPublicKey their_node_id_ref;
9624         CHECK(their_node_id->arr_len == 33);
9625         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9626         LDKReplyShortChannelIdsEnd msg_conv;
9627         msg_conv.inner = (void*)(msg & (~1));
9628         msg_conv.is_owned = (msg & 1) || (msg == 0);
9629         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9630         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
9631         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9632         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9633         return (uint32_t)ret_conv;
9634 }
9635
9636 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) {
9637         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9638         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9639         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9640         LDKPublicKey their_node_id_ref;
9641         CHECK(their_node_id->arr_len == 33);
9642         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9643         LDKQueryChannelRange msg_conv;
9644         msg_conv.inner = (void*)(msg & (~1));
9645         msg_conv.is_owned = (msg & 1) || (msg == 0);
9646         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9647         msg_conv = QueryChannelRange_clone(&msg_conv);
9648         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9649         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9650         return (uint32_t)ret_conv;
9651 }
9652
9653 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) {
9654         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9655         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9656         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9657         LDKPublicKey their_node_id_ref;
9658         CHECK(their_node_id->arr_len == 33);
9659         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9660         LDKQueryShortChannelIds msg_conv;
9661         msg_conv.inner = (void*)(msg & (~1));
9662         msg_conv.is_owned = (msg & 1) || (msg == 0);
9663         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9664         msg_conv = QueryShortChannelIds_clone(&msg_conv);
9665         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9666         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9667         return (uint32_t)ret_conv;
9668 }
9669
9670 typedef struct LDKCustomMessageReader_JCalls {
9671         atomic_size_t refcnt;
9672         uint32_t instance_ptr;
9673 } LDKCustomMessageReader_JCalls;
9674 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
9675         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
9676         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9677                 FREE(j_calls);
9678         }
9679 }
9680 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
9681         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
9682         int16_t message_type_conv = message_type;
9683         LDKu8slice buffer_var = buffer;
9684         int8_tArray buffer_arr = init_int8_tArray(buffer_var.datalen, __LINE__);
9685         memcpy(buffer_arr->elems, buffer_var.data, buffer_var.datalen);
9686         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 75, (uint32_t)message_type_conv, (uint32_t)buffer_arr);
9687         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9688         CHECK_ACCESS(ret_ptr);
9689         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
9690         FREE((void*)ret);
9691         return ret_conv;
9692 }
9693 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
9694         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
9695         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9696 }
9697 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JSValue o) {
9698         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
9699         atomic_init(&calls->refcnt, 1);
9700         calls->instance_ptr = o;
9701
9702         LDKCustomMessageReader ret = {
9703                 .this_arg = (void*) calls,
9704                 .read = read_LDKCustomMessageReader_jcall,
9705                 .free = LDKCustomMessageReader_JCalls_free,
9706         };
9707         return ret;
9708 }
9709 long  __attribute__((export_name("TS_LDKCustomMessageReader_new"))) TS_LDKCustomMessageReader_new(JSValue o) {
9710         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
9711         *res_ptr = LDKCustomMessageReader_init(o);
9712         return (long)res_ptr;
9713 }
9714 uint32_t  __attribute__((export_name("TS_CustomMessageReader_read"))) TS_CustomMessageReader_read(uint32_t this_arg, int16_t message_type, int8_tArray buffer) {
9715         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9716         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9717         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
9718         LDKu8slice buffer_ref;
9719         buffer_ref.datalen = buffer->arr_len;
9720         buffer_ref.data = buffer->elems /* XXX buffer leaks */;
9721         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
9722         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
9723         return (uint32_t)ret_conv;
9724 }
9725
9726 typedef struct LDKCustomMessageHandler_JCalls {
9727         atomic_size_t refcnt;
9728         uint32_t instance_ptr;
9729         LDKCustomMessageReader_JCalls* CustomMessageReader;
9730 } LDKCustomMessageHandler_JCalls;
9731 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
9732         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
9733         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9734                 FREE(j_calls);
9735         }
9736 }
9737 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
9738         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
9739         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
9740         *msg_ret = msg;
9741         int8_tArray sender_node_id_arr = init_int8_tArray(33, __LINE__);
9742         memcpy(sender_node_id_arr->elems, sender_node_id.compressed_form, 33);
9743         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 76, (uint32_t)(uint32_t)msg_ret, (uint32_t)sender_node_id_arr);
9744         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9745         CHECK_ACCESS(ret_ptr);
9746         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9747         FREE((void*)ret);
9748         return ret_conv;
9749 }
9750 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
9751         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
9752         uint32_tArray ret = (uint32_tArray)js_invoke_function_0(j_calls->instance_ptr, 77);
9753         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
9754         ret_constr.datalen = ret->arr_len;
9755         if (ret_constr.datalen > 0)
9756                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
9757         else
9758                 ret_constr.data = NULL;
9759         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
9760         for (size_t z = 0; z < ret_constr.datalen; z++) {
9761                 uint32_t ret_conv_25 = ret_vals[z];
9762                 void* ret_conv_25_ptr = (void*)(((uintptr_t)ret_conv_25) & ~1);
9763                 CHECK_ACCESS(ret_conv_25_ptr);
9764                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
9765                 FREE((void*)ret_conv_25);
9766                 ret_constr.data[z] = ret_conv_25_conv;
9767         }
9768         return ret_constr;
9769 }
9770 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
9771         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
9772         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9773         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
9774 }
9775 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JSValue o, JSValue CustomMessageReader) {
9776         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
9777         atomic_init(&calls->refcnt, 1);
9778         calls->instance_ptr = o;
9779
9780         LDKCustomMessageHandler ret = {
9781                 .this_arg = (void*) calls,
9782                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
9783                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
9784                 .free = LDKCustomMessageHandler_JCalls_free,
9785                 .CustomMessageReader = LDKCustomMessageReader_init(CustomMessageReader),
9786         };
9787         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
9788         return ret;
9789 }
9790 long  __attribute__((export_name("TS_LDKCustomMessageHandler_new"))) TS_LDKCustomMessageHandler_new(JSValue o, JSValue CustomMessageReader) {
9791         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
9792         *res_ptr = LDKCustomMessageHandler_init(o, CustomMessageReader);
9793         return (long)res_ptr;
9794 }
9795 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) {
9796         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9797         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9798         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
9799         void* msg_ptr = (void*)(((uintptr_t)msg) & ~1);
9800         CHECK_ACCESS(msg_ptr);
9801         LDKType msg_conv = *(LDKType*)(msg_ptr);
9802         if (msg_conv.free == LDKType_JCalls_free) {
9803                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9804                 LDKType_JCalls_cloned(&msg_conv);
9805         }
9806         LDKPublicKey sender_node_id_ref;
9807         CHECK(sender_node_id->arr_len == 33);
9808         memcpy(sender_node_id_ref.compressed_form, sender_node_id->elems, 33); FREE(sender_node_id);
9809         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9810         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
9811         return (uint32_t)ret_conv;
9812 }
9813
9814 uint32_tArray  __attribute__((export_name("TS_CustomMessageHandler_get_and_clear_pending_msg"))) TS_CustomMessageHandler_get_and_clear_pending_msg(uint32_t this_arg) {
9815         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9816         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9817         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
9818         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
9819         uint32_tArray ret_arr = NULL;
9820         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
9821         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
9822         for (size_t z = 0; z < ret_var.datalen; z++) {
9823                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
9824                 *ret_conv_25_conv = ret_var.data[z];
9825                 ret_arr_ptr[z] = ((uint32_t)ret_conv_25_conv);
9826         }
9827         
9828         FREE(ret_var.data);
9829         return ret_arr;
9830 }
9831
9832 typedef struct LDKSocketDescriptor_JCalls {
9833         atomic_size_t refcnt;
9834         uint32_t instance_ptr;
9835 } LDKSocketDescriptor_JCalls;
9836 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
9837         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
9838         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9839                 FREE(j_calls);
9840         }
9841 }
9842 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
9843         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
9844         LDKu8slice data_var = data;
9845         int8_tArray data_arr = init_int8_tArray(data_var.datalen, __LINE__);
9846         memcpy(data_arr->elems, data_var.data, data_var.datalen);
9847         jboolean resume_read_conv = resume_read;
9848         return js_invoke_function_2(j_calls->instance_ptr, 78, (uint32_t)data_arr, (uint32_t)resume_read_conv);
9849 }
9850 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
9851         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
9852         js_invoke_function_0(j_calls->instance_ptr, 79);
9853 }
9854 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
9855         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
9856         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
9857         *other_arg_clone = SocketDescriptor_clone(other_arg);
9858         return js_invoke_function_1(j_calls->instance_ptr, 80, (uint32_t)(uint32_t)other_arg_clone);
9859 }
9860 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
9861         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
9862         return js_invoke_function_0(j_calls->instance_ptr, 81);
9863 }
9864 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
9865         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
9866         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9867 }
9868 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JSValue o) {
9869         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
9870         atomic_init(&calls->refcnt, 1);
9871         calls->instance_ptr = o;
9872
9873         LDKSocketDescriptor ret = {
9874                 .this_arg = (void*) calls,
9875                 .send_data = send_data_LDKSocketDescriptor_jcall,
9876                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
9877                 .eq = eq_LDKSocketDescriptor_jcall,
9878                 .hash = hash_LDKSocketDescriptor_jcall,
9879                 .cloned = LDKSocketDescriptor_JCalls_cloned,
9880                 .free = LDKSocketDescriptor_JCalls_free,
9881         };
9882         return ret;
9883 }
9884 long  __attribute__((export_name("TS_LDKSocketDescriptor_new"))) TS_LDKSocketDescriptor_new(JSValue o) {
9885         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
9886         *res_ptr = LDKSocketDescriptor_init(o);
9887         return (long)res_ptr;
9888 }
9889 uint32_t  __attribute__((export_name("TS_SocketDescriptor_send_data"))) TS_SocketDescriptor_send_data(uint32_t this_arg, int8_tArray data, jboolean resume_read) {
9890         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9891         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9892         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
9893         LDKu8slice data_ref;
9894         data_ref.datalen = data->arr_len;
9895         data_ref.data = data->elems /* XXX data leaks */;
9896         uint32_t ret_conv = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
9897         return ret_conv;
9898 }
9899
9900 void  __attribute__((export_name("TS_SocketDescriptor_disconnect_socket"))) TS_SocketDescriptor_disconnect_socket(uint32_t this_arg) {
9901         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9902         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9903         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
9904         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
9905 }
9906
9907 int64_t  __attribute__((export_name("TS_SocketDescriptor_hash"))) TS_SocketDescriptor_hash(uint32_t this_arg) {
9908         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9909         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9910         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
9911         int64_t ret_conv = (this_arg_conv->hash)(this_arg_conv->this_arg);
9912         return ret_conv;
9913 }
9914
9915 uint32_t __attribute__((export_name("TS_LDKEffectiveCapacity_ty_from_ptr"))) TS_LDKEffectiveCapacity_ty_from_ptr(uint32_t ptr) {
9916         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
9917         switch(obj->tag) {
9918                 case LDKEffectiveCapacity_ExactLiquidity: return 0;
9919                 case LDKEffectiveCapacity_MaximumHTLC: return 1;
9920                 case LDKEffectiveCapacity_Total: return 2;
9921                 case LDKEffectiveCapacity_Infinite: return 3;
9922                 case LDKEffectiveCapacity_Unknown: return 4;
9923                 default: abort();
9924         }
9925 }
9926 int64_t __attribute__((export_name("TS_LDKEffectiveCapacity_ExactLiquidity_get_liquidity_msat"))) TS_LDKEffectiveCapacity_ExactLiquidity_get_liquidity_msat(uint32_t ptr) {
9927         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
9928         assert(obj->tag == LDKEffectiveCapacity_ExactLiquidity);
9929                         int64_t liquidity_msat_conv = obj->exact_liquidity.liquidity_msat;
9930         return liquidity_msat_conv;
9931 }
9932 int64_t __attribute__((export_name("TS_LDKEffectiveCapacity_MaximumHTLC_get_amount_msat"))) TS_LDKEffectiveCapacity_MaximumHTLC_get_amount_msat(uint32_t ptr) {
9933         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
9934         assert(obj->tag == LDKEffectiveCapacity_MaximumHTLC);
9935                         int64_t amount_msat_conv = obj->maximum_htlc.amount_msat;
9936         return amount_msat_conv;
9937 }
9938 int64_t __attribute__((export_name("TS_LDKEffectiveCapacity_Total_get_capacity_msat"))) TS_LDKEffectiveCapacity_Total_get_capacity_msat(uint32_t ptr) {
9939         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
9940         assert(obj->tag == LDKEffectiveCapacity_Total);
9941                         int64_t capacity_msat_conv = obj->total.capacity_msat;
9942         return capacity_msat_conv;
9943 }
9944 typedef struct LDKScore_JCalls {
9945         atomic_size_t refcnt;
9946         uint32_t instance_ptr;
9947 } LDKScore_JCalls;
9948 static void LDKScore_JCalls_free(void* this_arg) {
9949         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
9950         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9951                 FREE(j_calls);
9952         }
9953 }
9954 uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id, uint64_t send_amt_msat, uint64_t capacity_msat, const LDKNodeId * source, const LDKNodeId * target) {
9955         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
9956         int64_t short_channel_id_conv = short_channel_id;
9957         int64_t send_amt_msat_conv = send_amt_msat;
9958         int64_t capacity_msat_conv = capacity_msat;
9959         LDKNodeId source_var = *source;
9960         uint32_t source_ref = 0;
9961         source_var = NodeId_clone(&source_var);
9962         CHECK((((uintptr_t)source_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9963         CHECK((((uintptr_t)&source_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9964         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
9965         source_ref = (uintptr_t)source_var.inner;
9966         if (source_var.is_owned) {
9967                 source_ref |= 1;
9968         }
9969         LDKNodeId target_var = *target;
9970         uint32_t target_ref = 0;
9971         target_var = NodeId_clone(&target_var);
9972         CHECK((((uintptr_t)target_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9973         CHECK((((uintptr_t)&target_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9974         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
9975         target_ref = (uintptr_t)target_var.inner;
9976         if (target_var.is_owned) {
9977                 target_ref |= 1;
9978         }
9979         return js_invoke_function_5(j_calls->instance_ptr, 82, (uint32_t)short_channel_id_conv, (uint32_t)send_amt_msat_conv, (uint32_t)capacity_msat_conv, (uint32_t)source_ref, (uint32_t)target_ref);
9980 }
9981 void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
9982         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
9983         LDKCVec_RouteHopZ path_var = path;
9984         uint32_tArray path_arr = NULL;
9985         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
9986         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
9987         for (size_t k = 0; k < path_var.datalen; k++) {
9988                 LDKRouteHop path_conv_10_var = path_var.data[k];
9989                 uint32_t path_conv_10_ref = 0;
9990                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9991                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9992                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
9993                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
9994                 if (path_conv_10_var.is_owned) {
9995                         path_conv_10_ref |= 1;
9996                 }
9997                 path_arr_ptr[k] = path_conv_10_ref;
9998         }
9999         
10000         FREE(path_var.data);
10001         int64_t short_channel_id_conv = short_channel_id;
10002         js_invoke_function_2(j_calls->instance_ptr, 83, (uint32_t)path_arr, (uint32_t)short_channel_id_conv);
10003 }
10004 void payment_path_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
10005         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10006         LDKCVec_RouteHopZ path_var = path;
10007         uint32_tArray path_arr = NULL;
10008         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
10009         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
10010         for (size_t k = 0; k < path_var.datalen; k++) {
10011                 LDKRouteHop path_conv_10_var = path_var.data[k];
10012                 uint32_t path_conv_10_ref = 0;
10013                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10014                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10015                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
10016                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
10017                 if (path_conv_10_var.is_owned) {
10018                         path_conv_10_ref |= 1;
10019                 }
10020                 path_arr_ptr[k] = path_conv_10_ref;
10021         }
10022         
10023         FREE(path_var.data);
10024         js_invoke_function_1(j_calls->instance_ptr, 84, (uint32_t)path_arr);
10025 }
10026 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
10027         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10028         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 85);
10029         LDKCVec_u8Z ret_ref;
10030         ret_ref.datalen = ret->arr_len;
10031         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
10032         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
10033         return ret_ref;
10034 }
10035 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
10036         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
10037         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10038 }
10039 static inline LDKScore LDKScore_init (JSValue o) {
10040         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
10041         atomic_init(&calls->refcnt, 1);
10042         calls->instance_ptr = o;
10043
10044         LDKScore ret = {
10045                 .this_arg = (void*) calls,
10046                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
10047                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
10048                 .payment_path_successful = payment_path_successful_LDKScore_jcall,
10049                 .write = write_LDKScore_jcall,
10050                 .free = LDKScore_JCalls_free,
10051         };
10052         return ret;
10053 }
10054 long  __attribute__((export_name("TS_LDKScore_new"))) TS_LDKScore_new(JSValue o) {
10055         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
10056         *res_ptr = LDKScore_init(o);
10057         return (long)res_ptr;
10058 }
10059 int64_t  __attribute__((export_name("TS_Score_channel_penalty_msat"))) TS_Score_channel_penalty_msat(uint32_t this_arg, int64_t short_channel_id, int64_t send_amt_msat, int64_t capacity_msat, uint32_t source, uint32_t target) {
10060         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10061         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10062         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10063         LDKNodeId source_conv;
10064         source_conv.inner = (void*)(source & (~1));
10065         source_conv.is_owned = false;
10066         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
10067         LDKNodeId target_conv;
10068         target_conv.inner = (void*)(target & (~1));
10069         target_conv.is_owned = false;
10070         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
10071         int64_t ret_conv = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, send_amt_msat, capacity_msat, &source_conv, &target_conv);
10072         return ret_conv;
10073 }
10074
10075 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) {
10076         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10077         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10078         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10079         LDKCVec_RouteHopZ path_constr;
10080         path_constr.datalen = path->arr_len;
10081         if (path_constr.datalen > 0)
10082                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
10083         else
10084                 path_constr.data = NULL;
10085         uint32_t* path_vals = path->elems /* XXX path leaks */;
10086         for (size_t k = 0; k < path_constr.datalen; k++) {
10087                 uint32_t path_conv_10 = path_vals[k];
10088                 LDKRouteHop path_conv_10_conv;
10089                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
10090                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
10091                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
10092                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
10093                 path_constr.data[k] = path_conv_10_conv;
10094         }
10095         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
10096 }
10097
10098 void  __attribute__((export_name("TS_Score_payment_path_successful"))) TS_Score_payment_path_successful(uint32_t this_arg, uint32_tArray path) {
10099         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10100         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10101         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10102         LDKCVec_RouteHopZ path_constr;
10103         path_constr.datalen = path->arr_len;
10104         if (path_constr.datalen > 0)
10105                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
10106         else
10107                 path_constr.data = NULL;
10108         uint32_t* path_vals = path->elems /* XXX path leaks */;
10109         for (size_t k = 0; k < path_constr.datalen; k++) {
10110                 uint32_t path_conv_10 = path_vals[k];
10111                 LDKRouteHop path_conv_10_conv;
10112                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
10113                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
10114                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
10115                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
10116                 path_constr.data[k] = path_conv_10_conv;
10117         }
10118         (this_arg_conv->payment_path_successful)(this_arg_conv->this_arg, path_constr);
10119 }
10120
10121 int8_tArray  __attribute__((export_name("TS_Score_write"))) TS_Score_write(uint32_t this_arg) {
10122         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10123         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10124         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10125         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
10126         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
10127         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
10128         CVec_u8Z_free(ret_var);
10129         return ret_arr;
10130 }
10131
10132 typedef struct LDKLockableScore_JCalls {
10133         atomic_size_t refcnt;
10134         uint32_t instance_ptr;
10135 } LDKLockableScore_JCalls;
10136 static void LDKLockableScore_JCalls_free(void* this_arg) {
10137         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
10138         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10139                 FREE(j_calls);
10140         }
10141 }
10142 LDKScore lock_LDKLockableScore_jcall(const void* this_arg) {
10143         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
10144         uint32_t ret = js_invoke_function_0(j_calls->instance_ptr, 86);
10145         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10146         CHECK_ACCESS(ret_ptr);
10147         LDKScore ret_conv = *(LDKScore*)(ret_ptr);
10148         if (ret_conv.free == LDKScore_JCalls_free) {
10149                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10150                 LDKScore_JCalls_cloned(&ret_conv);
10151         }// WARNING: we may need a move here but no clone is available for LDKScore
10152         
10153         return ret_conv;
10154 }
10155 static void LDKLockableScore_JCalls_cloned(LDKLockableScore* new_obj) {
10156         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) new_obj->this_arg;
10157         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10158 }
10159 static inline LDKLockableScore LDKLockableScore_init (JSValue o) {
10160         LDKLockableScore_JCalls *calls = MALLOC(sizeof(LDKLockableScore_JCalls), "LDKLockableScore_JCalls");
10161         atomic_init(&calls->refcnt, 1);
10162         calls->instance_ptr = o;
10163
10164         LDKLockableScore ret = {
10165                 .this_arg = (void*) calls,
10166                 .lock = lock_LDKLockableScore_jcall,
10167                 .free = LDKLockableScore_JCalls_free,
10168         };
10169         return ret;
10170 }
10171 long  __attribute__((export_name("TS_LDKLockableScore_new"))) TS_LDKLockableScore_new(JSValue o) {
10172         LDKLockableScore *res_ptr = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
10173         *res_ptr = LDKLockableScore_init(o);
10174         return (long)res_ptr;
10175 }
10176 uint32_t  __attribute__((export_name("TS_LockableScore_lock"))) TS_LockableScore_lock(uint32_t this_arg) {
10177         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10178         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10179         LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
10180         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
10181         *ret_ret = (this_arg_conv->lock)(this_arg_conv->this_arg);
10182         return (uint32_t)ret_ret;
10183 }
10184
10185 uint32_t __attribute__((export_name("TS_LDKFallback_ty_from_ptr"))) TS_LDKFallback_ty_from_ptr(uint32_t ptr) {
10186         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10187         switch(obj->tag) {
10188                 case LDKFallback_SegWitProgram: return 0;
10189                 case LDKFallback_PubKeyHash: return 1;
10190                 case LDKFallback_ScriptHash: return 2;
10191                 default: abort();
10192         }
10193 }
10194 int8_t __attribute__((export_name("TS_LDKFallback_SegWitProgram_get_version"))) TS_LDKFallback_SegWitProgram_get_version(uint32_t ptr) {
10195         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10196         assert(obj->tag == LDKFallback_SegWitProgram);
10197                         uint8_t version_val = obj->seg_wit_program.version._0;
10198         return version_val;
10199 }
10200 int8_tArray __attribute__((export_name("TS_LDKFallback_SegWitProgram_get_program"))) TS_LDKFallback_SegWitProgram_get_program(uint32_t ptr) {
10201         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10202         assert(obj->tag == LDKFallback_SegWitProgram);
10203                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
10204                         int8_tArray program_arr = init_int8_tArray(program_var.datalen, __LINE__);
10205                         memcpy(program_arr->elems, program_var.data, program_var.datalen);
10206         return program_arr;
10207 }
10208 int8_tArray __attribute__((export_name("TS_LDKFallback_PubKeyHash_get_pub_key_hash"))) TS_LDKFallback_PubKeyHash_get_pub_key_hash(uint32_t ptr) {
10209         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10210         assert(obj->tag == LDKFallback_PubKeyHash);
10211                         int8_tArray pub_key_hash_arr = init_int8_tArray(20, __LINE__);
10212                         memcpy(pub_key_hash_arr->elems, obj->pub_key_hash.data, 20);
10213         return pub_key_hash_arr;
10214 }
10215 int8_tArray __attribute__((export_name("TS_LDKFallback_ScriptHash_get_script_hash"))) TS_LDKFallback_ScriptHash_get_script_hash(uint32_t ptr) {
10216         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10217         assert(obj->tag == LDKFallback_ScriptHash);
10218                         int8_tArray script_hash_arr = init_int8_tArray(20, __LINE__);
10219                         memcpy(script_hash_arr->elems, obj->script_hash.data, 20);
10220         return script_hash_arr;
10221 }
10222 typedef struct LDKPayer_JCalls {
10223         atomic_size_t refcnt;
10224         uint32_t instance_ptr;
10225 } LDKPayer_JCalls;
10226 static void LDKPayer_JCalls_free(void* this_arg) {
10227         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10228         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10229                 FREE(j_calls);
10230         }
10231 }
10232 LDKPublicKey node_id_LDKPayer_jcall(const void* this_arg) {
10233         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10234         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 87);
10235         LDKPublicKey ret_ref;
10236         CHECK(ret->arr_len == 33);
10237         memcpy(ret_ref.compressed_form, ret->elems, 33); FREE(ret);
10238         return ret_ref;
10239 }
10240 LDKCVec_ChannelDetailsZ first_hops_LDKPayer_jcall(const void* this_arg) {
10241         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10242         uint32_tArray ret = (uint32_tArray)js_invoke_function_0(j_calls->instance_ptr, 88);
10243         LDKCVec_ChannelDetailsZ ret_constr;
10244         ret_constr.datalen = ret->arr_len;
10245         if (ret_constr.datalen > 0)
10246                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
10247         else
10248                 ret_constr.data = NULL;
10249         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
10250         for (size_t q = 0; q < ret_constr.datalen; q++) {
10251                 uint32_t ret_conv_16 = ret_vals[q];
10252                 LDKChannelDetails ret_conv_16_conv;
10253                 ret_conv_16_conv.inner = (void*)(ret_conv_16 & (~1));
10254                 ret_conv_16_conv.is_owned = (ret_conv_16 & 1) || (ret_conv_16 == 0);
10255                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_conv);
10256                 ret_constr.data[q] = ret_conv_16_conv;
10257         }
10258         return ret_constr;
10259 }
10260 LDKCResult_PaymentIdPaymentSendFailureZ send_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret) {
10261         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10262         LDKRoute route_var = *route;
10263         uint32_t route_ref = 0;
10264         route_var = Route_clone(&route_var);
10265         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10266         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10267         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
10268         route_ref = (uintptr_t)route_var.inner;
10269         if (route_var.is_owned) {
10270                 route_ref |= 1;
10271         }
10272         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
10273         memcpy(payment_hash_arr->elems, payment_hash.data, 32);
10274         int8_tArray payment_secret_arr = init_int8_tArray(32, __LINE__);
10275         memcpy(payment_secret_arr->elems, payment_secret.data, 32);
10276         uint32_t ret = js_invoke_function_3(j_calls->instance_ptr, 89, (uint32_t)route_ref, (uint32_t)payment_hash_arr, (uint32_t)payment_secret_arr);
10277         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10278         CHECK_ACCESS(ret_ptr);
10279         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
10280         FREE((void*)ret);
10281         return ret_conv;
10282 }
10283 LDKCResult_PaymentIdPaymentSendFailureZ send_spontaneous_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_preimage) {
10284         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10285         LDKRoute route_var = *route;
10286         uint32_t route_ref = 0;
10287         route_var = Route_clone(&route_var);
10288         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10289         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10290         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
10291         route_ref = (uintptr_t)route_var.inner;
10292         if (route_var.is_owned) {
10293                 route_ref |= 1;
10294         }
10295         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
10296         memcpy(payment_preimage_arr->elems, payment_preimage.data, 32);
10297         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 90, (uint32_t)route_ref, (uint32_t)payment_preimage_arr);
10298         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10299         CHECK_ACCESS(ret_ptr);
10300         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
10301         FREE((void*)ret);
10302         return ret_conv;
10303 }
10304 LDKCResult_NonePaymentSendFailureZ retry_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_id) {
10305         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10306         LDKRoute route_var = *route;
10307         uint32_t route_ref = 0;
10308         route_var = Route_clone(&route_var);
10309         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10310         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10311         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
10312         route_ref = (uintptr_t)route_var.inner;
10313         if (route_var.is_owned) {
10314                 route_ref |= 1;
10315         }
10316         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
10317         memcpy(payment_id_arr->elems, payment_id.data, 32);
10318         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 91, (uint32_t)route_ref, (uint32_t)payment_id_arr);
10319         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10320         CHECK_ACCESS(ret_ptr);
10321         LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
10322         FREE((void*)ret);
10323         return ret_conv;
10324 }
10325 void abandon_payment_LDKPayer_jcall(const void* this_arg, LDKThirtyTwoBytes payment_id) {
10326         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10327         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
10328         memcpy(payment_id_arr->elems, payment_id.data, 32);
10329         js_invoke_function_1(j_calls->instance_ptr, 92, (uint32_t)payment_id_arr);
10330 }
10331 static void LDKPayer_JCalls_cloned(LDKPayer* new_obj) {
10332         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) new_obj->this_arg;
10333         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10334 }
10335 static inline LDKPayer LDKPayer_init (JSValue o) {
10336         LDKPayer_JCalls *calls = MALLOC(sizeof(LDKPayer_JCalls), "LDKPayer_JCalls");
10337         atomic_init(&calls->refcnt, 1);
10338         calls->instance_ptr = o;
10339
10340         LDKPayer ret = {
10341                 .this_arg = (void*) calls,
10342                 .node_id = node_id_LDKPayer_jcall,
10343                 .first_hops = first_hops_LDKPayer_jcall,
10344                 .send_payment = send_payment_LDKPayer_jcall,
10345                 .send_spontaneous_payment = send_spontaneous_payment_LDKPayer_jcall,
10346                 .retry_payment = retry_payment_LDKPayer_jcall,
10347                 .abandon_payment = abandon_payment_LDKPayer_jcall,
10348                 .free = LDKPayer_JCalls_free,
10349         };
10350         return ret;
10351 }
10352 long  __attribute__((export_name("TS_LDKPayer_new"))) TS_LDKPayer_new(JSValue o) {
10353         LDKPayer *res_ptr = MALLOC(sizeof(LDKPayer), "LDKPayer");
10354         *res_ptr = LDKPayer_init(o);
10355         return (long)res_ptr;
10356 }
10357 int8_tArray  __attribute__((export_name("TS_Payer_node_id"))) TS_Payer_node_id(uint32_t this_arg) {
10358         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10359         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10360         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10361         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
10362         memcpy(ret_arr->elems, (this_arg_conv->node_id)(this_arg_conv->this_arg).compressed_form, 33);
10363         return ret_arr;
10364 }
10365
10366 uint32_tArray  __attribute__((export_name("TS_Payer_first_hops"))) TS_Payer_first_hops(uint32_t this_arg) {
10367         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10368         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10369         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10370         LDKCVec_ChannelDetailsZ ret_var = (this_arg_conv->first_hops)(this_arg_conv->this_arg);
10371         uint32_tArray ret_arr = NULL;
10372         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
10373         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
10374         for (size_t q = 0; q < ret_var.datalen; q++) {
10375                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
10376                 uint32_t ret_conv_16_ref = 0;
10377                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10378                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10379                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
10380                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
10381                 if (ret_conv_16_var.is_owned) {
10382                         ret_conv_16_ref |= 1;
10383                 }
10384                 ret_arr_ptr[q] = ret_conv_16_ref;
10385         }
10386         
10387         FREE(ret_var.data);
10388         return ret_arr;
10389 }
10390
10391 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) {
10392         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10393         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10394         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10395         LDKRoute route_conv;
10396         route_conv.inner = (void*)(route & (~1));
10397         route_conv.is_owned = false;
10398         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
10399         LDKThirtyTwoBytes payment_hash_ref;
10400         CHECK(payment_hash->arr_len == 32);
10401         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
10402         LDKThirtyTwoBytes payment_secret_ref;
10403         CHECK(payment_secret->arr_len == 32);
10404         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
10405         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
10406         *ret_conv = (this_arg_conv->send_payment)(this_arg_conv->this_arg, &route_conv, payment_hash_ref, payment_secret_ref);
10407         return (uint32_t)ret_conv;
10408 }
10409
10410 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) {
10411         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10412         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10413         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10414         LDKRoute route_conv;
10415         route_conv.inner = (void*)(route & (~1));
10416         route_conv.is_owned = false;
10417         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
10418         LDKThirtyTwoBytes payment_preimage_ref;
10419         CHECK(payment_preimage->arr_len == 32);
10420         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
10421         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
10422         *ret_conv = (this_arg_conv->send_spontaneous_payment)(this_arg_conv->this_arg, &route_conv, payment_preimage_ref);
10423         return (uint32_t)ret_conv;
10424 }
10425
10426 uint32_t  __attribute__((export_name("TS_Payer_retry_payment"))) TS_Payer_retry_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_id) {
10427         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10428         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10429         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10430         LDKRoute route_conv;
10431         route_conv.inner = (void*)(route & (~1));
10432         route_conv.is_owned = false;
10433         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
10434         LDKThirtyTwoBytes payment_id_ref;
10435         CHECK(payment_id->arr_len == 32);
10436         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
10437         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10438         *ret_conv = (this_arg_conv->retry_payment)(this_arg_conv->this_arg, &route_conv, payment_id_ref);
10439         return (uint32_t)ret_conv;
10440 }
10441
10442 void  __attribute__((export_name("TS_Payer_abandon_payment"))) TS_Payer_abandon_payment(uint32_t this_arg, int8_tArray payment_id) {
10443         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10444         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10445         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10446         LDKThirtyTwoBytes payment_id_ref;
10447         CHECK(payment_id->arr_len == 32);
10448         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
10449         (this_arg_conv->abandon_payment)(this_arg_conv->this_arg, payment_id_ref);
10450 }
10451
10452 typedef struct LDKRouter_JCalls {
10453         atomic_size_t refcnt;
10454         uint32_t instance_ptr;
10455 } LDKRouter_JCalls;
10456 static void LDKRouter_JCalls_free(void* this_arg) {
10457         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
10458         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10459                 FREE(j_calls);
10460         }
10461 }
10462 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) {
10463         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
10464         int8_tArray payer_arr = init_int8_tArray(33, __LINE__);
10465         memcpy(payer_arr->elems, payer.compressed_form, 33);
10466         LDKRouteParameters route_params_var = *route_params;
10467         uint32_t route_params_ref = 0;
10468         route_params_var = RouteParameters_clone(&route_params_var);
10469         CHECK((((uintptr_t)route_params_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10470         CHECK((((uintptr_t)&route_params_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10471         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
10472         route_params_ref = (uintptr_t)route_params_var.inner;
10473         if (route_params_var.is_owned) {
10474                 route_params_ref |= 1;
10475         }
10476         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
10477         memcpy(payment_hash_arr->elems, *payment_hash, 32);
10478         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
10479         uint32_tArray first_hops_arr = NULL;
10480         if (first_hops != NULL) {
10481                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
10482                 first_hops_arr = init_uint32_tArray(first_hops_var.datalen, __LINE__);
10483                 uint32_t *first_hops_arr_ptr = (uint32_t*)(((uint8_t*)first_hops_arr) + 4);
10484                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
10485                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
10486                         uint32_t first_hops_conv_16_ref = 0;
10487                         CHECK((((uintptr_t)first_hops_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10488                         CHECK((((uintptr_t)&first_hops_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10489                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
10490                         first_hops_conv_16_ref = (uintptr_t)first_hops_conv_16_var.inner;
10491                         if (first_hops_conv_16_var.is_owned) {
10492                                 first_hops_conv_16_ref |= 1;
10493                         }
10494                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
10495                 }
10496         
10497         }
10498         // WARNING: This object doesn't live past this scope, needs clone!
10499         uint32_t ret_scorer = ((uintptr_t)scorer) | 1;
10500         uint32_t ret = js_invoke_function_5(j_calls->instance_ptr, 93, (uint32_t)payer_arr, (uint32_t)route_params_ref, (uint32_t)payment_hash_arr, (uint32_t)first_hops_arr, (uint32_t)ret_scorer);
10501         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10502         CHECK_ACCESS(ret_ptr);
10503         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
10504         FREE((void*)ret);
10505         return ret_conv;
10506 }
10507 static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
10508         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
10509         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10510 }
10511 static inline LDKRouter LDKRouter_init (JSValue o) {
10512         LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
10513         atomic_init(&calls->refcnt, 1);
10514         calls->instance_ptr = o;
10515
10516         LDKRouter ret = {
10517                 .this_arg = (void*) calls,
10518                 .find_route = find_route_LDKRouter_jcall,
10519                 .free = LDKRouter_JCalls_free,
10520         };
10521         return ret;
10522 }
10523 long  __attribute__((export_name("TS_LDKRouter_new"))) TS_LDKRouter_new(JSValue o) {
10524         LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
10525         *res_ptr = LDKRouter_init(o);
10526         return (long)res_ptr;
10527 }
10528 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) {
10529         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10530         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10531         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
10532         LDKPublicKey payer_ref;
10533         CHECK(payer->arr_len == 33);
10534         memcpy(payer_ref.compressed_form, payer->elems, 33); FREE(payer);
10535         LDKRouteParameters route_params_conv;
10536         route_params_conv.inner = (void*)(route_params & (~1));
10537         route_params_conv.is_owned = false;
10538         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
10539         unsigned char payment_hash_arr[32];
10540         CHECK(payment_hash->arr_len == 32);
10541         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
10542         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
10543         LDKCVec_ChannelDetailsZ first_hops_constr;
10544         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
10545         if (first_hops != 0) {
10546                 first_hops_constr.datalen = first_hops->arr_len;
10547                 if (first_hops_constr.datalen > 0)
10548                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
10549                 else
10550                         first_hops_constr.data = NULL;
10551                 uint32_t* first_hops_vals = first_hops->elems /* XXX first_hops leaks */;
10552                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
10553                         uint32_t first_hops_conv_16 = first_hops_vals[q];
10554                         LDKChannelDetails first_hops_conv_16_conv;
10555                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
10556                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
10557                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
10558                         first_hops_constr.data[q] = first_hops_conv_16_conv;
10559                 }
10560                 first_hops_ptr = &first_hops_constr;
10561         }
10562         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
10563         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
10564         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
10565         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
10566         *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);
10567         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
10568         return (uint32_t)ret_conv;
10569 }
10570
10571 jstring  __attribute__((export_name("TS__ldk_get_compiled_version"))) TS__ldk_get_compiled_version() {
10572         LDKStr ret_str = _ldk_get_compiled_version();
10573         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
10574         Str_free(ret_str);
10575         return ret_conv;
10576 }
10577
10578 jstring  __attribute__((export_name("TS__ldk_c_bindings_get_compiled_version"))) TS__ldk_c_bindings_get_compiled_version() {
10579         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
10580         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
10581         Str_free(ret_str);
10582         return ret_conv;
10583 }
10584
10585 static inline uintptr_t Bech32Error_clone_ptr(LDKBech32Error *NONNULL_PTR arg) {
10586         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
10587         *ret_copy = Bech32Error_clone(arg);
10588 uint32_t ret_ref = (uintptr_t)ret_copy;
10589         return ret_ref;
10590 }
10591 uint32_t  __attribute__((export_name("TS_Bech32Error_clone_ptr"))) TS_Bech32Error_clone_ptr(uint32_t arg) {
10592         LDKBech32Error* arg_conv = (LDKBech32Error*)arg;
10593         uint32_t ret_conv = Bech32Error_clone_ptr(arg_conv);
10594         return ret_conv;
10595 }
10596
10597 uint32_t  __attribute__((export_name("TS_Bech32Error_clone"))) TS_Bech32Error_clone(uint32_t orig) {
10598         LDKBech32Error* orig_conv = (LDKBech32Error*)orig;
10599         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
10600         *ret_copy = Bech32Error_clone(orig_conv);
10601         uint32_t ret_ref = (uintptr_t)ret_copy;
10602         return ret_ref;
10603 }
10604
10605 void  __attribute__((export_name("TS_Bech32Error_free"))) TS_Bech32Error_free(uint32_t o) {
10606         if ((o & 1) != 0) return;
10607         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
10608         CHECK_ACCESS(o_ptr);
10609         LDKBech32Error o_conv = *(LDKBech32Error*)(o_ptr);
10610         FREE((void*)o);
10611         Bech32Error_free(o_conv);
10612 }
10613
10614 void  __attribute__((export_name("TS_Transaction_free"))) TS_Transaction_free(int8_tArray _res) {
10615         LDKTransaction _res_ref;
10616         _res_ref.datalen = _res->arr_len;
10617         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
10618         memcpy(_res_ref.data, _res->elems, _res_ref.datalen); FREE(_res);
10619         _res_ref.data_is_owned = true;
10620         Transaction_free(_res_ref);
10621 }
10622
10623 uint32_t  __attribute__((export_name("TS_TxOut_new"))) TS_TxOut_new(int8_tArray script_pubkey, int64_t value) {
10624         LDKCVec_u8Z script_pubkey_ref;
10625         script_pubkey_ref.datalen = script_pubkey->arr_len;
10626         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
10627         memcpy(script_pubkey_ref.data, script_pubkey->elems, script_pubkey_ref.datalen); FREE(script_pubkey);
10628         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
10629         *ret_ref = TxOut_new(script_pubkey_ref, value);
10630         return (uint32_t)ret_ref;
10631 }
10632
10633 void  __attribute__((export_name("TS_TxOut_free"))) TS_TxOut_free(uint32_t _res) {
10634         if ((_res & 1) != 0) return;
10635         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10636         CHECK_ACCESS(_res_ptr);
10637         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
10638         FREE((void*)_res);
10639         TxOut_free(_res_conv);
10640 }
10641
10642 static inline uintptr_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
10643         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
10644         *ret_ref = TxOut_clone(arg);
10645         return (uint32_t)ret_ref;
10646 }
10647 uint32_t  __attribute__((export_name("TS_TxOut_clone_ptr"))) TS_TxOut_clone_ptr(uint32_t arg) {
10648         LDKTxOut* arg_conv = (LDKTxOut*)(arg & ~1);
10649         uint32_t ret_conv = TxOut_clone_ptr(arg_conv);
10650         return ret_conv;
10651 }
10652
10653 uint32_t  __attribute__((export_name("TS_TxOut_clone"))) TS_TxOut_clone(uint32_t orig) {
10654         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
10655         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
10656         *ret_ref = TxOut_clone(orig_conv);
10657         return (uint32_t)ret_ref;
10658 }
10659
10660 void  __attribute__((export_name("TS_Str_free"))) TS_Str_free(jstring _res) {
10661         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
10662         Str_free(dummy);
10663 }
10664
10665 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_ok"))) TS_CResult_NoneNoneZ_ok() {
10666         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10667         *ret_conv = CResult_NoneNoneZ_ok();
10668         return (uint32_t)ret_conv;
10669 }
10670
10671 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_err"))) TS_CResult_NoneNoneZ_err() {
10672         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10673         *ret_conv = CResult_NoneNoneZ_err();
10674         return (uint32_t)ret_conv;
10675 }
10676
10677 jboolean  __attribute__((export_name("TS_CResult_NoneNoneZ_is_ok"))) TS_CResult_NoneNoneZ_is_ok(uint32_t o) {
10678         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)(o & ~1);
10679         jboolean ret_conv = CResult_NoneNoneZ_is_ok(o_conv);
10680         return ret_conv;
10681 }
10682
10683 void  __attribute__((export_name("TS_CResult_NoneNoneZ_free"))) TS_CResult_NoneNoneZ_free(uint32_t _res) {
10684         if ((_res & 1) != 0) return;
10685         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10686         CHECK_ACCESS(_res_ptr);
10687         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
10688         FREE((void*)_res);
10689         CResult_NoneNoneZ_free(_res_conv);
10690 }
10691
10692 static inline uintptr_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
10693         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10694         *ret_conv = CResult_NoneNoneZ_clone(arg);
10695         return (uint32_t)ret_conv;
10696 }
10697 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_clone_ptr"))) TS_CResult_NoneNoneZ_clone_ptr(uint32_t arg) {
10698         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)(arg & ~1);
10699         uint32_t ret_conv = CResult_NoneNoneZ_clone_ptr(arg_conv);
10700         return ret_conv;
10701 }
10702
10703 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_clone"))) TS_CResult_NoneNoneZ_clone(uint32_t orig) {
10704         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1);
10705         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10706         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
10707         return (uint32_t)ret_conv;
10708 }
10709
10710 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(uint32_t o) {
10711         LDKCounterpartyCommitmentSecrets o_conv;
10712         o_conv.inner = (void*)(o & (~1));
10713         o_conv.is_owned = (o & 1) || (o == 0);
10714         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10715         o_conv = CounterpartyCommitmentSecrets_clone(&o_conv);
10716         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
10717         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(o_conv);
10718         return (uint32_t)ret_conv;
10719 }
10720
10721 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(uint32_t e) {
10722         LDKDecodeError e_conv;
10723         e_conv.inner = (void*)(e & (~1));
10724         e_conv.is_owned = (e & 1) || (e == 0);
10725         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10726         e_conv = DecodeError_clone(&e_conv);
10727         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
10728         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e_conv);
10729         return (uint32_t)ret_conv;
10730 }
10731
10732 jboolean  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(uint32_t o) {
10733         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* o_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(o & ~1);
10734         jboolean ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(o_conv);
10735         return ret_conv;
10736 }
10737
10738 void  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(uint32_t _res) {
10739         if ((_res & 1) != 0) return;
10740         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10741         CHECK_ACCESS(_res_ptr);
10742         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(_res_ptr);
10743         FREE((void*)_res);
10744         CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(_res_conv);
10745 }
10746
10747 static inline uintptr_t CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR arg) {
10748         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
10749         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(arg);
10750         return (uint32_t)ret_conv;
10751 }
10752 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(uint32_t arg) {
10753         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(arg & ~1);
10754         uint32_t ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(arg_conv);
10755         return ret_conv;
10756 }
10757
10758 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(uint32_t orig) {
10759         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(orig & ~1);
10760         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
10761         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(orig_conv);
10762         return (uint32_t)ret_conv;
10763 }
10764
10765 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_ok"))) TS_CResult_SecretKeyErrorZ_ok(int8_tArray o) {
10766         LDKSecretKey o_ref;
10767         CHECK(o->arr_len == 32);
10768         memcpy(o_ref.bytes, o->elems, 32); FREE(o);
10769         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
10770         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
10771         return (uint32_t)ret_conv;
10772 }
10773
10774 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_err"))) TS_CResult_SecretKeyErrorZ_err(uint32_t e) {
10775         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
10776         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
10777         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
10778         return (uint32_t)ret_conv;
10779 }
10780
10781 jboolean  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_is_ok"))) TS_CResult_SecretKeyErrorZ_is_ok(uint32_t o) {
10782         LDKCResult_SecretKeyErrorZ* o_conv = (LDKCResult_SecretKeyErrorZ*)(o & ~1);
10783         jboolean ret_conv = CResult_SecretKeyErrorZ_is_ok(o_conv);
10784         return ret_conv;
10785 }
10786
10787 void  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_free"))) TS_CResult_SecretKeyErrorZ_free(uint32_t _res) {
10788         if ((_res & 1) != 0) return;
10789         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10790         CHECK_ACCESS(_res_ptr);
10791         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
10792         FREE((void*)_res);
10793         CResult_SecretKeyErrorZ_free(_res_conv);
10794 }
10795
10796 static inline uintptr_t CResult_SecretKeyErrorZ_clone_ptr(LDKCResult_SecretKeyErrorZ *NONNULL_PTR arg) {
10797         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
10798         *ret_conv = CResult_SecretKeyErrorZ_clone(arg);
10799         return (uint32_t)ret_conv;
10800 }
10801 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_clone_ptr"))) TS_CResult_SecretKeyErrorZ_clone_ptr(uint32_t arg) {
10802         LDKCResult_SecretKeyErrorZ* arg_conv = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
10803         uint32_t ret_conv = CResult_SecretKeyErrorZ_clone_ptr(arg_conv);
10804         return ret_conv;
10805 }
10806
10807 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_clone"))) TS_CResult_SecretKeyErrorZ_clone(uint32_t orig) {
10808         LDKCResult_SecretKeyErrorZ* orig_conv = (LDKCResult_SecretKeyErrorZ*)(orig & ~1);
10809         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
10810         *ret_conv = CResult_SecretKeyErrorZ_clone(orig_conv);
10811         return (uint32_t)ret_conv;
10812 }
10813
10814 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_ok"))) TS_CResult_PublicKeyErrorZ_ok(int8_tArray o) {
10815         LDKPublicKey o_ref;
10816         CHECK(o->arr_len == 33);
10817         memcpy(o_ref.compressed_form, o->elems, 33); FREE(o);
10818         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
10819         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
10820         return (uint32_t)ret_conv;
10821 }
10822
10823 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_err"))) TS_CResult_PublicKeyErrorZ_err(uint32_t e) {
10824         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
10825         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
10826         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
10827         return (uint32_t)ret_conv;
10828 }
10829
10830 jboolean  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_is_ok"))) TS_CResult_PublicKeyErrorZ_is_ok(uint32_t o) {
10831         LDKCResult_PublicKeyErrorZ* o_conv = (LDKCResult_PublicKeyErrorZ*)(o & ~1);
10832         jboolean ret_conv = CResult_PublicKeyErrorZ_is_ok(o_conv);
10833         return ret_conv;
10834 }
10835
10836 void  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_free"))) TS_CResult_PublicKeyErrorZ_free(uint32_t _res) {
10837         if ((_res & 1) != 0) return;
10838         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10839         CHECK_ACCESS(_res_ptr);
10840         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
10841         FREE((void*)_res);
10842         CResult_PublicKeyErrorZ_free(_res_conv);
10843 }
10844
10845 static inline uintptr_t CResult_PublicKeyErrorZ_clone_ptr(LDKCResult_PublicKeyErrorZ *NONNULL_PTR arg) {
10846         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
10847         *ret_conv = CResult_PublicKeyErrorZ_clone(arg);
10848         return (uint32_t)ret_conv;
10849 }
10850 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_clone_ptr"))) TS_CResult_PublicKeyErrorZ_clone_ptr(uint32_t arg) {
10851         LDKCResult_PublicKeyErrorZ* arg_conv = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
10852         uint32_t ret_conv = CResult_PublicKeyErrorZ_clone_ptr(arg_conv);
10853         return ret_conv;
10854 }
10855
10856 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_clone"))) TS_CResult_PublicKeyErrorZ_clone(uint32_t orig) {
10857         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
10858         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
10859         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
10860         return (uint32_t)ret_conv;
10861 }
10862
10863 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_ok(uint32_t o) {
10864         LDKTxCreationKeys o_conv;
10865         o_conv.inner = (void*)(o & (~1));
10866         o_conv.is_owned = (o & 1) || (o == 0);
10867         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10868         o_conv = TxCreationKeys_clone(&o_conv);
10869         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
10870         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
10871         return (uint32_t)ret_conv;
10872 }
10873
10874 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_err"))) TS_CResult_TxCreationKeysDecodeErrorZ_err(uint32_t e) {
10875         LDKDecodeError e_conv;
10876         e_conv.inner = (void*)(e & (~1));
10877         e_conv.is_owned = (e & 1) || (e == 0);
10878         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10879         e_conv = DecodeError_clone(&e_conv);
10880         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
10881         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
10882         return (uint32_t)ret_conv;
10883 }
10884
10885 jboolean  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_is_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_is_ok(uint32_t o) {
10886         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(o & ~1);
10887         jboolean ret_conv = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
10888         return ret_conv;
10889 }
10890
10891 void  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_free"))) TS_CResult_TxCreationKeysDecodeErrorZ_free(uint32_t _res) {
10892         if ((_res & 1) != 0) return;
10893         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10894         CHECK_ACCESS(_res_ptr);
10895         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
10896         FREE((void*)_res);
10897         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
10898 }
10899
10900 static inline uintptr_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
10901         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
10902         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
10903         return (uint32_t)ret_conv;
10904 }
10905 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_clone_ptr"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone_ptr(uint32_t arg) {
10906         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
10907         uint32_t ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
10908         return ret_conv;
10909 }
10910
10911 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_clone"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone(uint32_t orig) {
10912         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
10913         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
10914         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
10915         return (uint32_t)ret_conv;
10916 }
10917
10918 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_ok(uint32_t o) {
10919         LDKChannelPublicKeys o_conv;
10920         o_conv.inner = (void*)(o & (~1));
10921         o_conv.is_owned = (o & 1) || (o == 0);
10922         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10923         o_conv = ChannelPublicKeys_clone(&o_conv);
10924         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
10925         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
10926         return (uint32_t)ret_conv;
10927 }
10928
10929 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_err"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_err(uint32_t e) {
10930         LDKDecodeError e_conv;
10931         e_conv.inner = (void*)(e & (~1));
10932         e_conv.is_owned = (e & 1) || (e == 0);
10933         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10934         e_conv = DecodeError_clone(&e_conv);
10935         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
10936         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
10937         return (uint32_t)ret_conv;
10938 }
10939
10940 jboolean  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_is_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_is_ok(uint32_t o) {
10941         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(o & ~1);
10942         jboolean ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
10943         return ret_conv;
10944 }
10945
10946 void  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_free"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_free(uint32_t _res) {
10947         if ((_res & 1) != 0) return;
10948         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10949         CHECK_ACCESS(_res_ptr);
10950         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
10951         FREE((void*)_res);
10952         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
10953 }
10954
10955 static inline uintptr_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
10956         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
10957         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
10958         return (uint32_t)ret_conv;
10959 }
10960 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(uint32_t arg) {
10961         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
10962         uint32_t ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
10963         return ret_conv;
10964 }
10965
10966 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_clone"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone(uint32_t orig) {
10967         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
10968         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
10969         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
10970         return (uint32_t)ret_conv;
10971 }
10972
10973 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_ok"))) TS_CResult_TxCreationKeysErrorZ_ok(uint32_t o) {
10974         LDKTxCreationKeys o_conv;
10975         o_conv.inner = (void*)(o & (~1));
10976         o_conv.is_owned = (o & 1) || (o == 0);
10977         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10978         o_conv = TxCreationKeys_clone(&o_conv);
10979         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
10980         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
10981         return (uint32_t)ret_conv;
10982 }
10983
10984 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_err"))) TS_CResult_TxCreationKeysErrorZ_err(uint32_t e) {
10985         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
10986         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
10987         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
10988         return (uint32_t)ret_conv;
10989 }
10990
10991 jboolean  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_is_ok"))) TS_CResult_TxCreationKeysErrorZ_is_ok(uint32_t o) {
10992         LDKCResult_TxCreationKeysErrorZ* o_conv = (LDKCResult_TxCreationKeysErrorZ*)(o & ~1);
10993         jboolean ret_conv = CResult_TxCreationKeysErrorZ_is_ok(o_conv);
10994         return ret_conv;
10995 }
10996
10997 void  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_free"))) TS_CResult_TxCreationKeysErrorZ_free(uint32_t _res) {
10998         if ((_res & 1) != 0) return;
10999         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11000         CHECK_ACCESS(_res_ptr);
11001         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
11002         FREE((void*)_res);
11003         CResult_TxCreationKeysErrorZ_free(_res_conv);
11004 }
11005
11006 static inline uintptr_t CResult_TxCreationKeysErrorZ_clone_ptr(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR arg) {
11007         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11008         *ret_conv = CResult_TxCreationKeysErrorZ_clone(arg);
11009         return (uint32_t)ret_conv;
11010 }
11011 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_clone_ptr"))) TS_CResult_TxCreationKeysErrorZ_clone_ptr(uint32_t arg) {
11012         LDKCResult_TxCreationKeysErrorZ* arg_conv = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
11013         uint32_t ret_conv = CResult_TxCreationKeysErrorZ_clone_ptr(arg_conv);
11014         return ret_conv;
11015 }
11016
11017 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_clone"))) TS_CResult_TxCreationKeysErrorZ_clone(uint32_t orig) {
11018         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
11019         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11020         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
11021         return (uint32_t)ret_conv;
11022 }
11023
11024 uint32_t  __attribute__((export_name("TS_COption_u32Z_some"))) TS_COption_u32Z_some(int32_t o) {
11025         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11026         *ret_copy = COption_u32Z_some(o);
11027         uint32_t ret_ref = (uintptr_t)ret_copy;
11028         return ret_ref;
11029 }
11030
11031 uint32_t  __attribute__((export_name("TS_COption_u32Z_none"))) TS_COption_u32Z_none() {
11032         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11033         *ret_copy = COption_u32Z_none();
11034         uint32_t ret_ref = (uintptr_t)ret_copy;
11035         return ret_ref;
11036 }
11037
11038 void  __attribute__((export_name("TS_COption_u32Z_free"))) TS_COption_u32Z_free(uint32_t _res) {
11039         if ((_res & 1) != 0) return;
11040         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11041         CHECK_ACCESS(_res_ptr);
11042         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
11043         FREE((void*)_res);
11044         COption_u32Z_free(_res_conv);
11045 }
11046
11047 static inline uintptr_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
11048         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11049         *ret_copy = COption_u32Z_clone(arg);
11050 uint32_t ret_ref = (uintptr_t)ret_copy;
11051         return ret_ref;
11052 }
11053 uint32_t  __attribute__((export_name("TS_COption_u32Z_clone_ptr"))) TS_COption_u32Z_clone_ptr(uint32_t arg) {
11054         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)arg;
11055         uint32_t ret_conv = COption_u32Z_clone_ptr(arg_conv);
11056         return ret_conv;
11057 }
11058
11059 uint32_t  __attribute__((export_name("TS_COption_u32Z_clone"))) TS_COption_u32Z_clone(uint32_t orig) {
11060         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
11061         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11062         *ret_copy = COption_u32Z_clone(orig_conv);
11063         uint32_t ret_ref = (uintptr_t)ret_copy;
11064         return ret_ref;
11065 }
11066
11067 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(uint32_t o) {
11068         LDKHTLCOutputInCommitment o_conv;
11069         o_conv.inner = (void*)(o & (~1));
11070         o_conv.is_owned = (o & 1) || (o == 0);
11071         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11072         o_conv = HTLCOutputInCommitment_clone(&o_conv);
11073         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11074         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
11075         return (uint32_t)ret_conv;
11076 }
11077
11078 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err(uint32_t e) {
11079         LDKDecodeError e_conv;
11080         e_conv.inner = (void*)(e & (~1));
11081         e_conv.is_owned = (e & 1) || (e == 0);
11082         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11083         e_conv = DecodeError_clone(&e_conv);
11084         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11085         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
11086         return (uint32_t)ret_conv;
11087 }
11088
11089 jboolean  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(uint32_t o) {
11090         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(o & ~1);
11091         jboolean ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
11092         return ret_conv;
11093 }
11094
11095 void  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free(uint32_t _res) {
11096         if ((_res & 1) != 0) return;
11097         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11098         CHECK_ACCESS(_res_ptr);
11099         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
11100         FREE((void*)_res);
11101         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
11102 }
11103
11104 static inline uintptr_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
11105         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11106         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
11107         return (uint32_t)ret_conv;
11108 }
11109 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(uint32_t arg) {
11110         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
11111         uint32_t ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
11112         return ret_conv;
11113 }
11114
11115 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(uint32_t orig) {
11116         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
11117         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11118         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
11119         return (uint32_t)ret_conv;
11120 }
11121
11122 uint32_t  __attribute__((export_name("TS_COption_NoneZ_some"))) TS_COption_NoneZ_some() {
11123         uint32_t ret_conv = LDKCOption_NoneZ_to_js(COption_NoneZ_some());
11124         return ret_conv;
11125 }
11126
11127 uint32_t  __attribute__((export_name("TS_COption_NoneZ_none"))) TS_COption_NoneZ_none() {
11128         uint32_t ret_conv = LDKCOption_NoneZ_to_js(COption_NoneZ_none());
11129         return ret_conv;
11130 }
11131
11132 void  __attribute__((export_name("TS_COption_NoneZ_free"))) TS_COption_NoneZ_free(uint32_t _res) {
11133         LDKCOption_NoneZ _res_conv = LDKCOption_NoneZ_from_js(_res);
11134         COption_NoneZ_free(_res_conv);
11135 }
11136
11137 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
11138         LDKCounterpartyChannelTransactionParameters o_conv;
11139         o_conv.inner = (void*)(o & (~1));
11140         o_conv.is_owned = (o & 1) || (o == 0);
11141         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11142         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
11143         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11144         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
11145         return (uint32_t)ret_conv;
11146 }
11147
11148 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
11149         LDKDecodeError e_conv;
11150         e_conv.inner = (void*)(e & (~1));
11151         e_conv.is_owned = (e & 1) || (e == 0);
11152         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11153         e_conv = DecodeError_clone(&e_conv);
11154         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11155         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
11156         return (uint32_t)ret_conv;
11157 }
11158
11159 jboolean  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(uint32_t o) {
11160         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(o & ~1);
11161         jboolean ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
11162         return ret_conv;
11163 }
11164
11165 void  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
11166         if ((_res & 1) != 0) return;
11167         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11168         CHECK_ACCESS(_res_ptr);
11169         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
11170         FREE((void*)_res);
11171         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
11172 }
11173
11174 static inline uintptr_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
11175         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11176         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
11177         return (uint32_t)ret_conv;
11178 }
11179 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
11180         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
11181         uint32_t ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
11182         return ret_conv;
11183 }
11184
11185 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
11186         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
11187         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11188         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
11189         return (uint32_t)ret_conv;
11190 }
11191
11192 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
11193         LDKChannelTransactionParameters o_conv;
11194         o_conv.inner = (void*)(o & (~1));
11195         o_conv.is_owned = (o & 1) || (o == 0);
11196         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11197         o_conv = ChannelTransactionParameters_clone(&o_conv);
11198         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11199         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
11200         return (uint32_t)ret_conv;
11201 }
11202
11203 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_err"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
11204         LDKDecodeError e_conv;
11205         e_conv.inner = (void*)(e & (~1));
11206         e_conv.is_owned = (e & 1) || (e == 0);
11207         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11208         e_conv = DecodeError_clone(&e_conv);
11209         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11210         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
11211         return (uint32_t)ret_conv;
11212 }
11213
11214 jboolean  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_is_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(uint32_t o) {
11215         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(o & ~1);
11216         jboolean ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
11217         return ret_conv;
11218 }
11219
11220 void  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_free"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
11221         if ((_res & 1) != 0) return;
11222         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11223         CHECK_ACCESS(_res_ptr);
11224         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
11225         FREE((void*)_res);
11226         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
11227 }
11228
11229 static inline uintptr_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
11230         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11231         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
11232         return (uint32_t)ret_conv;
11233 }
11234 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
11235         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
11236         uint32_t ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
11237         return ret_conv;
11238 }
11239
11240 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
11241         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
11242         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11243         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
11244         return (uint32_t)ret_conv;
11245 }
11246
11247 void  __attribute__((export_name("TS_CVec_SignatureZ_free"))) TS_CVec_SignatureZ_free(ptrArray _res) {
11248         LDKCVec_SignatureZ _res_constr;
11249         _res_constr.datalen = _res->arr_len;
11250         if (_res_constr.datalen > 0)
11251                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
11252         else
11253                 _res_constr.data = NULL;
11254         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
11255         for (size_t m = 0; m < _res_constr.datalen; m++) {
11256                 int8_tArray _res_conv_12 = _res_vals[m];
11257                 LDKSignature _res_conv_12_ref;
11258                 CHECK(_res_conv_12->arr_len == 64);
11259                 memcpy(_res_conv_12_ref.compact_form, _res_conv_12->elems, 64); FREE(_res_conv_12);
11260                 _res_constr.data[m] = _res_conv_12_ref;
11261         }
11262         CVec_SignatureZ_free(_res_constr);
11263 }
11264
11265 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
11266         LDKHolderCommitmentTransaction o_conv;
11267         o_conv.inner = (void*)(o & (~1));
11268         o_conv.is_owned = (o & 1) || (o == 0);
11269         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11270         o_conv = HolderCommitmentTransaction_clone(&o_conv);
11271         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11272         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
11273         return (uint32_t)ret_conv;
11274 }
11275
11276 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
11277         LDKDecodeError e_conv;
11278         e_conv.inner = (void*)(e & (~1));
11279         e_conv.is_owned = (e & 1) || (e == 0);
11280         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11281         e_conv = DecodeError_clone(&e_conv);
11282         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11283         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
11284         return (uint32_t)ret_conv;
11285 }
11286
11287 jboolean  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
11288         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(o & ~1);
11289         jboolean ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
11290         return ret_conv;
11291 }
11292
11293 void  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
11294         if ((_res & 1) != 0) return;
11295         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11296         CHECK_ACCESS(_res_ptr);
11297         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
11298         FREE((void*)_res);
11299         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
11300 }
11301
11302 static inline uintptr_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
11303         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11304         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
11305         return (uint32_t)ret_conv;
11306 }
11307 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
11308         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
11309         uint32_t ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
11310         return ret_conv;
11311 }
11312
11313 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
11314         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
11315         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11316         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
11317         return (uint32_t)ret_conv;
11318 }
11319
11320 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
11321         LDKBuiltCommitmentTransaction o_conv;
11322         o_conv.inner = (void*)(o & (~1));
11323         o_conv.is_owned = (o & 1) || (o == 0);
11324         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11325         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
11326         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11327         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
11328         return (uint32_t)ret_conv;
11329 }
11330
11331 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
11332         LDKDecodeError e_conv;
11333         e_conv.inner = (void*)(e & (~1));
11334         e_conv.is_owned = (e & 1) || (e == 0);
11335         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11336         e_conv = DecodeError_clone(&e_conv);
11337         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11338         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
11339         return (uint32_t)ret_conv;
11340 }
11341
11342 jboolean  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
11343         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(o & ~1);
11344         jboolean ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
11345         return ret_conv;
11346 }
11347
11348 void  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_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         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
11353         FREE((void*)_res);
11354         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
11355 }
11356
11357 static inline uintptr_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
11358         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11359         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
11360         return (uint32_t)ret_conv;
11361 }
11362 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
11363         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
11364         uint32_t ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
11365         return ret_conv;
11366 }
11367
11368 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
11369         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
11370         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11371         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
11372         return (uint32_t)ret_conv;
11373 }
11374
11375 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_ok(uint32_t o) {
11376         LDKTrustedClosingTransaction o_conv;
11377         o_conv.inner = (void*)(o & (~1));
11378         o_conv.is_owned = (o & 1) || (o == 0);
11379         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11380         // WARNING: we need a move here but no clone is available for LDKTrustedClosingTransaction
11381         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
11382         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
11383         return (uint32_t)ret_conv;
11384 }
11385
11386 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_err"))) TS_CResult_TrustedClosingTransactionNoneZ_err() {
11387         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
11388         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
11389         return (uint32_t)ret_conv;
11390 }
11391
11392 jboolean  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_is_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_is_ok(uint32_t o) {
11393         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(o & ~1);
11394         jboolean ret_conv = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
11395         return ret_conv;
11396 }
11397
11398 void  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_free"))) TS_CResult_TrustedClosingTransactionNoneZ_free(uint32_t _res) {
11399         if ((_res & 1) != 0) return;
11400         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11401         CHECK_ACCESS(_res_ptr);
11402         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
11403         FREE((void*)_res);
11404         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
11405 }
11406
11407 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
11408         LDKCommitmentTransaction o_conv;
11409         o_conv.inner = (void*)(o & (~1));
11410         o_conv.is_owned = (o & 1) || (o == 0);
11411         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11412         o_conv = CommitmentTransaction_clone(&o_conv);
11413         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11414         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
11415         return (uint32_t)ret_conv;
11416 }
11417
11418 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_err"))) TS_CResult_CommitmentTransactionDecodeErrorZ_err(uint32_t e) {
11419         LDKDecodeError e_conv;
11420         e_conv.inner = (void*)(e & (~1));
11421         e_conv.is_owned = (e & 1) || (e == 0);
11422         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11423         e_conv = DecodeError_clone(&e_conv);
11424         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11425         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
11426         return (uint32_t)ret_conv;
11427 }
11428
11429 jboolean  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
11430         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(o & ~1);
11431         jboolean ret_conv = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
11432         return ret_conv;
11433 }
11434
11435 void  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_free"))) TS_CResult_CommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
11436         if ((_res & 1) != 0) return;
11437         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11438         CHECK_ACCESS(_res_ptr);
11439         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
11440         FREE((void*)_res);
11441         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
11442 }
11443
11444 static inline uintptr_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
11445         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11446         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
11447         return (uint32_t)ret_conv;
11448 }
11449 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
11450         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
11451         uint32_t ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
11452         return ret_conv;
11453 }
11454
11455 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
11456         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
11457         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11458         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
11459         return (uint32_t)ret_conv;
11460 }
11461
11462 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_ok(uint32_t o) {
11463         LDKTrustedCommitmentTransaction o_conv;
11464         o_conv.inner = (void*)(o & (~1));
11465         o_conv.is_owned = (o & 1) || (o == 0);
11466         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11467         // WARNING: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
11468         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
11469         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
11470         return (uint32_t)ret_conv;
11471 }
11472
11473 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_err"))) TS_CResult_TrustedCommitmentTransactionNoneZ_err() {
11474         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
11475         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
11476         return (uint32_t)ret_conv;
11477 }
11478
11479 jboolean  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_is_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_is_ok(uint32_t o) {
11480         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(o & ~1);
11481         jboolean ret_conv = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
11482         return ret_conv;
11483 }
11484
11485 void  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_free"))) TS_CResult_TrustedCommitmentTransactionNoneZ_free(uint32_t _res) {
11486         if ((_res & 1) != 0) return;
11487         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11488         CHECK_ACCESS(_res_ptr);
11489         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
11490         FREE((void*)_res);
11491         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
11492 }
11493
11494 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_ok"))) TS_CResult_CVec_SignatureZNoneZ_ok(ptrArray o) {
11495         LDKCVec_SignatureZ o_constr;
11496         o_constr.datalen = o->arr_len;
11497         if (o_constr.datalen > 0)
11498                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
11499         else
11500                 o_constr.data = NULL;
11501         int8_tArray* o_vals = (void*) o->elems /* XXX o leaks */;
11502         for (size_t m = 0; m < o_constr.datalen; m++) {
11503                 int8_tArray o_conv_12 = o_vals[m];
11504                 LDKSignature o_conv_12_ref;
11505                 CHECK(o_conv_12->arr_len == 64);
11506                 memcpy(o_conv_12_ref.compact_form, o_conv_12->elems, 64); FREE(o_conv_12);
11507                 o_constr.data[m] = o_conv_12_ref;
11508         }
11509         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11510         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
11511         return (uint32_t)ret_conv;
11512 }
11513
11514 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_err"))) TS_CResult_CVec_SignatureZNoneZ_err() {
11515         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11516         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
11517         return (uint32_t)ret_conv;
11518 }
11519
11520 jboolean  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_is_ok"))) TS_CResult_CVec_SignatureZNoneZ_is_ok(uint32_t o) {
11521         LDKCResult_CVec_SignatureZNoneZ* o_conv = (LDKCResult_CVec_SignatureZNoneZ*)(o & ~1);
11522         jboolean ret_conv = CResult_CVec_SignatureZNoneZ_is_ok(o_conv);
11523         return ret_conv;
11524 }
11525
11526 void  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_free"))) TS_CResult_CVec_SignatureZNoneZ_free(uint32_t _res) {
11527         if ((_res & 1) != 0) return;
11528         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11529         CHECK_ACCESS(_res_ptr);
11530         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
11531         FREE((void*)_res);
11532         CResult_CVec_SignatureZNoneZ_free(_res_conv);
11533 }
11534
11535 static inline uintptr_t CResult_CVec_SignatureZNoneZ_clone_ptr(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR arg) {
11536         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11537         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(arg);
11538         return (uint32_t)ret_conv;
11539 }
11540 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_clone_ptr"))) TS_CResult_CVec_SignatureZNoneZ_clone_ptr(uint32_t arg) {
11541         LDKCResult_CVec_SignatureZNoneZ* arg_conv = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
11542         uint32_t ret_conv = CResult_CVec_SignatureZNoneZ_clone_ptr(arg_conv);
11543         return ret_conv;
11544 }
11545
11546 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_clone"))) TS_CResult_CVec_SignatureZNoneZ_clone(uint32_t orig) {
11547         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
11548         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11549         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
11550         return (uint32_t)ret_conv;
11551 }
11552
11553 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_ok(uint32_t o) {
11554         LDKShutdownScript o_conv;
11555         o_conv.inner = (void*)(o & (~1));
11556         o_conv.is_owned = (o & 1) || (o == 0);
11557         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11558         o_conv = ShutdownScript_clone(&o_conv);
11559         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11560         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
11561         return (uint32_t)ret_conv;
11562 }
11563
11564 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_err"))) TS_CResult_ShutdownScriptDecodeErrorZ_err(uint32_t e) {
11565         LDKDecodeError e_conv;
11566         e_conv.inner = (void*)(e & (~1));
11567         e_conv.is_owned = (e & 1) || (e == 0);
11568         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11569         e_conv = DecodeError_clone(&e_conv);
11570         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11571         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
11572         return (uint32_t)ret_conv;
11573 }
11574
11575 jboolean  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_is_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_is_ok(uint32_t o) {
11576         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(o & ~1);
11577         jboolean ret_conv = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
11578         return ret_conv;
11579 }
11580
11581 void  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_free"))) TS_CResult_ShutdownScriptDecodeErrorZ_free(uint32_t _res) {
11582         if ((_res & 1) != 0) return;
11583         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11584         CHECK_ACCESS(_res_ptr);
11585         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
11586         FREE((void*)_res);
11587         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
11588 }
11589
11590 static inline uintptr_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
11591         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11592         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
11593         return (uint32_t)ret_conv;
11594 }
11595 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_clone_ptr"))) TS_CResult_ShutdownScriptDecodeErrorZ_clone_ptr(uint32_t arg) {
11596         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
11597         uint32_t ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
11598         return ret_conv;
11599 }
11600
11601 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_clone"))) TS_CResult_ShutdownScriptDecodeErrorZ_clone(uint32_t orig) {
11602         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1);
11603         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11604         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
11605         return (uint32_t)ret_conv;
11606 }
11607
11608 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_ok(uint32_t o) {
11609         LDKShutdownScript o_conv;
11610         o_conv.inner = (void*)(o & (~1));
11611         o_conv.is_owned = (o & 1) || (o == 0);
11612         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11613         o_conv = ShutdownScript_clone(&o_conv);
11614         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
11615         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
11616         return (uint32_t)ret_conv;
11617 }
11618
11619 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_err"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_err(uint32_t e) {
11620         LDKInvalidShutdownScript e_conv;
11621         e_conv.inner = (void*)(e & (~1));
11622         e_conv.is_owned = (e & 1) || (e == 0);
11623         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11624         e_conv = InvalidShutdownScript_clone(&e_conv);
11625         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
11626         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
11627         return (uint32_t)ret_conv;
11628 }
11629
11630 jboolean  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(uint32_t o) {
11631         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(o & ~1);
11632         jboolean ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
11633         return ret_conv;
11634 }
11635
11636 void  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_free"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_free(uint32_t _res) {
11637         if ((_res & 1) != 0) return;
11638         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11639         CHECK_ACCESS(_res_ptr);
11640         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
11641         FREE((void*)_res);
11642         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
11643 }
11644
11645 static inline uintptr_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
11646         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
11647         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
11648         return (uint32_t)ret_conv;
11649 }
11650 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(uint32_t arg) {
11651         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
11652         uint32_t ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
11653         return ret_conv;
11654 }
11655
11656 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone(uint32_t orig) {
11657         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(orig & ~1);
11658         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
11659         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
11660         return (uint32_t)ret_conv;
11661 }
11662
11663 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_ok"))) TS_CResult_RouteHopDecodeErrorZ_ok(uint32_t o) {
11664         LDKRouteHop o_conv;
11665         o_conv.inner = (void*)(o & (~1));
11666         o_conv.is_owned = (o & 1) || (o == 0);
11667         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11668         o_conv = RouteHop_clone(&o_conv);
11669         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
11670         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
11671         return (uint32_t)ret_conv;
11672 }
11673
11674 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_err"))) TS_CResult_RouteHopDecodeErrorZ_err(uint32_t e) {
11675         LDKDecodeError e_conv;
11676         e_conv.inner = (void*)(e & (~1));
11677         e_conv.is_owned = (e & 1) || (e == 0);
11678         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11679         e_conv = DecodeError_clone(&e_conv);
11680         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
11681         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
11682         return (uint32_t)ret_conv;
11683 }
11684
11685 jboolean  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_is_ok"))) TS_CResult_RouteHopDecodeErrorZ_is_ok(uint32_t o) {
11686         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)(o & ~1);
11687         jboolean ret_conv = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
11688         return ret_conv;
11689 }
11690
11691 void  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_free"))) TS_CResult_RouteHopDecodeErrorZ_free(uint32_t _res) {
11692         if ((_res & 1) != 0) return;
11693         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11694         CHECK_ACCESS(_res_ptr);
11695         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
11696         FREE((void*)_res);
11697         CResult_RouteHopDecodeErrorZ_free(_res_conv);
11698 }
11699
11700 static inline uintptr_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
11701         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
11702         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
11703         return (uint32_t)ret_conv;
11704 }
11705 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHopDecodeErrorZ_clone_ptr(uint32_t arg) {
11706         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
11707         uint32_t ret_conv = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
11708         return ret_conv;
11709 }
11710
11711 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_clone"))) TS_CResult_RouteHopDecodeErrorZ_clone(uint32_t orig) {
11712         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
11713         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
11714         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
11715         return (uint32_t)ret_conv;
11716 }
11717
11718 void  __attribute__((export_name("TS_CVec_RouteHopZ_free"))) TS_CVec_RouteHopZ_free(uint32_tArray _res) {
11719         LDKCVec_RouteHopZ _res_constr;
11720         _res_constr.datalen = _res->arr_len;
11721         if (_res_constr.datalen > 0)
11722                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
11723         else
11724                 _res_constr.data = NULL;
11725         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
11726         for (size_t k = 0; k < _res_constr.datalen; k++) {
11727                 uint32_t _res_conv_10 = _res_vals[k];
11728                 LDKRouteHop _res_conv_10_conv;
11729                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
11730                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
11731                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
11732                 _res_constr.data[k] = _res_conv_10_conv;
11733         }
11734         CVec_RouteHopZ_free(_res_constr);
11735 }
11736
11737 void  __attribute__((export_name("TS_CVec_CVec_RouteHopZZ_free"))) TS_CVec_CVec_RouteHopZZ_free(ptrArray _res) {
11738         LDKCVec_CVec_RouteHopZZ _res_constr;
11739         _res_constr.datalen = _res->arr_len;
11740         if (_res_constr.datalen > 0)
11741                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
11742         else
11743                 _res_constr.data = NULL;
11744         uint32_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
11745         for (size_t m = 0; m < _res_constr.datalen; m++) {
11746                 uint32_tArray _res_conv_12 = _res_vals[m];
11747                 LDKCVec_RouteHopZ _res_conv_12_constr;
11748                 _res_conv_12_constr.datalen = _res_conv_12->arr_len;
11749                 if (_res_conv_12_constr.datalen > 0)
11750                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
11751                 else
11752                         _res_conv_12_constr.data = NULL;
11753                 uint32_t* _res_conv_12_vals = _res_conv_12->elems /* XXX _res_conv_12 leaks */;
11754                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
11755                         uint32_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
11756                         LDKRouteHop _res_conv_12_conv_10_conv;
11757                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
11758                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
11759                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv_10_conv);
11760                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
11761                 }
11762                 _res_constr.data[m] = _res_conv_12_constr;
11763         }
11764         CVec_CVec_RouteHopZZ_free(_res_constr);
11765 }
11766
11767 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_ok"))) TS_CResult_RouteDecodeErrorZ_ok(uint32_t o) {
11768         LDKRoute o_conv;
11769         o_conv.inner = (void*)(o & (~1));
11770         o_conv.is_owned = (o & 1) || (o == 0);
11771         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11772         o_conv = Route_clone(&o_conv);
11773         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
11774         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
11775         return (uint32_t)ret_conv;
11776 }
11777
11778 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_err"))) TS_CResult_RouteDecodeErrorZ_err(uint32_t e) {
11779         LDKDecodeError e_conv;
11780         e_conv.inner = (void*)(e & (~1));
11781         e_conv.is_owned = (e & 1) || (e == 0);
11782         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11783         e_conv = DecodeError_clone(&e_conv);
11784         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
11785         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
11786         return (uint32_t)ret_conv;
11787 }
11788
11789 jboolean  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_is_ok"))) TS_CResult_RouteDecodeErrorZ_is_ok(uint32_t o) {
11790         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)(o & ~1);
11791         jboolean ret_conv = CResult_RouteDecodeErrorZ_is_ok(o_conv);
11792         return ret_conv;
11793 }
11794
11795 void  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_free"))) TS_CResult_RouteDecodeErrorZ_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_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
11800         FREE((void*)_res);
11801         CResult_RouteDecodeErrorZ_free(_res_conv);
11802 }
11803
11804 static inline uintptr_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
11805         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
11806         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
11807         return (uint32_t)ret_conv;
11808 }
11809 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_clone_ptr"))) TS_CResult_RouteDecodeErrorZ_clone_ptr(uint32_t arg) {
11810         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
11811         uint32_t ret_conv = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
11812         return ret_conv;
11813 }
11814
11815 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_clone"))) TS_CResult_RouteDecodeErrorZ_clone(uint32_t orig) {
11816         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
11817         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
11818         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
11819         return (uint32_t)ret_conv;
11820 }
11821
11822 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_ok"))) TS_CResult_RouteParametersDecodeErrorZ_ok(uint32_t o) {
11823         LDKRouteParameters o_conv;
11824         o_conv.inner = (void*)(o & (~1));
11825         o_conv.is_owned = (o & 1) || (o == 0);
11826         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11827         o_conv = RouteParameters_clone(&o_conv);
11828         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
11829         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
11830         return (uint32_t)ret_conv;
11831 }
11832
11833 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_err"))) TS_CResult_RouteParametersDecodeErrorZ_err(uint32_t e) {
11834         LDKDecodeError e_conv;
11835         e_conv.inner = (void*)(e & (~1));
11836         e_conv.is_owned = (e & 1) || (e == 0);
11837         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11838         e_conv = DecodeError_clone(&e_conv);
11839         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
11840         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
11841         return (uint32_t)ret_conv;
11842 }
11843
11844 jboolean  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_is_ok"))) TS_CResult_RouteParametersDecodeErrorZ_is_ok(uint32_t o) {
11845         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(o & ~1);
11846         jboolean ret_conv = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
11847         return ret_conv;
11848 }
11849
11850 void  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_free"))) TS_CResult_RouteParametersDecodeErrorZ_free(uint32_t _res) {
11851         if ((_res & 1) != 0) return;
11852         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11853         CHECK_ACCESS(_res_ptr);
11854         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
11855         FREE((void*)_res);
11856         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
11857 }
11858
11859 static inline uintptr_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
11860         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
11861         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
11862         return (uint32_t)ret_conv;
11863 }
11864 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_clone_ptr"))) TS_CResult_RouteParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
11865         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
11866         uint32_t ret_conv = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
11867         return ret_conv;
11868 }
11869
11870 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_clone"))) TS_CResult_RouteParametersDecodeErrorZ_clone(uint32_t orig) {
11871         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(orig & ~1);
11872         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
11873         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
11874         return (uint32_t)ret_conv;
11875 }
11876
11877 void  __attribute__((export_name("TS_CVec_RouteHintZ_free"))) TS_CVec_RouteHintZ_free(uint32_tArray _res) {
11878         LDKCVec_RouteHintZ _res_constr;
11879         _res_constr.datalen = _res->arr_len;
11880         if (_res_constr.datalen > 0)
11881                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
11882         else
11883                 _res_constr.data = NULL;
11884         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
11885         for (size_t l = 0; l < _res_constr.datalen; l++) {
11886                 uint32_t _res_conv_11 = _res_vals[l];
11887                 LDKRouteHint _res_conv_11_conv;
11888                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
11889                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
11890                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
11891                 _res_constr.data[l] = _res_conv_11_conv;
11892         }
11893         CVec_RouteHintZ_free(_res_constr);
11894 }
11895
11896 uint32_t  __attribute__((export_name("TS_COption_u64Z_some"))) TS_COption_u64Z_some(int64_t o) {
11897         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11898         *ret_copy = COption_u64Z_some(o);
11899         uint32_t ret_ref = (uintptr_t)ret_copy;
11900         return ret_ref;
11901 }
11902
11903 uint32_t  __attribute__((export_name("TS_COption_u64Z_none"))) TS_COption_u64Z_none() {
11904         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11905         *ret_copy = COption_u64Z_none();
11906         uint32_t ret_ref = (uintptr_t)ret_copy;
11907         return ret_ref;
11908 }
11909
11910 void  __attribute__((export_name("TS_COption_u64Z_free"))) TS_COption_u64Z_free(uint32_t _res) {
11911         if ((_res & 1) != 0) return;
11912         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11913         CHECK_ACCESS(_res_ptr);
11914         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
11915         FREE((void*)_res);
11916         COption_u64Z_free(_res_conv);
11917 }
11918
11919 static inline uintptr_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
11920         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11921         *ret_copy = COption_u64Z_clone(arg);
11922 uint32_t ret_ref = (uintptr_t)ret_copy;
11923         return ret_ref;
11924 }
11925 uint32_t  __attribute__((export_name("TS_COption_u64Z_clone_ptr"))) TS_COption_u64Z_clone_ptr(uint32_t arg) {
11926         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)arg;
11927         uint32_t ret_conv = COption_u64Z_clone_ptr(arg_conv);
11928         return ret_conv;
11929 }
11930
11931 uint32_t  __attribute__((export_name("TS_COption_u64Z_clone"))) TS_COption_u64Z_clone(uint32_t orig) {
11932         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
11933         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11934         *ret_copy = COption_u64Z_clone(orig_conv);
11935         uint32_t ret_ref = (uintptr_t)ret_copy;
11936         return ret_ref;
11937 }
11938
11939 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_ok"))) TS_CResult_PaymentParametersDecodeErrorZ_ok(uint32_t o) {
11940         LDKPaymentParameters o_conv;
11941         o_conv.inner = (void*)(o & (~1));
11942         o_conv.is_owned = (o & 1) || (o == 0);
11943         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11944         o_conv = PaymentParameters_clone(&o_conv);
11945         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
11946         *ret_conv = CResult_PaymentParametersDecodeErrorZ_ok(o_conv);
11947         return (uint32_t)ret_conv;
11948 }
11949
11950 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_err"))) TS_CResult_PaymentParametersDecodeErrorZ_err(uint32_t e) {
11951         LDKDecodeError e_conv;
11952         e_conv.inner = (void*)(e & (~1));
11953         e_conv.is_owned = (e & 1) || (e == 0);
11954         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11955         e_conv = DecodeError_clone(&e_conv);
11956         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
11957         *ret_conv = CResult_PaymentParametersDecodeErrorZ_err(e_conv);
11958         return (uint32_t)ret_conv;
11959 }
11960
11961 jboolean  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_is_ok"))) TS_CResult_PaymentParametersDecodeErrorZ_is_ok(uint32_t o) {
11962         LDKCResult_PaymentParametersDecodeErrorZ* o_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(o & ~1);
11963         jboolean ret_conv = CResult_PaymentParametersDecodeErrorZ_is_ok(o_conv);
11964         return ret_conv;
11965 }
11966
11967 void  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_free"))) TS_CResult_PaymentParametersDecodeErrorZ_free(uint32_t _res) {
11968         if ((_res & 1) != 0) return;
11969         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11970         CHECK_ACCESS(_res_ptr);
11971         LDKCResult_PaymentParametersDecodeErrorZ _res_conv = *(LDKCResult_PaymentParametersDecodeErrorZ*)(_res_ptr);
11972         FREE((void*)_res);
11973         CResult_PaymentParametersDecodeErrorZ_free(_res_conv);
11974 }
11975
11976 static inline uintptr_t CResult_PaymentParametersDecodeErrorZ_clone_ptr(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR arg) {
11977         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
11978         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(arg);
11979         return (uint32_t)ret_conv;
11980 }
11981 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_clone_ptr"))) TS_CResult_PaymentParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
11982         LDKCResult_PaymentParametersDecodeErrorZ* arg_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(arg & ~1);
11983         uint32_t ret_conv = CResult_PaymentParametersDecodeErrorZ_clone_ptr(arg_conv);
11984         return ret_conv;
11985 }
11986
11987 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_clone"))) TS_CResult_PaymentParametersDecodeErrorZ_clone(uint32_t orig) {
11988         LDKCResult_PaymentParametersDecodeErrorZ* orig_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(orig & ~1);
11989         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
11990         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(orig_conv);
11991         return (uint32_t)ret_conv;
11992 }
11993
11994 void  __attribute__((export_name("TS_CVec_RouteHintHopZ_free"))) TS_CVec_RouteHintHopZ_free(uint32_tArray _res) {
11995         LDKCVec_RouteHintHopZ _res_constr;
11996         _res_constr.datalen = _res->arr_len;
11997         if (_res_constr.datalen > 0)
11998                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
11999         else
12000                 _res_constr.data = NULL;
12001         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12002         for (size_t o = 0; o < _res_constr.datalen; o++) {
12003                 uint32_t _res_conv_14 = _res_vals[o];
12004                 LDKRouteHintHop _res_conv_14_conv;
12005                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
12006                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
12007                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
12008                 _res_constr.data[o] = _res_conv_14_conv;
12009         }
12010         CVec_RouteHintHopZ_free(_res_constr);
12011 }
12012
12013 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_ok"))) TS_CResult_RouteHintDecodeErrorZ_ok(uint32_t o) {
12014         LDKRouteHint o_conv;
12015         o_conv.inner = (void*)(o & (~1));
12016         o_conv.is_owned = (o & 1) || (o == 0);
12017         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12018         o_conv = RouteHint_clone(&o_conv);
12019         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12020         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
12021         return (uint32_t)ret_conv;
12022 }
12023
12024 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_err"))) TS_CResult_RouteHintDecodeErrorZ_err(uint32_t e) {
12025         LDKDecodeError e_conv;
12026         e_conv.inner = (void*)(e & (~1));
12027         e_conv.is_owned = (e & 1) || (e == 0);
12028         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12029         e_conv = DecodeError_clone(&e_conv);
12030         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12031         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
12032         return (uint32_t)ret_conv;
12033 }
12034
12035 jboolean  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_is_ok"))) TS_CResult_RouteHintDecodeErrorZ_is_ok(uint32_t o) {
12036         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)(o & ~1);
12037         jboolean ret_conv = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
12038         return ret_conv;
12039 }
12040
12041 void  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_free"))) TS_CResult_RouteHintDecodeErrorZ_free(uint32_t _res) {
12042         if ((_res & 1) != 0) return;
12043         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12044         CHECK_ACCESS(_res_ptr);
12045         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
12046         FREE((void*)_res);
12047         CResult_RouteHintDecodeErrorZ_free(_res_conv);
12048 }
12049
12050 static inline uintptr_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
12051         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12052         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
12053         return (uint32_t)ret_conv;
12054 }
12055 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHintDecodeErrorZ_clone_ptr(uint32_t arg) {
12056         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
12057         uint32_t ret_conv = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
12058         return ret_conv;
12059 }
12060
12061 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_clone"))) TS_CResult_RouteHintDecodeErrorZ_clone(uint32_t orig) {
12062         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)(orig & ~1);
12063         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12064         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
12065         return (uint32_t)ret_conv;
12066 }
12067
12068 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_ok(uint32_t o) {
12069         LDKRouteHintHop o_conv;
12070         o_conv.inner = (void*)(o & (~1));
12071         o_conv.is_owned = (o & 1) || (o == 0);
12072         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12073         o_conv = RouteHintHop_clone(&o_conv);
12074         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12075         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
12076         return (uint32_t)ret_conv;
12077 }
12078
12079 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_err"))) TS_CResult_RouteHintHopDecodeErrorZ_err(uint32_t e) {
12080         LDKDecodeError e_conv;
12081         e_conv.inner = (void*)(e & (~1));
12082         e_conv.is_owned = (e & 1) || (e == 0);
12083         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12084         e_conv = DecodeError_clone(&e_conv);
12085         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12086         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
12087         return (uint32_t)ret_conv;
12088 }
12089
12090 jboolean  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_is_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_is_ok(uint32_t o) {
12091         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(o & ~1);
12092         jboolean ret_conv = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
12093         return ret_conv;
12094 }
12095
12096 void  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_free"))) TS_CResult_RouteHintHopDecodeErrorZ_free(uint32_t _res) {
12097         if ((_res & 1) != 0) return;
12098         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12099         CHECK_ACCESS(_res_ptr);
12100         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
12101         FREE((void*)_res);
12102         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
12103 }
12104
12105 static inline uintptr_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
12106         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12107         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
12108         return (uint32_t)ret_conv;
12109 }
12110 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHintHopDecodeErrorZ_clone_ptr(uint32_t arg) {
12111         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
12112         uint32_t ret_conv = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
12113         return ret_conv;
12114 }
12115
12116 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_clone"))) TS_CResult_RouteHintHopDecodeErrorZ_clone(uint32_t orig) {
12117         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(orig & ~1);
12118         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12119         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
12120         return (uint32_t)ret_conv;
12121 }
12122
12123 void  __attribute__((export_name("TS_CVec_ChannelDetailsZ_free"))) TS_CVec_ChannelDetailsZ_free(uint32_tArray _res) {
12124         LDKCVec_ChannelDetailsZ _res_constr;
12125         _res_constr.datalen = _res->arr_len;
12126         if (_res_constr.datalen > 0)
12127                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
12128         else
12129                 _res_constr.data = NULL;
12130         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12131         for (size_t q = 0; q < _res_constr.datalen; q++) {
12132                 uint32_t _res_conv_16 = _res_vals[q];
12133                 LDKChannelDetails _res_conv_16_conv;
12134                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
12135                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
12136                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
12137                 _res_constr.data[q] = _res_conv_16_conv;
12138         }
12139         CVec_ChannelDetailsZ_free(_res_constr);
12140 }
12141
12142 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_ok"))) TS_CResult_RouteLightningErrorZ_ok(uint32_t o) {
12143         LDKRoute o_conv;
12144         o_conv.inner = (void*)(o & (~1));
12145         o_conv.is_owned = (o & 1) || (o == 0);
12146         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12147         o_conv = Route_clone(&o_conv);
12148         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12149         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
12150         return (uint32_t)ret_conv;
12151 }
12152
12153 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_err"))) TS_CResult_RouteLightningErrorZ_err(uint32_t e) {
12154         LDKLightningError e_conv;
12155         e_conv.inner = (void*)(e & (~1));
12156         e_conv.is_owned = (e & 1) || (e == 0);
12157         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12158         e_conv = LightningError_clone(&e_conv);
12159         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12160         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
12161         return (uint32_t)ret_conv;
12162 }
12163
12164 jboolean  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_is_ok"))) TS_CResult_RouteLightningErrorZ_is_ok(uint32_t o) {
12165         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)(o & ~1);
12166         jboolean ret_conv = CResult_RouteLightningErrorZ_is_ok(o_conv);
12167         return ret_conv;
12168 }
12169
12170 void  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_free"))) TS_CResult_RouteLightningErrorZ_free(uint32_t _res) {
12171         if ((_res & 1) != 0) return;
12172         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12173         CHECK_ACCESS(_res_ptr);
12174         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
12175         FREE((void*)_res);
12176         CResult_RouteLightningErrorZ_free(_res_conv);
12177 }
12178
12179 static inline uintptr_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
12180         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12181         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
12182         return (uint32_t)ret_conv;
12183 }
12184 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_clone_ptr"))) TS_CResult_RouteLightningErrorZ_clone_ptr(uint32_t arg) {
12185         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
12186         uint32_t ret_conv = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
12187         return ret_conv;
12188 }
12189
12190 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_clone"))) TS_CResult_RouteLightningErrorZ_clone(uint32_t orig) {
12191         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
12192         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12193         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
12194         return (uint32_t)ret_conv;
12195 }
12196
12197 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_ok"))) TS_CResult_TxOutAccessErrorZ_ok(uint32_t o) {
12198         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12199         CHECK_ACCESS(o_ptr);
12200         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
12201         o_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)o) & ~1));
12202         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
12203         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
12204         return (uint32_t)ret_conv;
12205 }
12206
12207 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_err"))) TS_CResult_TxOutAccessErrorZ_err(uint32_t e) {
12208         LDKAccessError e_conv = LDKAccessError_from_js(e);
12209         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
12210         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
12211         return (uint32_t)ret_conv;
12212 }
12213
12214 jboolean  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_is_ok"))) TS_CResult_TxOutAccessErrorZ_is_ok(uint32_t o) {
12215         LDKCResult_TxOutAccessErrorZ* o_conv = (LDKCResult_TxOutAccessErrorZ*)(o & ~1);
12216         jboolean ret_conv = CResult_TxOutAccessErrorZ_is_ok(o_conv);
12217         return ret_conv;
12218 }
12219
12220 void  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_free"))) TS_CResult_TxOutAccessErrorZ_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         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
12225         FREE((void*)_res);
12226         CResult_TxOutAccessErrorZ_free(_res_conv);
12227 }
12228
12229 static inline uintptr_t CResult_TxOutAccessErrorZ_clone_ptr(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR arg) {
12230         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
12231         *ret_conv = CResult_TxOutAccessErrorZ_clone(arg);
12232         return (uint32_t)ret_conv;
12233 }
12234 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_clone_ptr"))) TS_CResult_TxOutAccessErrorZ_clone_ptr(uint32_t arg) {
12235         LDKCResult_TxOutAccessErrorZ* arg_conv = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
12236         uint32_t ret_conv = CResult_TxOutAccessErrorZ_clone_ptr(arg_conv);
12237         return ret_conv;
12238 }
12239
12240 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_clone"))) TS_CResult_TxOutAccessErrorZ_clone(uint32_t orig) {
12241         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
12242         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
12243         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
12244         return (uint32_t)ret_conv;
12245 }
12246
12247 static inline uintptr_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
12248         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
12249         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
12250         return ((uint32_t)ret_conv);
12251 }
12252 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_clone_ptr"))) TS_C2Tuple_usizeTransactionZ_clone_ptr(uint32_t arg) {
12253         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)(arg & ~1);
12254         uint32_t ret_conv = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
12255         return ret_conv;
12256 }
12257
12258 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_clone"))) TS_C2Tuple_usizeTransactionZ_clone(uint32_t orig) {
12259         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
12260         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
12261         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
12262         return ((uint32_t)ret_conv);
12263 }
12264
12265 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_new"))) TS_C2Tuple_usizeTransactionZ_new(uint32_t a, int8_tArray b) {
12266         LDKTransaction b_ref;
12267         b_ref.datalen = b->arr_len;
12268         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
12269         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
12270         b_ref.data_is_owned = true;
12271         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
12272         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
12273         return ((uint32_t)ret_conv);
12274 }
12275
12276 void  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_free"))) TS_C2Tuple_usizeTransactionZ_free(uint32_t _res) {
12277         if ((_res & 1) != 0) return;
12278         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12279         CHECK_ACCESS(_res_ptr);
12280         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
12281         FREE((void*)_res);
12282         C2Tuple_usizeTransactionZ_free(_res_conv);
12283 }
12284
12285 void  __attribute__((export_name("TS_CVec_C2Tuple_usizeTransactionZZ_free"))) TS_CVec_C2Tuple_usizeTransactionZZ_free(uint32_tArray _res) {
12286         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
12287         _res_constr.datalen = _res->arr_len;
12288         if (_res_constr.datalen > 0)
12289                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
12290         else
12291                 _res_constr.data = NULL;
12292         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12293         for (size_t c = 0; c < _res_constr.datalen; c++) {
12294                 uint32_t _res_conv_28 = _res_vals[c];
12295                 void* _res_conv_28_ptr = (void*)(((uintptr_t)_res_conv_28) & ~1);
12296                 CHECK_ACCESS(_res_conv_28_ptr);
12297                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
12298                 FREE((void*)_res_conv_28);
12299                 _res_constr.data[c] = _res_conv_28_conv;
12300         }
12301         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
12302 }
12303
12304 void  __attribute__((export_name("TS_CVec_TxidZ_free"))) TS_CVec_TxidZ_free(ptrArray _res) {
12305         LDKCVec_TxidZ _res_constr;
12306         _res_constr.datalen = _res->arr_len;
12307         if (_res_constr.datalen > 0)
12308                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
12309         else
12310                 _res_constr.data = NULL;
12311         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
12312         for (size_t m = 0; m < _res_constr.datalen; m++) {
12313                 int8_tArray _res_conv_12 = _res_vals[m];
12314                 LDKThirtyTwoBytes _res_conv_12_ref;
12315                 CHECK(_res_conv_12->arr_len == 32);
12316                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, 32); FREE(_res_conv_12);
12317                 _res_constr.data[m] = _res_conv_12_ref;
12318         }
12319         CVec_TxidZ_free(_res_constr);
12320 }
12321
12322 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_ok() {
12323         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
12324         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
12325         return (uint32_t)ret_conv;
12326 }
12327
12328 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_err"))) TS_CResult_NoneChannelMonitorUpdateErrZ_err(uint32_t e) {
12329         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_js(e);
12330         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
12331         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
12332         return (uint32_t)ret_conv;
12333 }
12334
12335 jboolean  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_is_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_is_ok(uint32_t o) {
12336         LDKCResult_NoneChannelMonitorUpdateErrZ* o_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(o & ~1);
12337         jboolean ret_conv = CResult_NoneChannelMonitorUpdateErrZ_is_ok(o_conv);
12338         return ret_conv;
12339 }
12340
12341 void  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_free"))) TS_CResult_NoneChannelMonitorUpdateErrZ_free(uint32_t _res) {
12342         if ((_res & 1) != 0) return;
12343         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12344         CHECK_ACCESS(_res_ptr);
12345         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(_res_ptr);
12346         FREE((void*)_res);
12347         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
12348 }
12349
12350 static inline uintptr_t CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR arg) {
12351         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
12352         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(arg);
12353         return (uint32_t)ret_conv;
12354 }
12355 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_clone_ptr"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(uint32_t arg) {
12356         LDKCResult_NoneChannelMonitorUpdateErrZ* arg_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
12357         uint32_t ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(arg_conv);
12358         return ret_conv;
12359 }
12360
12361 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_clone"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone(uint32_t orig) {
12362         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
12363         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
12364         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
12365         return (uint32_t)ret_conv;
12366 }
12367
12368 void  __attribute__((export_name("TS_CVec_MonitorEventZ_free"))) TS_CVec_MonitorEventZ_free(uint32_tArray _res) {
12369         LDKCVec_MonitorEventZ _res_constr;
12370         _res_constr.datalen = _res->arr_len;
12371         if (_res_constr.datalen > 0)
12372                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
12373         else
12374                 _res_constr.data = NULL;
12375         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12376         for (size_t o = 0; o < _res_constr.datalen; o++) {
12377                 uint32_t _res_conv_14 = _res_vals[o];
12378                 void* _res_conv_14_ptr = (void*)(((uintptr_t)_res_conv_14) & ~1);
12379                 CHECK_ACCESS(_res_conv_14_ptr);
12380                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
12381                 FREE((void*)_res_conv_14);
12382                 _res_constr.data[o] = _res_conv_14_conv;
12383         }
12384         CVec_MonitorEventZ_free(_res_constr);
12385 }
12386
12387 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_some"))) TS_COption_C2Tuple_usizeTransactionZZ_some(uint32_t o) {
12388         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12389         CHECK_ACCESS(o_ptr);
12390         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(o_ptr);
12391         o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)o) & ~1));
12392         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
12393         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
12394         uint32_t ret_ref = (uintptr_t)ret_copy;
12395         return ret_ref;
12396 }
12397
12398 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_none"))) TS_COption_C2Tuple_usizeTransactionZZ_none() {
12399         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
12400         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
12401         uint32_t ret_ref = (uintptr_t)ret_copy;
12402         return ret_ref;
12403 }
12404
12405 void  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_free"))) TS_COption_C2Tuple_usizeTransactionZZ_free(uint32_t _res) {
12406         if ((_res & 1) != 0) return;
12407         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12408         CHECK_ACCESS(_res_ptr);
12409         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(_res_ptr);
12410         FREE((void*)_res);
12411         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
12412 }
12413
12414 static inline uintptr_t COption_C2Tuple_usizeTransactionZZ_clone_ptr(LDKCOption_C2Tuple_usizeTransactionZZ *NONNULL_PTR arg) {
12415         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
12416         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(arg);
12417 uint32_t ret_ref = (uintptr_t)ret_copy;
12418         return ret_ref;
12419 }
12420 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_clone_ptr"))) TS_COption_C2Tuple_usizeTransactionZZ_clone_ptr(uint32_t arg) {
12421         LDKCOption_C2Tuple_usizeTransactionZZ* arg_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)arg;
12422         uint32_t ret_conv = COption_C2Tuple_usizeTransactionZZ_clone_ptr(arg_conv);
12423         return ret_conv;
12424 }
12425
12426 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_clone"))) TS_COption_C2Tuple_usizeTransactionZZ_clone(uint32_t orig) {
12427         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
12428         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
12429         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
12430         uint32_t ret_ref = (uintptr_t)ret_copy;
12431         return ret_ref;
12432 }
12433
12434 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_some"))) TS_COption_ClosureReasonZ_some(uint32_t o) {
12435         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12436         CHECK_ACCESS(o_ptr);
12437         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
12438         o_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)o) & ~1));
12439         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12440         *ret_copy = COption_ClosureReasonZ_some(o_conv);
12441         uint32_t ret_ref = (uintptr_t)ret_copy;
12442         return ret_ref;
12443 }
12444
12445 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_none"))) TS_COption_ClosureReasonZ_none() {
12446         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12447         *ret_copy = COption_ClosureReasonZ_none();
12448         uint32_t ret_ref = (uintptr_t)ret_copy;
12449         return ret_ref;
12450 }
12451
12452 void  __attribute__((export_name("TS_COption_ClosureReasonZ_free"))) TS_COption_ClosureReasonZ_free(uint32_t _res) {
12453         if ((_res & 1) != 0) return;
12454         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12455         CHECK_ACCESS(_res_ptr);
12456         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
12457         FREE((void*)_res);
12458         COption_ClosureReasonZ_free(_res_conv);
12459 }
12460
12461 static inline uintptr_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
12462         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12463         *ret_copy = COption_ClosureReasonZ_clone(arg);
12464 uint32_t ret_ref = (uintptr_t)ret_copy;
12465         return ret_ref;
12466 }
12467 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_clone_ptr"))) TS_COption_ClosureReasonZ_clone_ptr(uint32_t arg) {
12468         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)arg;
12469         uint32_t ret_conv = COption_ClosureReasonZ_clone_ptr(arg_conv);
12470         return ret_conv;
12471 }
12472
12473 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_clone"))) TS_COption_ClosureReasonZ_clone(uint32_t orig) {
12474         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)orig;
12475         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12476         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
12477         uint32_t ret_ref = (uintptr_t)ret_copy;
12478         return ret_ref;
12479 }
12480
12481 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_ok(uint32_t o) {
12482         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12483         CHECK_ACCESS(o_ptr);
12484         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
12485         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)(((uintptr_t)o) & ~1));
12486         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12487         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
12488         return (uint32_t)ret_conv;
12489 }
12490
12491 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_err"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_err(uint32_t e) {
12492         LDKDecodeError e_conv;
12493         e_conv.inner = (void*)(e & (~1));
12494         e_conv.is_owned = (e & 1) || (e == 0);
12495         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12496         e_conv = DecodeError_clone(&e_conv);
12497         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12498         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
12499         return (uint32_t)ret_conv;
12500 }
12501
12502 jboolean  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_is_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(uint32_t o) {
12503         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(o & ~1);
12504         jboolean ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
12505         return ret_conv;
12506 }
12507
12508 void  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_free"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_free(uint32_t _res) {
12509         if ((_res & 1) != 0) return;
12510         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12511         CHECK_ACCESS(_res_ptr);
12512         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
12513         FREE((void*)_res);
12514         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
12515 }
12516
12517 static inline uintptr_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
12518         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12519         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
12520         return (uint32_t)ret_conv;
12521 }
12522 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(uint32_t arg) {
12523         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(arg & ~1);
12524         uint32_t ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
12525         return ret_conv;
12526 }
12527
12528 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone(uint32_t orig) {
12529         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(orig & ~1);
12530         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12531         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
12532         return (uint32_t)ret_conv;
12533 }
12534
12535 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_some"))) TS_COption_NetworkUpdateZ_some(uint32_t o) {
12536         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12537         CHECK_ACCESS(o_ptr);
12538         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
12539         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uintptr_t)o) & ~1));
12540         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12541         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
12542         uint32_t ret_ref = (uintptr_t)ret_copy;
12543         return ret_ref;
12544 }
12545
12546 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_none"))) TS_COption_NetworkUpdateZ_none() {
12547         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12548         *ret_copy = COption_NetworkUpdateZ_none();
12549         uint32_t ret_ref = (uintptr_t)ret_copy;
12550         return ret_ref;
12551 }
12552
12553 void  __attribute__((export_name("TS_COption_NetworkUpdateZ_free"))) TS_COption_NetworkUpdateZ_free(uint32_t _res) {
12554         if ((_res & 1) != 0) return;
12555         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12556         CHECK_ACCESS(_res_ptr);
12557         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
12558         FREE((void*)_res);
12559         COption_NetworkUpdateZ_free(_res_conv);
12560 }
12561
12562 static inline uintptr_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
12563         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12564         *ret_copy = COption_NetworkUpdateZ_clone(arg);
12565 uint32_t ret_ref = (uintptr_t)ret_copy;
12566         return ret_ref;
12567 }
12568 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_clone_ptr"))) TS_COption_NetworkUpdateZ_clone_ptr(uint32_t arg) {
12569         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)arg;
12570         uint32_t ret_conv = COption_NetworkUpdateZ_clone_ptr(arg_conv);
12571         return ret_conv;
12572 }
12573
12574 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_clone"))) TS_COption_NetworkUpdateZ_clone(uint32_t orig) {
12575         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig;
12576         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12577         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
12578         uint32_t ret_ref = (uintptr_t)ret_copy;
12579         return ret_ref;
12580 }
12581
12582 void  __attribute__((export_name("TS_CVec_SpendableOutputDescriptorZ_free"))) TS_CVec_SpendableOutputDescriptorZ_free(uint32_tArray _res) {
12583         LDKCVec_SpendableOutputDescriptorZ _res_constr;
12584         _res_constr.datalen = _res->arr_len;
12585         if (_res_constr.datalen > 0)
12586                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
12587         else
12588                 _res_constr.data = NULL;
12589         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12590         for (size_t b = 0; b < _res_constr.datalen; b++) {
12591                 uint32_t _res_conv_27 = _res_vals[b];
12592                 void* _res_conv_27_ptr = (void*)(((uintptr_t)_res_conv_27) & ~1);
12593                 CHECK_ACCESS(_res_conv_27_ptr);
12594                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
12595                 FREE((void*)_res_conv_27);
12596                 _res_constr.data[b] = _res_conv_27_conv;
12597         }
12598         CVec_SpendableOutputDescriptorZ_free(_res_constr);
12599 }
12600
12601 uint32_t  __attribute__((export_name("TS_COption_EventZ_some"))) TS_COption_EventZ_some(uint32_t o) {
12602         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12603         CHECK_ACCESS(o_ptr);
12604         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
12605         o_conv = Event_clone((LDKEvent*)(((uintptr_t)o) & ~1));
12606         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12607         *ret_copy = COption_EventZ_some(o_conv);
12608         uint32_t ret_ref = (uintptr_t)ret_copy;
12609         return ret_ref;
12610 }
12611
12612 uint32_t  __attribute__((export_name("TS_COption_EventZ_none"))) TS_COption_EventZ_none() {
12613         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12614         *ret_copy = COption_EventZ_none();
12615         uint32_t ret_ref = (uintptr_t)ret_copy;
12616         return ret_ref;
12617 }
12618
12619 void  __attribute__((export_name("TS_COption_EventZ_free"))) TS_COption_EventZ_free(uint32_t _res) {
12620         if ((_res & 1) != 0) return;
12621         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12622         CHECK_ACCESS(_res_ptr);
12623         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
12624         FREE((void*)_res);
12625         COption_EventZ_free(_res_conv);
12626 }
12627
12628 static inline uintptr_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
12629         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12630         *ret_copy = COption_EventZ_clone(arg);
12631 uint32_t ret_ref = (uintptr_t)ret_copy;
12632         return ret_ref;
12633 }
12634 uint32_t  __attribute__((export_name("TS_COption_EventZ_clone_ptr"))) TS_COption_EventZ_clone_ptr(uint32_t arg) {
12635         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)arg;
12636         uint32_t ret_conv = COption_EventZ_clone_ptr(arg_conv);
12637         return ret_conv;
12638 }
12639
12640 uint32_t  __attribute__((export_name("TS_COption_EventZ_clone"))) TS_COption_EventZ_clone(uint32_t orig) {
12641         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)orig;
12642         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12643         *ret_copy = COption_EventZ_clone(orig_conv);
12644         uint32_t ret_ref = (uintptr_t)ret_copy;
12645         return ret_ref;
12646 }
12647
12648 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_ok"))) TS_CResult_COption_EventZDecodeErrorZ_ok(uint32_t o) {
12649         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12650         CHECK_ACCESS(o_ptr);
12651         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
12652         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)(((uintptr_t)o) & ~1));
12653         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12654         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
12655         return (uint32_t)ret_conv;
12656 }
12657
12658 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_err"))) TS_CResult_COption_EventZDecodeErrorZ_err(uint32_t e) {
12659         LDKDecodeError e_conv;
12660         e_conv.inner = (void*)(e & (~1));
12661         e_conv.is_owned = (e & 1) || (e == 0);
12662         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12663         e_conv = DecodeError_clone(&e_conv);
12664         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12665         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
12666         return (uint32_t)ret_conv;
12667 }
12668
12669 jboolean  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_is_ok"))) TS_CResult_COption_EventZDecodeErrorZ_is_ok(uint32_t o) {
12670         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(o & ~1);
12671         jboolean ret_conv = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
12672         return ret_conv;
12673 }
12674
12675 void  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_free"))) TS_CResult_COption_EventZDecodeErrorZ_free(uint32_t _res) {
12676         if ((_res & 1) != 0) return;
12677         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12678         CHECK_ACCESS(_res_ptr);
12679         LDKCResult_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
12680         FREE((void*)_res);
12681         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
12682 }
12683
12684 static inline uintptr_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
12685         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12686         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
12687         return (uint32_t)ret_conv;
12688 }
12689 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_EventZDecodeErrorZ_clone_ptr(uint32_t arg) {
12690         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(arg & ~1);
12691         uint32_t ret_conv = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
12692         return ret_conv;
12693 }
12694
12695 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_clone"))) TS_CResult_COption_EventZDecodeErrorZ_clone(uint32_t orig) {
12696         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(orig & ~1);
12697         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12698         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
12699         return (uint32_t)ret_conv;
12700 }
12701
12702 void  __attribute__((export_name("TS_CVec_MessageSendEventZ_free"))) TS_CVec_MessageSendEventZ_free(uint32_tArray _res) {
12703         LDKCVec_MessageSendEventZ _res_constr;
12704         _res_constr.datalen = _res->arr_len;
12705         if (_res_constr.datalen > 0)
12706                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
12707         else
12708                 _res_constr.data = NULL;
12709         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12710         for (size_t s = 0; s < _res_constr.datalen; s++) {
12711                 uint32_t _res_conv_18 = _res_vals[s];
12712                 void* _res_conv_18_ptr = (void*)(((uintptr_t)_res_conv_18) & ~1);
12713                 CHECK_ACCESS(_res_conv_18_ptr);
12714                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
12715                 FREE((void*)_res_conv_18);
12716                 _res_constr.data[s] = _res_conv_18_conv;
12717         }
12718         CVec_MessageSendEventZ_free(_res_constr);
12719 }
12720
12721 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_ok"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_ok(uint32_t o) {
12722         LDKFixedPenaltyScorer o_conv;
12723         o_conv.inner = (void*)(o & (~1));
12724         o_conv.is_owned = (o & 1) || (o == 0);
12725         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12726         o_conv = FixedPenaltyScorer_clone(&o_conv);
12727         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
12728         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_ok(o_conv);
12729         return (uint32_t)ret_conv;
12730 }
12731
12732 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_err"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_err(uint32_t e) {
12733         LDKDecodeError e_conv;
12734         e_conv.inner = (void*)(e & (~1));
12735         e_conv.is_owned = (e & 1) || (e == 0);
12736         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12737         e_conv = DecodeError_clone(&e_conv);
12738         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
12739         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_err(e_conv);
12740         return (uint32_t)ret_conv;
12741 }
12742
12743 jboolean  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_is_ok"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(uint32_t o) {
12744         LDKCResult_FixedPenaltyScorerDecodeErrorZ* o_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(o & ~1);
12745         jboolean ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(o_conv);
12746         return ret_conv;
12747 }
12748
12749 void  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_free"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_free(uint32_t _res) {
12750         if ((_res & 1) != 0) return;
12751         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12752         CHECK_ACCESS(_res_ptr);
12753         LDKCResult_FixedPenaltyScorerDecodeErrorZ _res_conv = *(LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(_res_ptr);
12754         FREE((void*)_res);
12755         CResult_FixedPenaltyScorerDecodeErrorZ_free(_res_conv);
12756 }
12757
12758 static inline uintptr_t CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR arg) {
12759         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
12760         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(arg);
12761         return (uint32_t)ret_conv;
12762 }
12763 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(uint32_t arg) {
12764         LDKCResult_FixedPenaltyScorerDecodeErrorZ* arg_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(arg & ~1);
12765         uint32_t ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(arg_conv);
12766         return ret_conv;
12767 }
12768
12769 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone(uint32_t orig) {
12770         LDKCResult_FixedPenaltyScorerDecodeErrorZ* orig_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(orig & ~1);
12771         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
12772         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig_conv);
12773         return (uint32_t)ret_conv;
12774 }
12775
12776 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_ok"))) TS_CResult_ScoringParametersDecodeErrorZ_ok(uint32_t o) {
12777         LDKScoringParameters o_conv;
12778         o_conv.inner = (void*)(o & (~1));
12779         o_conv.is_owned = (o & 1) || (o == 0);
12780         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12781         o_conv = ScoringParameters_clone(&o_conv);
12782         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
12783         *ret_conv = CResult_ScoringParametersDecodeErrorZ_ok(o_conv);
12784         return (uint32_t)ret_conv;
12785 }
12786
12787 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_err"))) TS_CResult_ScoringParametersDecodeErrorZ_err(uint32_t e) {
12788         LDKDecodeError e_conv;
12789         e_conv.inner = (void*)(e & (~1));
12790         e_conv.is_owned = (e & 1) || (e == 0);
12791         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12792         e_conv = DecodeError_clone(&e_conv);
12793         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
12794         *ret_conv = CResult_ScoringParametersDecodeErrorZ_err(e_conv);
12795         return (uint32_t)ret_conv;
12796 }
12797
12798 jboolean  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_is_ok"))) TS_CResult_ScoringParametersDecodeErrorZ_is_ok(uint32_t o) {
12799         LDKCResult_ScoringParametersDecodeErrorZ* o_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(o & ~1);
12800         jboolean ret_conv = CResult_ScoringParametersDecodeErrorZ_is_ok(o_conv);
12801         return ret_conv;
12802 }
12803
12804 void  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_free"))) TS_CResult_ScoringParametersDecodeErrorZ_free(uint32_t _res) {
12805         if ((_res & 1) != 0) return;
12806         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12807         CHECK_ACCESS(_res_ptr);
12808         LDKCResult_ScoringParametersDecodeErrorZ _res_conv = *(LDKCResult_ScoringParametersDecodeErrorZ*)(_res_ptr);
12809         FREE((void*)_res);
12810         CResult_ScoringParametersDecodeErrorZ_free(_res_conv);
12811 }
12812
12813 static inline uintptr_t CResult_ScoringParametersDecodeErrorZ_clone_ptr(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR arg) {
12814         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
12815         *ret_conv = CResult_ScoringParametersDecodeErrorZ_clone(arg);
12816         return (uint32_t)ret_conv;
12817 }
12818 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_clone_ptr"))) TS_CResult_ScoringParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
12819         LDKCResult_ScoringParametersDecodeErrorZ* arg_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(arg & ~1);
12820         uint32_t ret_conv = CResult_ScoringParametersDecodeErrorZ_clone_ptr(arg_conv);
12821         return ret_conv;
12822 }
12823
12824 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_clone"))) TS_CResult_ScoringParametersDecodeErrorZ_clone(uint32_t orig) {
12825         LDKCResult_ScoringParametersDecodeErrorZ* orig_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(orig & ~1);
12826         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
12827         *ret_conv = CResult_ScoringParametersDecodeErrorZ_clone(orig_conv);
12828         return (uint32_t)ret_conv;
12829 }
12830
12831 uint32_t  __attribute__((export_name("TS_CResult_ScorerDecodeErrorZ_ok"))) TS_CResult_ScorerDecodeErrorZ_ok(uint32_t o) {
12832         LDKScorer o_conv;
12833         o_conv.inner = (void*)(o & (~1));
12834         o_conv.is_owned = (o & 1) || (o == 0);
12835         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12836         // WARNING: we need a move here but no clone is available for LDKScorer
12837         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
12838         *ret_conv = CResult_ScorerDecodeErrorZ_ok(o_conv);
12839         return (uint32_t)ret_conv;
12840 }
12841
12842 uint32_t  __attribute__((export_name("TS_CResult_ScorerDecodeErrorZ_err"))) TS_CResult_ScorerDecodeErrorZ_err(uint32_t e) {
12843         LDKDecodeError e_conv;
12844         e_conv.inner = (void*)(e & (~1));
12845         e_conv.is_owned = (e & 1) || (e == 0);
12846         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12847         e_conv = DecodeError_clone(&e_conv);
12848         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
12849         *ret_conv = CResult_ScorerDecodeErrorZ_err(e_conv);
12850         return (uint32_t)ret_conv;
12851 }
12852
12853 jboolean  __attribute__((export_name("TS_CResult_ScorerDecodeErrorZ_is_ok"))) TS_CResult_ScorerDecodeErrorZ_is_ok(uint32_t o) {
12854         LDKCResult_ScorerDecodeErrorZ* o_conv = (LDKCResult_ScorerDecodeErrorZ*)(o & ~1);
12855         jboolean ret_conv = CResult_ScorerDecodeErrorZ_is_ok(o_conv);
12856         return ret_conv;
12857 }
12858
12859 void  __attribute__((export_name("TS_CResult_ScorerDecodeErrorZ_free"))) TS_CResult_ScorerDecodeErrorZ_free(uint32_t _res) {
12860         if ((_res & 1) != 0) return;
12861         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12862         CHECK_ACCESS(_res_ptr);
12863         LDKCResult_ScorerDecodeErrorZ _res_conv = *(LDKCResult_ScorerDecodeErrorZ*)(_res_ptr);
12864         FREE((void*)_res);
12865         CResult_ScorerDecodeErrorZ_free(_res_conv);
12866 }
12867
12868 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_ok"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_ok(uint32_t o) {
12869         LDKProbabilisticScorer o_conv;
12870         o_conv.inner = (void*)(o & (~1));
12871         o_conv.is_owned = (o & 1) || (o == 0);
12872         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12873         // WARNING: we need a move here but no clone is available for LDKProbabilisticScorer
12874         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
12875         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_ok(o_conv);
12876         return (uint32_t)ret_conv;
12877 }
12878
12879 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_err"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_err(uint32_t e) {
12880         LDKDecodeError e_conv;
12881         e_conv.inner = (void*)(e & (~1));
12882         e_conv.is_owned = (e & 1) || (e == 0);
12883         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12884         e_conv = DecodeError_clone(&e_conv);
12885         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
12886         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_err(e_conv);
12887         return (uint32_t)ret_conv;
12888 }
12889
12890 jboolean  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_is_ok"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_is_ok(uint32_t o) {
12891         LDKCResult_ProbabilisticScorerDecodeErrorZ* o_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(o & ~1);
12892         jboolean ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_is_ok(o_conv);
12893         return ret_conv;
12894 }
12895
12896 void  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_free"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_free(uint32_t _res) {
12897         if ((_res & 1) != 0) return;
12898         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12899         CHECK_ACCESS(_res_ptr);
12900         LDKCResult_ProbabilisticScorerDecodeErrorZ _res_conv = *(LDKCResult_ProbabilisticScorerDecodeErrorZ*)(_res_ptr);
12901         FREE((void*)_res);
12902         CResult_ProbabilisticScorerDecodeErrorZ_free(_res_conv);
12903 }
12904
12905 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_ok(uint32_t o) {
12906         LDKInitFeatures o_conv;
12907         o_conv.inner = (void*)(o & (~1));
12908         o_conv.is_owned = (o & 1) || (o == 0);
12909         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12910         o_conv = InitFeatures_clone(&o_conv);
12911         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
12912         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
12913         return (uint32_t)ret_conv;
12914 }
12915
12916 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_err"))) TS_CResult_InitFeaturesDecodeErrorZ_err(uint32_t e) {
12917         LDKDecodeError e_conv;
12918         e_conv.inner = (void*)(e & (~1));
12919         e_conv.is_owned = (e & 1) || (e == 0);
12920         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12921         e_conv = DecodeError_clone(&e_conv);
12922         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
12923         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
12924         return (uint32_t)ret_conv;
12925 }
12926
12927 jboolean  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_is_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_is_ok(uint32_t o) {
12928         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(o & ~1);
12929         jboolean ret_conv = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
12930         return ret_conv;
12931 }
12932
12933 void  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_free"))) TS_CResult_InitFeaturesDecodeErrorZ_free(uint32_t _res) {
12934         if ((_res & 1) != 0) return;
12935         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12936         CHECK_ACCESS(_res_ptr);
12937         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
12938         FREE((void*)_res);
12939         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
12940 }
12941
12942 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_ok(uint32_t o) {
12943         LDKChannelFeatures o_conv;
12944         o_conv.inner = (void*)(o & (~1));
12945         o_conv.is_owned = (o & 1) || (o == 0);
12946         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12947         o_conv = ChannelFeatures_clone(&o_conv);
12948         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
12949         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
12950         return (uint32_t)ret_conv;
12951 }
12952
12953 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_err"))) TS_CResult_ChannelFeaturesDecodeErrorZ_err(uint32_t e) {
12954         LDKDecodeError e_conv;
12955         e_conv.inner = (void*)(e & (~1));
12956         e_conv.is_owned = (e & 1) || (e == 0);
12957         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12958         e_conv = DecodeError_clone(&e_conv);
12959         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
12960         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
12961         return (uint32_t)ret_conv;
12962 }
12963
12964 jboolean  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_is_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_is_ok(uint32_t o) {
12965         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(o & ~1);
12966         jboolean ret_conv = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
12967         return ret_conv;
12968 }
12969
12970 void  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_free"))) TS_CResult_ChannelFeaturesDecodeErrorZ_free(uint32_t _res) {
12971         if ((_res & 1) != 0) return;
12972         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12973         CHECK_ACCESS(_res_ptr);
12974         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
12975         FREE((void*)_res);
12976         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
12977 }
12978
12979 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_ok(uint32_t o) {
12980         LDKNodeFeatures o_conv;
12981         o_conv.inner = (void*)(o & (~1));
12982         o_conv.is_owned = (o & 1) || (o == 0);
12983         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12984         o_conv = NodeFeatures_clone(&o_conv);
12985         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
12986         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
12987         return (uint32_t)ret_conv;
12988 }
12989
12990 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_err"))) TS_CResult_NodeFeaturesDecodeErrorZ_err(uint32_t e) {
12991         LDKDecodeError e_conv;
12992         e_conv.inner = (void*)(e & (~1));
12993         e_conv.is_owned = (e & 1) || (e == 0);
12994         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12995         e_conv = DecodeError_clone(&e_conv);
12996         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
12997         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
12998         return (uint32_t)ret_conv;
12999 }
13000
13001 jboolean  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_is_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_is_ok(uint32_t o) {
13002         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(o & ~1);
13003         jboolean ret_conv = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
13004         return ret_conv;
13005 }
13006
13007 void  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_free"))) TS_CResult_NodeFeaturesDecodeErrorZ_free(uint32_t _res) {
13008         if ((_res & 1) != 0) return;
13009         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13010         CHECK_ACCESS(_res_ptr);
13011         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
13012         FREE((void*)_res);
13013         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
13014 }
13015
13016 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_ok(uint32_t o) {
13017         LDKInvoiceFeatures o_conv;
13018         o_conv.inner = (void*)(o & (~1));
13019         o_conv.is_owned = (o & 1) || (o == 0);
13020         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13021         o_conv = InvoiceFeatures_clone(&o_conv);
13022         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
13023         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
13024         return (uint32_t)ret_conv;
13025 }
13026
13027 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_err"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_err(uint32_t e) {
13028         LDKDecodeError e_conv;
13029         e_conv.inner = (void*)(e & (~1));
13030         e_conv.is_owned = (e & 1) || (e == 0);
13031         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13032         e_conv = DecodeError_clone(&e_conv);
13033         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
13034         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
13035         return (uint32_t)ret_conv;
13036 }
13037
13038 jboolean  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_is_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_is_ok(uint32_t o) {
13039         LDKCResult_InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(o & ~1);
13040         jboolean ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
13041         return ret_conv;
13042 }
13043
13044 void  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_free"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_free(uint32_t _res) {
13045         if ((_res & 1) != 0) return;
13046         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13047         CHECK_ACCESS(_res_ptr);
13048         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
13049         FREE((void*)_res);
13050         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
13051 }
13052
13053 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_ok(uint32_t o) {
13054         LDKChannelTypeFeatures o_conv;
13055         o_conv.inner = (void*)(o & (~1));
13056         o_conv.is_owned = (o & 1) || (o == 0);
13057         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13058         o_conv = ChannelTypeFeatures_clone(&o_conv);
13059         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
13060         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o_conv);
13061         return (uint32_t)ret_conv;
13062 }
13063
13064 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_err"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_err(uint32_t e) {
13065         LDKDecodeError e_conv;
13066         e_conv.inner = (void*)(e & (~1));
13067         e_conv.is_owned = (e & 1) || (e == 0);
13068         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13069         e_conv = DecodeError_clone(&e_conv);
13070         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
13071         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_err(e_conv);
13072         return (uint32_t)ret_conv;
13073 }
13074
13075 jboolean  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(uint32_t o) {
13076         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(o & ~1);
13077         jboolean ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o_conv);
13078         return ret_conv;
13079 }
13080
13081 void  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_free"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_free(uint32_t _res) {
13082         if ((_res & 1) != 0) return;
13083         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13084         CHECK_ACCESS(_res_ptr);
13085         LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(_res_ptr);
13086         FREE((void*)_res);
13087         CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res_conv);
13088 }
13089
13090 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
13091         LDKDelayedPaymentOutputDescriptor o_conv;
13092         o_conv.inner = (void*)(o & (~1));
13093         o_conv.is_owned = (o & 1) || (o == 0);
13094         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13095         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
13096         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
13097         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
13098         return (uint32_t)ret_conv;
13099 }
13100
13101 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
13102         LDKDecodeError e_conv;
13103         e_conv.inner = (void*)(e & (~1));
13104         e_conv.is_owned = (e & 1) || (e == 0);
13105         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13106         e_conv = DecodeError_clone(&e_conv);
13107         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
13108         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
13109         return (uint32_t)ret_conv;
13110 }
13111
13112 jboolean  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
13113         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
13114         jboolean ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
13115         return ret_conv;
13116 }
13117
13118 void  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
13119         if ((_res & 1) != 0) return;
13120         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13121         CHECK_ACCESS(_res_ptr);
13122         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
13123         FREE((void*)_res);
13124         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
13125 }
13126
13127 static inline uintptr_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
13128         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
13129         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
13130         return (uint32_t)ret_conv;
13131 }
13132 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
13133         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
13134         uint32_t ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
13135         return ret_conv;
13136 }
13137
13138 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
13139         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
13140         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
13141         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
13142         return (uint32_t)ret_conv;
13143 }
13144
13145 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
13146         LDKStaticPaymentOutputDescriptor o_conv;
13147         o_conv.inner = (void*)(o & (~1));
13148         o_conv.is_owned = (o & 1) || (o == 0);
13149         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13150         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
13151         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
13152         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
13153         return (uint32_t)ret_conv;
13154 }
13155
13156 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
13157         LDKDecodeError e_conv;
13158         e_conv.inner = (void*)(e & (~1));
13159         e_conv.is_owned = (e & 1) || (e == 0);
13160         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13161         e_conv = DecodeError_clone(&e_conv);
13162         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
13163         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
13164         return (uint32_t)ret_conv;
13165 }
13166
13167 jboolean  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
13168         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
13169         jboolean ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
13170         return ret_conv;
13171 }
13172
13173 void  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
13174         if ((_res & 1) != 0) return;
13175         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13176         CHECK_ACCESS(_res_ptr);
13177         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
13178         FREE((void*)_res);
13179         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
13180 }
13181
13182 static inline uintptr_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
13183         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
13184         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
13185         return (uint32_t)ret_conv;
13186 }
13187 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
13188         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
13189         uint32_t ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
13190         return ret_conv;
13191 }
13192
13193 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
13194         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
13195         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
13196         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
13197         return (uint32_t)ret_conv;
13198 }
13199
13200 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
13201         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13202         CHECK_ACCESS(o_ptr);
13203         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
13204         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)o) & ~1));
13205         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
13206         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
13207         return (uint32_t)ret_conv;
13208 }
13209
13210 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err(uint32_t e) {
13211         LDKDecodeError e_conv;
13212         e_conv.inner = (void*)(e & (~1));
13213         e_conv.is_owned = (e & 1) || (e == 0);
13214         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13215         e_conv = DecodeError_clone(&e_conv);
13216         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
13217         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
13218         return (uint32_t)ret_conv;
13219 }
13220
13221 jboolean  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
13222         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(o & ~1);
13223         jboolean ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
13224         return ret_conv;
13225 }
13226
13227 void  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
13228         if ((_res & 1) != 0) return;
13229         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13230         CHECK_ACCESS(_res_ptr);
13231         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
13232         FREE((void*)_res);
13233         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
13234 }
13235
13236 static inline uintptr_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
13237         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
13238         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
13239         return (uint32_t)ret_conv;
13240 }
13241 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
13242         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
13243         uint32_t ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
13244         return ret_conv;
13245 }
13246
13247 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
13248         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
13249         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
13250         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
13251         return (uint32_t)ret_conv;
13252 }
13253
13254 void  __attribute__((export_name("TS_CVec_PaymentPreimageZ_free"))) TS_CVec_PaymentPreimageZ_free(ptrArray _res) {
13255         LDKCVec_PaymentPreimageZ _res_constr;
13256         _res_constr.datalen = _res->arr_len;
13257         if (_res_constr.datalen > 0)
13258                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
13259         else
13260                 _res_constr.data = NULL;
13261         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
13262         for (size_t m = 0; m < _res_constr.datalen; m++) {
13263                 int8_tArray _res_conv_12 = _res_vals[m];
13264                 LDKThirtyTwoBytes _res_conv_12_ref;
13265                 CHECK(_res_conv_12->arr_len == 32);
13266                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, 32); FREE(_res_conv_12);
13267                 _res_constr.data[m] = _res_conv_12_ref;
13268         }
13269         CVec_PaymentPreimageZ_free(_res_constr);
13270 }
13271
13272 static inline uintptr_t C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR arg) {
13273         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
13274         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(arg);
13275         return ((uint32_t)ret_conv);
13276 }
13277 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_clone_ptr"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(uint32_t arg) {
13278         LDKC2Tuple_SignatureCVec_SignatureZZ* arg_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(arg & ~1);
13279         uint32_t ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(arg_conv);
13280         return ret_conv;
13281 }
13282
13283 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_clone"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone(uint32_t orig) {
13284         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
13285         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
13286         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
13287         return ((uint32_t)ret_conv);
13288 }
13289
13290 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_new"))) TS_C2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
13291         LDKSignature a_ref;
13292         CHECK(a->arr_len == 64);
13293         memcpy(a_ref.compact_form, a->elems, 64); FREE(a);
13294         LDKCVec_SignatureZ b_constr;
13295         b_constr.datalen = b->arr_len;
13296         if (b_constr.datalen > 0)
13297                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
13298         else
13299                 b_constr.data = NULL;
13300         int8_tArray* b_vals = (void*) b->elems /* XXX b leaks */;
13301         for (size_t m = 0; m < b_constr.datalen; m++) {
13302                 int8_tArray b_conv_12 = b_vals[m];
13303                 LDKSignature b_conv_12_ref;
13304                 CHECK(b_conv_12->arr_len == 64);
13305                 memcpy(b_conv_12_ref.compact_form, b_conv_12->elems, 64); FREE(b_conv_12);
13306                 b_constr.data[m] = b_conv_12_ref;
13307         }
13308         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
13309         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
13310         return ((uint32_t)ret_conv);
13311 }
13312
13313 void  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_free"))) TS_C2Tuple_SignatureCVec_SignatureZZ_free(uint32_t _res) {
13314         if ((_res & 1) != 0) return;
13315         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13316         CHECK_ACCESS(_res_ptr);
13317         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
13318         FREE((void*)_res);
13319         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
13320 }
13321
13322 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(uint32_t o) {
13323         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13324         CHECK_ACCESS(o_ptr);
13325         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
13326         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uintptr_t)o) & ~1));
13327         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
13328         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
13329         return (uint32_t)ret_conv;
13330 }
13331
13332 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() {
13333         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
13334         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
13335         return (uint32_t)ret_conv;
13336 }
13337
13338 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(uint32_t o) {
13339         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(o & ~1);
13340         jboolean ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o_conv);
13341         return ret_conv;
13342 }
13343
13344 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(uint32_t _res) {
13345         if ((_res & 1) != 0) return;
13346         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13347         CHECK_ACCESS(_res_ptr);
13348         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
13349         FREE((void*)_res);
13350         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
13351 }
13352
13353 static inline uintptr_t CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR arg) {
13354         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
13355         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(arg);
13356         return (uint32_t)ret_conv;
13357 }
13358 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(uint32_t arg) {
13359         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
13360         uint32_t ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(arg_conv);
13361         return ret_conv;
13362 }
13363
13364 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(uint32_t orig) {
13365         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
13366         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
13367         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
13368         return (uint32_t)ret_conv;
13369 }
13370
13371 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_ok"))) TS_CResult_SignatureNoneZ_ok(int8_tArray o) {
13372         LDKSignature o_ref;
13373         CHECK(o->arr_len == 64);
13374         memcpy(o_ref.compact_form, o->elems, 64); FREE(o);
13375         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
13376         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
13377         return (uint32_t)ret_conv;
13378 }
13379
13380 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_err"))) TS_CResult_SignatureNoneZ_err() {
13381         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
13382         *ret_conv = CResult_SignatureNoneZ_err();
13383         return (uint32_t)ret_conv;
13384 }
13385
13386 jboolean  __attribute__((export_name("TS_CResult_SignatureNoneZ_is_ok"))) TS_CResult_SignatureNoneZ_is_ok(uint32_t o) {
13387         LDKCResult_SignatureNoneZ* o_conv = (LDKCResult_SignatureNoneZ*)(o & ~1);
13388         jboolean ret_conv = CResult_SignatureNoneZ_is_ok(o_conv);
13389         return ret_conv;
13390 }
13391
13392 void  __attribute__((export_name("TS_CResult_SignatureNoneZ_free"))) TS_CResult_SignatureNoneZ_free(uint32_t _res) {
13393         if ((_res & 1) != 0) return;
13394         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13395         CHECK_ACCESS(_res_ptr);
13396         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
13397         FREE((void*)_res);
13398         CResult_SignatureNoneZ_free(_res_conv);
13399 }
13400
13401 static inline uintptr_t CResult_SignatureNoneZ_clone_ptr(LDKCResult_SignatureNoneZ *NONNULL_PTR arg) {
13402         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
13403         *ret_conv = CResult_SignatureNoneZ_clone(arg);
13404         return (uint32_t)ret_conv;
13405 }
13406 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_clone_ptr"))) TS_CResult_SignatureNoneZ_clone_ptr(uint32_t arg) {
13407         LDKCResult_SignatureNoneZ* arg_conv = (LDKCResult_SignatureNoneZ*)(arg & ~1);
13408         uint32_t ret_conv = CResult_SignatureNoneZ_clone_ptr(arg_conv);
13409         return ret_conv;
13410 }
13411
13412 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_clone"))) TS_CResult_SignatureNoneZ_clone(uint32_t orig) {
13413         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
13414         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
13415         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
13416         return (uint32_t)ret_conv;
13417 }
13418
13419 static inline uintptr_t C2Tuple_SignatureSignatureZ_clone_ptr(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR arg) {
13420         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
13421         *ret_conv = C2Tuple_SignatureSignatureZ_clone(arg);
13422         return ((uint32_t)ret_conv);
13423 }
13424 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_clone_ptr"))) TS_C2Tuple_SignatureSignatureZ_clone_ptr(uint32_t arg) {
13425         LDKC2Tuple_SignatureSignatureZ* arg_conv = (LDKC2Tuple_SignatureSignatureZ*)(arg & ~1);
13426         uint32_t ret_conv = C2Tuple_SignatureSignatureZ_clone_ptr(arg_conv);
13427         return ret_conv;
13428 }
13429
13430 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_clone"))) TS_C2Tuple_SignatureSignatureZ_clone(uint32_t orig) {
13431         LDKC2Tuple_SignatureSignatureZ* orig_conv = (LDKC2Tuple_SignatureSignatureZ*)(orig & ~1);
13432         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
13433         *ret_conv = C2Tuple_SignatureSignatureZ_clone(orig_conv);
13434         return ((uint32_t)ret_conv);
13435 }
13436
13437 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_new"))) TS_C2Tuple_SignatureSignatureZ_new(int8_tArray a, int8_tArray b) {
13438         LDKSignature a_ref;
13439         CHECK(a->arr_len == 64);
13440         memcpy(a_ref.compact_form, a->elems, 64); FREE(a);
13441         LDKSignature b_ref;
13442         CHECK(b->arr_len == 64);
13443         memcpy(b_ref.compact_form, b->elems, 64); FREE(b);
13444         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
13445         *ret_conv = C2Tuple_SignatureSignatureZ_new(a_ref, b_ref);
13446         return ((uint32_t)ret_conv);
13447 }
13448
13449 void  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_free"))) TS_C2Tuple_SignatureSignatureZ_free(uint32_t _res) {
13450         if ((_res & 1) != 0) return;
13451         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13452         CHECK_ACCESS(_res_ptr);
13453         LDKC2Tuple_SignatureSignatureZ _res_conv = *(LDKC2Tuple_SignatureSignatureZ*)(_res_ptr);
13454         FREE((void*)_res);
13455         C2Tuple_SignatureSignatureZ_free(_res_conv);
13456 }
13457
13458 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_ok"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_ok(uint32_t o) {
13459         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13460         CHECK_ACCESS(o_ptr);
13461         LDKC2Tuple_SignatureSignatureZ o_conv = *(LDKC2Tuple_SignatureSignatureZ*)(o_ptr);
13462         o_conv = C2Tuple_SignatureSignatureZ_clone((LDKC2Tuple_SignatureSignatureZ*)(((uintptr_t)o) & ~1));
13463         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
13464         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_ok(o_conv);
13465         return (uint32_t)ret_conv;
13466 }
13467
13468 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_err"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_err() {
13469         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
13470         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_err();
13471         return (uint32_t)ret_conv;
13472 }
13473
13474 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(uint32_t o) {
13475         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(o & ~1);
13476         jboolean ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(o_conv);
13477         return ret_conv;
13478 }
13479
13480 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_free"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_free(uint32_t _res) {
13481         if ((_res & 1) != 0) return;
13482         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13483         CHECK_ACCESS(_res_ptr);
13484         LDKCResult_C2Tuple_SignatureSignatureZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(_res_ptr);
13485         FREE((void*)_res);
13486         CResult_C2Tuple_SignatureSignatureZNoneZ_free(_res_conv);
13487 }
13488
13489 static inline uintptr_t CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR arg) {
13490         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
13491         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(arg);
13492         return (uint32_t)ret_conv;
13493 }
13494 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(uint32_t arg) {
13495         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(arg & ~1);
13496         uint32_t ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(arg_conv);
13497         return ret_conv;
13498 }
13499
13500 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone(uint32_t orig) {
13501         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(orig & ~1);
13502         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
13503         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(orig_conv);
13504         return (uint32_t)ret_conv;
13505 }
13506
13507 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_ok"))) TS_CResult_SecretKeyNoneZ_ok(int8_tArray o) {
13508         LDKSecretKey o_ref;
13509         CHECK(o->arr_len == 32);
13510         memcpy(o_ref.bytes, o->elems, 32); FREE(o);
13511         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
13512         *ret_conv = CResult_SecretKeyNoneZ_ok(o_ref);
13513         return (uint32_t)ret_conv;
13514 }
13515
13516 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_err"))) TS_CResult_SecretKeyNoneZ_err() {
13517         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
13518         *ret_conv = CResult_SecretKeyNoneZ_err();
13519         return (uint32_t)ret_conv;
13520 }
13521
13522 jboolean  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_is_ok"))) TS_CResult_SecretKeyNoneZ_is_ok(uint32_t o) {
13523         LDKCResult_SecretKeyNoneZ* o_conv = (LDKCResult_SecretKeyNoneZ*)(o & ~1);
13524         jboolean ret_conv = CResult_SecretKeyNoneZ_is_ok(o_conv);
13525         return ret_conv;
13526 }
13527
13528 void  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_free"))) TS_CResult_SecretKeyNoneZ_free(uint32_t _res) {
13529         if ((_res & 1) != 0) return;
13530         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13531         CHECK_ACCESS(_res_ptr);
13532         LDKCResult_SecretKeyNoneZ _res_conv = *(LDKCResult_SecretKeyNoneZ*)(_res_ptr);
13533         FREE((void*)_res);
13534         CResult_SecretKeyNoneZ_free(_res_conv);
13535 }
13536
13537 static inline uintptr_t CResult_SecretKeyNoneZ_clone_ptr(LDKCResult_SecretKeyNoneZ *NONNULL_PTR arg) {
13538         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
13539         *ret_conv = CResult_SecretKeyNoneZ_clone(arg);
13540         return (uint32_t)ret_conv;
13541 }
13542 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_clone_ptr"))) TS_CResult_SecretKeyNoneZ_clone_ptr(uint32_t arg) {
13543         LDKCResult_SecretKeyNoneZ* arg_conv = (LDKCResult_SecretKeyNoneZ*)(arg & ~1);
13544         uint32_t ret_conv = CResult_SecretKeyNoneZ_clone_ptr(arg_conv);
13545         return ret_conv;
13546 }
13547
13548 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_clone"))) TS_CResult_SecretKeyNoneZ_clone(uint32_t orig) {
13549         LDKCResult_SecretKeyNoneZ* orig_conv = (LDKCResult_SecretKeyNoneZ*)(orig & ~1);
13550         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
13551         *ret_conv = CResult_SecretKeyNoneZ_clone(orig_conv);
13552         return (uint32_t)ret_conv;
13553 }
13554
13555 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_ok"))) TS_CResult_SignDecodeErrorZ_ok(uint32_t o) {
13556         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13557         CHECK_ACCESS(o_ptr);
13558         LDKSign o_conv = *(LDKSign*)(o_ptr);
13559         if (o_conv.free == LDKSign_JCalls_free) {
13560                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13561                 LDKSign_JCalls_cloned(&o_conv);
13562         }
13563         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
13564         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
13565         return (uint32_t)ret_conv;
13566 }
13567
13568 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_err"))) TS_CResult_SignDecodeErrorZ_err(uint32_t e) {
13569         LDKDecodeError e_conv;
13570         e_conv.inner = (void*)(e & (~1));
13571         e_conv.is_owned = (e & 1) || (e == 0);
13572         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13573         e_conv = DecodeError_clone(&e_conv);
13574         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
13575         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
13576         return (uint32_t)ret_conv;
13577 }
13578
13579 jboolean  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_is_ok"))) TS_CResult_SignDecodeErrorZ_is_ok(uint32_t o) {
13580         LDKCResult_SignDecodeErrorZ* o_conv = (LDKCResult_SignDecodeErrorZ*)(o & ~1);
13581         jboolean ret_conv = CResult_SignDecodeErrorZ_is_ok(o_conv);
13582         return ret_conv;
13583 }
13584
13585 void  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_free"))) TS_CResult_SignDecodeErrorZ_free(uint32_t _res) {
13586         if ((_res & 1) != 0) return;
13587         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13588         CHECK_ACCESS(_res_ptr);
13589         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
13590         FREE((void*)_res);
13591         CResult_SignDecodeErrorZ_free(_res_conv);
13592 }
13593
13594 static inline uintptr_t CResult_SignDecodeErrorZ_clone_ptr(LDKCResult_SignDecodeErrorZ *NONNULL_PTR arg) {
13595         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
13596         *ret_conv = CResult_SignDecodeErrorZ_clone(arg);
13597         return (uint32_t)ret_conv;
13598 }
13599 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_clone_ptr"))) TS_CResult_SignDecodeErrorZ_clone_ptr(uint32_t arg) {
13600         LDKCResult_SignDecodeErrorZ* arg_conv = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
13601         uint32_t ret_conv = CResult_SignDecodeErrorZ_clone_ptr(arg_conv);
13602         return ret_conv;
13603 }
13604
13605 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_clone"))) TS_CResult_SignDecodeErrorZ_clone(uint32_t orig) {
13606         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
13607         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
13608         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
13609         return (uint32_t)ret_conv;
13610 }
13611
13612 void  __attribute__((export_name("TS_CVec_u5Z_free"))) TS_CVec_u5Z_free(ptrArray _res) {
13613         LDKCVec_u5Z _res_constr;
13614         _res_constr.datalen = _res->arr_len;
13615         if (_res_constr.datalen > 0)
13616                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
13617         else
13618                 _res_constr.data = NULL;
13619         int8_t* _res_vals = (void*) _res->elems /* XXX _res leaks */;
13620         for (size_t h = 0; h < _res_constr.datalen; h++) {
13621                 int8_t _res_conv_7 = _res_vals[h];
13622                 
13623                 _res_constr.data[h] = (LDKu5){ ._0 = _res_conv_7 };
13624         }
13625         CVec_u5Z_free(_res_constr);
13626 }
13627
13628 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_ok"))) TS_CResult_RecoverableSignatureNoneZ_ok(int8_tArray o) {
13629         LDKRecoverableSignature o_ref;
13630         CHECK(o->arr_len == 68);
13631         memcpy(o_ref.serialized_form, o->elems, 68); FREE(o);
13632         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
13633         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(o_ref);
13634         return (uint32_t)ret_conv;
13635 }
13636
13637 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_err"))) TS_CResult_RecoverableSignatureNoneZ_err() {
13638         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
13639         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
13640         return (uint32_t)ret_conv;
13641 }
13642
13643 jboolean  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_is_ok"))) TS_CResult_RecoverableSignatureNoneZ_is_ok(uint32_t o) {
13644         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)(o & ~1);
13645         jboolean ret_conv = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
13646         return ret_conv;
13647 }
13648
13649 void  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_free"))) TS_CResult_RecoverableSignatureNoneZ_free(uint32_t _res) {
13650         if ((_res & 1) != 0) return;
13651         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13652         CHECK_ACCESS(_res_ptr);
13653         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
13654         FREE((void*)_res);
13655         CResult_RecoverableSignatureNoneZ_free(_res_conv);
13656 }
13657
13658 static inline uintptr_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
13659         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
13660         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
13661         return (uint32_t)ret_conv;
13662 }
13663 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_clone_ptr"))) TS_CResult_RecoverableSignatureNoneZ_clone_ptr(uint32_t arg) {
13664         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
13665         uint32_t ret_conv = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
13666         return ret_conv;
13667 }
13668
13669 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_clone"))) TS_CResult_RecoverableSignatureNoneZ_clone(uint32_t orig) {
13670         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
13671         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
13672         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
13673         return (uint32_t)ret_conv;
13674 }
13675
13676 void  __attribute__((export_name("TS_CVec_u8Z_free"))) TS_CVec_u8Z_free(int8_tArray _res) {
13677         LDKCVec_u8Z _res_ref;
13678         _res_ref.datalen = _res->arr_len;
13679         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
13680         memcpy(_res_ref.data, _res->elems, _res_ref.datalen); FREE(_res);
13681         CVec_u8Z_free(_res_ref);
13682 }
13683
13684 void  __attribute__((export_name("TS_CVec_CVec_u8ZZ_free"))) TS_CVec_CVec_u8ZZ_free(ptrArray _res) {
13685         LDKCVec_CVec_u8ZZ _res_constr;
13686         _res_constr.datalen = _res->arr_len;
13687         if (_res_constr.datalen > 0)
13688                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
13689         else
13690                 _res_constr.data = NULL;
13691         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
13692         for (size_t m = 0; m < _res_constr.datalen; m++) {
13693                 int8_tArray _res_conv_12 = _res_vals[m];
13694                 LDKCVec_u8Z _res_conv_12_ref;
13695                 _res_conv_12_ref.datalen = _res_conv_12->arr_len;
13696                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
13697                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, _res_conv_12_ref.datalen); FREE(_res_conv_12);
13698                 _res_constr.data[m] = _res_conv_12_ref;
13699         }
13700         CVec_CVec_u8ZZ_free(_res_constr);
13701 }
13702
13703 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_ok(ptrArray o) {
13704         LDKCVec_CVec_u8ZZ o_constr;
13705         o_constr.datalen = o->arr_len;
13706         if (o_constr.datalen > 0)
13707                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
13708         else
13709                 o_constr.data = NULL;
13710         int8_tArray* o_vals = (void*) o->elems /* XXX o leaks */;
13711         for (size_t m = 0; m < o_constr.datalen; m++) {
13712                 int8_tArray o_conv_12 = o_vals[m];
13713                 LDKCVec_u8Z o_conv_12_ref;
13714                 o_conv_12_ref.datalen = o_conv_12->arr_len;
13715                 o_conv_12_ref.data = MALLOC(o_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
13716                 memcpy(o_conv_12_ref.data, o_conv_12->elems, o_conv_12_ref.datalen); FREE(o_conv_12);
13717                 o_constr.data[m] = o_conv_12_ref;
13718         }
13719         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
13720         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
13721         return (uint32_t)ret_conv;
13722 }
13723
13724 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_err"))) TS_CResult_CVec_CVec_u8ZZNoneZ_err() {
13725         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
13726         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
13727         return (uint32_t)ret_conv;
13728 }
13729
13730 jboolean  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_is_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_is_ok(uint32_t o) {
13731         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(o & ~1);
13732         jboolean ret_conv = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
13733         return ret_conv;
13734 }
13735
13736 void  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_free"))) TS_CResult_CVec_CVec_u8ZZNoneZ_free(uint32_t _res) {
13737         if ((_res & 1) != 0) return;
13738         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13739         CHECK_ACCESS(_res_ptr);
13740         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
13741         FREE((void*)_res);
13742         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
13743 }
13744
13745 static inline uintptr_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
13746         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
13747         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
13748         return (uint32_t)ret_conv;
13749 }
13750 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_clone_ptr"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(uint32_t arg) {
13751         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
13752         uint32_t ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
13753         return ret_conv;
13754 }
13755
13756 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_clone"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone(uint32_t orig) {
13757         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
13758         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
13759         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
13760         return (uint32_t)ret_conv;
13761 }
13762
13763 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_ok(uint32_t o) {
13764         LDKInMemorySigner o_conv;
13765         o_conv.inner = (void*)(o & (~1));
13766         o_conv.is_owned = (o & 1) || (o == 0);
13767         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13768         o_conv = InMemorySigner_clone(&o_conv);
13769         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
13770         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
13771         return (uint32_t)ret_conv;
13772 }
13773
13774 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_err"))) TS_CResult_InMemorySignerDecodeErrorZ_err(uint32_t e) {
13775         LDKDecodeError e_conv;
13776         e_conv.inner = (void*)(e & (~1));
13777         e_conv.is_owned = (e & 1) || (e == 0);
13778         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13779         e_conv = DecodeError_clone(&e_conv);
13780         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
13781         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
13782         return (uint32_t)ret_conv;
13783 }
13784
13785 jboolean  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_is_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_is_ok(uint32_t o) {
13786         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(o & ~1);
13787         jboolean ret_conv = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
13788         return ret_conv;
13789 }
13790
13791 void  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_free"))) TS_CResult_InMemorySignerDecodeErrorZ_free(uint32_t _res) {
13792         if ((_res & 1) != 0) return;
13793         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13794         CHECK_ACCESS(_res_ptr);
13795         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
13796         FREE((void*)_res);
13797         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
13798 }
13799
13800 static inline uintptr_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
13801         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
13802         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
13803         return (uint32_t)ret_conv;
13804 }
13805 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_clone_ptr"))) TS_CResult_InMemorySignerDecodeErrorZ_clone_ptr(uint32_t arg) {
13806         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
13807         uint32_t ret_conv = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
13808         return ret_conv;
13809 }
13810
13811 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_clone"))) TS_CResult_InMemorySignerDecodeErrorZ_clone(uint32_t orig) {
13812         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
13813         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
13814         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
13815         return (uint32_t)ret_conv;
13816 }
13817
13818 void  __attribute__((export_name("TS_CVec_TxOutZ_free"))) TS_CVec_TxOutZ_free(uint32_tArray _res) {
13819         LDKCVec_TxOutZ _res_constr;
13820         _res_constr.datalen = _res->arr_len;
13821         if (_res_constr.datalen > 0)
13822                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
13823         else
13824                 _res_constr.data = NULL;
13825         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
13826         for (size_t h = 0; h < _res_constr.datalen; h++) {
13827                 uint32_t _res_conv_7 = _res_vals[h];
13828                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
13829                 CHECK_ACCESS(_res_conv_7_ptr);
13830                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
13831                 FREE((void*)_res_conv_7);
13832                 _res_constr.data[h] = _res_conv_7_conv;
13833         }
13834         CVec_TxOutZ_free(_res_constr);
13835 }
13836
13837 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_ok"))) TS_CResult_TransactionNoneZ_ok(int8_tArray o) {
13838         LDKTransaction o_ref;
13839         o_ref.datalen = o->arr_len;
13840         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
13841         memcpy(o_ref.data, o->elems, o_ref.datalen); FREE(o);
13842         o_ref.data_is_owned = true;
13843         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
13844         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
13845         return (uint32_t)ret_conv;
13846 }
13847
13848 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_err"))) TS_CResult_TransactionNoneZ_err() {
13849         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
13850         *ret_conv = CResult_TransactionNoneZ_err();
13851         return (uint32_t)ret_conv;
13852 }
13853
13854 jboolean  __attribute__((export_name("TS_CResult_TransactionNoneZ_is_ok"))) TS_CResult_TransactionNoneZ_is_ok(uint32_t o) {
13855         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)(o & ~1);
13856         jboolean ret_conv = CResult_TransactionNoneZ_is_ok(o_conv);
13857         return ret_conv;
13858 }
13859
13860 void  __attribute__((export_name("TS_CResult_TransactionNoneZ_free"))) TS_CResult_TransactionNoneZ_free(uint32_t _res) {
13861         if ((_res & 1) != 0) return;
13862         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13863         CHECK_ACCESS(_res_ptr);
13864         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
13865         FREE((void*)_res);
13866         CResult_TransactionNoneZ_free(_res_conv);
13867 }
13868
13869 static inline uintptr_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
13870         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
13871         *ret_conv = CResult_TransactionNoneZ_clone(arg);
13872         return (uint32_t)ret_conv;
13873 }
13874 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_clone_ptr"))) TS_CResult_TransactionNoneZ_clone_ptr(uint32_t arg) {
13875         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)(arg & ~1);
13876         uint32_t ret_conv = CResult_TransactionNoneZ_clone_ptr(arg_conv);
13877         return ret_conv;
13878 }
13879
13880 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_clone"))) TS_CResult_TransactionNoneZ_clone(uint32_t orig) {
13881         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
13882         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
13883         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
13884         return (uint32_t)ret_conv;
13885 }
13886
13887 uint32_t  __attribute__((export_name("TS_COption_u16Z_some"))) TS_COption_u16Z_some(int16_t o) {
13888         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
13889         *ret_copy = COption_u16Z_some(o);
13890         uint32_t ret_ref = (uintptr_t)ret_copy;
13891         return ret_ref;
13892 }
13893
13894 uint32_t  __attribute__((export_name("TS_COption_u16Z_none"))) TS_COption_u16Z_none() {
13895         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
13896         *ret_copy = COption_u16Z_none();
13897         uint32_t ret_ref = (uintptr_t)ret_copy;
13898         return ret_ref;
13899 }
13900
13901 void  __attribute__((export_name("TS_COption_u16Z_free"))) TS_COption_u16Z_free(uint32_t _res) {
13902         if ((_res & 1) != 0) return;
13903         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13904         CHECK_ACCESS(_res_ptr);
13905         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
13906         FREE((void*)_res);
13907         COption_u16Z_free(_res_conv);
13908 }
13909
13910 static inline uintptr_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
13911         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
13912         *ret_copy = COption_u16Z_clone(arg);
13913 uint32_t ret_ref = (uintptr_t)ret_copy;
13914         return ret_ref;
13915 }
13916 uint32_t  __attribute__((export_name("TS_COption_u16Z_clone_ptr"))) TS_COption_u16Z_clone_ptr(uint32_t arg) {
13917         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)arg;
13918         uint32_t ret_conv = COption_u16Z_clone_ptr(arg_conv);
13919         return ret_conv;
13920 }
13921
13922 uint32_t  __attribute__((export_name("TS_COption_u16Z_clone"))) TS_COption_u16Z_clone(uint32_t orig) {
13923         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
13924         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
13925         *ret_copy = COption_u16Z_clone(orig_conv);
13926         uint32_t ret_ref = (uintptr_t)ret_copy;
13927         return ret_ref;
13928 }
13929
13930 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_ok"))) TS_CResult_NoneAPIErrorZ_ok() {
13931         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13932         *ret_conv = CResult_NoneAPIErrorZ_ok();
13933         return (uint32_t)ret_conv;
13934 }
13935
13936 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_err"))) TS_CResult_NoneAPIErrorZ_err(uint32_t e) {
13937         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
13938         CHECK_ACCESS(e_ptr);
13939         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
13940         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
13941         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13942         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
13943         return (uint32_t)ret_conv;
13944 }
13945
13946 jboolean  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_is_ok"))) TS_CResult_NoneAPIErrorZ_is_ok(uint32_t o) {
13947         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)(o & ~1);
13948         jboolean ret_conv = CResult_NoneAPIErrorZ_is_ok(o_conv);
13949         return ret_conv;
13950 }
13951
13952 void  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_free"))) TS_CResult_NoneAPIErrorZ_free(uint32_t _res) {
13953         if ((_res & 1) != 0) return;
13954         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13955         CHECK_ACCESS(_res_ptr);
13956         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
13957         FREE((void*)_res);
13958         CResult_NoneAPIErrorZ_free(_res_conv);
13959 }
13960
13961 static inline uintptr_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
13962         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13963         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
13964         return (uint32_t)ret_conv;
13965 }
13966 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_clone_ptr"))) TS_CResult_NoneAPIErrorZ_clone_ptr(uint32_t arg) {
13967         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
13968         uint32_t ret_conv = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
13969         return ret_conv;
13970 }
13971
13972 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_clone"))) TS_CResult_NoneAPIErrorZ_clone(uint32_t orig) {
13973         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
13974         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13975         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
13976         return (uint32_t)ret_conv;
13977 }
13978
13979 void  __attribute__((export_name("TS_CVec_CResult_NoneAPIErrorZZ_free"))) TS_CVec_CResult_NoneAPIErrorZZ_free(uint32_tArray _res) {
13980         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
13981         _res_constr.datalen = _res->arr_len;
13982         if (_res_constr.datalen > 0)
13983                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
13984         else
13985                 _res_constr.data = NULL;
13986         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
13987         for (size_t w = 0; w < _res_constr.datalen; w++) {
13988                 uint32_t _res_conv_22 = _res_vals[w];
13989                 void* _res_conv_22_ptr = (void*)(((uintptr_t)_res_conv_22) & ~1);
13990                 CHECK_ACCESS(_res_conv_22_ptr);
13991                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
13992                 FREE((void*)_res_conv_22);
13993                 _res_constr.data[w] = _res_conv_22_conv;
13994         }
13995         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
13996 }
13997
13998 void  __attribute__((export_name("TS_CVec_APIErrorZ_free"))) TS_CVec_APIErrorZ_free(uint32_tArray _res) {
13999         LDKCVec_APIErrorZ _res_constr;
14000         _res_constr.datalen = _res->arr_len;
14001         if (_res_constr.datalen > 0)
14002                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
14003         else
14004                 _res_constr.data = NULL;
14005         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
14006         for (size_t k = 0; k < _res_constr.datalen; k++) {
14007                 uint32_t _res_conv_10 = _res_vals[k];
14008                 void* _res_conv_10_ptr = (void*)(((uintptr_t)_res_conv_10) & ~1);
14009                 CHECK_ACCESS(_res_conv_10_ptr);
14010                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
14011                 FREE((void*)_res_conv_10);
14012                 _res_constr.data[k] = _res_conv_10_conv;
14013         }
14014         CVec_APIErrorZ_free(_res_constr);
14015 }
14016
14017 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_ok"))) TS_CResult__u832APIErrorZ_ok(int8_tArray o) {
14018         LDKThirtyTwoBytes o_ref;
14019         CHECK(o->arr_len == 32);
14020         memcpy(o_ref.data, o->elems, 32); FREE(o);
14021         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
14022         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
14023         return (uint32_t)ret_conv;
14024 }
14025
14026 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_err"))) TS_CResult__u832APIErrorZ_err(uint32_t e) {
14027         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
14028         CHECK_ACCESS(e_ptr);
14029         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
14030         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
14031         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
14032         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
14033         return (uint32_t)ret_conv;
14034 }
14035
14036 jboolean  __attribute__((export_name("TS_CResult__u832APIErrorZ_is_ok"))) TS_CResult__u832APIErrorZ_is_ok(uint32_t o) {
14037         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)(o & ~1);
14038         jboolean ret_conv = CResult__u832APIErrorZ_is_ok(o_conv);
14039         return ret_conv;
14040 }
14041
14042 void  __attribute__((export_name("TS_CResult__u832APIErrorZ_free"))) TS_CResult__u832APIErrorZ_free(uint32_t _res) {
14043         if ((_res & 1) != 0) return;
14044         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14045         CHECK_ACCESS(_res_ptr);
14046         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
14047         FREE((void*)_res);
14048         CResult__u832APIErrorZ_free(_res_conv);
14049 }
14050
14051 static inline uintptr_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
14052         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
14053         *ret_conv = CResult__u832APIErrorZ_clone(arg);
14054         return (uint32_t)ret_conv;
14055 }
14056 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_clone_ptr"))) TS_CResult__u832APIErrorZ_clone_ptr(uint32_t arg) {
14057         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)(arg & ~1);
14058         uint32_t ret_conv = CResult__u832APIErrorZ_clone_ptr(arg_conv);
14059         return ret_conv;
14060 }
14061
14062 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_clone"))) TS_CResult__u832APIErrorZ_clone(uint32_t orig) {
14063         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)(orig & ~1);
14064         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
14065         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
14066         return (uint32_t)ret_conv;
14067 }
14068
14069 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_ok(int8_tArray o) {
14070         LDKThirtyTwoBytes o_ref;
14071         CHECK(o->arr_len == 32);
14072         memcpy(o_ref.data, o->elems, 32); FREE(o);
14073         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14074         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_ref);
14075         return (uint32_t)ret_conv;
14076 }
14077
14078 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_err"))) TS_CResult_PaymentIdPaymentSendFailureZ_err(uint32_t e) {
14079         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
14080         CHECK_ACCESS(e_ptr);
14081         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
14082         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
14083         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14084         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
14085         return (uint32_t)ret_conv;
14086 }
14087
14088 jboolean  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_is_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_is_ok(uint32_t o) {
14089         LDKCResult_PaymentIdPaymentSendFailureZ* o_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(o & ~1);
14090         jboolean ret_conv = CResult_PaymentIdPaymentSendFailureZ_is_ok(o_conv);
14091         return ret_conv;
14092 }
14093
14094 void  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_free"))) TS_CResult_PaymentIdPaymentSendFailureZ_free(uint32_t _res) {
14095         if ((_res & 1) != 0) return;
14096         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14097         CHECK_ACCESS(_res_ptr);
14098         LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
14099         FREE((void*)_res);
14100         CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
14101 }
14102
14103 static inline uintptr_t CResult_PaymentIdPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR arg) {
14104         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14105         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(arg);
14106         return (uint32_t)ret_conv;
14107 }
14108 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_clone_ptr"))) TS_CResult_PaymentIdPaymentSendFailureZ_clone_ptr(uint32_t arg) {
14109         LDKCResult_PaymentIdPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
14110         uint32_t ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone_ptr(arg_conv);
14111         return ret_conv;
14112 }
14113
14114 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_clone"))) TS_CResult_PaymentIdPaymentSendFailureZ_clone(uint32_t orig) {
14115         LDKCResult_PaymentIdPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(orig & ~1);
14116         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14117         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(orig_conv);
14118         return (uint32_t)ret_conv;
14119 }
14120
14121 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_ok"))) TS_CResult_NonePaymentSendFailureZ_ok() {
14122         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
14123         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
14124         return (uint32_t)ret_conv;
14125 }
14126
14127 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_err"))) TS_CResult_NonePaymentSendFailureZ_err(uint32_t e) {
14128         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
14129         CHECK_ACCESS(e_ptr);
14130         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
14131         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
14132         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
14133         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
14134         return (uint32_t)ret_conv;
14135 }
14136
14137 jboolean  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_is_ok"))) TS_CResult_NonePaymentSendFailureZ_is_ok(uint32_t o) {
14138         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)(o & ~1);
14139         jboolean ret_conv = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
14140         return ret_conv;
14141 }
14142
14143 void  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_free"))) TS_CResult_NonePaymentSendFailureZ_free(uint32_t _res) {
14144         if ((_res & 1) != 0) return;
14145         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14146         CHECK_ACCESS(_res_ptr);
14147         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
14148         FREE((void*)_res);
14149         CResult_NonePaymentSendFailureZ_free(_res_conv);
14150 }
14151
14152 static inline uintptr_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
14153         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
14154         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
14155         return (uint32_t)ret_conv;
14156 }
14157 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_clone_ptr"))) TS_CResult_NonePaymentSendFailureZ_clone_ptr(uint32_t arg) {
14158         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
14159         uint32_t ret_conv = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
14160         return ret_conv;
14161 }
14162
14163 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_clone"))) TS_CResult_NonePaymentSendFailureZ_clone(uint32_t orig) {
14164         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
14165         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
14166         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
14167         return (uint32_t)ret_conv;
14168 }
14169
14170 static inline uintptr_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
14171         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
14172         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
14173         return ((uint32_t)ret_conv);
14174 }
14175 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_clone_ptr"))) TS_C2Tuple_PaymentHashPaymentIdZ_clone_ptr(uint32_t arg) {
14176         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(arg & ~1);
14177         uint32_t ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
14178         return ret_conv;
14179 }
14180
14181 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_clone"))) TS_C2Tuple_PaymentHashPaymentIdZ_clone(uint32_t orig) {
14182         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(orig & ~1);
14183         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
14184         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
14185         return ((uint32_t)ret_conv);
14186 }
14187
14188 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_new"))) TS_C2Tuple_PaymentHashPaymentIdZ_new(int8_tArray a, int8_tArray b) {
14189         LDKThirtyTwoBytes a_ref;
14190         CHECK(a->arr_len == 32);
14191         memcpy(a_ref.data, a->elems, 32); FREE(a);
14192         LDKThirtyTwoBytes b_ref;
14193         CHECK(b->arr_len == 32);
14194         memcpy(b_ref.data, b->elems, 32); FREE(b);
14195         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
14196         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
14197         return ((uint32_t)ret_conv);
14198 }
14199
14200 void  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_free"))) TS_C2Tuple_PaymentHashPaymentIdZ_free(uint32_t _res) {
14201         if ((_res & 1) != 0) return;
14202         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14203         CHECK_ACCESS(_res_ptr);
14204         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
14205         FREE((void*)_res);
14206         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
14207 }
14208
14209 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(uint32_t o) {
14210         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14211         CHECK_ACCESS(o_ptr);
14212         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
14213         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)(((uintptr_t)o) & ~1));
14214         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
14215         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
14216         return (uint32_t)ret_conv;
14217 }
14218
14219 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(uint32_t e) {
14220         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
14221         CHECK_ACCESS(e_ptr);
14222         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
14223         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
14224         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
14225         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
14226         return (uint32_t)ret_conv;
14227 }
14228
14229 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(uint32_t o) {
14230         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(o & ~1);
14231         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
14232         return ret_conv;
14233 }
14234
14235 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(uint32_t _res) {
14236         if ((_res & 1) != 0) return;
14237         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14238         CHECK_ACCESS(_res_ptr);
14239         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
14240         FREE((void*)_res);
14241         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
14242 }
14243
14244 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
14245         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
14246         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
14247         return (uint32_t)ret_conv;
14248 }
14249 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(uint32_t arg) {
14250         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
14251         uint32_t ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
14252         return ret_conv;
14253 }
14254
14255 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(uint32_t orig) {
14256         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(orig & ~1);
14257         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
14258         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
14259         return (uint32_t)ret_conv;
14260 }
14261
14262 void  __attribute__((export_name("TS_CVec_NetAddressZ_free"))) TS_CVec_NetAddressZ_free(uint32_tArray _res) {
14263         LDKCVec_NetAddressZ _res_constr;
14264         _res_constr.datalen = _res->arr_len;
14265         if (_res_constr.datalen > 0)
14266                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
14267         else
14268                 _res_constr.data = NULL;
14269         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
14270         for (size_t m = 0; m < _res_constr.datalen; m++) {
14271                 uint32_t _res_conv_12 = _res_vals[m];
14272                 void* _res_conv_12_ptr = (void*)(((uintptr_t)_res_conv_12) & ~1);
14273                 CHECK_ACCESS(_res_conv_12_ptr);
14274                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
14275                 FREE((void*)_res_conv_12);
14276                 _res_constr.data[m] = _res_conv_12_conv;
14277         }
14278         CVec_NetAddressZ_free(_res_constr);
14279 }
14280
14281 static inline uintptr_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
14282         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
14283         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
14284         return ((uint32_t)ret_conv);
14285 }
14286 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_clone_ptr"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(uint32_t arg) {
14287         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(arg & ~1);
14288         uint32_t ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
14289         return ret_conv;
14290 }
14291
14292 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_clone"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone(uint32_t orig) {
14293         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
14294         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
14295         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
14296         return ((uint32_t)ret_conv);
14297 }
14298
14299 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_new"))) TS_C2Tuple_PaymentHashPaymentSecretZ_new(int8_tArray a, int8_tArray b) {
14300         LDKThirtyTwoBytes a_ref;
14301         CHECK(a->arr_len == 32);
14302         memcpy(a_ref.data, a->elems, 32); FREE(a);
14303         LDKThirtyTwoBytes b_ref;
14304         CHECK(b->arr_len == 32);
14305         memcpy(b_ref.data, b->elems, 32); FREE(b);
14306         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
14307         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
14308         return ((uint32_t)ret_conv);
14309 }
14310
14311 void  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_free"))) TS_C2Tuple_PaymentHashPaymentSecretZ_free(uint32_t _res) {
14312         if ((_res & 1) != 0) return;
14313         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14314         CHECK_ACCESS(_res_ptr);
14315         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
14316         FREE((void*)_res);
14317         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
14318 }
14319
14320 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(uint32_t o) {
14321         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14322         CHECK_ACCESS(o_ptr);
14323         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
14324         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
14325         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
14326         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o_conv);
14327         return (uint32_t)ret_conv;
14328 }
14329
14330 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err() {
14331         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
14332         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err();
14333         return (uint32_t)ret_conv;
14334 }
14335
14336 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(uint32_t o) {
14337         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(o & ~1);
14338         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o_conv);
14339         return ret_conv;
14340 }
14341
14342 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(uint32_t _res) {
14343         if ((_res & 1) != 0) return;
14344         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14345         CHECK_ACCESS(_res_ptr);
14346         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(_res_ptr);
14347         FREE((void*)_res);
14348         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res_conv);
14349 }
14350
14351 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR arg) {
14352         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
14353         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(arg);
14354         return (uint32_t)ret_conv;
14355 }
14356 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(uint32_t arg) {
14357         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(arg & ~1);
14358         uint32_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(arg_conv);
14359         return ret_conv;
14360 }
14361
14362 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(uint32_t orig) {
14363         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(orig & ~1);
14364         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
14365         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig_conv);
14366         return (uint32_t)ret_conv;
14367 }
14368
14369 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(uint32_t o) {
14370         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14371         CHECK_ACCESS(o_ptr);
14372         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
14373         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
14374         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
14375         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(o_conv);
14376         return (uint32_t)ret_conv;
14377 }
14378
14379 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(uint32_t e) {
14380         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
14381         CHECK_ACCESS(e_ptr);
14382         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
14383         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
14384         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
14385         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e_conv);
14386         return (uint32_t)ret_conv;
14387 }
14388
14389 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(uint32_t o) {
14390         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(o & ~1);
14391         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(o_conv);
14392         return ret_conv;
14393 }
14394
14395 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(uint32_t _res) {
14396         if ((_res & 1) != 0) return;
14397         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14398         CHECK_ACCESS(_res_ptr);
14399         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(_res_ptr);
14400         FREE((void*)_res);
14401         CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(_res_conv);
14402 }
14403
14404 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR arg) {
14405         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
14406         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(arg);
14407         return (uint32_t)ret_conv;
14408 }
14409 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(uint32_t arg) {
14410         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(arg & ~1);
14411         uint32_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(arg_conv);
14412         return ret_conv;
14413 }
14414
14415 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(uint32_t orig) {
14416         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(orig & ~1);
14417         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
14418         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(orig_conv);
14419         return (uint32_t)ret_conv;
14420 }
14421
14422 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_ok"))) TS_CResult_PaymentSecretNoneZ_ok(int8_tArray o) {
14423         LDKThirtyTwoBytes o_ref;
14424         CHECK(o->arr_len == 32);
14425         memcpy(o_ref.data, o->elems, 32); FREE(o);
14426         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
14427         *ret_conv = CResult_PaymentSecretNoneZ_ok(o_ref);
14428         return (uint32_t)ret_conv;
14429 }
14430
14431 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_err"))) TS_CResult_PaymentSecretNoneZ_err() {
14432         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
14433         *ret_conv = CResult_PaymentSecretNoneZ_err();
14434         return (uint32_t)ret_conv;
14435 }
14436
14437 jboolean  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_is_ok"))) TS_CResult_PaymentSecretNoneZ_is_ok(uint32_t o) {
14438         LDKCResult_PaymentSecretNoneZ* o_conv = (LDKCResult_PaymentSecretNoneZ*)(o & ~1);
14439         jboolean ret_conv = CResult_PaymentSecretNoneZ_is_ok(o_conv);
14440         return ret_conv;
14441 }
14442
14443 void  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_free"))) TS_CResult_PaymentSecretNoneZ_free(uint32_t _res) {
14444         if ((_res & 1) != 0) return;
14445         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14446         CHECK_ACCESS(_res_ptr);
14447         LDKCResult_PaymentSecretNoneZ _res_conv = *(LDKCResult_PaymentSecretNoneZ*)(_res_ptr);
14448         FREE((void*)_res);
14449         CResult_PaymentSecretNoneZ_free(_res_conv);
14450 }
14451
14452 static inline uintptr_t CResult_PaymentSecretNoneZ_clone_ptr(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR arg) {
14453         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
14454         *ret_conv = CResult_PaymentSecretNoneZ_clone(arg);
14455         return (uint32_t)ret_conv;
14456 }
14457 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_clone_ptr"))) TS_CResult_PaymentSecretNoneZ_clone_ptr(uint32_t arg) {
14458         LDKCResult_PaymentSecretNoneZ* arg_conv = (LDKCResult_PaymentSecretNoneZ*)(arg & ~1);
14459         uint32_t ret_conv = CResult_PaymentSecretNoneZ_clone_ptr(arg_conv);
14460         return ret_conv;
14461 }
14462
14463 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_clone"))) TS_CResult_PaymentSecretNoneZ_clone(uint32_t orig) {
14464         LDKCResult_PaymentSecretNoneZ* orig_conv = (LDKCResult_PaymentSecretNoneZ*)(orig & ~1);
14465         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
14466         *ret_conv = CResult_PaymentSecretNoneZ_clone(orig_conv);
14467         return (uint32_t)ret_conv;
14468 }
14469
14470 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_ok"))) TS_CResult_PaymentSecretAPIErrorZ_ok(int8_tArray o) {
14471         LDKThirtyTwoBytes o_ref;
14472         CHECK(o->arr_len == 32);
14473         memcpy(o_ref.data, o->elems, 32); FREE(o);
14474         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
14475         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
14476         return (uint32_t)ret_conv;
14477 }
14478
14479 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_err"))) TS_CResult_PaymentSecretAPIErrorZ_err(uint32_t e) {
14480         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
14481         CHECK_ACCESS(e_ptr);
14482         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
14483         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
14484         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
14485         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
14486         return (uint32_t)ret_conv;
14487 }
14488
14489 jboolean  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_is_ok"))) TS_CResult_PaymentSecretAPIErrorZ_is_ok(uint32_t o) {
14490         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(o & ~1);
14491         jboolean ret_conv = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
14492         return ret_conv;
14493 }
14494
14495 void  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_free"))) TS_CResult_PaymentSecretAPIErrorZ_free(uint32_t _res) {
14496         if ((_res & 1) != 0) return;
14497         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14498         CHECK_ACCESS(_res_ptr);
14499         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
14500         FREE((void*)_res);
14501         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
14502 }
14503
14504 static inline uintptr_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
14505         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
14506         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
14507         return (uint32_t)ret_conv;
14508 }
14509 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_clone_ptr"))) TS_CResult_PaymentSecretAPIErrorZ_clone_ptr(uint32_t arg) {
14510         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
14511         uint32_t ret_conv = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
14512         return ret_conv;
14513 }
14514
14515 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_clone"))) TS_CResult_PaymentSecretAPIErrorZ_clone(uint32_t orig) {
14516         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
14517         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
14518         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
14519         return (uint32_t)ret_conv;
14520 }
14521
14522 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_ok(int8_tArray o) {
14523         LDKThirtyTwoBytes o_ref;
14524         CHECK(o->arr_len == 32);
14525         memcpy(o_ref.data, o->elems, 32); FREE(o);
14526         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
14527         *ret_conv = CResult_PaymentPreimageAPIErrorZ_ok(o_ref);
14528         return (uint32_t)ret_conv;
14529 }
14530
14531 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_err"))) TS_CResult_PaymentPreimageAPIErrorZ_err(uint32_t e) {
14532         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
14533         CHECK_ACCESS(e_ptr);
14534         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
14535         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
14536         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
14537         *ret_conv = CResult_PaymentPreimageAPIErrorZ_err(e_conv);
14538         return (uint32_t)ret_conv;
14539 }
14540
14541 jboolean  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_is_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_is_ok(uint32_t o) {
14542         LDKCResult_PaymentPreimageAPIErrorZ* o_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(o & ~1);
14543         jboolean ret_conv = CResult_PaymentPreimageAPIErrorZ_is_ok(o_conv);
14544         return ret_conv;
14545 }
14546
14547 void  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_free"))) TS_CResult_PaymentPreimageAPIErrorZ_free(uint32_t _res) {
14548         if ((_res & 1) != 0) return;
14549         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14550         CHECK_ACCESS(_res_ptr);
14551         LDKCResult_PaymentPreimageAPIErrorZ _res_conv = *(LDKCResult_PaymentPreimageAPIErrorZ*)(_res_ptr);
14552         FREE((void*)_res);
14553         CResult_PaymentPreimageAPIErrorZ_free(_res_conv);
14554 }
14555
14556 static inline uintptr_t CResult_PaymentPreimageAPIErrorZ_clone_ptr(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR arg) {
14557         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
14558         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(arg);
14559         return (uint32_t)ret_conv;
14560 }
14561 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_clone_ptr"))) TS_CResult_PaymentPreimageAPIErrorZ_clone_ptr(uint32_t arg) {
14562         LDKCResult_PaymentPreimageAPIErrorZ* arg_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(arg & ~1);
14563         uint32_t ret_conv = CResult_PaymentPreimageAPIErrorZ_clone_ptr(arg_conv);
14564         return ret_conv;
14565 }
14566
14567 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_clone"))) TS_CResult_PaymentPreimageAPIErrorZ_clone(uint32_t orig) {
14568         LDKCResult_PaymentPreimageAPIErrorZ* orig_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(orig & ~1);
14569         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
14570         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(orig_conv);
14571         return (uint32_t)ret_conv;
14572 }
14573
14574 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_ok"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(uint32_t o) {
14575         LDKCounterpartyForwardingInfo o_conv;
14576         o_conv.inner = (void*)(o & (~1));
14577         o_conv.is_owned = (o & 1) || (o == 0);
14578         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14579         o_conv = CounterpartyForwardingInfo_clone(&o_conv);
14580         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
14581         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(o_conv);
14582         return (uint32_t)ret_conv;
14583 }
14584
14585 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_err"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_err(uint32_t e) {
14586         LDKDecodeError e_conv;
14587         e_conv.inner = (void*)(e & (~1));
14588         e_conv.is_owned = (e & 1) || (e == 0);
14589         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14590         e_conv = DecodeError_clone(&e_conv);
14591         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
14592         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e_conv);
14593         return (uint32_t)ret_conv;
14594 }
14595
14596 jboolean  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(uint32_t o) {
14597         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* o_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(o & ~1);
14598         jboolean ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(o_conv);
14599         return ret_conv;
14600 }
14601
14602 void  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_free"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_free(uint32_t _res) {
14603         if ((_res & 1) != 0) return;
14604         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14605         CHECK_ACCESS(_res_ptr);
14606         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(_res_ptr);
14607         FREE((void*)_res);
14608         CResult_CounterpartyForwardingInfoDecodeErrorZ_free(_res_conv);
14609 }
14610
14611 static inline uintptr_t CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR arg) {
14612         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
14613         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(arg);
14614         return (uint32_t)ret_conv;
14615 }
14616 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
14617         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(arg & ~1);
14618         uint32_t ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(arg_conv);
14619         return ret_conv;
14620 }
14621
14622 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(uint32_t orig) {
14623         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(orig & ~1);
14624         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
14625         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(orig_conv);
14626         return (uint32_t)ret_conv;
14627 }
14628
14629 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_ok"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_ok(uint32_t o) {
14630         LDKChannelCounterparty o_conv;
14631         o_conv.inner = (void*)(o & (~1));
14632         o_conv.is_owned = (o & 1) || (o == 0);
14633         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14634         o_conv = ChannelCounterparty_clone(&o_conv);
14635         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
14636         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_ok(o_conv);
14637         return (uint32_t)ret_conv;
14638 }
14639
14640 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_err"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_err(uint32_t e) {
14641         LDKDecodeError e_conv;
14642         e_conv.inner = (void*)(e & (~1));
14643         e_conv.is_owned = (e & 1) || (e == 0);
14644         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14645         e_conv = DecodeError_clone(&e_conv);
14646         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
14647         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_err(e_conv);
14648         return (uint32_t)ret_conv;
14649 }
14650
14651 jboolean  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_is_ok"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_is_ok(uint32_t o) {
14652         LDKCResult_ChannelCounterpartyDecodeErrorZ* o_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(o & ~1);
14653         jboolean ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_is_ok(o_conv);
14654         return ret_conv;
14655 }
14656
14657 void  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_free"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_free(uint32_t _res) {
14658         if ((_res & 1) != 0) return;
14659         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14660         CHECK_ACCESS(_res_ptr);
14661         LDKCResult_ChannelCounterpartyDecodeErrorZ _res_conv = *(LDKCResult_ChannelCounterpartyDecodeErrorZ*)(_res_ptr);
14662         FREE((void*)_res);
14663         CResult_ChannelCounterpartyDecodeErrorZ_free(_res_conv);
14664 }
14665
14666 static inline uintptr_t CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR arg) {
14667         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
14668         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(arg);
14669         return (uint32_t)ret_conv;
14670 }
14671 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(uint32_t arg) {
14672         LDKCResult_ChannelCounterpartyDecodeErrorZ* arg_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(arg & ~1);
14673         uint32_t ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(arg_conv);
14674         return ret_conv;
14675 }
14676
14677 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_clone"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_clone(uint32_t orig) {
14678         LDKCResult_ChannelCounterpartyDecodeErrorZ* orig_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(orig & ~1);
14679         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
14680         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(orig_conv);
14681         return (uint32_t)ret_conv;
14682 }
14683
14684 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_ok"))) TS_CResult_ChannelDetailsDecodeErrorZ_ok(uint32_t o) {
14685         LDKChannelDetails o_conv;
14686         o_conv.inner = (void*)(o & (~1));
14687         o_conv.is_owned = (o & 1) || (o == 0);
14688         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14689         o_conv = ChannelDetails_clone(&o_conv);
14690         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
14691         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_ok(o_conv);
14692         return (uint32_t)ret_conv;
14693 }
14694
14695 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_err"))) TS_CResult_ChannelDetailsDecodeErrorZ_err(uint32_t e) {
14696         LDKDecodeError e_conv;
14697         e_conv.inner = (void*)(e & (~1));
14698         e_conv.is_owned = (e & 1) || (e == 0);
14699         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14700         e_conv = DecodeError_clone(&e_conv);
14701         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
14702         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_err(e_conv);
14703         return (uint32_t)ret_conv;
14704 }
14705
14706 jboolean  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_is_ok"))) TS_CResult_ChannelDetailsDecodeErrorZ_is_ok(uint32_t o) {
14707         LDKCResult_ChannelDetailsDecodeErrorZ* o_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(o & ~1);
14708         jboolean ret_conv = CResult_ChannelDetailsDecodeErrorZ_is_ok(o_conv);
14709         return ret_conv;
14710 }
14711
14712 void  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_free"))) TS_CResult_ChannelDetailsDecodeErrorZ_free(uint32_t _res) {
14713         if ((_res & 1) != 0) return;
14714         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14715         CHECK_ACCESS(_res_ptr);
14716         LDKCResult_ChannelDetailsDecodeErrorZ _res_conv = *(LDKCResult_ChannelDetailsDecodeErrorZ*)(_res_ptr);
14717         FREE((void*)_res);
14718         CResult_ChannelDetailsDecodeErrorZ_free(_res_conv);
14719 }
14720
14721 static inline uintptr_t CResult_ChannelDetailsDecodeErrorZ_clone_ptr(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR arg) {
14722         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
14723         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(arg);
14724         return (uint32_t)ret_conv;
14725 }
14726 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelDetailsDecodeErrorZ_clone_ptr(uint32_t arg) {
14727         LDKCResult_ChannelDetailsDecodeErrorZ* arg_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(arg & ~1);
14728         uint32_t ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone_ptr(arg_conv);
14729         return ret_conv;
14730 }
14731
14732 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_clone"))) TS_CResult_ChannelDetailsDecodeErrorZ_clone(uint32_t orig) {
14733         LDKCResult_ChannelDetailsDecodeErrorZ* orig_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(orig & ~1);
14734         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
14735         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(orig_conv);
14736         return (uint32_t)ret_conv;
14737 }
14738
14739 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_ok"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_ok(uint32_t o) {
14740         LDKPhantomRouteHints o_conv;
14741         o_conv.inner = (void*)(o & (~1));
14742         o_conv.is_owned = (o & 1) || (o == 0);
14743         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14744         o_conv = PhantomRouteHints_clone(&o_conv);
14745         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
14746         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_ok(o_conv);
14747         return (uint32_t)ret_conv;
14748 }
14749
14750 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_err"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_err(uint32_t e) {
14751         LDKDecodeError e_conv;
14752         e_conv.inner = (void*)(e & (~1));
14753         e_conv.is_owned = (e & 1) || (e == 0);
14754         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14755         e_conv = DecodeError_clone(&e_conv);
14756         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
14757         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_err(e_conv);
14758         return (uint32_t)ret_conv;
14759 }
14760
14761 jboolean  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_is_ok"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_is_ok(uint32_t o) {
14762         LDKCResult_PhantomRouteHintsDecodeErrorZ* o_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(o & ~1);
14763         jboolean ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_is_ok(o_conv);
14764         return ret_conv;
14765 }
14766
14767 void  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_free"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_free(uint32_t _res) {
14768         if ((_res & 1) != 0) return;
14769         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14770         CHECK_ACCESS(_res_ptr);
14771         LDKCResult_PhantomRouteHintsDecodeErrorZ _res_conv = *(LDKCResult_PhantomRouteHintsDecodeErrorZ*)(_res_ptr);
14772         FREE((void*)_res);
14773         CResult_PhantomRouteHintsDecodeErrorZ_free(_res_conv);
14774 }
14775
14776 static inline uintptr_t CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR arg) {
14777         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
14778         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(arg);
14779         return (uint32_t)ret_conv;
14780 }
14781 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(uint32_t arg) {
14782         LDKCResult_PhantomRouteHintsDecodeErrorZ* arg_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(arg & ~1);
14783         uint32_t ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(arg_conv);
14784         return ret_conv;
14785 }
14786
14787 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_clone"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_clone(uint32_t orig) {
14788         LDKCResult_PhantomRouteHintsDecodeErrorZ* orig_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(orig & ~1);
14789         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
14790         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(orig_conv);
14791         return (uint32_t)ret_conv;
14792 }
14793
14794 void  __attribute__((export_name("TS_CVec_ChannelMonitorZ_free"))) TS_CVec_ChannelMonitorZ_free(uint32_tArray _res) {
14795         LDKCVec_ChannelMonitorZ _res_constr;
14796         _res_constr.datalen = _res->arr_len;
14797         if (_res_constr.datalen > 0)
14798                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
14799         else
14800                 _res_constr.data = NULL;
14801         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
14802         for (size_t q = 0; q < _res_constr.datalen; q++) {
14803                 uint32_t _res_conv_16 = _res_vals[q];
14804                 LDKChannelMonitor _res_conv_16_conv;
14805                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
14806                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
14807                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
14808                 _res_constr.data[q] = _res_conv_16_conv;
14809         }
14810         CVec_ChannelMonitorZ_free(_res_constr);
14811 }
14812
14813 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_new"))) TS_C2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
14814         LDKThirtyTwoBytes a_ref;
14815         CHECK(a->arr_len == 32);
14816         memcpy(a_ref.data, a->elems, 32); FREE(a);
14817         LDKChannelManager b_conv;
14818         b_conv.inner = (void*)(b & (~1));
14819         b_conv.is_owned = (b & 1) || (b == 0);
14820         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
14821         // WARNING: we need a move here but no clone is available for LDKChannelManager
14822         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
14823         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
14824         return ((uint32_t)ret_conv);
14825 }
14826
14827 void  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_free"))) TS_C2Tuple_BlockHashChannelManagerZ_free(uint32_t _res) {
14828         if ((_res & 1) != 0) return;
14829         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14830         CHECK_ACCESS(_res_ptr);
14831         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
14832         FREE((void*)_res);
14833         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
14834 }
14835
14836 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(uint32_t o) {
14837         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14838         CHECK_ACCESS(o_ptr);
14839         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
14840         // WARNING: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
14841         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
14842         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
14843         return (uint32_t)ret_conv;
14844 }
14845
14846 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(uint32_t e) {
14847         LDKDecodeError e_conv;
14848         e_conv.inner = (void*)(e & (~1));
14849         e_conv.is_owned = (e & 1) || (e == 0);
14850         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14851         e_conv = DecodeError_clone(&e_conv);
14852         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
14853         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
14854         return (uint32_t)ret_conv;
14855 }
14856
14857 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(uint32_t o) {
14858         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(o & ~1);
14859         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
14860         return ret_conv;
14861 }
14862
14863 void  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(uint32_t _res) {
14864         if ((_res & 1) != 0) return;
14865         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14866         CHECK_ACCESS(_res_ptr);
14867         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
14868         FREE((void*)_res);
14869         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
14870 }
14871
14872 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_ok(uint32_t o) {
14873         LDKChannelConfig o_conv;
14874         o_conv.inner = (void*)(o & (~1));
14875         o_conv.is_owned = (o & 1) || (o == 0);
14876         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14877         o_conv = ChannelConfig_clone(&o_conv);
14878         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
14879         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
14880         return (uint32_t)ret_conv;
14881 }
14882
14883 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_err"))) TS_CResult_ChannelConfigDecodeErrorZ_err(uint32_t e) {
14884         LDKDecodeError e_conv;
14885         e_conv.inner = (void*)(e & (~1));
14886         e_conv.is_owned = (e & 1) || (e == 0);
14887         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14888         e_conv = DecodeError_clone(&e_conv);
14889         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
14890         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
14891         return (uint32_t)ret_conv;
14892 }
14893
14894 jboolean  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_is_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_is_ok(uint32_t o) {
14895         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(o & ~1);
14896         jboolean ret_conv = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
14897         return ret_conv;
14898 }
14899
14900 void  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_free"))) TS_CResult_ChannelConfigDecodeErrorZ_free(uint32_t _res) {
14901         if ((_res & 1) != 0) return;
14902         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14903         CHECK_ACCESS(_res_ptr);
14904         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
14905         FREE((void*)_res);
14906         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
14907 }
14908
14909 static inline uintptr_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
14910         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
14911         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
14912         return (uint32_t)ret_conv;
14913 }
14914 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelConfigDecodeErrorZ_clone_ptr(uint32_t arg) {
14915         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
14916         uint32_t ret_conv = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
14917         return ret_conv;
14918 }
14919
14920 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_clone"))) TS_CResult_ChannelConfigDecodeErrorZ_clone(uint32_t orig) {
14921         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
14922         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
14923         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
14924         return (uint32_t)ret_conv;
14925 }
14926
14927 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_ok"))) TS_CResult_OutPointDecodeErrorZ_ok(uint32_t o) {
14928         LDKOutPoint o_conv;
14929         o_conv.inner = (void*)(o & (~1));
14930         o_conv.is_owned = (o & 1) || (o == 0);
14931         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14932         o_conv = OutPoint_clone(&o_conv);
14933         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14934         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
14935         return (uint32_t)ret_conv;
14936 }
14937
14938 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_err"))) TS_CResult_OutPointDecodeErrorZ_err(uint32_t e) {
14939         LDKDecodeError e_conv;
14940         e_conv.inner = (void*)(e & (~1));
14941         e_conv.is_owned = (e & 1) || (e == 0);
14942         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14943         e_conv = DecodeError_clone(&e_conv);
14944         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14945         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
14946         return (uint32_t)ret_conv;
14947 }
14948
14949 jboolean  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_is_ok"))) TS_CResult_OutPointDecodeErrorZ_is_ok(uint32_t o) {
14950         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)(o & ~1);
14951         jboolean ret_conv = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
14952         return ret_conv;
14953 }
14954
14955 void  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_free"))) TS_CResult_OutPointDecodeErrorZ_free(uint32_t _res) {
14956         if ((_res & 1) != 0) return;
14957         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14958         CHECK_ACCESS(_res_ptr);
14959         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
14960         FREE((void*)_res);
14961         CResult_OutPointDecodeErrorZ_free(_res_conv);
14962 }
14963
14964 static inline uintptr_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
14965         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14966         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
14967         return (uint32_t)ret_conv;
14968 }
14969 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_clone_ptr"))) TS_CResult_OutPointDecodeErrorZ_clone_ptr(uint32_t arg) {
14970         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
14971         uint32_t ret_conv = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
14972         return ret_conv;
14973 }
14974
14975 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_clone"))) TS_CResult_OutPointDecodeErrorZ_clone(uint32_t orig) {
14976         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
14977         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14978         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
14979         return (uint32_t)ret_conv;
14980 }
14981
14982 uint32_t  __attribute__((export_name("TS_COption_TypeZ_some"))) TS_COption_TypeZ_some(uint32_t o) {
14983         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14984         CHECK_ACCESS(o_ptr);
14985         LDKType o_conv = *(LDKType*)(o_ptr);
14986         if (o_conv.free == LDKType_JCalls_free) {
14987                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14988                 LDKType_JCalls_cloned(&o_conv);
14989         }
14990         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
14991         *ret_copy = COption_TypeZ_some(o_conv);
14992         uint32_t ret_ref = (uintptr_t)ret_copy;
14993         return ret_ref;
14994 }
14995
14996 uint32_t  __attribute__((export_name("TS_COption_TypeZ_none"))) TS_COption_TypeZ_none() {
14997         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
14998         *ret_copy = COption_TypeZ_none();
14999         uint32_t ret_ref = (uintptr_t)ret_copy;
15000         return ret_ref;
15001 }
15002
15003 void  __attribute__((export_name("TS_COption_TypeZ_free"))) TS_COption_TypeZ_free(uint32_t _res) {
15004         if ((_res & 1) != 0) return;
15005         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15006         CHECK_ACCESS(_res_ptr);
15007         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
15008         FREE((void*)_res);
15009         COption_TypeZ_free(_res_conv);
15010 }
15011
15012 static inline uintptr_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
15013         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
15014         *ret_copy = COption_TypeZ_clone(arg);
15015 uint32_t ret_ref = (uintptr_t)ret_copy;
15016         return ret_ref;
15017 }
15018 uint32_t  __attribute__((export_name("TS_COption_TypeZ_clone_ptr"))) TS_COption_TypeZ_clone_ptr(uint32_t arg) {
15019         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)arg;
15020         uint32_t ret_conv = COption_TypeZ_clone_ptr(arg_conv);
15021         return ret_conv;
15022 }
15023
15024 uint32_t  __attribute__((export_name("TS_COption_TypeZ_clone"))) TS_COption_TypeZ_clone(uint32_t orig) {
15025         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig;
15026         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
15027         *ret_copy = COption_TypeZ_clone(orig_conv);
15028         uint32_t ret_ref = (uintptr_t)ret_copy;
15029         return ret_ref;
15030 }
15031
15032 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_ok(uint32_t o) {
15033         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15034         CHECK_ACCESS(o_ptr);
15035         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
15036         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uintptr_t)o) & ~1));
15037         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
15038         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
15039         return (uint32_t)ret_conv;
15040 }
15041
15042 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_err"))) TS_CResult_COption_TypeZDecodeErrorZ_err(uint32_t e) {
15043         LDKDecodeError e_conv;
15044         e_conv.inner = (void*)(e & (~1));
15045         e_conv.is_owned = (e & 1) || (e == 0);
15046         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15047         e_conv = DecodeError_clone(&e_conv);
15048         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
15049         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
15050         return (uint32_t)ret_conv;
15051 }
15052
15053 jboolean  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_is_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_is_ok(uint32_t o) {
15054         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(o & ~1);
15055         jboolean ret_conv = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
15056         return ret_conv;
15057 }
15058
15059 void  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_free"))) TS_CResult_COption_TypeZDecodeErrorZ_free(uint32_t _res) {
15060         if ((_res & 1) != 0) return;
15061         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15062         CHECK_ACCESS(_res_ptr);
15063         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
15064         FREE((void*)_res);
15065         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
15066 }
15067
15068 static inline uintptr_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
15069         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
15070         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
15071         return (uint32_t)ret_conv;
15072 }
15073 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_TypeZDecodeErrorZ_clone_ptr(uint32_t arg) {
15074         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
15075         uint32_t ret_conv = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
15076         return ret_conv;
15077 }
15078
15079 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_clone"))) TS_CResult_COption_TypeZDecodeErrorZ_clone(uint32_t orig) {
15080         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1);
15081         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
15082         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
15083         return (uint32_t)ret_conv;
15084 }
15085
15086 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_ok"))) TS_CResult_PaymentIdPaymentErrorZ_ok(int8_tArray o) {
15087         LDKThirtyTwoBytes o_ref;
15088         CHECK(o->arr_len == 32);
15089         memcpy(o_ref.data, o->elems, 32); FREE(o);
15090         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
15091         *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
15092         return (uint32_t)ret_conv;
15093 }
15094
15095 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_err"))) TS_CResult_PaymentIdPaymentErrorZ_err(uint32_t e) {
15096         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15097         CHECK_ACCESS(e_ptr);
15098         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
15099         e_conv = PaymentError_clone((LDKPaymentError*)(((uintptr_t)e) & ~1));
15100         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
15101         *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
15102         return (uint32_t)ret_conv;
15103 }
15104
15105 jboolean  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_is_ok"))) TS_CResult_PaymentIdPaymentErrorZ_is_ok(uint32_t o) {
15106         LDKCResult_PaymentIdPaymentErrorZ* o_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(o & ~1);
15107         jboolean ret_conv = CResult_PaymentIdPaymentErrorZ_is_ok(o_conv);
15108         return ret_conv;
15109 }
15110
15111 void  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_free"))) TS_CResult_PaymentIdPaymentErrorZ_free(uint32_t _res) {
15112         if ((_res & 1) != 0) return;
15113         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15114         CHECK_ACCESS(_res_ptr);
15115         LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
15116         FREE((void*)_res);
15117         CResult_PaymentIdPaymentErrorZ_free(_res_conv);
15118 }
15119
15120 static inline uintptr_t CResult_PaymentIdPaymentErrorZ_clone_ptr(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR arg) {
15121         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
15122         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(arg);
15123         return (uint32_t)ret_conv;
15124 }
15125 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_clone_ptr"))) TS_CResult_PaymentIdPaymentErrorZ_clone_ptr(uint32_t arg) {
15126         LDKCResult_PaymentIdPaymentErrorZ* arg_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
15127         uint32_t ret_conv = CResult_PaymentIdPaymentErrorZ_clone_ptr(arg_conv);
15128         return ret_conv;
15129 }
15130
15131 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_clone"))) TS_CResult_PaymentIdPaymentErrorZ_clone(uint32_t orig) {
15132         LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(orig & ~1);
15133         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
15134         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(orig_conv);
15135         return (uint32_t)ret_conv;
15136 }
15137
15138 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_ok"))) TS_CResult_SiPrefixParseErrorZ_ok(uint32_t o) {
15139         LDKSiPrefix o_conv = LDKSiPrefix_from_js(o);
15140         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
15141         *ret_conv = CResult_SiPrefixParseErrorZ_ok(o_conv);
15142         return (uint32_t)ret_conv;
15143 }
15144
15145 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_err"))) TS_CResult_SiPrefixParseErrorZ_err(uint32_t e) {
15146         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15147         CHECK_ACCESS(e_ptr);
15148         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
15149         e_conv = ParseError_clone((LDKParseError*)(((uintptr_t)e) & ~1));
15150         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
15151         *ret_conv = CResult_SiPrefixParseErrorZ_err(e_conv);
15152         return (uint32_t)ret_conv;
15153 }
15154
15155 jboolean  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_is_ok"))) TS_CResult_SiPrefixParseErrorZ_is_ok(uint32_t o) {
15156         LDKCResult_SiPrefixParseErrorZ* o_conv = (LDKCResult_SiPrefixParseErrorZ*)(o & ~1);
15157         jboolean ret_conv = CResult_SiPrefixParseErrorZ_is_ok(o_conv);
15158         return ret_conv;
15159 }
15160
15161 void  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_free"))) TS_CResult_SiPrefixParseErrorZ_free(uint32_t _res) {
15162         if ((_res & 1) != 0) return;
15163         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15164         CHECK_ACCESS(_res_ptr);
15165         LDKCResult_SiPrefixParseErrorZ _res_conv = *(LDKCResult_SiPrefixParseErrorZ*)(_res_ptr);
15166         FREE((void*)_res);
15167         CResult_SiPrefixParseErrorZ_free(_res_conv);
15168 }
15169
15170 static inline uintptr_t CResult_SiPrefixParseErrorZ_clone_ptr(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR arg) {
15171         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
15172         *ret_conv = CResult_SiPrefixParseErrorZ_clone(arg);
15173         return (uint32_t)ret_conv;
15174 }
15175 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_clone_ptr"))) TS_CResult_SiPrefixParseErrorZ_clone_ptr(uint32_t arg) {
15176         LDKCResult_SiPrefixParseErrorZ* arg_conv = (LDKCResult_SiPrefixParseErrorZ*)(arg & ~1);
15177         uint32_t ret_conv = CResult_SiPrefixParseErrorZ_clone_ptr(arg_conv);
15178         return ret_conv;
15179 }
15180
15181 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_clone"))) TS_CResult_SiPrefixParseErrorZ_clone(uint32_t orig) {
15182         LDKCResult_SiPrefixParseErrorZ* orig_conv = (LDKCResult_SiPrefixParseErrorZ*)(orig & ~1);
15183         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
15184         *ret_conv = CResult_SiPrefixParseErrorZ_clone(orig_conv);
15185         return (uint32_t)ret_conv;
15186 }
15187
15188 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_ok"))) TS_CResult_InvoiceParseOrSemanticErrorZ_ok(uint32_t o) {
15189         LDKInvoice o_conv;
15190         o_conv.inner = (void*)(o & (~1));
15191         o_conv.is_owned = (o & 1) || (o == 0);
15192         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15193         o_conv = Invoice_clone(&o_conv);
15194         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
15195         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_ok(o_conv);
15196         return (uint32_t)ret_conv;
15197 }
15198
15199 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_err"))) TS_CResult_InvoiceParseOrSemanticErrorZ_err(uint32_t e) {
15200         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15201         CHECK_ACCESS(e_ptr);
15202         LDKParseOrSemanticError e_conv = *(LDKParseOrSemanticError*)(e_ptr);
15203         e_conv = ParseOrSemanticError_clone((LDKParseOrSemanticError*)(((uintptr_t)e) & ~1));
15204         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
15205         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_err(e_conv);
15206         return (uint32_t)ret_conv;
15207 }
15208
15209 jboolean  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_is_ok"))) TS_CResult_InvoiceParseOrSemanticErrorZ_is_ok(uint32_t o) {
15210         LDKCResult_InvoiceParseOrSemanticErrorZ* o_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(o & ~1);
15211         jboolean ret_conv = CResult_InvoiceParseOrSemanticErrorZ_is_ok(o_conv);
15212         return ret_conv;
15213 }
15214
15215 void  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_free"))) TS_CResult_InvoiceParseOrSemanticErrorZ_free(uint32_t _res) {
15216         if ((_res & 1) != 0) return;
15217         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15218         CHECK_ACCESS(_res_ptr);
15219         LDKCResult_InvoiceParseOrSemanticErrorZ _res_conv = *(LDKCResult_InvoiceParseOrSemanticErrorZ*)(_res_ptr);
15220         FREE((void*)_res);
15221         CResult_InvoiceParseOrSemanticErrorZ_free(_res_conv);
15222 }
15223
15224 static inline uintptr_t CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR arg) {
15225         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
15226         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(arg);
15227         return (uint32_t)ret_conv;
15228 }
15229 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_clone_ptr"))) TS_CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(uint32_t arg) {
15230         LDKCResult_InvoiceParseOrSemanticErrorZ* arg_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(arg & ~1);
15231         uint32_t ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(arg_conv);
15232         return ret_conv;
15233 }
15234
15235 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_clone"))) TS_CResult_InvoiceParseOrSemanticErrorZ_clone(uint32_t orig) {
15236         LDKCResult_InvoiceParseOrSemanticErrorZ* orig_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(orig & ~1);
15237         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
15238         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(orig_conv);
15239         return (uint32_t)ret_conv;
15240 }
15241
15242 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_ok"))) TS_CResult_SignedRawInvoiceParseErrorZ_ok(uint32_t o) {
15243         LDKSignedRawInvoice o_conv;
15244         o_conv.inner = (void*)(o & (~1));
15245         o_conv.is_owned = (o & 1) || (o == 0);
15246         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15247         o_conv = SignedRawInvoice_clone(&o_conv);
15248         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
15249         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_ok(o_conv);
15250         return (uint32_t)ret_conv;
15251 }
15252
15253 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_err"))) TS_CResult_SignedRawInvoiceParseErrorZ_err(uint32_t e) {
15254         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15255         CHECK_ACCESS(e_ptr);
15256         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
15257         e_conv = ParseError_clone((LDKParseError*)(((uintptr_t)e) & ~1));
15258         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
15259         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_err(e_conv);
15260         return (uint32_t)ret_conv;
15261 }
15262
15263 jboolean  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_is_ok"))) TS_CResult_SignedRawInvoiceParseErrorZ_is_ok(uint32_t o) {
15264         LDKCResult_SignedRawInvoiceParseErrorZ* o_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(o & ~1);
15265         jboolean ret_conv = CResult_SignedRawInvoiceParseErrorZ_is_ok(o_conv);
15266         return ret_conv;
15267 }
15268
15269 void  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_free"))) TS_CResult_SignedRawInvoiceParseErrorZ_free(uint32_t _res) {
15270         if ((_res & 1) != 0) return;
15271         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15272         CHECK_ACCESS(_res_ptr);
15273         LDKCResult_SignedRawInvoiceParseErrorZ _res_conv = *(LDKCResult_SignedRawInvoiceParseErrorZ*)(_res_ptr);
15274         FREE((void*)_res);
15275         CResult_SignedRawInvoiceParseErrorZ_free(_res_conv);
15276 }
15277
15278 static inline uintptr_t CResult_SignedRawInvoiceParseErrorZ_clone_ptr(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR arg) {
15279         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
15280         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(arg);
15281         return (uint32_t)ret_conv;
15282 }
15283 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_clone_ptr"))) TS_CResult_SignedRawInvoiceParseErrorZ_clone_ptr(uint32_t arg) {
15284         LDKCResult_SignedRawInvoiceParseErrorZ* arg_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(arg & ~1);
15285         uint32_t ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone_ptr(arg_conv);
15286         return ret_conv;
15287 }
15288
15289 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_clone"))) TS_CResult_SignedRawInvoiceParseErrorZ_clone(uint32_t orig) {
15290         LDKCResult_SignedRawInvoiceParseErrorZ* orig_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(orig & ~1);
15291         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
15292         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(orig_conv);
15293         return (uint32_t)ret_conv;
15294 }
15295
15296 static inline uintptr_t C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR arg) {
15297         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
15298         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(arg);
15299         return ((uint32_t)ret_conv);
15300 }
15301 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(uint32_t arg) {
15302         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* arg_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(arg & ~1);
15303         uint32_t ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(arg_conv);
15304         return ret_conv;
15305 }
15306
15307 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(uint32_t orig) {
15308         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
15309         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
15310         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
15311         return ((uint32_t)ret_conv);
15312 }
15313
15314 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_new"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(uint32_t a, int8_tArray b, uint32_t c) {
15315         LDKRawInvoice a_conv;
15316         a_conv.inner = (void*)(a & (~1));
15317         a_conv.is_owned = (a & 1) || (a == 0);
15318         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
15319         a_conv = RawInvoice_clone(&a_conv);
15320         LDKThirtyTwoBytes b_ref;
15321         CHECK(b->arr_len == 32);
15322         memcpy(b_ref.data, b->elems, 32); FREE(b);
15323         LDKInvoiceSignature c_conv;
15324         c_conv.inner = (void*)(c & (~1));
15325         c_conv.is_owned = (c & 1) || (c == 0);
15326         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
15327         c_conv = InvoiceSignature_clone(&c_conv);
15328         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
15329         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
15330         return ((uint32_t)ret_conv);
15331 }
15332
15333 void  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_free"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(uint32_t _res) {
15334         if ((_res & 1) != 0) return;
15335         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15336         CHECK_ACCESS(_res_ptr);
15337         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
15338         FREE((void*)_res);
15339         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
15340 }
15341
15342 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_ok"))) TS_CResult_PayeePubKeyErrorZ_ok(uint32_t o) {
15343         LDKPayeePubKey o_conv;
15344         o_conv.inner = (void*)(o & (~1));
15345         o_conv.is_owned = (o & 1) || (o == 0);
15346         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15347         o_conv = PayeePubKey_clone(&o_conv);
15348         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
15349         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
15350         return (uint32_t)ret_conv;
15351 }
15352
15353 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_err"))) TS_CResult_PayeePubKeyErrorZ_err(uint32_t e) {
15354         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
15355         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
15356         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
15357         return (uint32_t)ret_conv;
15358 }
15359
15360 jboolean  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_is_ok"))) TS_CResult_PayeePubKeyErrorZ_is_ok(uint32_t o) {
15361         LDKCResult_PayeePubKeyErrorZ* o_conv = (LDKCResult_PayeePubKeyErrorZ*)(o & ~1);
15362         jboolean ret_conv = CResult_PayeePubKeyErrorZ_is_ok(o_conv);
15363         return ret_conv;
15364 }
15365
15366 void  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_free"))) TS_CResult_PayeePubKeyErrorZ_free(uint32_t _res) {
15367         if ((_res & 1) != 0) return;
15368         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15369         CHECK_ACCESS(_res_ptr);
15370         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
15371         FREE((void*)_res);
15372         CResult_PayeePubKeyErrorZ_free(_res_conv);
15373 }
15374
15375 static inline uintptr_t CResult_PayeePubKeyErrorZ_clone_ptr(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR arg) {
15376         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
15377         *ret_conv = CResult_PayeePubKeyErrorZ_clone(arg);
15378         return (uint32_t)ret_conv;
15379 }
15380 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_clone_ptr"))) TS_CResult_PayeePubKeyErrorZ_clone_ptr(uint32_t arg) {
15381         LDKCResult_PayeePubKeyErrorZ* arg_conv = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
15382         uint32_t ret_conv = CResult_PayeePubKeyErrorZ_clone_ptr(arg_conv);
15383         return ret_conv;
15384 }
15385
15386 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_clone"))) TS_CResult_PayeePubKeyErrorZ_clone(uint32_t orig) {
15387         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
15388         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
15389         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
15390         return (uint32_t)ret_conv;
15391 }
15392
15393 void  __attribute__((export_name("TS_CVec_PrivateRouteZ_free"))) TS_CVec_PrivateRouteZ_free(uint32_tArray _res) {
15394         LDKCVec_PrivateRouteZ _res_constr;
15395         _res_constr.datalen = _res->arr_len;
15396         if (_res_constr.datalen > 0)
15397                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
15398         else
15399                 _res_constr.data = NULL;
15400         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
15401         for (size_t o = 0; o < _res_constr.datalen; o++) {
15402                 uint32_t _res_conv_14 = _res_vals[o];
15403                 LDKPrivateRoute _res_conv_14_conv;
15404                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
15405                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
15406                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
15407                 _res_constr.data[o] = _res_conv_14_conv;
15408         }
15409         CVec_PrivateRouteZ_free(_res_constr);
15410 }
15411
15412 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_ok"))) TS_CResult_PositiveTimestampCreationErrorZ_ok(uint32_t o) {
15413         LDKPositiveTimestamp o_conv;
15414         o_conv.inner = (void*)(o & (~1));
15415         o_conv.is_owned = (o & 1) || (o == 0);
15416         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15417         o_conv = PositiveTimestamp_clone(&o_conv);
15418         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
15419         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
15420         return (uint32_t)ret_conv;
15421 }
15422
15423 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_err"))) TS_CResult_PositiveTimestampCreationErrorZ_err(uint32_t e) {
15424         LDKCreationError e_conv = LDKCreationError_from_js(e);
15425         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
15426         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
15427         return (uint32_t)ret_conv;
15428 }
15429
15430 jboolean  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_is_ok"))) TS_CResult_PositiveTimestampCreationErrorZ_is_ok(uint32_t o) {
15431         LDKCResult_PositiveTimestampCreationErrorZ* o_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(o & ~1);
15432         jboolean ret_conv = CResult_PositiveTimestampCreationErrorZ_is_ok(o_conv);
15433         return ret_conv;
15434 }
15435
15436 void  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_free"))) TS_CResult_PositiveTimestampCreationErrorZ_free(uint32_t _res) {
15437         if ((_res & 1) != 0) return;
15438         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15439         CHECK_ACCESS(_res_ptr);
15440         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
15441         FREE((void*)_res);
15442         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
15443 }
15444
15445 static inline uintptr_t CResult_PositiveTimestampCreationErrorZ_clone_ptr(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR arg) {
15446         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
15447         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(arg);
15448         return (uint32_t)ret_conv;
15449 }
15450 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_clone_ptr"))) TS_CResult_PositiveTimestampCreationErrorZ_clone_ptr(uint32_t arg) {
15451         LDKCResult_PositiveTimestampCreationErrorZ* arg_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
15452         uint32_t ret_conv = CResult_PositiveTimestampCreationErrorZ_clone_ptr(arg_conv);
15453         return ret_conv;
15454 }
15455
15456 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_clone"))) TS_CResult_PositiveTimestampCreationErrorZ_clone(uint32_t orig) {
15457         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
15458         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
15459         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
15460         return (uint32_t)ret_conv;
15461 }
15462
15463 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_ok"))) TS_CResult_NoneSemanticErrorZ_ok() {
15464         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
15465         *ret_conv = CResult_NoneSemanticErrorZ_ok();
15466         return (uint32_t)ret_conv;
15467 }
15468
15469 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_err"))) TS_CResult_NoneSemanticErrorZ_err(uint32_t e) {
15470         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
15471         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
15472         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
15473         return (uint32_t)ret_conv;
15474 }
15475
15476 jboolean  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_is_ok"))) TS_CResult_NoneSemanticErrorZ_is_ok(uint32_t o) {
15477         LDKCResult_NoneSemanticErrorZ* o_conv = (LDKCResult_NoneSemanticErrorZ*)(o & ~1);
15478         jboolean ret_conv = CResult_NoneSemanticErrorZ_is_ok(o_conv);
15479         return ret_conv;
15480 }
15481
15482 void  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_free"))) TS_CResult_NoneSemanticErrorZ_free(uint32_t _res) {
15483         if ((_res & 1) != 0) return;
15484         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15485         CHECK_ACCESS(_res_ptr);
15486         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
15487         FREE((void*)_res);
15488         CResult_NoneSemanticErrorZ_free(_res_conv);
15489 }
15490
15491 static inline uintptr_t CResult_NoneSemanticErrorZ_clone_ptr(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR arg) {
15492         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
15493         *ret_conv = CResult_NoneSemanticErrorZ_clone(arg);
15494         return (uint32_t)ret_conv;
15495 }
15496 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_clone_ptr"))) TS_CResult_NoneSemanticErrorZ_clone_ptr(uint32_t arg) {
15497         LDKCResult_NoneSemanticErrorZ* arg_conv = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
15498         uint32_t ret_conv = CResult_NoneSemanticErrorZ_clone_ptr(arg_conv);
15499         return ret_conv;
15500 }
15501
15502 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_clone"))) TS_CResult_NoneSemanticErrorZ_clone(uint32_t orig) {
15503         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
15504         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
15505         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
15506         return (uint32_t)ret_conv;
15507 }
15508
15509 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_ok"))) TS_CResult_InvoiceSemanticErrorZ_ok(uint32_t o) {
15510         LDKInvoice o_conv;
15511         o_conv.inner = (void*)(o & (~1));
15512         o_conv.is_owned = (o & 1) || (o == 0);
15513         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15514         o_conv = Invoice_clone(&o_conv);
15515         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
15516         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
15517         return (uint32_t)ret_conv;
15518 }
15519
15520 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_err"))) TS_CResult_InvoiceSemanticErrorZ_err(uint32_t e) {
15521         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
15522         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
15523         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
15524         return (uint32_t)ret_conv;
15525 }
15526
15527 jboolean  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_is_ok"))) TS_CResult_InvoiceSemanticErrorZ_is_ok(uint32_t o) {
15528         LDKCResult_InvoiceSemanticErrorZ* o_conv = (LDKCResult_InvoiceSemanticErrorZ*)(o & ~1);
15529         jboolean ret_conv = CResult_InvoiceSemanticErrorZ_is_ok(o_conv);
15530         return ret_conv;
15531 }
15532
15533 void  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_free"))) TS_CResult_InvoiceSemanticErrorZ_free(uint32_t _res) {
15534         if ((_res & 1) != 0) return;
15535         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15536         CHECK_ACCESS(_res_ptr);
15537         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
15538         FREE((void*)_res);
15539         CResult_InvoiceSemanticErrorZ_free(_res_conv);
15540 }
15541
15542 static inline uintptr_t CResult_InvoiceSemanticErrorZ_clone_ptr(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR arg) {
15543         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
15544         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(arg);
15545         return (uint32_t)ret_conv;
15546 }
15547 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_clone_ptr"))) TS_CResult_InvoiceSemanticErrorZ_clone_ptr(uint32_t arg) {
15548         LDKCResult_InvoiceSemanticErrorZ* arg_conv = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
15549         uint32_t ret_conv = CResult_InvoiceSemanticErrorZ_clone_ptr(arg_conv);
15550         return ret_conv;
15551 }
15552
15553 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_clone"))) TS_CResult_InvoiceSemanticErrorZ_clone(uint32_t orig) {
15554         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
15555         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
15556         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
15557         return (uint32_t)ret_conv;
15558 }
15559
15560 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_ok"))) TS_CResult_DescriptionCreationErrorZ_ok(uint32_t o) {
15561         LDKDescription o_conv;
15562         o_conv.inner = (void*)(o & (~1));
15563         o_conv.is_owned = (o & 1) || (o == 0);
15564         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15565         o_conv = Description_clone(&o_conv);
15566         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
15567         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
15568         return (uint32_t)ret_conv;
15569 }
15570
15571 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_err"))) TS_CResult_DescriptionCreationErrorZ_err(uint32_t e) {
15572         LDKCreationError e_conv = LDKCreationError_from_js(e);
15573         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
15574         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
15575         return (uint32_t)ret_conv;
15576 }
15577
15578 jboolean  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_is_ok"))) TS_CResult_DescriptionCreationErrorZ_is_ok(uint32_t o) {
15579         LDKCResult_DescriptionCreationErrorZ* o_conv = (LDKCResult_DescriptionCreationErrorZ*)(o & ~1);
15580         jboolean ret_conv = CResult_DescriptionCreationErrorZ_is_ok(o_conv);
15581         return ret_conv;
15582 }
15583
15584 void  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_free"))) TS_CResult_DescriptionCreationErrorZ_free(uint32_t _res) {
15585         if ((_res & 1) != 0) return;
15586         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15587         CHECK_ACCESS(_res_ptr);
15588         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
15589         FREE((void*)_res);
15590         CResult_DescriptionCreationErrorZ_free(_res_conv);
15591 }
15592
15593 static inline uintptr_t CResult_DescriptionCreationErrorZ_clone_ptr(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR arg) {
15594         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
15595         *ret_conv = CResult_DescriptionCreationErrorZ_clone(arg);
15596         return (uint32_t)ret_conv;
15597 }
15598 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_clone_ptr"))) TS_CResult_DescriptionCreationErrorZ_clone_ptr(uint32_t arg) {
15599         LDKCResult_DescriptionCreationErrorZ* arg_conv = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
15600         uint32_t ret_conv = CResult_DescriptionCreationErrorZ_clone_ptr(arg_conv);
15601         return ret_conv;
15602 }
15603
15604 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_clone"))) TS_CResult_DescriptionCreationErrorZ_clone(uint32_t orig) {
15605         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
15606         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
15607         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
15608         return (uint32_t)ret_conv;
15609 }
15610
15611 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_ok"))) TS_CResult_PrivateRouteCreationErrorZ_ok(uint32_t o) {
15612         LDKPrivateRoute o_conv;
15613         o_conv.inner = (void*)(o & (~1));
15614         o_conv.is_owned = (o & 1) || (o == 0);
15615         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15616         o_conv = PrivateRoute_clone(&o_conv);
15617         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
15618         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
15619         return (uint32_t)ret_conv;
15620 }
15621
15622 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_err"))) TS_CResult_PrivateRouteCreationErrorZ_err(uint32_t e) {
15623         LDKCreationError e_conv = LDKCreationError_from_js(e);
15624         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
15625         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
15626         return (uint32_t)ret_conv;
15627 }
15628
15629 jboolean  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_is_ok"))) TS_CResult_PrivateRouteCreationErrorZ_is_ok(uint32_t o) {
15630         LDKCResult_PrivateRouteCreationErrorZ* o_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(o & ~1);
15631         jboolean ret_conv = CResult_PrivateRouteCreationErrorZ_is_ok(o_conv);
15632         return ret_conv;
15633 }
15634
15635 void  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_free"))) TS_CResult_PrivateRouteCreationErrorZ_free(uint32_t _res) {
15636         if ((_res & 1) != 0) return;
15637         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15638         CHECK_ACCESS(_res_ptr);
15639         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
15640         FREE((void*)_res);
15641         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
15642 }
15643
15644 static inline uintptr_t CResult_PrivateRouteCreationErrorZ_clone_ptr(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR arg) {
15645         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
15646         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(arg);
15647         return (uint32_t)ret_conv;
15648 }
15649 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_clone_ptr"))) TS_CResult_PrivateRouteCreationErrorZ_clone_ptr(uint32_t arg) {
15650         LDKCResult_PrivateRouteCreationErrorZ* arg_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
15651         uint32_t ret_conv = CResult_PrivateRouteCreationErrorZ_clone_ptr(arg_conv);
15652         return ret_conv;
15653 }
15654
15655 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_clone"))) TS_CResult_PrivateRouteCreationErrorZ_clone(uint32_t orig) {
15656         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
15657         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
15658         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
15659         return (uint32_t)ret_conv;
15660 }
15661
15662 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_ok"))) TS_CResult_StringErrorZ_ok(jstring o) {
15663         LDKStr o_conv = str_ref_to_owned_c(o);
15664         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
15665         *ret_conv = CResult_StringErrorZ_ok(o_conv);
15666         return (uint32_t)ret_conv;
15667 }
15668
15669 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_err"))) TS_CResult_StringErrorZ_err(uint32_t e) {
15670         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
15671         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
15672         *ret_conv = CResult_StringErrorZ_err(e_conv);
15673         return (uint32_t)ret_conv;
15674 }
15675
15676 jboolean  __attribute__((export_name("TS_CResult_StringErrorZ_is_ok"))) TS_CResult_StringErrorZ_is_ok(uint32_t o) {
15677         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)(o & ~1);
15678         jboolean ret_conv = CResult_StringErrorZ_is_ok(o_conv);
15679         return ret_conv;
15680 }
15681
15682 void  __attribute__((export_name("TS_CResult_StringErrorZ_free"))) TS_CResult_StringErrorZ_free(uint32_t _res) {
15683         if ((_res & 1) != 0) return;
15684         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15685         CHECK_ACCESS(_res_ptr);
15686         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
15687         FREE((void*)_res);
15688         CResult_StringErrorZ_free(_res_conv);
15689 }
15690
15691 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok(uint32_t o) {
15692         LDKChannelMonitorUpdate o_conv;
15693         o_conv.inner = (void*)(o & (~1));
15694         o_conv.is_owned = (o & 1) || (o == 0);
15695         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15696         o_conv = ChannelMonitorUpdate_clone(&o_conv);
15697         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
15698         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
15699         return (uint32_t)ret_conv;
15700 }
15701
15702 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err(uint32_t e) {
15703         LDKDecodeError e_conv;
15704         e_conv.inner = (void*)(e & (~1));
15705         e_conv.is_owned = (e & 1) || (e == 0);
15706         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15707         e_conv = DecodeError_clone(&e_conv);
15708         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
15709         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
15710         return (uint32_t)ret_conv;
15711 }
15712
15713 jboolean  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(uint32_t o) {
15714         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(o & ~1);
15715         jboolean ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
15716         return ret_conv;
15717 }
15718
15719 void  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free(uint32_t _res) {
15720         if ((_res & 1) != 0) return;
15721         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15722         CHECK_ACCESS(_res_ptr);
15723         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
15724         FREE((void*)_res);
15725         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
15726 }
15727
15728 static inline uintptr_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
15729         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
15730         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
15731         return (uint32_t)ret_conv;
15732 }
15733 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
15734         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
15735         uint32_t ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
15736         return ret_conv;
15737 }
15738
15739 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone(uint32_t orig) {
15740         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
15741         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
15742         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
15743         return (uint32_t)ret_conv;
15744 }
15745
15746 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_some"))) TS_COption_MonitorEventZ_some(uint32_t o) {
15747         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15748         CHECK_ACCESS(o_ptr);
15749         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
15750         o_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uintptr_t)o) & ~1));
15751         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
15752         *ret_copy = COption_MonitorEventZ_some(o_conv);
15753         uint32_t ret_ref = (uintptr_t)ret_copy;
15754         return ret_ref;
15755 }
15756
15757 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_none"))) TS_COption_MonitorEventZ_none() {
15758         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
15759         *ret_copy = COption_MonitorEventZ_none();
15760         uint32_t ret_ref = (uintptr_t)ret_copy;
15761         return ret_ref;
15762 }
15763
15764 void  __attribute__((export_name("TS_COption_MonitorEventZ_free"))) TS_COption_MonitorEventZ_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         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
15769         FREE((void*)_res);
15770         COption_MonitorEventZ_free(_res_conv);
15771 }
15772
15773 static inline uintptr_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
15774         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
15775         *ret_copy = COption_MonitorEventZ_clone(arg);
15776 uint32_t ret_ref = (uintptr_t)ret_copy;
15777         return ret_ref;
15778 }
15779 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_clone_ptr"))) TS_COption_MonitorEventZ_clone_ptr(uint32_t arg) {
15780         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)arg;
15781         uint32_t ret_conv = COption_MonitorEventZ_clone_ptr(arg_conv);
15782         return ret_conv;
15783 }
15784
15785 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_clone"))) TS_COption_MonitorEventZ_clone(uint32_t orig) {
15786         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)orig;
15787         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
15788         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
15789         uint32_t ret_ref = (uintptr_t)ret_copy;
15790         return ret_ref;
15791 }
15792
15793 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_ok(uint32_t o) {
15794         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15795         CHECK_ACCESS(o_ptr);
15796         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
15797         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)(((uintptr_t)o) & ~1));
15798         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
15799         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
15800         return (uint32_t)ret_conv;
15801 }
15802
15803 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_err"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_err(uint32_t e) {
15804         LDKDecodeError e_conv;
15805         e_conv.inner = (void*)(e & (~1));
15806         e_conv.is_owned = (e & 1) || (e == 0);
15807         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15808         e_conv = DecodeError_clone(&e_conv);
15809         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
15810         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
15811         return (uint32_t)ret_conv;
15812 }
15813
15814 jboolean  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_is_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_is_ok(uint32_t o) {
15815         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(o & ~1);
15816         jboolean ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
15817         return ret_conv;
15818 }
15819
15820 void  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_free"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_free(uint32_t _res) {
15821         if ((_res & 1) != 0) return;
15822         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15823         CHECK_ACCESS(_res_ptr);
15824         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
15825         FREE((void*)_res);
15826         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
15827 }
15828
15829 static inline uintptr_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
15830         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
15831         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
15832         return (uint32_t)ret_conv;
15833 }
15834 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(uint32_t arg) {
15835         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(arg & ~1);
15836         uint32_t ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
15837         return ret_conv;
15838 }
15839
15840 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_clone"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_clone(uint32_t orig) {
15841         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(orig & ~1);
15842         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
15843         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
15844         return (uint32_t)ret_conv;
15845 }
15846
15847 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_ok(uint32_t o) {
15848         LDKHTLCUpdate o_conv;
15849         o_conv.inner = (void*)(o & (~1));
15850         o_conv.is_owned = (o & 1) || (o == 0);
15851         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15852         o_conv = HTLCUpdate_clone(&o_conv);
15853         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
15854         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
15855         return (uint32_t)ret_conv;
15856 }
15857
15858 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_err"))) TS_CResult_HTLCUpdateDecodeErrorZ_err(uint32_t e) {
15859         LDKDecodeError e_conv;
15860         e_conv.inner = (void*)(e & (~1));
15861         e_conv.is_owned = (e & 1) || (e == 0);
15862         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15863         e_conv = DecodeError_clone(&e_conv);
15864         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
15865         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
15866         return (uint32_t)ret_conv;
15867 }
15868
15869 jboolean  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_is_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_is_ok(uint32_t o) {
15870         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(o & ~1);
15871         jboolean ret_conv = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
15872         return ret_conv;
15873 }
15874
15875 void  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_free"))) TS_CResult_HTLCUpdateDecodeErrorZ_free(uint32_t _res) {
15876         if ((_res & 1) != 0) return;
15877         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15878         CHECK_ACCESS(_res_ptr);
15879         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
15880         FREE((void*)_res);
15881         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
15882 }
15883
15884 static inline uintptr_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
15885         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
15886         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
15887         return (uint32_t)ret_conv;
15888 }
15889 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
15890         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
15891         uint32_t ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
15892         return ret_conv;
15893 }
15894
15895 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_clone"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone(uint32_t orig) {
15896         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
15897         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
15898         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
15899         return (uint32_t)ret_conv;
15900 }
15901
15902 static inline uintptr_t C2Tuple_OutPointScriptZ_clone_ptr(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR arg) {
15903         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
15904         *ret_conv = C2Tuple_OutPointScriptZ_clone(arg);
15905         return ((uint32_t)ret_conv);
15906 }
15907 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_clone_ptr"))) TS_C2Tuple_OutPointScriptZ_clone_ptr(uint32_t arg) {
15908         LDKC2Tuple_OutPointScriptZ* arg_conv = (LDKC2Tuple_OutPointScriptZ*)(arg & ~1);
15909         uint32_t ret_conv = C2Tuple_OutPointScriptZ_clone_ptr(arg_conv);
15910         return ret_conv;
15911 }
15912
15913 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_clone"))) TS_C2Tuple_OutPointScriptZ_clone(uint32_t orig) {
15914         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
15915         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
15916         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
15917         return ((uint32_t)ret_conv);
15918 }
15919
15920 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_new"))) TS_C2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
15921         LDKOutPoint a_conv;
15922         a_conv.inner = (void*)(a & (~1));
15923         a_conv.is_owned = (a & 1) || (a == 0);
15924         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
15925         a_conv = OutPoint_clone(&a_conv);
15926         LDKCVec_u8Z b_ref;
15927         b_ref.datalen = b->arr_len;
15928         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
15929         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
15930         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
15931         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
15932         return ((uint32_t)ret_conv);
15933 }
15934
15935 void  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_free"))) TS_C2Tuple_OutPointScriptZ_free(uint32_t _res) {
15936         if ((_res & 1) != 0) return;
15937         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15938         CHECK_ACCESS(_res_ptr);
15939         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
15940         FREE((void*)_res);
15941         C2Tuple_OutPointScriptZ_free(_res_conv);
15942 }
15943
15944 static inline uintptr_t C2Tuple_u32ScriptZ_clone_ptr(LDKC2Tuple_u32ScriptZ *NONNULL_PTR arg) {
15945         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
15946         *ret_conv = C2Tuple_u32ScriptZ_clone(arg);
15947         return ((uint32_t)ret_conv);
15948 }
15949 uint32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_clone_ptr"))) TS_C2Tuple_u32ScriptZ_clone_ptr(uint32_t arg) {
15950         LDKC2Tuple_u32ScriptZ* arg_conv = (LDKC2Tuple_u32ScriptZ*)(arg & ~1);
15951         uint32_t ret_conv = C2Tuple_u32ScriptZ_clone_ptr(arg_conv);
15952         return ret_conv;
15953 }
15954
15955 uint32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_clone"))) TS_C2Tuple_u32ScriptZ_clone(uint32_t orig) {
15956         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
15957         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
15958         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
15959         return ((uint32_t)ret_conv);
15960 }
15961
15962 uint32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_new"))) TS_C2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
15963         LDKCVec_u8Z b_ref;
15964         b_ref.datalen = b->arr_len;
15965         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
15966         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
15967         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
15968         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
15969         return ((uint32_t)ret_conv);
15970 }
15971
15972 void  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_free"))) TS_C2Tuple_u32ScriptZ_free(uint32_t _res) {
15973         if ((_res & 1) != 0) return;
15974         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15975         CHECK_ACCESS(_res_ptr);
15976         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
15977         FREE((void*)_res);
15978         C2Tuple_u32ScriptZ_free(_res_conv);
15979 }
15980
15981 void  __attribute__((export_name("TS_CVec_C2Tuple_u32ScriptZZ_free"))) TS_CVec_C2Tuple_u32ScriptZZ_free(uint32_tArray _res) {
15982         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
15983         _res_constr.datalen = _res->arr_len;
15984         if (_res_constr.datalen > 0)
15985                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
15986         else
15987                 _res_constr.data = NULL;
15988         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
15989         for (size_t v = 0; v < _res_constr.datalen; v++) {
15990                 uint32_t _res_conv_21 = _res_vals[v];
15991                 void* _res_conv_21_ptr = (void*)(((uintptr_t)_res_conv_21) & ~1);
15992                 CHECK_ACCESS(_res_conv_21_ptr);
15993                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
15994                 FREE((void*)_res_conv_21);
15995                 _res_constr.data[v] = _res_conv_21_conv;
15996         }
15997         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
15998 }
15999
16000 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR arg) {
16001         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
16002         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(arg);
16003         return ((uint32_t)ret_conv);
16004 }
16005 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(uint32_t arg) {
16006         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(arg & ~1);
16007         uint32_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(arg_conv);
16008         return ret_conv;
16009 }
16010
16011 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(uint32_t orig) {
16012         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
16013         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
16014         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
16015         return ((uint32_t)ret_conv);
16016 }
16017
16018 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
16019         LDKThirtyTwoBytes a_ref;
16020         CHECK(a->arr_len == 32);
16021         memcpy(a_ref.data, a->elems, 32); FREE(a);
16022         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
16023         b_constr.datalen = b->arr_len;
16024         if (b_constr.datalen > 0)
16025                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
16026         else
16027                 b_constr.data = NULL;
16028         uint32_t* b_vals = b->elems /* XXX b leaks */;
16029         for (size_t v = 0; v < b_constr.datalen; v++) {
16030                 uint32_t b_conv_21 = b_vals[v];
16031                 void* b_conv_21_ptr = (void*)(((uintptr_t)b_conv_21) & ~1);
16032                 CHECK_ACCESS(b_conv_21_ptr);
16033                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
16034                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uintptr_t)b_conv_21) & ~1));
16035                 b_constr.data[v] = b_conv_21_conv;
16036         }
16037         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
16038         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
16039         return ((uint32_t)ret_conv);
16040 }
16041
16042 void  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(uint32_t _res) {
16043         if ((_res & 1) != 0) return;
16044         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16045         CHECK_ACCESS(_res_ptr);
16046         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
16047         FREE((void*)_res);
16048         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
16049 }
16050
16051 void  __attribute__((export_name("TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(uint32_tArray _res) {
16052         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
16053         _res_constr.datalen = _res->arr_len;
16054         if (_res_constr.datalen > 0)
16055                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
16056         else
16057                 _res_constr.data = NULL;
16058         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16059         for (size_t o = 0; o < _res_constr.datalen; o++) {
16060                 uint32_t _res_conv_40 = _res_vals[o];
16061                 void* _res_conv_40_ptr = (void*)(((uintptr_t)_res_conv_40) & ~1);
16062                 CHECK_ACCESS(_res_conv_40_ptr);
16063                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
16064                 FREE((void*)_res_conv_40);
16065                 _res_constr.data[o] = _res_conv_40_conv;
16066         }
16067         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
16068 }
16069
16070 void  __attribute__((export_name("TS_CVec_EventZ_free"))) TS_CVec_EventZ_free(uint32_tArray _res) {
16071         LDKCVec_EventZ _res_constr;
16072         _res_constr.datalen = _res->arr_len;
16073         if (_res_constr.datalen > 0)
16074                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
16075         else
16076                 _res_constr.data = NULL;
16077         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16078         for (size_t h = 0; h < _res_constr.datalen; h++) {
16079                 uint32_t _res_conv_7 = _res_vals[h];
16080                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
16081                 CHECK_ACCESS(_res_conv_7_ptr);
16082                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
16083                 FREE((void*)_res_conv_7);
16084                 _res_constr.data[h] = _res_conv_7_conv;
16085         }
16086         CVec_EventZ_free(_res_constr);
16087 }
16088
16089 void  __attribute__((export_name("TS_CVec_TransactionZ_free"))) TS_CVec_TransactionZ_free(ptrArray _res) {
16090         LDKCVec_TransactionZ _res_constr;
16091         _res_constr.datalen = _res->arr_len;
16092         if (_res_constr.datalen > 0)
16093                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
16094         else
16095                 _res_constr.data = NULL;
16096         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
16097         for (size_t m = 0; m < _res_constr.datalen; m++) {
16098                 int8_tArray _res_conv_12 = _res_vals[m];
16099                 LDKTransaction _res_conv_12_ref;
16100                 _res_conv_12_ref.datalen = _res_conv_12->arr_len;
16101                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKTransaction Bytes");
16102                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, _res_conv_12_ref.datalen); FREE(_res_conv_12);
16103                 _res_conv_12_ref.data_is_owned = true;
16104                 _res_constr.data[m] = _res_conv_12_ref;
16105         }
16106         CVec_TransactionZ_free(_res_constr);
16107 }
16108
16109 static inline uintptr_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
16110         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
16111         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
16112         return ((uint32_t)ret_conv);
16113 }
16114 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_clone_ptr"))) TS_C2Tuple_u32TxOutZ_clone_ptr(uint32_t arg) {
16115         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)(arg & ~1);
16116         uint32_t ret_conv = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
16117         return ret_conv;
16118 }
16119
16120 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_clone"))) TS_C2Tuple_u32TxOutZ_clone(uint32_t orig) {
16121         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
16122         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
16123         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
16124         return ((uint32_t)ret_conv);
16125 }
16126
16127 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_new"))) TS_C2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
16128         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
16129         CHECK_ACCESS(b_ptr);
16130         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
16131         b_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)b) & ~1));
16132         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
16133         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
16134         return ((uint32_t)ret_conv);
16135 }
16136
16137 void  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_free"))) TS_C2Tuple_u32TxOutZ_free(uint32_t _res) {
16138         if ((_res & 1) != 0) return;
16139         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16140         CHECK_ACCESS(_res_ptr);
16141         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
16142         FREE((void*)_res);
16143         C2Tuple_u32TxOutZ_free(_res_conv);
16144 }
16145
16146 void  __attribute__((export_name("TS_CVec_C2Tuple_u32TxOutZZ_free"))) TS_CVec_C2Tuple_u32TxOutZZ_free(uint32_tArray _res) {
16147         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
16148         _res_constr.datalen = _res->arr_len;
16149         if (_res_constr.datalen > 0)
16150                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
16151         else
16152                 _res_constr.data = NULL;
16153         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16154         for (size_t u = 0; u < _res_constr.datalen; u++) {
16155                 uint32_t _res_conv_20 = _res_vals[u];
16156                 void* _res_conv_20_ptr = (void*)(((uintptr_t)_res_conv_20) & ~1);
16157                 CHECK_ACCESS(_res_conv_20_ptr);
16158                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
16159                 FREE((void*)_res_conv_20);
16160                 _res_constr.data[u] = _res_conv_20_conv;
16161         }
16162         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
16163 }
16164
16165 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
16166         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
16167         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
16168         return ((uint32_t)ret_conv);
16169 }
16170 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(uint32_t arg) {
16171         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(arg & ~1);
16172         uint32_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
16173         return ret_conv;
16174 }
16175
16176 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(uint32_t orig) {
16177         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
16178         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
16179         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
16180         return ((uint32_t)ret_conv);
16181 }
16182
16183 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
16184         LDKThirtyTwoBytes a_ref;
16185         CHECK(a->arr_len == 32);
16186         memcpy(a_ref.data, a->elems, 32); FREE(a);
16187         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
16188         b_constr.datalen = b->arr_len;
16189         if (b_constr.datalen > 0)
16190                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
16191         else
16192                 b_constr.data = NULL;
16193         uint32_t* b_vals = b->elems /* XXX b leaks */;
16194         for (size_t u = 0; u < b_constr.datalen; u++) {
16195                 uint32_t b_conv_20 = b_vals[u];
16196                 void* b_conv_20_ptr = (void*)(((uintptr_t)b_conv_20) & ~1);
16197                 CHECK_ACCESS(b_conv_20_ptr);
16198                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
16199                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uintptr_t)b_conv_20) & ~1));
16200                 b_constr.data[u] = b_conv_20_conv;
16201         }
16202         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
16203         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
16204         return ((uint32_t)ret_conv);
16205 }
16206
16207 void  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(uint32_t _res) {
16208         if ((_res & 1) != 0) return;
16209         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16210         CHECK_ACCESS(_res_ptr);
16211         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
16212         FREE((void*)_res);
16213         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
16214 }
16215
16216 void  __attribute__((export_name("TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(uint32_tArray _res) {
16217         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
16218         _res_constr.datalen = _res->arr_len;
16219         if (_res_constr.datalen > 0)
16220                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
16221         else
16222                 _res_constr.data = NULL;
16223         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16224         for (size_t n = 0; n < _res_constr.datalen; n++) {
16225                 uint32_t _res_conv_39 = _res_vals[n];
16226                 void* _res_conv_39_ptr = (void*)(((uintptr_t)_res_conv_39) & ~1);
16227                 CHECK_ACCESS(_res_conv_39_ptr);
16228                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
16229                 FREE((void*)_res_conv_39);
16230                 _res_constr.data[n] = _res_conv_39_conv;
16231         }
16232         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
16233 }
16234
16235 void  __attribute__((export_name("TS_CVec_BalanceZ_free"))) TS_CVec_BalanceZ_free(uint32_tArray _res) {
16236         LDKCVec_BalanceZ _res_constr;
16237         _res_constr.datalen = _res->arr_len;
16238         if (_res_constr.datalen > 0)
16239                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
16240         else
16241                 _res_constr.data = NULL;
16242         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16243         for (size_t j = 0; j < _res_constr.datalen; j++) {
16244                 uint32_t _res_conv_9 = _res_vals[j];
16245                 void* _res_conv_9_ptr = (void*)(((uintptr_t)_res_conv_9) & ~1);
16246                 CHECK_ACCESS(_res_conv_9_ptr);
16247                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
16248                 FREE((void*)_res_conv_9);
16249                 _res_constr.data[j] = _res_conv_9_conv;
16250         }
16251         CVec_BalanceZ_free(_res_constr);
16252 }
16253
16254 static inline uintptr_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
16255         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
16256         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
16257         return ((uint32_t)ret_conv);
16258 }
16259 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_clone_ptr"))) TS_C2Tuple_BlockHashChannelMonitorZ_clone_ptr(uint32_t arg) {
16260         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(arg & ~1);
16261         uint32_t ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
16262         return ret_conv;
16263 }
16264
16265 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_clone"))) TS_C2Tuple_BlockHashChannelMonitorZ_clone(uint32_t orig) {
16266         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(orig & ~1);
16267         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
16268         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
16269         return ((uint32_t)ret_conv);
16270 }
16271
16272 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_new"))) TS_C2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
16273         LDKThirtyTwoBytes a_ref;
16274         CHECK(a->arr_len == 32);
16275         memcpy(a_ref.data, a->elems, 32); FREE(a);
16276         LDKChannelMonitor b_conv;
16277         b_conv.inner = (void*)(b & (~1));
16278         b_conv.is_owned = (b & 1) || (b == 0);
16279         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
16280         b_conv = ChannelMonitor_clone(&b_conv);
16281         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
16282         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
16283         return ((uint32_t)ret_conv);
16284 }
16285
16286 void  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_free"))) TS_C2Tuple_BlockHashChannelMonitorZ_free(uint32_t _res) {
16287         if ((_res & 1) != 0) return;
16288         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16289         CHECK_ACCESS(_res_ptr);
16290         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
16291         FREE((void*)_res);
16292         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
16293 }
16294
16295 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(uint32_t o) {
16296         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16297         CHECK_ACCESS(o_ptr);
16298         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
16299         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uintptr_t)o) & ~1));
16300         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
16301         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
16302         return (uint32_t)ret_conv;
16303 }
16304
16305 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(uint32_t e) {
16306         LDKDecodeError e_conv;
16307         e_conv.inner = (void*)(e & (~1));
16308         e_conv.is_owned = (e & 1) || (e == 0);
16309         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16310         e_conv = DecodeError_clone(&e_conv);
16311         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
16312         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
16313         return (uint32_t)ret_conv;
16314 }
16315
16316 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(uint32_t o) {
16317         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(o & ~1);
16318         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
16319         return ret_conv;
16320 }
16321
16322 void  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(uint32_t _res) {
16323         if ((_res & 1) != 0) return;
16324         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16325         CHECK_ACCESS(_res_ptr);
16326         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
16327         FREE((void*)_res);
16328         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
16329 }
16330
16331 static inline uintptr_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
16332         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
16333         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
16334         return (uint32_t)ret_conv;
16335 }
16336 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(uint32_t arg) {
16337         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
16338         uint32_t ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
16339         return ret_conv;
16340 }
16341
16342 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(uint32_t orig) {
16343         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(orig & ~1);
16344         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
16345         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
16346         return (uint32_t)ret_conv;
16347 }
16348
16349 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_ok"))) TS_CResult_NoneLightningErrorZ_ok() {
16350         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
16351         *ret_conv = CResult_NoneLightningErrorZ_ok();
16352         return (uint32_t)ret_conv;
16353 }
16354
16355 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_err"))) TS_CResult_NoneLightningErrorZ_err(uint32_t e) {
16356         LDKLightningError e_conv;
16357         e_conv.inner = (void*)(e & (~1));
16358         e_conv.is_owned = (e & 1) || (e == 0);
16359         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16360         e_conv = LightningError_clone(&e_conv);
16361         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
16362         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
16363         return (uint32_t)ret_conv;
16364 }
16365
16366 jboolean  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_is_ok"))) TS_CResult_NoneLightningErrorZ_is_ok(uint32_t o) {
16367         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)(o & ~1);
16368         jboolean ret_conv = CResult_NoneLightningErrorZ_is_ok(o_conv);
16369         return ret_conv;
16370 }
16371
16372 void  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_free"))) TS_CResult_NoneLightningErrorZ_free(uint32_t _res) {
16373         if ((_res & 1) != 0) return;
16374         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16375         CHECK_ACCESS(_res_ptr);
16376         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
16377         FREE((void*)_res);
16378         CResult_NoneLightningErrorZ_free(_res_conv);
16379 }
16380
16381 static inline uintptr_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
16382         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
16383         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
16384         return (uint32_t)ret_conv;
16385 }
16386 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_clone_ptr"))) TS_CResult_NoneLightningErrorZ_clone_ptr(uint32_t arg) {
16387         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
16388         uint32_t ret_conv = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
16389         return ret_conv;
16390 }
16391
16392 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_clone"))) TS_CResult_NoneLightningErrorZ_clone(uint32_t orig) {
16393         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
16394         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
16395         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
16396         return (uint32_t)ret_conv;
16397 }
16398
16399 static inline uintptr_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
16400         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
16401         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
16402         return ((uint32_t)ret_conv);
16403 }
16404 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_clone_ptr"))) TS_C2Tuple_PublicKeyTypeZ_clone_ptr(uint32_t arg) {
16405         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)(arg & ~1);
16406         uint32_t ret_conv = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
16407         return ret_conv;
16408 }
16409
16410 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_clone"))) TS_C2Tuple_PublicKeyTypeZ_clone(uint32_t orig) {
16411         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1);
16412         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
16413         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
16414         return ((uint32_t)ret_conv);
16415 }
16416
16417 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_new"))) TS_C2Tuple_PublicKeyTypeZ_new(int8_tArray a, uint32_t b) {
16418         LDKPublicKey a_ref;
16419         CHECK(a->arr_len == 33);
16420         memcpy(a_ref.compressed_form, a->elems, 33); FREE(a);
16421         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
16422         CHECK_ACCESS(b_ptr);
16423         LDKType b_conv = *(LDKType*)(b_ptr);
16424         if (b_conv.free == LDKType_JCalls_free) {
16425                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16426                 LDKType_JCalls_cloned(&b_conv);
16427         }
16428         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
16429         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
16430         return ((uint32_t)ret_conv);
16431 }
16432
16433 void  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_free"))) TS_C2Tuple_PublicKeyTypeZ_free(uint32_t _res) {
16434         if ((_res & 1) != 0) return;
16435         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16436         CHECK_ACCESS(_res_ptr);
16437         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
16438         FREE((void*)_res);
16439         C2Tuple_PublicKeyTypeZ_free(_res_conv);
16440 }
16441
16442 void  __attribute__((export_name("TS_CVec_C2Tuple_PublicKeyTypeZZ_free"))) TS_CVec_C2Tuple_PublicKeyTypeZZ_free(uint32_tArray _res) {
16443         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
16444         _res_constr.datalen = _res->arr_len;
16445         if (_res_constr.datalen > 0)
16446                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
16447         else
16448                 _res_constr.data = NULL;
16449         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16450         for (size_t z = 0; z < _res_constr.datalen; z++) {
16451                 uint32_t _res_conv_25 = _res_vals[z];
16452                 void* _res_conv_25_ptr = (void*)(((uintptr_t)_res_conv_25) & ~1);
16453                 CHECK_ACCESS(_res_conv_25_ptr);
16454                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
16455                 FREE((void*)_res_conv_25);
16456                 _res_constr.data[z] = _res_conv_25_conv;
16457         }
16458         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
16459 }
16460
16461 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_ok"))) TS_CResult_boolLightningErrorZ_ok(jboolean o) {
16462         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
16463         *ret_conv = CResult_boolLightningErrorZ_ok(o);
16464         return (uint32_t)ret_conv;
16465 }
16466
16467 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_err"))) TS_CResult_boolLightningErrorZ_err(uint32_t e) {
16468         LDKLightningError e_conv;
16469         e_conv.inner = (void*)(e & (~1));
16470         e_conv.is_owned = (e & 1) || (e == 0);
16471         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16472         e_conv = LightningError_clone(&e_conv);
16473         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
16474         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
16475         return (uint32_t)ret_conv;
16476 }
16477
16478 jboolean  __attribute__((export_name("TS_CResult_boolLightningErrorZ_is_ok"))) TS_CResult_boolLightningErrorZ_is_ok(uint32_t o) {
16479         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)(o & ~1);
16480         jboolean ret_conv = CResult_boolLightningErrorZ_is_ok(o_conv);
16481         return ret_conv;
16482 }
16483
16484 void  __attribute__((export_name("TS_CResult_boolLightningErrorZ_free"))) TS_CResult_boolLightningErrorZ_free(uint32_t _res) {
16485         if ((_res & 1) != 0) return;
16486         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16487         CHECK_ACCESS(_res_ptr);
16488         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
16489         FREE((void*)_res);
16490         CResult_boolLightningErrorZ_free(_res_conv);
16491 }
16492
16493 static inline uintptr_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
16494         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
16495         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
16496         return (uint32_t)ret_conv;
16497 }
16498 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_clone_ptr"))) TS_CResult_boolLightningErrorZ_clone_ptr(uint32_t arg) {
16499         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
16500         uint32_t ret_conv = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
16501         return ret_conv;
16502 }
16503
16504 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_clone"))) TS_CResult_boolLightningErrorZ_clone(uint32_t orig) {
16505         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
16506         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
16507         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
16508         return (uint32_t)ret_conv;
16509 }
16510
16511 static inline uintptr_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
16512         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
16513         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
16514         return ((uint32_t)ret_conv);
16515 }
16516 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(uint32_t arg) {
16517         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(arg & ~1);
16518         uint32_t ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
16519         return ret_conv;
16520 }
16521
16522 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(uint32_t orig) {
16523         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
16524         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
16525         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
16526         return ((uint32_t)ret_conv);
16527 }
16528
16529 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
16530         LDKChannelAnnouncement a_conv;
16531         a_conv.inner = (void*)(a & (~1));
16532         a_conv.is_owned = (a & 1) || (a == 0);
16533         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
16534         a_conv = ChannelAnnouncement_clone(&a_conv);
16535         LDKChannelUpdate b_conv;
16536         b_conv.inner = (void*)(b & (~1));
16537         b_conv.is_owned = (b & 1) || (b == 0);
16538         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
16539         b_conv = ChannelUpdate_clone(&b_conv);
16540         LDKChannelUpdate c_conv;
16541         c_conv.inner = (void*)(c & (~1));
16542         c_conv.is_owned = (c & 1) || (c == 0);
16543         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
16544         c_conv = ChannelUpdate_clone(&c_conv);
16545         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
16546         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
16547         return ((uint32_t)ret_conv);
16548 }
16549
16550 void  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(uint32_t _res) {
16551         if ((_res & 1) != 0) return;
16552         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16553         CHECK_ACCESS(_res_ptr);
16554         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
16555         FREE((void*)_res);
16556         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
16557 }
16558
16559 void  __attribute__((export_name("TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free"))) TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(uint32_tArray _res) {
16560         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
16561         _res_constr.datalen = _res->arr_len;
16562         if (_res_constr.datalen > 0)
16563                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
16564         else
16565                 _res_constr.data = NULL;
16566         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16567         for (size_t h = 0; h < _res_constr.datalen; h++) {
16568                 uint32_t _res_conv_59 = _res_vals[h];
16569                 void* _res_conv_59_ptr = (void*)(((uintptr_t)_res_conv_59) & ~1);
16570                 CHECK_ACCESS(_res_conv_59_ptr);
16571                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_conv_59_ptr);
16572                 FREE((void*)_res_conv_59);
16573                 _res_constr.data[h] = _res_conv_59_conv;
16574         }
16575         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
16576 }
16577
16578 void  __attribute__((export_name("TS_CVec_NodeAnnouncementZ_free"))) TS_CVec_NodeAnnouncementZ_free(uint32_tArray _res) {
16579         LDKCVec_NodeAnnouncementZ _res_constr;
16580         _res_constr.datalen = _res->arr_len;
16581         if (_res_constr.datalen > 0)
16582                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
16583         else
16584                 _res_constr.data = NULL;
16585         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16586         for (size_t s = 0; s < _res_constr.datalen; s++) {
16587                 uint32_t _res_conv_18 = _res_vals[s];
16588                 LDKNodeAnnouncement _res_conv_18_conv;
16589                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
16590                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
16591                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_18_conv);
16592                 _res_constr.data[s] = _res_conv_18_conv;
16593         }
16594         CVec_NodeAnnouncementZ_free(_res_constr);
16595 }
16596
16597 void  __attribute__((export_name("TS_CVec_PublicKeyZ_free"))) TS_CVec_PublicKeyZ_free(ptrArray _res) {
16598         LDKCVec_PublicKeyZ _res_constr;
16599         _res_constr.datalen = _res->arr_len;
16600         if (_res_constr.datalen > 0)
16601                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
16602         else
16603                 _res_constr.data = NULL;
16604         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
16605         for (size_t m = 0; m < _res_constr.datalen; m++) {
16606                 int8_tArray _res_conv_12 = _res_vals[m];
16607                 LDKPublicKey _res_conv_12_ref;
16608                 CHECK(_res_conv_12->arr_len == 33);
16609                 memcpy(_res_conv_12_ref.compressed_form, _res_conv_12->elems, 33); FREE(_res_conv_12);
16610                 _res_constr.data[m] = _res_conv_12_ref;
16611         }
16612         CVec_PublicKeyZ_free(_res_constr);
16613 }
16614
16615 uint32_t  __attribute__((export_name("TS_COption_NetAddressZ_some"))) TS_COption_NetAddressZ_some(uint32_t o) {
16616         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16617         CHECK_ACCESS(o_ptr);
16618         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
16619         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
16620         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
16621         *ret_copy = COption_NetAddressZ_some(o_conv);
16622         uint32_t ret_ref = (uintptr_t)ret_copy;
16623         return ret_ref;
16624 }
16625
16626 uint32_t  __attribute__((export_name("TS_COption_NetAddressZ_none"))) TS_COption_NetAddressZ_none() {
16627         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
16628         *ret_copy = COption_NetAddressZ_none();
16629         uint32_t ret_ref = (uintptr_t)ret_copy;
16630         return ret_ref;
16631 }
16632
16633 void  __attribute__((export_name("TS_COption_NetAddressZ_free"))) TS_COption_NetAddressZ_free(uint32_t _res) {
16634         if ((_res & 1) != 0) return;
16635         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16636         CHECK_ACCESS(_res_ptr);
16637         LDKCOption_NetAddressZ _res_conv = *(LDKCOption_NetAddressZ*)(_res_ptr);
16638         FREE((void*)_res);
16639         COption_NetAddressZ_free(_res_conv);
16640 }
16641
16642 static inline uintptr_t COption_NetAddressZ_clone_ptr(LDKCOption_NetAddressZ *NONNULL_PTR arg) {
16643         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
16644         *ret_copy = COption_NetAddressZ_clone(arg);
16645 uint32_t ret_ref = (uintptr_t)ret_copy;
16646         return ret_ref;
16647 }
16648 uint32_t  __attribute__((export_name("TS_COption_NetAddressZ_clone_ptr"))) TS_COption_NetAddressZ_clone_ptr(uint32_t arg) {
16649         LDKCOption_NetAddressZ* arg_conv = (LDKCOption_NetAddressZ*)arg;
16650         uint32_t ret_conv = COption_NetAddressZ_clone_ptr(arg_conv);
16651         return ret_conv;
16652 }
16653
16654 uint32_t  __attribute__((export_name("TS_COption_NetAddressZ_clone"))) TS_COption_NetAddressZ_clone(uint32_t orig) {
16655         LDKCOption_NetAddressZ* orig_conv = (LDKCOption_NetAddressZ*)orig;
16656         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
16657         *ret_copy = COption_NetAddressZ_clone(orig_conv);
16658         uint32_t ret_ref = (uintptr_t)ret_copy;
16659         return ret_ref;
16660 }
16661
16662 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_ok(int8_tArray o) {
16663         LDKCVec_u8Z o_ref;
16664         o_ref.datalen = o->arr_len;
16665         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
16666         memcpy(o_ref.data, o->elems, o_ref.datalen); FREE(o);
16667         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
16668         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
16669         return (uint32_t)ret_conv;
16670 }
16671
16672 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_err"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_err(uint32_t e) {
16673         LDKPeerHandleError e_conv;
16674         e_conv.inner = (void*)(e & (~1));
16675         e_conv.is_owned = (e & 1) || (e == 0);
16676         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16677         e_conv = PeerHandleError_clone(&e_conv);
16678         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
16679         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
16680         return (uint32_t)ret_conv;
16681 }
16682
16683 jboolean  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_is_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_is_ok(uint32_t o) {
16684         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(o & ~1);
16685         jboolean ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
16686         return ret_conv;
16687 }
16688
16689 void  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_free"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_free(uint32_t _res) {
16690         if ((_res & 1) != 0) return;
16691         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16692         CHECK_ACCESS(_res_ptr);
16693         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
16694         FREE((void*)_res);
16695         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
16696 }
16697
16698 static inline uintptr_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
16699         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
16700         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
16701         return (uint32_t)ret_conv;
16702 }
16703 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(uint32_t arg) {
16704         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
16705         uint32_t ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
16706         return ret_conv;
16707 }
16708
16709 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_clone"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone(uint32_t orig) {
16710         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
16711         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
16712         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
16713         return (uint32_t)ret_conv;
16714 }
16715
16716 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_ok"))) TS_CResult_NonePeerHandleErrorZ_ok() {
16717         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
16718         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
16719         return (uint32_t)ret_conv;
16720 }
16721
16722 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_err"))) TS_CResult_NonePeerHandleErrorZ_err(uint32_t e) {
16723         LDKPeerHandleError e_conv;
16724         e_conv.inner = (void*)(e & (~1));
16725         e_conv.is_owned = (e & 1) || (e == 0);
16726         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16727         e_conv = PeerHandleError_clone(&e_conv);
16728         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
16729         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
16730         return (uint32_t)ret_conv;
16731 }
16732
16733 jboolean  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_is_ok"))) TS_CResult_NonePeerHandleErrorZ_is_ok(uint32_t o) {
16734         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)(o & ~1);
16735         jboolean ret_conv = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
16736         return ret_conv;
16737 }
16738
16739 void  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_free"))) TS_CResult_NonePeerHandleErrorZ_free(uint32_t _res) {
16740         if ((_res & 1) != 0) return;
16741         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16742         CHECK_ACCESS(_res_ptr);
16743         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
16744         FREE((void*)_res);
16745         CResult_NonePeerHandleErrorZ_free(_res_conv);
16746 }
16747
16748 static inline uintptr_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
16749         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
16750         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
16751         return (uint32_t)ret_conv;
16752 }
16753 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_clone_ptr"))) TS_CResult_NonePeerHandleErrorZ_clone_ptr(uint32_t arg) {
16754         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
16755         uint32_t ret_conv = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
16756         return ret_conv;
16757 }
16758
16759 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_clone"))) TS_CResult_NonePeerHandleErrorZ_clone(uint32_t orig) {
16760         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
16761         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
16762         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
16763         return (uint32_t)ret_conv;
16764 }
16765
16766 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_ok"))) TS_CResult_boolPeerHandleErrorZ_ok(jboolean o) {
16767         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
16768         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
16769         return (uint32_t)ret_conv;
16770 }
16771
16772 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_err"))) TS_CResult_boolPeerHandleErrorZ_err(uint32_t e) {
16773         LDKPeerHandleError e_conv;
16774         e_conv.inner = (void*)(e & (~1));
16775         e_conv.is_owned = (e & 1) || (e == 0);
16776         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16777         e_conv = PeerHandleError_clone(&e_conv);
16778         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
16779         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
16780         return (uint32_t)ret_conv;
16781 }
16782
16783 jboolean  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_is_ok"))) TS_CResult_boolPeerHandleErrorZ_is_ok(uint32_t o) {
16784         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)(o & ~1);
16785         jboolean ret_conv = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
16786         return ret_conv;
16787 }
16788
16789 void  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_free"))) TS_CResult_boolPeerHandleErrorZ_free(uint32_t _res) {
16790         if ((_res & 1) != 0) return;
16791         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16792         CHECK_ACCESS(_res_ptr);
16793         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
16794         FREE((void*)_res);
16795         CResult_boolPeerHandleErrorZ_free(_res_conv);
16796 }
16797
16798 static inline uintptr_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
16799         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
16800         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
16801         return (uint32_t)ret_conv;
16802 }
16803 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_clone_ptr"))) TS_CResult_boolPeerHandleErrorZ_clone_ptr(uint32_t arg) {
16804         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
16805         uint32_t ret_conv = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
16806         return ret_conv;
16807 }
16808
16809 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_clone"))) TS_CResult_boolPeerHandleErrorZ_clone(uint32_t orig) {
16810         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
16811         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
16812         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
16813         return (uint32_t)ret_conv;
16814 }
16815
16816 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_ok"))) TS_CResult_NodeIdDecodeErrorZ_ok(uint32_t o) {
16817         LDKNodeId o_conv;
16818         o_conv.inner = (void*)(o & (~1));
16819         o_conv.is_owned = (o & 1) || (o == 0);
16820         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16821         o_conv = NodeId_clone(&o_conv);
16822         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
16823         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
16824         return (uint32_t)ret_conv;
16825 }
16826
16827 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_err"))) TS_CResult_NodeIdDecodeErrorZ_err(uint32_t e) {
16828         LDKDecodeError e_conv;
16829         e_conv.inner = (void*)(e & (~1));
16830         e_conv.is_owned = (e & 1) || (e == 0);
16831         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16832         e_conv = DecodeError_clone(&e_conv);
16833         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
16834         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
16835         return (uint32_t)ret_conv;
16836 }
16837
16838 jboolean  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_is_ok"))) TS_CResult_NodeIdDecodeErrorZ_is_ok(uint32_t o) {
16839         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)(o & ~1);
16840         jboolean ret_conv = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
16841         return ret_conv;
16842 }
16843
16844 void  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_free"))) TS_CResult_NodeIdDecodeErrorZ_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_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
16849         FREE((void*)_res);
16850         CResult_NodeIdDecodeErrorZ_free(_res_conv);
16851 }
16852
16853 static inline uintptr_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
16854         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
16855         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
16856         return (uint32_t)ret_conv;
16857 }
16858 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_clone_ptr"))) TS_CResult_NodeIdDecodeErrorZ_clone_ptr(uint32_t arg) {
16859         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
16860         uint32_t ret_conv = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
16861         return ret_conv;
16862 }
16863
16864 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_clone"))) TS_CResult_NodeIdDecodeErrorZ_clone(uint32_t orig) {
16865         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)(orig & ~1);
16866         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
16867         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
16868         return (uint32_t)ret_conv;
16869 }
16870
16871 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_ok(uint32_t o) {
16872         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16873         CHECK_ACCESS(o_ptr);
16874         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
16875         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)o) & ~1));
16876         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
16877         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
16878         return (uint32_t)ret_conv;
16879 }
16880
16881 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_err"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_err(uint32_t e) {
16882         LDKDecodeError e_conv;
16883         e_conv.inner = (void*)(e & (~1));
16884         e_conv.is_owned = (e & 1) || (e == 0);
16885         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16886         e_conv = DecodeError_clone(&e_conv);
16887         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
16888         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
16889         return (uint32_t)ret_conv;
16890 }
16891
16892 jboolean  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(uint32_t o) {
16893         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(o & ~1);
16894         jboolean ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
16895         return ret_conv;
16896 }
16897
16898 void  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_free"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_free(uint32_t _res) {
16899         if ((_res & 1) != 0) return;
16900         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16901         CHECK_ACCESS(_res_ptr);
16902         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
16903         FREE((void*)_res);
16904         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
16905 }
16906
16907 static inline uintptr_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
16908         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
16909         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
16910         return (uint32_t)ret_conv;
16911 }
16912 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(uint32_t arg) {
16913         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(arg & ~1);
16914         uint32_t ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
16915         return ret_conv;
16916 }
16917
16918 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone(uint32_t orig) {
16919         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(orig & ~1);
16920         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
16921         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
16922         return (uint32_t)ret_conv;
16923 }
16924
16925 uint32_t  __attribute__((export_name("TS_COption_AccessZ_some"))) TS_COption_AccessZ_some(uint32_t o) {
16926         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16927         CHECK_ACCESS(o_ptr);
16928         LDKAccess o_conv = *(LDKAccess*)(o_ptr);
16929         if (o_conv.free == LDKAccess_JCalls_free) {
16930                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16931                 LDKAccess_JCalls_cloned(&o_conv);
16932         }
16933         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
16934         *ret_copy = COption_AccessZ_some(o_conv);
16935         uint32_t ret_ref = (uintptr_t)ret_copy;
16936         return ret_ref;
16937 }
16938
16939 uint32_t  __attribute__((export_name("TS_COption_AccessZ_none"))) TS_COption_AccessZ_none() {
16940         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
16941         *ret_copy = COption_AccessZ_none();
16942         uint32_t ret_ref = (uintptr_t)ret_copy;
16943         return ret_ref;
16944 }
16945
16946 void  __attribute__((export_name("TS_COption_AccessZ_free"))) TS_COption_AccessZ_free(uint32_t _res) {
16947         if ((_res & 1) != 0) return;
16948         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16949         CHECK_ACCESS(_res_ptr);
16950         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
16951         FREE((void*)_res);
16952         COption_AccessZ_free(_res_conv);
16953 }
16954
16955 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_ok"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_ok(uint32_t o) {
16956         LDKChannelUpdateInfo o_conv;
16957         o_conv.inner = (void*)(o & (~1));
16958         o_conv.is_owned = (o & 1) || (o == 0);
16959         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16960         o_conv = ChannelUpdateInfo_clone(&o_conv);
16961         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
16962         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_ok(o_conv);
16963         return (uint32_t)ret_conv;
16964 }
16965
16966 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_err"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_err(uint32_t e) {
16967         LDKDecodeError e_conv;
16968         e_conv.inner = (void*)(e & (~1));
16969         e_conv.is_owned = (e & 1) || (e == 0);
16970         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16971         e_conv = DecodeError_clone(&e_conv);
16972         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
16973         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_err(e_conv);
16974         return (uint32_t)ret_conv;
16975 }
16976
16977 jboolean  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_is_ok"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(uint32_t o) {
16978         LDKCResult_ChannelUpdateInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(o & ~1);
16979         jboolean ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(o_conv);
16980         return ret_conv;
16981 }
16982
16983 void  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_free"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_free(uint32_t _res) {
16984         if ((_res & 1) != 0) return;
16985         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16986         CHECK_ACCESS(_res_ptr);
16987         LDKCResult_ChannelUpdateInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(_res_ptr);
16988         FREE((void*)_res);
16989         CResult_ChannelUpdateInfoDecodeErrorZ_free(_res_conv);
16990 }
16991
16992 static inline uintptr_t CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR arg) {
16993         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
16994         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(arg);
16995         return (uint32_t)ret_conv;
16996 }
16997 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
16998         LDKCResult_ChannelUpdateInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(arg & ~1);
16999         uint32_t ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(arg_conv);
17000         return ret_conv;
17001 }
17002
17003 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone(uint32_t orig) {
17004         LDKCResult_ChannelUpdateInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(orig & ~1);
17005         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
17006         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(orig_conv);
17007         return (uint32_t)ret_conv;
17008 }
17009
17010 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_ok(uint32_t o) {
17011         LDKChannelInfo o_conv;
17012         o_conv.inner = (void*)(o & (~1));
17013         o_conv.is_owned = (o & 1) || (o == 0);
17014         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17015         o_conv = ChannelInfo_clone(&o_conv);
17016         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
17017         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
17018         return (uint32_t)ret_conv;
17019 }
17020
17021 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_err"))) TS_CResult_ChannelInfoDecodeErrorZ_err(uint32_t e) {
17022         LDKDecodeError e_conv;
17023         e_conv.inner = (void*)(e & (~1));
17024         e_conv.is_owned = (e & 1) || (e == 0);
17025         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17026         e_conv = DecodeError_clone(&e_conv);
17027         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
17028         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
17029         return (uint32_t)ret_conv;
17030 }
17031
17032 jboolean  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_is_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_is_ok(uint32_t o) {
17033         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(o & ~1);
17034         jboolean ret_conv = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
17035         return ret_conv;
17036 }
17037
17038 void  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_free"))) TS_CResult_ChannelInfoDecodeErrorZ_free(uint32_t _res) {
17039         if ((_res & 1) != 0) return;
17040         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17041         CHECK_ACCESS(_res_ptr);
17042         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
17043         FREE((void*)_res);
17044         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
17045 }
17046
17047 static inline uintptr_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
17048         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
17049         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
17050         return (uint32_t)ret_conv;
17051 }
17052 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
17053         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
17054         uint32_t ret_conv = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
17055         return ret_conv;
17056 }
17057
17058 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_clone"))) TS_CResult_ChannelInfoDecodeErrorZ_clone(uint32_t orig) {
17059         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
17060         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
17061         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
17062         return (uint32_t)ret_conv;
17063 }
17064
17065 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_ok(uint32_t o) {
17066         LDKRoutingFees o_conv;
17067         o_conv.inner = (void*)(o & (~1));
17068         o_conv.is_owned = (o & 1) || (o == 0);
17069         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17070         o_conv = RoutingFees_clone(&o_conv);
17071         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
17072         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
17073         return (uint32_t)ret_conv;
17074 }
17075
17076 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_err"))) TS_CResult_RoutingFeesDecodeErrorZ_err(uint32_t e) {
17077         LDKDecodeError e_conv;
17078         e_conv.inner = (void*)(e & (~1));
17079         e_conv.is_owned = (e & 1) || (e == 0);
17080         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17081         e_conv = DecodeError_clone(&e_conv);
17082         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
17083         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
17084         return (uint32_t)ret_conv;
17085 }
17086
17087 jboolean  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_is_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_is_ok(uint32_t o) {
17088         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(o & ~1);
17089         jboolean ret_conv = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
17090         return ret_conv;
17091 }
17092
17093 void  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_free"))) TS_CResult_RoutingFeesDecodeErrorZ_free(uint32_t _res) {
17094         if ((_res & 1) != 0) return;
17095         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17096         CHECK_ACCESS(_res_ptr);
17097         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
17098         FREE((void*)_res);
17099         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
17100 }
17101
17102 static inline uintptr_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
17103         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
17104         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
17105         return (uint32_t)ret_conv;
17106 }
17107 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_clone_ptr"))) TS_CResult_RoutingFeesDecodeErrorZ_clone_ptr(uint32_t arg) {
17108         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
17109         uint32_t ret_conv = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
17110         return ret_conv;
17111 }
17112
17113 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_clone"))) TS_CResult_RoutingFeesDecodeErrorZ_clone(uint32_t orig) {
17114         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
17115         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
17116         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
17117         return (uint32_t)ret_conv;
17118 }
17119
17120 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok(uint32_t o) {
17121         LDKNodeAnnouncementInfo o_conv;
17122         o_conv.inner = (void*)(o & (~1));
17123         o_conv.is_owned = (o & 1) || (o == 0);
17124         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17125         o_conv = NodeAnnouncementInfo_clone(&o_conv);
17126         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
17127         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
17128         return (uint32_t)ret_conv;
17129 }
17130
17131 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err(uint32_t e) {
17132         LDKDecodeError e_conv;
17133         e_conv.inner = (void*)(e & (~1));
17134         e_conv.is_owned = (e & 1) || (e == 0);
17135         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17136         e_conv = DecodeError_clone(&e_conv);
17137         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
17138         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
17139         return (uint32_t)ret_conv;
17140 }
17141
17142 jboolean  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(uint32_t o) {
17143         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(o & ~1);
17144         jboolean ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
17145         return ret_conv;
17146 }
17147
17148 void  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free(uint32_t _res) {
17149         if ((_res & 1) != 0) return;
17150         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17151         CHECK_ACCESS(_res_ptr);
17152         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
17153         FREE((void*)_res);
17154         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
17155 }
17156
17157 static inline uintptr_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
17158         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
17159         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
17160         return (uint32_t)ret_conv;
17161 }
17162 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
17163         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
17164         uint32_t ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
17165         return ret_conv;
17166 }
17167
17168 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone(uint32_t orig) {
17169         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
17170         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
17171         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
17172         return (uint32_t)ret_conv;
17173 }
17174
17175 void  __attribute__((export_name("TS_CVec_u64Z_free"))) TS_CVec_u64Z_free(int64_tArray _res) {
17176         LDKCVec_u64Z _res_constr;
17177         _res_constr.datalen = _res->arr_len;
17178         if (_res_constr.datalen > 0)
17179                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
17180         else
17181                 _res_constr.data = NULL;
17182         int64_t* _res_vals = _res->elems /* XXX _res leaks */;
17183         for (size_t i = 0; i < _res_constr.datalen; i++) {
17184                 int64_t _res_conv_8 = _res_vals[i];
17185                 _res_constr.data[i] = _res_conv_8;
17186         }
17187         CVec_u64Z_free(_res_constr);
17188 }
17189
17190 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_ok"))) TS_CResult_NodeInfoDecodeErrorZ_ok(uint32_t o) {
17191         LDKNodeInfo o_conv;
17192         o_conv.inner = (void*)(o & (~1));
17193         o_conv.is_owned = (o & 1) || (o == 0);
17194         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17195         o_conv = NodeInfo_clone(&o_conv);
17196         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
17197         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
17198         return (uint32_t)ret_conv;
17199 }
17200
17201 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_err"))) TS_CResult_NodeInfoDecodeErrorZ_err(uint32_t e) {
17202         LDKDecodeError e_conv;
17203         e_conv.inner = (void*)(e & (~1));
17204         e_conv.is_owned = (e & 1) || (e == 0);
17205         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17206         e_conv = DecodeError_clone(&e_conv);
17207         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
17208         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
17209         return (uint32_t)ret_conv;
17210 }
17211
17212 jboolean  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_is_ok"))) TS_CResult_NodeInfoDecodeErrorZ_is_ok(uint32_t o) {
17213         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(o & ~1);
17214         jboolean ret_conv = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
17215         return ret_conv;
17216 }
17217
17218 void  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_free"))) TS_CResult_NodeInfoDecodeErrorZ_free(uint32_t _res) {
17219         if ((_res & 1) != 0) return;
17220         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17221         CHECK_ACCESS(_res_ptr);
17222         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
17223         FREE((void*)_res);
17224         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
17225 }
17226
17227 static inline uintptr_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
17228         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
17229         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
17230         return (uint32_t)ret_conv;
17231 }
17232 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_clone_ptr"))) TS_CResult_NodeInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
17233         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
17234         uint32_t ret_conv = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
17235         return ret_conv;
17236 }
17237
17238 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_clone"))) TS_CResult_NodeInfoDecodeErrorZ_clone(uint32_t orig) {
17239         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
17240         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
17241         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
17242         return (uint32_t)ret_conv;
17243 }
17244
17245 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_ok(uint32_t o) {
17246         LDKNetworkGraph o_conv;
17247         o_conv.inner = (void*)(o & (~1));
17248         o_conv.is_owned = (o & 1) || (o == 0);
17249         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17250         o_conv = NetworkGraph_clone(&o_conv);
17251         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
17252         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
17253         return (uint32_t)ret_conv;
17254 }
17255
17256 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_err"))) TS_CResult_NetworkGraphDecodeErrorZ_err(uint32_t e) {
17257         LDKDecodeError e_conv;
17258         e_conv.inner = (void*)(e & (~1));
17259         e_conv.is_owned = (e & 1) || (e == 0);
17260         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17261         e_conv = DecodeError_clone(&e_conv);
17262         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
17263         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
17264         return (uint32_t)ret_conv;
17265 }
17266
17267 jboolean  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_is_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_is_ok(uint32_t o) {
17268         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(o & ~1);
17269         jboolean ret_conv = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
17270         return ret_conv;
17271 }
17272
17273 void  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_free"))) TS_CResult_NetworkGraphDecodeErrorZ_free(uint32_t _res) {
17274         if ((_res & 1) != 0) return;
17275         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17276         CHECK_ACCESS(_res_ptr);
17277         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
17278         FREE((void*)_res);
17279         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
17280 }
17281
17282 static inline uintptr_t CResult_NetworkGraphDecodeErrorZ_clone_ptr(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR arg) {
17283         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
17284         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(arg);
17285         return (uint32_t)ret_conv;
17286 }
17287 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_clone_ptr"))) TS_CResult_NetworkGraphDecodeErrorZ_clone_ptr(uint32_t arg) {
17288         LDKCResult_NetworkGraphDecodeErrorZ* arg_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
17289         uint32_t ret_conv = CResult_NetworkGraphDecodeErrorZ_clone_ptr(arg_conv);
17290         return ret_conv;
17291 }
17292
17293 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_clone"))) TS_CResult_NetworkGraphDecodeErrorZ_clone(uint32_t orig) {
17294         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
17295         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
17296         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
17297         return (uint32_t)ret_conv;
17298 }
17299
17300 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_some"))) TS_COption_CVec_NetAddressZZ_some(uint32_tArray o) {
17301         LDKCVec_NetAddressZ o_constr;
17302         o_constr.datalen = o->arr_len;
17303         if (o_constr.datalen > 0)
17304                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
17305         else
17306                 o_constr.data = NULL;
17307         uint32_t* o_vals = o->elems /* XXX o leaks */;
17308         for (size_t m = 0; m < o_constr.datalen; m++) {
17309                 uint32_t o_conv_12 = o_vals[m];
17310                 void* o_conv_12_ptr = (void*)(((uintptr_t)o_conv_12) & ~1);
17311                 CHECK_ACCESS(o_conv_12_ptr);
17312                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
17313                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o_conv_12) & ~1));
17314                 o_constr.data[m] = o_conv_12_conv;
17315         }
17316         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17317         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
17318         uint32_t ret_ref = (uintptr_t)ret_copy;
17319         return ret_ref;
17320 }
17321
17322 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_none"))) TS_COption_CVec_NetAddressZZ_none() {
17323         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17324         *ret_copy = COption_CVec_NetAddressZZ_none();
17325         uint32_t ret_ref = (uintptr_t)ret_copy;
17326         return ret_ref;
17327 }
17328
17329 void  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_free"))) TS_COption_CVec_NetAddressZZ_free(uint32_t _res) {
17330         if ((_res & 1) != 0) return;
17331         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17332         CHECK_ACCESS(_res_ptr);
17333         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
17334         FREE((void*)_res);
17335         COption_CVec_NetAddressZZ_free(_res_conv);
17336 }
17337
17338 static inline uintptr_t COption_CVec_NetAddressZZ_clone_ptr(LDKCOption_CVec_NetAddressZZ *NONNULL_PTR arg) {
17339         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17340         *ret_copy = COption_CVec_NetAddressZZ_clone(arg);
17341 uint32_t ret_ref = (uintptr_t)ret_copy;
17342         return ret_ref;
17343 }
17344 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_clone_ptr"))) TS_COption_CVec_NetAddressZZ_clone_ptr(uint32_t arg) {
17345         LDKCOption_CVec_NetAddressZZ* arg_conv = (LDKCOption_CVec_NetAddressZZ*)arg;
17346         uint32_t ret_conv = COption_CVec_NetAddressZZ_clone_ptr(arg_conv);
17347         return ret_conv;
17348 }
17349
17350 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_clone"))) TS_COption_CVec_NetAddressZZ_clone(uint32_t orig) {
17351         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)orig;
17352         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17353         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
17354         uint32_t ret_ref = (uintptr_t)ret_copy;
17355         return ret_ref;
17356 }
17357
17358 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_ok"))) TS_CResult_NetAddressDecodeErrorZ_ok(uint32_t o) {
17359         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17360         CHECK_ACCESS(o_ptr);
17361         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
17362         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
17363         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17364         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
17365         return (uint32_t)ret_conv;
17366 }
17367
17368 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_err"))) TS_CResult_NetAddressDecodeErrorZ_err(uint32_t e) {
17369         LDKDecodeError e_conv;
17370         e_conv.inner = (void*)(e & (~1));
17371         e_conv.is_owned = (e & 1) || (e == 0);
17372         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17373         e_conv = DecodeError_clone(&e_conv);
17374         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17375         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
17376         return (uint32_t)ret_conv;
17377 }
17378
17379 jboolean  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_is_ok"))) TS_CResult_NetAddressDecodeErrorZ_is_ok(uint32_t o) {
17380         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)(o & ~1);
17381         jboolean ret_conv = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
17382         return ret_conv;
17383 }
17384
17385 void  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_free"))) TS_CResult_NetAddressDecodeErrorZ_free(uint32_t _res) {
17386         if ((_res & 1) != 0) return;
17387         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17388         CHECK_ACCESS(_res_ptr);
17389         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
17390         FREE((void*)_res);
17391         CResult_NetAddressDecodeErrorZ_free(_res_conv);
17392 }
17393
17394 static inline uintptr_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
17395         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17396         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
17397         return (uint32_t)ret_conv;
17398 }
17399 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_clone_ptr"))) TS_CResult_NetAddressDecodeErrorZ_clone_ptr(uint32_t arg) {
17400         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
17401         uint32_t ret_conv = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
17402         return ret_conv;
17403 }
17404
17405 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_clone"))) TS_CResult_NetAddressDecodeErrorZ_clone(uint32_t orig) {
17406         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
17407         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17408         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
17409         return (uint32_t)ret_conv;
17410 }
17411
17412 void  __attribute__((export_name("TS_CVec_UpdateAddHTLCZ_free"))) TS_CVec_UpdateAddHTLCZ_free(uint32_tArray _res) {
17413         LDKCVec_UpdateAddHTLCZ _res_constr;
17414         _res_constr.datalen = _res->arr_len;
17415         if (_res_constr.datalen > 0)
17416                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
17417         else
17418                 _res_constr.data = NULL;
17419         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
17420         for (size_t p = 0; p < _res_constr.datalen; p++) {
17421                 uint32_t _res_conv_15 = _res_vals[p];
17422                 LDKUpdateAddHTLC _res_conv_15_conv;
17423                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
17424                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
17425                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
17426                 _res_constr.data[p] = _res_conv_15_conv;
17427         }
17428         CVec_UpdateAddHTLCZ_free(_res_constr);
17429 }
17430
17431 void  __attribute__((export_name("TS_CVec_UpdateFulfillHTLCZ_free"))) TS_CVec_UpdateFulfillHTLCZ_free(uint32_tArray _res) {
17432         LDKCVec_UpdateFulfillHTLCZ _res_constr;
17433         _res_constr.datalen = _res->arr_len;
17434         if (_res_constr.datalen > 0)
17435                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
17436         else
17437                 _res_constr.data = NULL;
17438         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
17439         for (size_t t = 0; t < _res_constr.datalen; t++) {
17440                 uint32_t _res_conv_19 = _res_vals[t];
17441                 LDKUpdateFulfillHTLC _res_conv_19_conv;
17442                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
17443                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
17444                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
17445                 _res_constr.data[t] = _res_conv_19_conv;
17446         }
17447         CVec_UpdateFulfillHTLCZ_free(_res_constr);
17448 }
17449
17450 void  __attribute__((export_name("TS_CVec_UpdateFailHTLCZ_free"))) TS_CVec_UpdateFailHTLCZ_free(uint32_tArray _res) {
17451         LDKCVec_UpdateFailHTLCZ _res_constr;
17452         _res_constr.datalen = _res->arr_len;
17453         if (_res_constr.datalen > 0)
17454                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
17455         else
17456                 _res_constr.data = NULL;
17457         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
17458         for (size_t q = 0; q < _res_constr.datalen; q++) {
17459                 uint32_t _res_conv_16 = _res_vals[q];
17460                 LDKUpdateFailHTLC _res_conv_16_conv;
17461                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
17462                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
17463                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
17464                 _res_constr.data[q] = _res_conv_16_conv;
17465         }
17466         CVec_UpdateFailHTLCZ_free(_res_constr);
17467 }
17468
17469 void  __attribute__((export_name("TS_CVec_UpdateFailMalformedHTLCZ_free"))) TS_CVec_UpdateFailMalformedHTLCZ_free(uint32_tArray _res) {
17470         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
17471         _res_constr.datalen = _res->arr_len;
17472         if (_res_constr.datalen > 0)
17473                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
17474         else
17475                 _res_constr.data = NULL;
17476         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
17477         for (size_t z = 0; z < _res_constr.datalen; z++) {
17478                 uint32_t _res_conv_25 = _res_vals[z];
17479                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
17480                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
17481                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
17482                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
17483                 _res_constr.data[z] = _res_conv_25_conv;
17484         }
17485         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
17486 }
17487
17488 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_ok(uint32_t o) {
17489         LDKAcceptChannel o_conv;
17490         o_conv.inner = (void*)(o & (~1));
17491         o_conv.is_owned = (o & 1) || (o == 0);
17492         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17493         o_conv = AcceptChannel_clone(&o_conv);
17494         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
17495         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
17496         return (uint32_t)ret_conv;
17497 }
17498
17499 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_err"))) TS_CResult_AcceptChannelDecodeErrorZ_err(uint32_t e) {
17500         LDKDecodeError e_conv;
17501         e_conv.inner = (void*)(e & (~1));
17502         e_conv.is_owned = (e & 1) || (e == 0);
17503         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17504         e_conv = DecodeError_clone(&e_conv);
17505         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
17506         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
17507         return (uint32_t)ret_conv;
17508 }
17509
17510 jboolean  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_is_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_is_ok(uint32_t o) {
17511         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(o & ~1);
17512         jboolean ret_conv = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
17513         return ret_conv;
17514 }
17515
17516 void  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_free"))) TS_CResult_AcceptChannelDecodeErrorZ_free(uint32_t _res) {
17517         if ((_res & 1) != 0) return;
17518         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17519         CHECK_ACCESS(_res_ptr);
17520         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
17521         FREE((void*)_res);
17522         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
17523 }
17524
17525 static inline uintptr_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
17526         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
17527         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
17528         return (uint32_t)ret_conv;
17529 }
17530 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_clone_ptr"))) TS_CResult_AcceptChannelDecodeErrorZ_clone_ptr(uint32_t arg) {
17531         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
17532         uint32_t ret_conv = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
17533         return ret_conv;
17534 }
17535
17536 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_clone"))) TS_CResult_AcceptChannelDecodeErrorZ_clone(uint32_t orig) {
17537         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
17538         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
17539         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
17540         return (uint32_t)ret_conv;
17541 }
17542
17543 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok(uint32_t o) {
17544         LDKAnnouncementSignatures o_conv;
17545         o_conv.inner = (void*)(o & (~1));
17546         o_conv.is_owned = (o & 1) || (o == 0);
17547         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17548         o_conv = AnnouncementSignatures_clone(&o_conv);
17549         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
17550         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
17551         return (uint32_t)ret_conv;
17552 }
17553
17554 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_err"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_err(uint32_t e) {
17555         LDKDecodeError e_conv;
17556         e_conv.inner = (void*)(e & (~1));
17557         e_conv.is_owned = (e & 1) || (e == 0);
17558         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17559         e_conv = DecodeError_clone(&e_conv);
17560         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
17561         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
17562         return (uint32_t)ret_conv;
17563 }
17564
17565 jboolean  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_is_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(uint32_t o) {
17566         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(o & ~1);
17567         jboolean ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
17568         return ret_conv;
17569 }
17570
17571 void  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_free"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_free(uint32_t _res) {
17572         if ((_res & 1) != 0) return;
17573         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17574         CHECK_ACCESS(_res_ptr);
17575         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
17576         FREE((void*)_res);
17577         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
17578 }
17579
17580 static inline uintptr_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
17581         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
17582         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
17583         return (uint32_t)ret_conv;
17584 }
17585 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
17586         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
17587         uint32_t ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
17588         return ret_conv;
17589 }
17590
17591 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone(uint32_t orig) {
17592         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
17593         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
17594         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
17595         return (uint32_t)ret_conv;
17596 }
17597
17598 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_ok(uint32_t o) {
17599         LDKChannelReestablish o_conv;
17600         o_conv.inner = (void*)(o & (~1));
17601         o_conv.is_owned = (o & 1) || (o == 0);
17602         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17603         o_conv = ChannelReestablish_clone(&o_conv);
17604         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
17605         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
17606         return (uint32_t)ret_conv;
17607 }
17608
17609 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_err"))) TS_CResult_ChannelReestablishDecodeErrorZ_err(uint32_t e) {
17610         LDKDecodeError e_conv;
17611         e_conv.inner = (void*)(e & (~1));
17612         e_conv.is_owned = (e & 1) || (e == 0);
17613         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17614         e_conv = DecodeError_clone(&e_conv);
17615         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
17616         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
17617         return (uint32_t)ret_conv;
17618 }
17619
17620 jboolean  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_is_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_is_ok(uint32_t o) {
17621         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(o & ~1);
17622         jboolean ret_conv = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
17623         return ret_conv;
17624 }
17625
17626 void  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_free"))) TS_CResult_ChannelReestablishDecodeErrorZ_free(uint32_t _res) {
17627         if ((_res & 1) != 0) return;
17628         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17629         CHECK_ACCESS(_res_ptr);
17630         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
17631         FREE((void*)_res);
17632         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
17633 }
17634
17635 static inline uintptr_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
17636         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
17637         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
17638         return (uint32_t)ret_conv;
17639 }
17640 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone_ptr(uint32_t arg) {
17641         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
17642         uint32_t ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
17643         return ret_conv;
17644 }
17645
17646 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_clone"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone(uint32_t orig) {
17647         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
17648         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
17649         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
17650         return (uint32_t)ret_conv;
17651 }
17652
17653 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_ok(uint32_t o) {
17654         LDKClosingSigned o_conv;
17655         o_conv.inner = (void*)(o & (~1));
17656         o_conv.is_owned = (o & 1) || (o == 0);
17657         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17658         o_conv = ClosingSigned_clone(&o_conv);
17659         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
17660         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
17661         return (uint32_t)ret_conv;
17662 }
17663
17664 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_err"))) TS_CResult_ClosingSignedDecodeErrorZ_err(uint32_t e) {
17665         LDKDecodeError e_conv;
17666         e_conv.inner = (void*)(e & (~1));
17667         e_conv.is_owned = (e & 1) || (e == 0);
17668         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17669         e_conv = DecodeError_clone(&e_conv);
17670         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
17671         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
17672         return (uint32_t)ret_conv;
17673 }
17674
17675 jboolean  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_is_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_is_ok(uint32_t o) {
17676         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(o & ~1);
17677         jboolean ret_conv = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
17678         return ret_conv;
17679 }
17680
17681 void  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_free"))) TS_CResult_ClosingSignedDecodeErrorZ_free(uint32_t _res) {
17682         if ((_res & 1) != 0) return;
17683         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17684         CHECK_ACCESS(_res_ptr);
17685         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
17686         FREE((void*)_res);
17687         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
17688 }
17689
17690 static inline uintptr_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
17691         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
17692         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
17693         return (uint32_t)ret_conv;
17694 }
17695 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_clone_ptr"))) TS_CResult_ClosingSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
17696         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
17697         uint32_t ret_conv = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
17698         return ret_conv;
17699 }
17700
17701 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_clone"))) TS_CResult_ClosingSignedDecodeErrorZ_clone(uint32_t orig) {
17702         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
17703         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
17704         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
17705         return (uint32_t)ret_conv;
17706 }
17707
17708 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(uint32_t o) {
17709         LDKClosingSignedFeeRange o_conv;
17710         o_conv.inner = (void*)(o & (~1));
17711         o_conv.is_owned = (o & 1) || (o == 0);
17712         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17713         o_conv = ClosingSignedFeeRange_clone(&o_conv);
17714         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
17715         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
17716         return (uint32_t)ret_conv;
17717 }
17718
17719 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_err"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_err(uint32_t e) {
17720         LDKDecodeError e_conv;
17721         e_conv.inner = (void*)(e & (~1));
17722         e_conv.is_owned = (e & 1) || (e == 0);
17723         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17724         e_conv = DecodeError_clone(&e_conv);
17725         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
17726         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
17727         return (uint32_t)ret_conv;
17728 }
17729
17730 jboolean  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(uint32_t o) {
17731         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(o & ~1);
17732         jboolean ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
17733         return ret_conv;
17734 }
17735
17736 void  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_free"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_free(uint32_t _res) {
17737         if ((_res & 1) != 0) return;
17738         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17739         CHECK_ACCESS(_res_ptr);
17740         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
17741         FREE((void*)_res);
17742         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
17743 }
17744
17745 static inline uintptr_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
17746         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
17747         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
17748         return (uint32_t)ret_conv;
17749 }
17750 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
17751         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
17752         uint32_t ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
17753         return ret_conv;
17754 }
17755
17756 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(uint32_t orig) {
17757         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1);
17758         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
17759         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
17760         return (uint32_t)ret_conv;
17761 }
17762
17763 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_ok(uint32_t o) {
17764         LDKCommitmentSigned o_conv;
17765         o_conv.inner = (void*)(o & (~1));
17766         o_conv.is_owned = (o & 1) || (o == 0);
17767         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17768         o_conv = CommitmentSigned_clone(&o_conv);
17769         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
17770         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
17771         return (uint32_t)ret_conv;
17772 }
17773
17774 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_err"))) TS_CResult_CommitmentSignedDecodeErrorZ_err(uint32_t e) {
17775         LDKDecodeError e_conv;
17776         e_conv.inner = (void*)(e & (~1));
17777         e_conv.is_owned = (e & 1) || (e == 0);
17778         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17779         e_conv = DecodeError_clone(&e_conv);
17780         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
17781         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
17782         return (uint32_t)ret_conv;
17783 }
17784
17785 jboolean  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_is_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_is_ok(uint32_t o) {
17786         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(o & ~1);
17787         jboolean ret_conv = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
17788         return ret_conv;
17789 }
17790
17791 void  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_free"))) TS_CResult_CommitmentSignedDecodeErrorZ_free(uint32_t _res) {
17792         if ((_res & 1) != 0) return;
17793         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17794         CHECK_ACCESS(_res_ptr);
17795         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
17796         FREE((void*)_res);
17797         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
17798 }
17799
17800 static inline uintptr_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
17801         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
17802         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
17803         return (uint32_t)ret_conv;
17804 }
17805 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_clone_ptr"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
17806         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
17807         uint32_t ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
17808         return ret_conv;
17809 }
17810
17811 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_clone"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone(uint32_t orig) {
17812         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
17813         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
17814         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
17815         return (uint32_t)ret_conv;
17816 }
17817
17818 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_ok(uint32_t o) {
17819         LDKFundingCreated o_conv;
17820         o_conv.inner = (void*)(o & (~1));
17821         o_conv.is_owned = (o & 1) || (o == 0);
17822         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17823         o_conv = FundingCreated_clone(&o_conv);
17824         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
17825         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
17826         return (uint32_t)ret_conv;
17827 }
17828
17829 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_err"))) TS_CResult_FundingCreatedDecodeErrorZ_err(uint32_t e) {
17830         LDKDecodeError e_conv;
17831         e_conv.inner = (void*)(e & (~1));
17832         e_conv.is_owned = (e & 1) || (e == 0);
17833         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17834         e_conv = DecodeError_clone(&e_conv);
17835         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
17836         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
17837         return (uint32_t)ret_conv;
17838 }
17839
17840 jboolean  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_is_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_is_ok(uint32_t o) {
17841         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(o & ~1);
17842         jboolean ret_conv = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
17843         return ret_conv;
17844 }
17845
17846 void  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_free"))) TS_CResult_FundingCreatedDecodeErrorZ_free(uint32_t _res) {
17847         if ((_res & 1) != 0) return;
17848         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17849         CHECK_ACCESS(_res_ptr);
17850         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
17851         FREE((void*)_res);
17852         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
17853 }
17854
17855 static inline uintptr_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
17856         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
17857         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
17858         return (uint32_t)ret_conv;
17859 }
17860 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_clone_ptr"))) TS_CResult_FundingCreatedDecodeErrorZ_clone_ptr(uint32_t arg) {
17861         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
17862         uint32_t ret_conv = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
17863         return ret_conv;
17864 }
17865
17866 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_clone"))) TS_CResult_FundingCreatedDecodeErrorZ_clone(uint32_t orig) {
17867         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
17868         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
17869         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
17870         return (uint32_t)ret_conv;
17871 }
17872
17873 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_ok"))) TS_CResult_FundingSignedDecodeErrorZ_ok(uint32_t o) {
17874         LDKFundingSigned o_conv;
17875         o_conv.inner = (void*)(o & (~1));
17876         o_conv.is_owned = (o & 1) || (o == 0);
17877         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17878         o_conv = FundingSigned_clone(&o_conv);
17879         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
17880         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
17881         return (uint32_t)ret_conv;
17882 }
17883
17884 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_err"))) TS_CResult_FundingSignedDecodeErrorZ_err(uint32_t e) {
17885         LDKDecodeError e_conv;
17886         e_conv.inner = (void*)(e & (~1));
17887         e_conv.is_owned = (e & 1) || (e == 0);
17888         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17889         e_conv = DecodeError_clone(&e_conv);
17890         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
17891         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
17892         return (uint32_t)ret_conv;
17893 }
17894
17895 jboolean  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_is_ok"))) TS_CResult_FundingSignedDecodeErrorZ_is_ok(uint32_t o) {
17896         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(o & ~1);
17897         jboolean ret_conv = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
17898         return ret_conv;
17899 }
17900
17901 void  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_free"))) TS_CResult_FundingSignedDecodeErrorZ_free(uint32_t _res) {
17902         if ((_res & 1) != 0) return;
17903         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17904         CHECK_ACCESS(_res_ptr);
17905         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
17906         FREE((void*)_res);
17907         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
17908 }
17909
17910 static inline uintptr_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
17911         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
17912         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
17913         return (uint32_t)ret_conv;
17914 }
17915 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_clone_ptr"))) TS_CResult_FundingSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
17916         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
17917         uint32_t ret_conv = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
17918         return ret_conv;
17919 }
17920
17921 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_clone"))) TS_CResult_FundingSignedDecodeErrorZ_clone(uint32_t orig) {
17922         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
17923         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
17924         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
17925         return (uint32_t)ret_conv;
17926 }
17927
17928 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_ok"))) TS_CResult_FundingLockedDecodeErrorZ_ok(uint32_t o) {
17929         LDKFundingLocked o_conv;
17930         o_conv.inner = (void*)(o & (~1));
17931         o_conv.is_owned = (o & 1) || (o == 0);
17932         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17933         o_conv = FundingLocked_clone(&o_conv);
17934         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
17935         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
17936         return (uint32_t)ret_conv;
17937 }
17938
17939 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_err"))) TS_CResult_FundingLockedDecodeErrorZ_err(uint32_t e) {
17940         LDKDecodeError e_conv;
17941         e_conv.inner = (void*)(e & (~1));
17942         e_conv.is_owned = (e & 1) || (e == 0);
17943         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17944         e_conv = DecodeError_clone(&e_conv);
17945         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
17946         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
17947         return (uint32_t)ret_conv;
17948 }
17949
17950 jboolean  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_is_ok"))) TS_CResult_FundingLockedDecodeErrorZ_is_ok(uint32_t o) {
17951         LDKCResult_FundingLockedDecodeErrorZ* o_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(o & ~1);
17952         jboolean ret_conv = CResult_FundingLockedDecodeErrorZ_is_ok(o_conv);
17953         return ret_conv;
17954 }
17955
17956 void  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_free"))) TS_CResult_FundingLockedDecodeErrorZ_free(uint32_t _res) {
17957         if ((_res & 1) != 0) return;
17958         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17959         CHECK_ACCESS(_res_ptr);
17960         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(_res_ptr);
17961         FREE((void*)_res);
17962         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
17963 }
17964
17965 static inline uintptr_t CResult_FundingLockedDecodeErrorZ_clone_ptr(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR arg) {
17966         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
17967         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(arg);
17968         return (uint32_t)ret_conv;
17969 }
17970 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_clone_ptr"))) TS_CResult_FundingLockedDecodeErrorZ_clone_ptr(uint32_t arg) {
17971         LDKCResult_FundingLockedDecodeErrorZ* arg_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
17972         uint32_t ret_conv = CResult_FundingLockedDecodeErrorZ_clone_ptr(arg_conv);
17973         return ret_conv;
17974 }
17975
17976 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_clone"))) TS_CResult_FundingLockedDecodeErrorZ_clone(uint32_t orig) {
17977         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
17978         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
17979         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
17980         return (uint32_t)ret_conv;
17981 }
17982
17983 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_ok"))) TS_CResult_InitDecodeErrorZ_ok(uint32_t o) {
17984         LDKInit o_conv;
17985         o_conv.inner = (void*)(o & (~1));
17986         o_conv.is_owned = (o & 1) || (o == 0);
17987         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17988         o_conv = Init_clone(&o_conv);
17989         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
17990         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
17991         return (uint32_t)ret_conv;
17992 }
17993
17994 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_err"))) TS_CResult_InitDecodeErrorZ_err(uint32_t e) {
17995         LDKDecodeError e_conv;
17996         e_conv.inner = (void*)(e & (~1));
17997         e_conv.is_owned = (e & 1) || (e == 0);
17998         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17999         e_conv = DecodeError_clone(&e_conv);
18000         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
18001         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
18002         return (uint32_t)ret_conv;
18003 }
18004
18005 jboolean  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_is_ok"))) TS_CResult_InitDecodeErrorZ_is_ok(uint32_t o) {
18006         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)(o & ~1);
18007         jboolean ret_conv = CResult_InitDecodeErrorZ_is_ok(o_conv);
18008         return ret_conv;
18009 }
18010
18011 void  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_free"))) TS_CResult_InitDecodeErrorZ_free(uint32_t _res) {
18012         if ((_res & 1) != 0) return;
18013         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18014         CHECK_ACCESS(_res_ptr);
18015         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
18016         FREE((void*)_res);
18017         CResult_InitDecodeErrorZ_free(_res_conv);
18018 }
18019
18020 static inline uintptr_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
18021         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
18022         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
18023         return (uint32_t)ret_conv;
18024 }
18025 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_clone_ptr"))) TS_CResult_InitDecodeErrorZ_clone_ptr(uint32_t arg) {
18026         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
18027         uint32_t ret_conv = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
18028         return ret_conv;
18029 }
18030
18031 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_clone"))) TS_CResult_InitDecodeErrorZ_clone(uint32_t orig) {
18032         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
18033         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
18034         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
18035         return (uint32_t)ret_conv;
18036 }
18037
18038 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_ok"))) TS_CResult_OpenChannelDecodeErrorZ_ok(uint32_t o) {
18039         LDKOpenChannel o_conv;
18040         o_conv.inner = (void*)(o & (~1));
18041         o_conv.is_owned = (o & 1) || (o == 0);
18042         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18043         o_conv = OpenChannel_clone(&o_conv);
18044         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
18045         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
18046         return (uint32_t)ret_conv;
18047 }
18048
18049 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_err"))) TS_CResult_OpenChannelDecodeErrorZ_err(uint32_t e) {
18050         LDKDecodeError e_conv;
18051         e_conv.inner = (void*)(e & (~1));
18052         e_conv.is_owned = (e & 1) || (e == 0);
18053         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18054         e_conv = DecodeError_clone(&e_conv);
18055         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
18056         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
18057         return (uint32_t)ret_conv;
18058 }
18059
18060 jboolean  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_is_ok"))) TS_CResult_OpenChannelDecodeErrorZ_is_ok(uint32_t o) {
18061         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(o & ~1);
18062         jboolean ret_conv = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
18063         return ret_conv;
18064 }
18065
18066 void  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_free"))) TS_CResult_OpenChannelDecodeErrorZ_free(uint32_t _res) {
18067         if ((_res & 1) != 0) return;
18068         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18069         CHECK_ACCESS(_res_ptr);
18070         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
18071         FREE((void*)_res);
18072         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
18073 }
18074
18075 static inline uintptr_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
18076         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
18077         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
18078         return (uint32_t)ret_conv;
18079 }
18080 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_clone_ptr"))) TS_CResult_OpenChannelDecodeErrorZ_clone_ptr(uint32_t arg) {
18081         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
18082         uint32_t ret_conv = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
18083         return ret_conv;
18084 }
18085
18086 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_clone"))) TS_CResult_OpenChannelDecodeErrorZ_clone(uint32_t orig) {
18087         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
18088         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
18089         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
18090         return (uint32_t)ret_conv;
18091 }
18092
18093 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_ok(uint32_t o) {
18094         LDKRevokeAndACK o_conv;
18095         o_conv.inner = (void*)(o & (~1));
18096         o_conv.is_owned = (o & 1) || (o == 0);
18097         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18098         o_conv = RevokeAndACK_clone(&o_conv);
18099         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
18100         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
18101         return (uint32_t)ret_conv;
18102 }
18103
18104 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_err"))) TS_CResult_RevokeAndACKDecodeErrorZ_err(uint32_t e) {
18105         LDKDecodeError e_conv;
18106         e_conv.inner = (void*)(e & (~1));
18107         e_conv.is_owned = (e & 1) || (e == 0);
18108         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18109         e_conv = DecodeError_clone(&e_conv);
18110         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
18111         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
18112         return (uint32_t)ret_conv;
18113 }
18114
18115 jboolean  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_is_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_is_ok(uint32_t o) {
18116         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(o & ~1);
18117         jboolean ret_conv = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
18118         return ret_conv;
18119 }
18120
18121 void  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_free"))) TS_CResult_RevokeAndACKDecodeErrorZ_free(uint32_t _res) {
18122         if ((_res & 1) != 0) return;
18123         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18124         CHECK_ACCESS(_res_ptr);
18125         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
18126         FREE((void*)_res);
18127         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
18128 }
18129
18130 static inline uintptr_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
18131         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
18132         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
18133         return (uint32_t)ret_conv;
18134 }
18135 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_clone_ptr"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone_ptr(uint32_t arg) {
18136         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
18137         uint32_t ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
18138         return ret_conv;
18139 }
18140
18141 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_clone"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone(uint32_t orig) {
18142         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
18143         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
18144         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
18145         return (uint32_t)ret_conv;
18146 }
18147
18148 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_ok"))) TS_CResult_ShutdownDecodeErrorZ_ok(uint32_t o) {
18149         LDKShutdown o_conv;
18150         o_conv.inner = (void*)(o & (~1));
18151         o_conv.is_owned = (o & 1) || (o == 0);
18152         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18153         o_conv = Shutdown_clone(&o_conv);
18154         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
18155         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
18156         return (uint32_t)ret_conv;
18157 }
18158
18159 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_err"))) TS_CResult_ShutdownDecodeErrorZ_err(uint32_t e) {
18160         LDKDecodeError e_conv;
18161         e_conv.inner = (void*)(e & (~1));
18162         e_conv.is_owned = (e & 1) || (e == 0);
18163         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18164         e_conv = DecodeError_clone(&e_conv);
18165         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
18166         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
18167         return (uint32_t)ret_conv;
18168 }
18169
18170 jboolean  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_is_ok"))) TS_CResult_ShutdownDecodeErrorZ_is_ok(uint32_t o) {
18171         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)(o & ~1);
18172         jboolean ret_conv = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
18173         return ret_conv;
18174 }
18175
18176 void  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_free"))) TS_CResult_ShutdownDecodeErrorZ_free(uint32_t _res) {
18177         if ((_res & 1) != 0) return;
18178         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18179         CHECK_ACCESS(_res_ptr);
18180         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
18181         FREE((void*)_res);
18182         CResult_ShutdownDecodeErrorZ_free(_res_conv);
18183 }
18184
18185 static inline uintptr_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
18186         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
18187         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
18188         return (uint32_t)ret_conv;
18189 }
18190 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_clone_ptr"))) TS_CResult_ShutdownDecodeErrorZ_clone_ptr(uint32_t arg) {
18191         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
18192         uint32_t ret_conv = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
18193         return ret_conv;
18194 }
18195
18196 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_clone"))) TS_CResult_ShutdownDecodeErrorZ_clone(uint32_t orig) {
18197         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
18198         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
18199         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
18200         return (uint32_t)ret_conv;
18201 }
18202
18203 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_ok(uint32_t o) {
18204         LDKUpdateFailHTLC o_conv;
18205         o_conv.inner = (void*)(o & (~1));
18206         o_conv.is_owned = (o & 1) || (o == 0);
18207         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18208         o_conv = UpdateFailHTLC_clone(&o_conv);
18209         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
18210         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
18211         return (uint32_t)ret_conv;
18212 }
18213
18214 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_err(uint32_t e) {
18215         LDKDecodeError e_conv;
18216         e_conv.inner = (void*)(e & (~1));
18217         e_conv.is_owned = (e & 1) || (e == 0);
18218         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18219         e_conv = DecodeError_clone(&e_conv);
18220         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
18221         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
18222         return (uint32_t)ret_conv;
18223 }
18224
18225 jboolean  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_is_ok(uint32_t o) {
18226         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(o & ~1);
18227         jboolean ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
18228         return ret_conv;
18229 }
18230
18231 void  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_free(uint32_t _res) {
18232         if ((_res & 1) != 0) return;
18233         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18234         CHECK_ACCESS(_res_ptr);
18235         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
18236         FREE((void*)_res);
18237         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
18238 }
18239
18240 static inline uintptr_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
18241         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
18242         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
18243         return (uint32_t)ret_conv;
18244 }
18245 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
18246         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
18247         uint32_t ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
18248         return ret_conv;
18249 }
18250
18251 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone(uint32_t orig) {
18252         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
18253         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
18254         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
18255         return (uint32_t)ret_conv;
18256 }
18257
18258 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(uint32_t o) {
18259         LDKUpdateFailMalformedHTLC o_conv;
18260         o_conv.inner = (void*)(o & (~1));
18261         o_conv.is_owned = (o & 1) || (o == 0);
18262         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18263         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
18264         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
18265         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
18266         return (uint32_t)ret_conv;
18267 }
18268
18269 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(uint32_t e) {
18270         LDKDecodeError e_conv;
18271         e_conv.inner = (void*)(e & (~1));
18272         e_conv.is_owned = (e & 1) || (e == 0);
18273         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18274         e_conv = DecodeError_clone(&e_conv);
18275         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
18276         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
18277         return (uint32_t)ret_conv;
18278 }
18279
18280 jboolean  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(uint32_t o) {
18281         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(o & ~1);
18282         jboolean ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
18283         return ret_conv;
18284 }
18285
18286 void  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(uint32_t _res) {
18287         if ((_res & 1) != 0) return;
18288         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18289         CHECK_ACCESS(_res_ptr);
18290         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
18291         FREE((void*)_res);
18292         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
18293 }
18294
18295 static inline uintptr_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
18296         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
18297         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
18298         return (uint32_t)ret_conv;
18299 }
18300 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
18301         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
18302         uint32_t ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
18303         return ret_conv;
18304 }
18305
18306 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(uint32_t orig) {
18307         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
18308         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
18309         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
18310         return (uint32_t)ret_conv;
18311 }
18312
18313 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_ok(uint32_t o) {
18314         LDKUpdateFee o_conv;
18315         o_conv.inner = (void*)(o & (~1));
18316         o_conv.is_owned = (o & 1) || (o == 0);
18317         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18318         o_conv = UpdateFee_clone(&o_conv);
18319         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18320         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
18321         return (uint32_t)ret_conv;
18322 }
18323
18324 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_err"))) TS_CResult_UpdateFeeDecodeErrorZ_err(uint32_t e) {
18325         LDKDecodeError e_conv;
18326         e_conv.inner = (void*)(e & (~1));
18327         e_conv.is_owned = (e & 1) || (e == 0);
18328         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18329         e_conv = DecodeError_clone(&e_conv);
18330         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18331         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
18332         return (uint32_t)ret_conv;
18333 }
18334
18335 jboolean  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_is_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_is_ok(uint32_t o) {
18336         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(o & ~1);
18337         jboolean ret_conv = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
18338         return ret_conv;
18339 }
18340
18341 void  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_free"))) TS_CResult_UpdateFeeDecodeErrorZ_free(uint32_t _res) {
18342         if ((_res & 1) != 0) return;
18343         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18344         CHECK_ACCESS(_res_ptr);
18345         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
18346         FREE((void*)_res);
18347         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
18348 }
18349
18350 static inline uintptr_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
18351         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18352         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
18353         return (uint32_t)ret_conv;
18354 }
18355 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFeeDecodeErrorZ_clone_ptr(uint32_t arg) {
18356         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
18357         uint32_t ret_conv = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
18358         return ret_conv;
18359 }
18360
18361 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_clone"))) TS_CResult_UpdateFeeDecodeErrorZ_clone(uint32_t orig) {
18362         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
18363         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18364         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
18365         return (uint32_t)ret_conv;
18366 }
18367
18368 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok(uint32_t o) {
18369         LDKUpdateFulfillHTLC o_conv;
18370         o_conv.inner = (void*)(o & (~1));
18371         o_conv.is_owned = (o & 1) || (o == 0);
18372         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18373         o_conv = UpdateFulfillHTLC_clone(&o_conv);
18374         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18375         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
18376         return (uint32_t)ret_conv;
18377 }
18378
18379 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err(uint32_t e) {
18380         LDKDecodeError e_conv;
18381         e_conv.inner = (void*)(e & (~1));
18382         e_conv.is_owned = (e & 1) || (e == 0);
18383         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18384         e_conv = DecodeError_clone(&e_conv);
18385         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18386         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
18387         return (uint32_t)ret_conv;
18388 }
18389
18390 jboolean  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(uint32_t o) {
18391         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(o & ~1);
18392         jboolean ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
18393         return ret_conv;
18394 }
18395
18396 void  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free(uint32_t _res) {
18397         if ((_res & 1) != 0) return;
18398         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18399         CHECK_ACCESS(_res_ptr);
18400         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
18401         FREE((void*)_res);
18402         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
18403 }
18404
18405 static inline uintptr_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
18406         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18407         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
18408         return (uint32_t)ret_conv;
18409 }
18410 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
18411         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
18412         uint32_t ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
18413         return ret_conv;
18414 }
18415
18416 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone(uint32_t orig) {
18417         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
18418         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18419         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
18420         return (uint32_t)ret_conv;
18421 }
18422
18423 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_ok(uint32_t o) {
18424         LDKUpdateAddHTLC o_conv;
18425         o_conv.inner = (void*)(o & (~1));
18426         o_conv.is_owned = (o & 1) || (o == 0);
18427         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18428         o_conv = UpdateAddHTLC_clone(&o_conv);
18429         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18430         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
18431         return (uint32_t)ret_conv;
18432 }
18433
18434 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_err"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_err(uint32_t e) {
18435         LDKDecodeError e_conv;
18436         e_conv.inner = (void*)(e & (~1));
18437         e_conv.is_owned = (e & 1) || (e == 0);
18438         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18439         e_conv = DecodeError_clone(&e_conv);
18440         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18441         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
18442         return (uint32_t)ret_conv;
18443 }
18444
18445 jboolean  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_is_ok(uint32_t o) {
18446         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(o & ~1);
18447         jboolean ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
18448         return ret_conv;
18449 }
18450
18451 void  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_free"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_free(uint32_t _res) {
18452         if ((_res & 1) != 0) return;
18453         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18454         CHECK_ACCESS(_res_ptr);
18455         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
18456         FREE((void*)_res);
18457         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
18458 }
18459
18460 static inline uintptr_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
18461         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18462         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
18463         return (uint32_t)ret_conv;
18464 }
18465 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
18466         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
18467         uint32_t ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
18468         return ret_conv;
18469 }
18470
18471 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone(uint32_t orig) {
18472         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
18473         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18474         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
18475         return (uint32_t)ret_conv;
18476 }
18477
18478 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_ok"))) TS_CResult_PingDecodeErrorZ_ok(uint32_t o) {
18479         LDKPing o_conv;
18480         o_conv.inner = (void*)(o & (~1));
18481         o_conv.is_owned = (o & 1) || (o == 0);
18482         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18483         o_conv = Ping_clone(&o_conv);
18484         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
18485         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
18486         return (uint32_t)ret_conv;
18487 }
18488
18489 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_err"))) TS_CResult_PingDecodeErrorZ_err(uint32_t e) {
18490         LDKDecodeError e_conv;
18491         e_conv.inner = (void*)(e & (~1));
18492         e_conv.is_owned = (e & 1) || (e == 0);
18493         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18494         e_conv = DecodeError_clone(&e_conv);
18495         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
18496         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
18497         return (uint32_t)ret_conv;
18498 }
18499
18500 jboolean  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_is_ok"))) TS_CResult_PingDecodeErrorZ_is_ok(uint32_t o) {
18501         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)(o & ~1);
18502         jboolean ret_conv = CResult_PingDecodeErrorZ_is_ok(o_conv);
18503         return ret_conv;
18504 }
18505
18506 void  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_free"))) TS_CResult_PingDecodeErrorZ_free(uint32_t _res) {
18507         if ((_res & 1) != 0) return;
18508         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18509         CHECK_ACCESS(_res_ptr);
18510         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
18511         FREE((void*)_res);
18512         CResult_PingDecodeErrorZ_free(_res_conv);
18513 }
18514
18515 static inline uintptr_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
18516         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
18517         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
18518         return (uint32_t)ret_conv;
18519 }
18520 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_clone_ptr"))) TS_CResult_PingDecodeErrorZ_clone_ptr(uint32_t arg) {
18521         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
18522         uint32_t ret_conv = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
18523         return ret_conv;
18524 }
18525
18526 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_clone"))) TS_CResult_PingDecodeErrorZ_clone(uint32_t orig) {
18527         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
18528         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
18529         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
18530         return (uint32_t)ret_conv;
18531 }
18532
18533 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_ok"))) TS_CResult_PongDecodeErrorZ_ok(uint32_t o) {
18534         LDKPong o_conv;
18535         o_conv.inner = (void*)(o & (~1));
18536         o_conv.is_owned = (o & 1) || (o == 0);
18537         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18538         o_conv = Pong_clone(&o_conv);
18539         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
18540         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
18541         return (uint32_t)ret_conv;
18542 }
18543
18544 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_err"))) TS_CResult_PongDecodeErrorZ_err(uint32_t e) {
18545         LDKDecodeError e_conv;
18546         e_conv.inner = (void*)(e & (~1));
18547         e_conv.is_owned = (e & 1) || (e == 0);
18548         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18549         e_conv = DecodeError_clone(&e_conv);
18550         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
18551         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
18552         return (uint32_t)ret_conv;
18553 }
18554
18555 jboolean  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_is_ok"))) TS_CResult_PongDecodeErrorZ_is_ok(uint32_t o) {
18556         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)(o & ~1);
18557         jboolean ret_conv = CResult_PongDecodeErrorZ_is_ok(o_conv);
18558         return ret_conv;
18559 }
18560
18561 void  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_free"))) TS_CResult_PongDecodeErrorZ_free(uint32_t _res) {
18562         if ((_res & 1) != 0) return;
18563         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18564         CHECK_ACCESS(_res_ptr);
18565         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
18566         FREE((void*)_res);
18567         CResult_PongDecodeErrorZ_free(_res_conv);
18568 }
18569
18570 static inline uintptr_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
18571         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
18572         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
18573         return (uint32_t)ret_conv;
18574 }
18575 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_clone_ptr"))) TS_CResult_PongDecodeErrorZ_clone_ptr(uint32_t arg) {
18576         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
18577         uint32_t ret_conv = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
18578         return ret_conv;
18579 }
18580
18581 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_clone"))) TS_CResult_PongDecodeErrorZ_clone(uint32_t orig) {
18582         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
18583         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
18584         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
18585         return (uint32_t)ret_conv;
18586 }
18587
18588 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
18589         LDKUnsignedChannelAnnouncement o_conv;
18590         o_conv.inner = (void*)(o & (~1));
18591         o_conv.is_owned = (o & 1) || (o == 0);
18592         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18593         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
18594         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
18595         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
18596         return (uint32_t)ret_conv;
18597 }
18598
18599 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
18600         LDKDecodeError e_conv;
18601         e_conv.inner = (void*)(e & (~1));
18602         e_conv.is_owned = (e & 1) || (e == 0);
18603         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18604         e_conv = DecodeError_clone(&e_conv);
18605         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
18606         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
18607         return (uint32_t)ret_conv;
18608 }
18609
18610 jboolean  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
18611         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(o & ~1);
18612         jboolean ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
18613         return ret_conv;
18614 }
18615
18616 void  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
18617         if ((_res & 1) != 0) return;
18618         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18619         CHECK_ACCESS(_res_ptr);
18620         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
18621         FREE((void*)_res);
18622         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
18623 }
18624
18625 static inline uintptr_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
18626         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
18627         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
18628         return (uint32_t)ret_conv;
18629 }
18630 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
18631         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
18632         uint32_t ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
18633         return ret_conv;
18634 }
18635
18636 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
18637         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
18638         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
18639         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
18640         return (uint32_t)ret_conv;
18641 }
18642
18643 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
18644         LDKChannelAnnouncement o_conv;
18645         o_conv.inner = (void*)(o & (~1));
18646         o_conv.is_owned = (o & 1) || (o == 0);
18647         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18648         o_conv = ChannelAnnouncement_clone(&o_conv);
18649         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
18650         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
18651         return (uint32_t)ret_conv;
18652 }
18653
18654 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_err"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
18655         LDKDecodeError e_conv;
18656         e_conv.inner = (void*)(e & (~1));
18657         e_conv.is_owned = (e & 1) || (e == 0);
18658         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18659         e_conv = DecodeError_clone(&e_conv);
18660         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
18661         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
18662         return (uint32_t)ret_conv;
18663 }
18664
18665 jboolean  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
18666         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(o & ~1);
18667         jboolean ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
18668         return ret_conv;
18669 }
18670
18671 void  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_free"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
18672         if ((_res & 1) != 0) return;
18673         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18674         CHECK_ACCESS(_res_ptr);
18675         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
18676         FREE((void*)_res);
18677         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
18678 }
18679
18680 static inline uintptr_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
18681         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
18682         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
18683         return (uint32_t)ret_conv;
18684 }
18685 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
18686         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
18687         uint32_t ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
18688         return ret_conv;
18689 }
18690
18691 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_clone"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
18692         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
18693         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
18694         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
18695         return (uint32_t)ret_conv;
18696 }
18697
18698 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok(uint32_t o) {
18699         LDKUnsignedChannelUpdate o_conv;
18700         o_conv.inner = (void*)(o & (~1));
18701         o_conv.is_owned = (o & 1) || (o == 0);
18702         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18703         o_conv = UnsignedChannelUpdate_clone(&o_conv);
18704         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
18705         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
18706         return (uint32_t)ret_conv;
18707 }
18708
18709 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err(uint32_t e) {
18710         LDKDecodeError e_conv;
18711         e_conv.inner = (void*)(e & (~1));
18712         e_conv.is_owned = (e & 1) || (e == 0);
18713         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18714         e_conv = DecodeError_clone(&e_conv);
18715         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
18716         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
18717         return (uint32_t)ret_conv;
18718 }
18719
18720 jboolean  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(uint32_t o) {
18721         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(o & ~1);
18722         jboolean ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
18723         return ret_conv;
18724 }
18725
18726 void  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free(uint32_t _res) {
18727         if ((_res & 1) != 0) return;
18728         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18729         CHECK_ACCESS(_res_ptr);
18730         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
18731         FREE((void*)_res);
18732         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
18733 }
18734
18735 static inline uintptr_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
18736         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
18737         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
18738         return (uint32_t)ret_conv;
18739 }
18740 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
18741         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
18742         uint32_t ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
18743         return ret_conv;
18744 }
18745
18746 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
18747         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
18748         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
18749         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
18750         return (uint32_t)ret_conv;
18751 }
18752
18753 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_ok(uint32_t o) {
18754         LDKChannelUpdate o_conv;
18755         o_conv.inner = (void*)(o & (~1));
18756         o_conv.is_owned = (o & 1) || (o == 0);
18757         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18758         o_conv = ChannelUpdate_clone(&o_conv);
18759         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
18760         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
18761         return (uint32_t)ret_conv;
18762 }
18763
18764 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_err"))) TS_CResult_ChannelUpdateDecodeErrorZ_err(uint32_t e) {
18765         LDKDecodeError e_conv;
18766         e_conv.inner = (void*)(e & (~1));
18767         e_conv.is_owned = (e & 1) || (e == 0);
18768         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18769         e_conv = DecodeError_clone(&e_conv);
18770         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
18771         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
18772         return (uint32_t)ret_conv;
18773 }
18774
18775 jboolean  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_is_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_is_ok(uint32_t o) {
18776         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(o & ~1);
18777         jboolean ret_conv = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
18778         return ret_conv;
18779 }
18780
18781 void  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_free"))) TS_CResult_ChannelUpdateDecodeErrorZ_free(uint32_t _res) {
18782         if ((_res & 1) != 0) return;
18783         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18784         CHECK_ACCESS(_res_ptr);
18785         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
18786         FREE((void*)_res);
18787         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
18788 }
18789
18790 static inline uintptr_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
18791         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
18792         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
18793         return (uint32_t)ret_conv;
18794 }
18795 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
18796         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
18797         uint32_t ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
18798         return ret_conv;
18799 }
18800
18801 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_clone"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
18802         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
18803         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
18804         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
18805         return (uint32_t)ret_conv;
18806 }
18807
18808 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_ok(uint32_t o) {
18809         LDKErrorMessage o_conv;
18810         o_conv.inner = (void*)(o & (~1));
18811         o_conv.is_owned = (o & 1) || (o == 0);
18812         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18813         o_conv = ErrorMessage_clone(&o_conv);
18814         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
18815         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
18816         return (uint32_t)ret_conv;
18817 }
18818
18819 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_err"))) TS_CResult_ErrorMessageDecodeErrorZ_err(uint32_t e) {
18820         LDKDecodeError e_conv;
18821         e_conv.inner = (void*)(e & (~1));
18822         e_conv.is_owned = (e & 1) || (e == 0);
18823         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18824         e_conv = DecodeError_clone(&e_conv);
18825         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
18826         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
18827         return (uint32_t)ret_conv;
18828 }
18829
18830 jboolean  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_is_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_is_ok(uint32_t o) {
18831         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(o & ~1);
18832         jboolean ret_conv = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
18833         return ret_conv;
18834 }
18835
18836 void  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_free"))) TS_CResult_ErrorMessageDecodeErrorZ_free(uint32_t _res) {
18837         if ((_res & 1) != 0) return;
18838         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18839         CHECK_ACCESS(_res_ptr);
18840         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
18841         FREE((void*)_res);
18842         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
18843 }
18844
18845 static inline uintptr_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
18846         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
18847         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
18848         return (uint32_t)ret_conv;
18849 }
18850 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_clone_ptr"))) TS_CResult_ErrorMessageDecodeErrorZ_clone_ptr(uint32_t arg) {
18851         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
18852         uint32_t ret_conv = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
18853         return ret_conv;
18854 }
18855
18856 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_clone"))) TS_CResult_ErrorMessageDecodeErrorZ_clone(uint32_t orig) {
18857         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
18858         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
18859         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
18860         return (uint32_t)ret_conv;
18861 }
18862
18863 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_ok"))) TS_CResult_WarningMessageDecodeErrorZ_ok(uint32_t o) {
18864         LDKWarningMessage o_conv;
18865         o_conv.inner = (void*)(o & (~1));
18866         o_conv.is_owned = (o & 1) || (o == 0);
18867         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18868         o_conv = WarningMessage_clone(&o_conv);
18869         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
18870         *ret_conv = CResult_WarningMessageDecodeErrorZ_ok(o_conv);
18871         return (uint32_t)ret_conv;
18872 }
18873
18874 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_err"))) TS_CResult_WarningMessageDecodeErrorZ_err(uint32_t e) {
18875         LDKDecodeError e_conv;
18876         e_conv.inner = (void*)(e & (~1));
18877         e_conv.is_owned = (e & 1) || (e == 0);
18878         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18879         e_conv = DecodeError_clone(&e_conv);
18880         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
18881         *ret_conv = CResult_WarningMessageDecodeErrorZ_err(e_conv);
18882         return (uint32_t)ret_conv;
18883 }
18884
18885 jboolean  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_is_ok"))) TS_CResult_WarningMessageDecodeErrorZ_is_ok(uint32_t o) {
18886         LDKCResult_WarningMessageDecodeErrorZ* o_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(o & ~1);
18887         jboolean ret_conv = CResult_WarningMessageDecodeErrorZ_is_ok(o_conv);
18888         return ret_conv;
18889 }
18890
18891 void  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_free"))) TS_CResult_WarningMessageDecodeErrorZ_free(uint32_t _res) {
18892         if ((_res & 1) != 0) return;
18893         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18894         CHECK_ACCESS(_res_ptr);
18895         LDKCResult_WarningMessageDecodeErrorZ _res_conv = *(LDKCResult_WarningMessageDecodeErrorZ*)(_res_ptr);
18896         FREE((void*)_res);
18897         CResult_WarningMessageDecodeErrorZ_free(_res_conv);
18898 }
18899
18900 static inline uintptr_t CResult_WarningMessageDecodeErrorZ_clone_ptr(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR arg) {
18901         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
18902         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(arg);
18903         return (uint32_t)ret_conv;
18904 }
18905 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_clone_ptr"))) TS_CResult_WarningMessageDecodeErrorZ_clone_ptr(uint32_t arg) {
18906         LDKCResult_WarningMessageDecodeErrorZ* arg_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(arg & ~1);
18907         uint32_t ret_conv = CResult_WarningMessageDecodeErrorZ_clone_ptr(arg_conv);
18908         return ret_conv;
18909 }
18910
18911 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_clone"))) TS_CResult_WarningMessageDecodeErrorZ_clone(uint32_t orig) {
18912         LDKCResult_WarningMessageDecodeErrorZ* orig_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(orig & ~1);
18913         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
18914         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(orig_conv);
18915         return (uint32_t)ret_conv;
18916 }
18917
18918 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
18919         LDKUnsignedNodeAnnouncement o_conv;
18920         o_conv.inner = (void*)(o & (~1));
18921         o_conv.is_owned = (o & 1) || (o == 0);
18922         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18923         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
18924         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
18925         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
18926         return (uint32_t)ret_conv;
18927 }
18928
18929 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(uint32_t e) {
18930         LDKDecodeError e_conv;
18931         e_conv.inner = (void*)(e & (~1));
18932         e_conv.is_owned = (e & 1) || (e == 0);
18933         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18934         e_conv = DecodeError_clone(&e_conv);
18935         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
18936         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
18937         return (uint32_t)ret_conv;
18938 }
18939
18940 jboolean  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
18941         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(o & ~1);
18942         jboolean ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
18943         return ret_conv;
18944 }
18945
18946 void  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
18947         if ((_res & 1) != 0) return;
18948         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18949         CHECK_ACCESS(_res_ptr);
18950         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
18951         FREE((void*)_res);
18952         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
18953 }
18954
18955 static inline uintptr_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
18956         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
18957         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
18958         return (uint32_t)ret_conv;
18959 }
18960 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
18961         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
18962         uint32_t ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
18963         return ret_conv;
18964 }
18965
18966 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
18967         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
18968         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
18969         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
18970         return (uint32_t)ret_conv;
18971 }
18972
18973 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
18974         LDKNodeAnnouncement o_conv;
18975         o_conv.inner = (void*)(o & (~1));
18976         o_conv.is_owned = (o & 1) || (o == 0);
18977         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18978         o_conv = NodeAnnouncement_clone(&o_conv);
18979         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
18980         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
18981         return (uint32_t)ret_conv;
18982 }
18983
18984 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_err"))) TS_CResult_NodeAnnouncementDecodeErrorZ_err(uint32_t e) {
18985         LDKDecodeError e_conv;
18986         e_conv.inner = (void*)(e & (~1));
18987         e_conv.is_owned = (e & 1) || (e == 0);
18988         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18989         e_conv = DecodeError_clone(&e_conv);
18990         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
18991         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
18992         return (uint32_t)ret_conv;
18993 }
18994
18995 jboolean  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
18996         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(o & ~1);
18997         jboolean ret_conv = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
18998         return ret_conv;
18999 }
19000
19001 void  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_free"))) TS_CResult_NodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
19002         if ((_res & 1) != 0) return;
19003         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19004         CHECK_ACCESS(_res_ptr);
19005         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
19006         FREE((void*)_res);
19007         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
19008 }
19009
19010 static inline uintptr_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
19011         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
19012         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
19013         return (uint32_t)ret_conv;
19014 }
19015 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
19016         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
19017         uint32_t ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
19018         return ret_conv;
19019 }
19020
19021 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_clone"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
19022         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
19023         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
19024         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
19025         return (uint32_t)ret_conv;
19026 }
19027
19028 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok(uint32_t o) {
19029         LDKQueryShortChannelIds o_conv;
19030         o_conv.inner = (void*)(o & (~1));
19031         o_conv.is_owned = (o & 1) || (o == 0);
19032         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19033         o_conv = QueryShortChannelIds_clone(&o_conv);
19034         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
19035         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
19036         return (uint32_t)ret_conv;
19037 }
19038
19039 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_err"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_err(uint32_t e) {
19040         LDKDecodeError e_conv;
19041         e_conv.inner = (void*)(e & (~1));
19042         e_conv.is_owned = (e & 1) || (e == 0);
19043         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19044         e_conv = DecodeError_clone(&e_conv);
19045         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
19046         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
19047         return (uint32_t)ret_conv;
19048 }
19049
19050 jboolean  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_is_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(uint32_t o) {
19051         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(o & ~1);
19052         jboolean ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
19053         return ret_conv;
19054 }
19055
19056 void  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_free"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_free(uint32_t _res) {
19057         if ((_res & 1) != 0) return;
19058         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19059         CHECK_ACCESS(_res_ptr);
19060         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
19061         FREE((void*)_res);
19062         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
19063 }
19064
19065 static inline uintptr_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
19066         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
19067         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
19068         return (uint32_t)ret_conv;
19069 }
19070 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(uint32_t arg) {
19071         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
19072         uint32_t ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
19073         return ret_conv;
19074 }
19075
19076 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone(uint32_t orig) {
19077         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
19078         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
19079         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
19080         return (uint32_t)ret_conv;
19081 }
19082
19083 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(uint32_t o) {
19084         LDKReplyShortChannelIdsEnd o_conv;
19085         o_conv.inner = (void*)(o & (~1));
19086         o_conv.is_owned = (o & 1) || (o == 0);
19087         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19088         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
19089         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
19090         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
19091         return (uint32_t)ret_conv;
19092 }
19093
19094 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(uint32_t e) {
19095         LDKDecodeError e_conv;
19096         e_conv.inner = (void*)(e & (~1));
19097         e_conv.is_owned = (e & 1) || (e == 0);
19098         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19099         e_conv = DecodeError_clone(&e_conv);
19100         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
19101         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
19102         return (uint32_t)ret_conv;
19103 }
19104
19105 jboolean  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(uint32_t o) {
19106         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(o & ~1);
19107         jboolean ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
19108         return ret_conv;
19109 }
19110
19111 void  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(uint32_t _res) {
19112         if ((_res & 1) != 0) return;
19113         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19114         CHECK_ACCESS(_res_ptr);
19115         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
19116         FREE((void*)_res);
19117         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
19118 }
19119
19120 static inline uintptr_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
19121         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
19122         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
19123         return (uint32_t)ret_conv;
19124 }
19125 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(uint32_t arg) {
19126         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
19127         uint32_t ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
19128         return ret_conv;
19129 }
19130
19131 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(uint32_t orig) {
19132         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
19133         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
19134         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
19135         return (uint32_t)ret_conv;
19136 }
19137
19138 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_ok(uint32_t o) {
19139         LDKQueryChannelRange o_conv;
19140         o_conv.inner = (void*)(o & (~1));
19141         o_conv.is_owned = (o & 1) || (o == 0);
19142         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19143         o_conv = QueryChannelRange_clone(&o_conv);
19144         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
19145         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
19146         return (uint32_t)ret_conv;
19147 }
19148
19149 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_err"))) TS_CResult_QueryChannelRangeDecodeErrorZ_err(uint32_t e) {
19150         LDKDecodeError e_conv;
19151         e_conv.inner = (void*)(e & (~1));
19152         e_conv.is_owned = (e & 1) || (e == 0);
19153         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19154         e_conv = DecodeError_clone(&e_conv);
19155         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
19156         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
19157         return (uint32_t)ret_conv;
19158 }
19159
19160 jboolean  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_is_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_is_ok(uint32_t o) {
19161         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(o & ~1);
19162         jboolean ret_conv = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
19163         return ret_conv;
19164 }
19165
19166 void  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_free"))) TS_CResult_QueryChannelRangeDecodeErrorZ_free(uint32_t _res) {
19167         if ((_res & 1) != 0) return;
19168         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19169         CHECK_ACCESS(_res_ptr);
19170         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
19171         FREE((void*)_res);
19172         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
19173 }
19174
19175 static inline uintptr_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
19176         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
19177         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
19178         return (uint32_t)ret_conv;
19179 }
19180 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_clone_ptr"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
19181         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
19182         uint32_t ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
19183         return ret_conv;
19184 }
19185
19186 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_clone"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone(uint32_t orig) {
19187         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
19188         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
19189         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
19190         return (uint32_t)ret_conv;
19191 }
19192
19193 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_ok(uint32_t o) {
19194         LDKReplyChannelRange o_conv;
19195         o_conv.inner = (void*)(o & (~1));
19196         o_conv.is_owned = (o & 1) || (o == 0);
19197         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19198         o_conv = ReplyChannelRange_clone(&o_conv);
19199         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
19200         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
19201         return (uint32_t)ret_conv;
19202 }
19203
19204 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_err"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_err(uint32_t e) {
19205         LDKDecodeError e_conv;
19206         e_conv.inner = (void*)(e & (~1));
19207         e_conv.is_owned = (e & 1) || (e == 0);
19208         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19209         e_conv = DecodeError_clone(&e_conv);
19210         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
19211         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
19212         return (uint32_t)ret_conv;
19213 }
19214
19215 jboolean  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_is_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_is_ok(uint32_t o) {
19216         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(o & ~1);
19217         jboolean ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
19218         return ret_conv;
19219 }
19220
19221 void  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_free"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_free(uint32_t _res) {
19222         if ((_res & 1) != 0) return;
19223         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19224         CHECK_ACCESS(_res_ptr);
19225         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
19226         FREE((void*)_res);
19227         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
19228 }
19229
19230 static inline uintptr_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
19231         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
19232         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
19233         return (uint32_t)ret_conv;
19234 }
19235 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
19236         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
19237         uint32_t ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
19238         return ret_conv;
19239 }
19240
19241 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_clone"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone(uint32_t orig) {
19242         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
19243         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
19244         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
19245         return (uint32_t)ret_conv;
19246 }
19247
19248 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_ok(uint32_t o) {
19249         LDKGossipTimestampFilter o_conv;
19250         o_conv.inner = (void*)(o & (~1));
19251         o_conv.is_owned = (o & 1) || (o == 0);
19252         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19253         o_conv = GossipTimestampFilter_clone(&o_conv);
19254         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
19255         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
19256         return (uint32_t)ret_conv;
19257 }
19258
19259 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_err"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_err(uint32_t e) {
19260         LDKDecodeError e_conv;
19261         e_conv.inner = (void*)(e & (~1));
19262         e_conv.is_owned = (e & 1) || (e == 0);
19263         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19264         e_conv = DecodeError_clone(&e_conv);
19265         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
19266         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
19267         return (uint32_t)ret_conv;
19268 }
19269
19270 jboolean  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_is_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_is_ok(uint32_t o) {
19271         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(o & ~1);
19272         jboolean ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
19273         return ret_conv;
19274 }
19275
19276 void  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_free"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_free(uint32_t _res) {
19277         if ((_res & 1) != 0) return;
19278         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19279         CHECK_ACCESS(_res_ptr);
19280         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
19281         FREE((void*)_res);
19282         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
19283 }
19284
19285 static inline uintptr_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
19286         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
19287         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
19288         return (uint32_t)ret_conv;
19289 }
19290 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(uint32_t arg) {
19291         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
19292         uint32_t ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
19293         return ret_conv;
19294 }
19295
19296 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_clone"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone(uint32_t orig) {
19297         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
19298         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
19299         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
19300         return (uint32_t)ret_conv;
19301 }
19302
19303 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_ok"))) TS_CResult_InvoiceSignOrCreationErrorZ_ok(uint32_t o) {
19304         LDKInvoice o_conv;
19305         o_conv.inner = (void*)(o & (~1));
19306         o_conv.is_owned = (o & 1) || (o == 0);
19307         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19308         o_conv = Invoice_clone(&o_conv);
19309         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
19310         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
19311         return (uint32_t)ret_conv;
19312 }
19313
19314 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_err"))) TS_CResult_InvoiceSignOrCreationErrorZ_err(uint32_t e) {
19315         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19316         CHECK_ACCESS(e_ptr);
19317         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
19318         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)(((uintptr_t)e) & ~1));
19319         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
19320         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
19321         return (uint32_t)ret_conv;
19322 }
19323
19324 jboolean  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_is_ok"))) TS_CResult_InvoiceSignOrCreationErrorZ_is_ok(uint32_t o) {
19325         LDKCResult_InvoiceSignOrCreationErrorZ* o_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(o & ~1);
19326         jboolean ret_conv = CResult_InvoiceSignOrCreationErrorZ_is_ok(o_conv);
19327         return ret_conv;
19328 }
19329
19330 void  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_free"))) TS_CResult_InvoiceSignOrCreationErrorZ_free(uint32_t _res) {
19331         if ((_res & 1) != 0) return;
19332         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19333         CHECK_ACCESS(_res_ptr);
19334         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
19335         FREE((void*)_res);
19336         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
19337 }
19338
19339 static inline uintptr_t CResult_InvoiceSignOrCreationErrorZ_clone_ptr(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR arg) {
19340         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
19341         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(arg);
19342         return (uint32_t)ret_conv;
19343 }
19344 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_clone_ptr"))) TS_CResult_InvoiceSignOrCreationErrorZ_clone_ptr(uint32_t arg) {
19345         LDKCResult_InvoiceSignOrCreationErrorZ* arg_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
19346         uint32_t ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone_ptr(arg_conv);
19347         return ret_conv;
19348 }
19349
19350 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_clone"))) TS_CResult_InvoiceSignOrCreationErrorZ_clone(uint32_t orig) {
19351         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
19352         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
19353         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
19354         return (uint32_t)ret_conv;
19355 }
19356
19357 uint32_t  __attribute__((export_name("TS_COption_FilterZ_some"))) TS_COption_FilterZ_some(uint32_t o) {
19358         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19359         CHECK_ACCESS(o_ptr);
19360         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
19361         if (o_conv.free == LDKFilter_JCalls_free) {
19362                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19363                 LDKFilter_JCalls_cloned(&o_conv);
19364         }
19365         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
19366         *ret_copy = COption_FilterZ_some(o_conv);
19367         uint32_t ret_ref = (uintptr_t)ret_copy;
19368         return ret_ref;
19369 }
19370
19371 uint32_t  __attribute__((export_name("TS_COption_FilterZ_none"))) TS_COption_FilterZ_none() {
19372         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
19373         *ret_copy = COption_FilterZ_none();
19374         uint32_t ret_ref = (uintptr_t)ret_copy;
19375         return ret_ref;
19376 }
19377
19378 void  __attribute__((export_name("TS_COption_FilterZ_free"))) TS_COption_FilterZ_free(uint32_t _res) {
19379         if ((_res & 1) != 0) return;
19380         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19381         CHECK_ACCESS(_res_ptr);
19382         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
19383         FREE((void*)_res);
19384         COption_FilterZ_free(_res_conv);
19385 }
19386
19387 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_ok"))) TS_CResult_LockedChannelMonitorNoneZ_ok(uint32_t o) {
19388         LDKLockedChannelMonitor o_conv;
19389         o_conv.inner = (void*)(o & (~1));
19390         o_conv.is_owned = (o & 1) || (o == 0);
19391         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19392         // WARNING: we need a move here but no clone is available for LDKLockedChannelMonitor
19393         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
19394         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
19395         return (uint32_t)ret_conv;
19396 }
19397
19398 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_err"))) TS_CResult_LockedChannelMonitorNoneZ_err() {
19399         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
19400         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
19401         return (uint32_t)ret_conv;
19402 }
19403
19404 jboolean  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_is_ok"))) TS_CResult_LockedChannelMonitorNoneZ_is_ok(uint32_t o) {
19405         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(o & ~1);
19406         jboolean ret_conv = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
19407         return ret_conv;
19408 }
19409
19410 void  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_free"))) TS_CResult_LockedChannelMonitorNoneZ_free(uint32_t _res) {
19411         if ((_res & 1) != 0) return;
19412         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19413         CHECK_ACCESS(_res_ptr);
19414         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
19415         FREE((void*)_res);
19416         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
19417 }
19418
19419 void  __attribute__((export_name("TS_CVec_OutPointZ_free"))) TS_CVec_OutPointZ_free(uint32_tArray _res) {
19420         LDKCVec_OutPointZ _res_constr;
19421         _res_constr.datalen = _res->arr_len;
19422         if (_res_constr.datalen > 0)
19423                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
19424         else
19425                 _res_constr.data = NULL;
19426         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
19427         for (size_t k = 0; k < _res_constr.datalen; k++) {
19428                 uint32_t _res_conv_10 = _res_vals[k];
19429                 LDKOutPoint _res_conv_10_conv;
19430                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
19431                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
19432                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
19433                 _res_constr.data[k] = _res_conv_10_conv;
19434         }
19435         CVec_OutPointZ_free(_res_constr);
19436 }
19437
19438 void  __attribute__((export_name("TS_PaymentPurpose_free"))) TS_PaymentPurpose_free(uint32_t this_ptr) {
19439         if ((this_ptr & 1) != 0) return;
19440         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
19441         CHECK_ACCESS(this_ptr_ptr);
19442         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
19443         FREE((void*)this_ptr);
19444         PaymentPurpose_free(this_ptr_conv);
19445 }
19446
19447 static inline uintptr_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
19448         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
19449         *ret_copy = PaymentPurpose_clone(arg);
19450 uint32_t ret_ref = (uintptr_t)ret_copy;
19451         return ret_ref;
19452 }
19453 uint32_t  __attribute__((export_name("TS_PaymentPurpose_clone_ptr"))) TS_PaymentPurpose_clone_ptr(uint32_t arg) {
19454         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)arg;
19455         uint32_t ret_conv = PaymentPurpose_clone_ptr(arg_conv);
19456         return ret_conv;
19457 }
19458
19459 uint32_t  __attribute__((export_name("TS_PaymentPurpose_clone"))) TS_PaymentPurpose_clone(uint32_t orig) {
19460         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
19461         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
19462         *ret_copy = PaymentPurpose_clone(orig_conv);
19463         uint32_t ret_ref = (uintptr_t)ret_copy;
19464         return ret_ref;
19465 }
19466
19467 uint32_t  __attribute__((export_name("TS_PaymentPurpose_invoice_payment"))) TS_PaymentPurpose_invoice_payment(int8_tArray payment_preimage, int8_tArray payment_secret) {
19468         LDKThirtyTwoBytes payment_preimage_ref;
19469         CHECK(payment_preimage->arr_len == 32);
19470         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
19471         LDKThirtyTwoBytes payment_secret_ref;
19472         CHECK(payment_secret->arr_len == 32);
19473         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
19474         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
19475         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref);
19476         uint32_t ret_ref = (uintptr_t)ret_copy;
19477         return ret_ref;
19478 }
19479
19480 uint32_t  __attribute__((export_name("TS_PaymentPurpose_spontaneous_payment"))) TS_PaymentPurpose_spontaneous_payment(int8_tArray a) {
19481         LDKThirtyTwoBytes a_ref;
19482         CHECK(a->arr_len == 32);
19483         memcpy(a_ref.data, a->elems, 32); FREE(a);
19484         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
19485         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
19486         uint32_t ret_ref = (uintptr_t)ret_copy;
19487         return ret_ref;
19488 }
19489
19490 void  __attribute__((export_name("TS_ClosureReason_free"))) TS_ClosureReason_free(uint32_t this_ptr) {
19491         if ((this_ptr & 1) != 0) return;
19492         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
19493         CHECK_ACCESS(this_ptr_ptr);
19494         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
19495         FREE((void*)this_ptr);
19496         ClosureReason_free(this_ptr_conv);
19497 }
19498
19499 static inline uintptr_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
19500         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19501         *ret_copy = ClosureReason_clone(arg);
19502 uint32_t ret_ref = (uintptr_t)ret_copy;
19503         return ret_ref;
19504 }
19505 uint32_t  __attribute__((export_name("TS_ClosureReason_clone_ptr"))) TS_ClosureReason_clone_ptr(uint32_t arg) {
19506         LDKClosureReason* arg_conv = (LDKClosureReason*)arg;
19507         uint32_t ret_conv = ClosureReason_clone_ptr(arg_conv);
19508         return ret_conv;
19509 }
19510
19511 uint32_t  __attribute__((export_name("TS_ClosureReason_clone"))) TS_ClosureReason_clone(uint32_t orig) {
19512         LDKClosureReason* orig_conv = (LDKClosureReason*)orig;
19513         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19514         *ret_copy = ClosureReason_clone(orig_conv);
19515         uint32_t ret_ref = (uintptr_t)ret_copy;
19516         return ret_ref;
19517 }
19518
19519 uint32_t  __attribute__((export_name("TS_ClosureReason_counterparty_force_closed"))) TS_ClosureReason_counterparty_force_closed(jstring peer_msg) {
19520         LDKStr peer_msg_conv = str_ref_to_owned_c(peer_msg);
19521         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19522         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
19523         uint32_t ret_ref = (uintptr_t)ret_copy;
19524         return ret_ref;
19525 }
19526
19527 uint32_t  __attribute__((export_name("TS_ClosureReason_holder_force_closed"))) TS_ClosureReason_holder_force_closed() {
19528         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19529         *ret_copy = ClosureReason_holder_force_closed();
19530         uint32_t ret_ref = (uintptr_t)ret_copy;
19531         return ret_ref;
19532 }
19533
19534 uint32_t  __attribute__((export_name("TS_ClosureReason_cooperative_closure"))) TS_ClosureReason_cooperative_closure() {
19535         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19536         *ret_copy = ClosureReason_cooperative_closure();
19537         uint32_t ret_ref = (uintptr_t)ret_copy;
19538         return ret_ref;
19539 }
19540
19541 uint32_t  __attribute__((export_name("TS_ClosureReason_commitment_tx_confirmed"))) TS_ClosureReason_commitment_tx_confirmed() {
19542         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19543         *ret_copy = ClosureReason_commitment_tx_confirmed();
19544         uint32_t ret_ref = (uintptr_t)ret_copy;
19545         return ret_ref;
19546 }
19547
19548 uint32_t  __attribute__((export_name("TS_ClosureReason_funding_timed_out"))) TS_ClosureReason_funding_timed_out() {
19549         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19550         *ret_copy = ClosureReason_funding_timed_out();
19551         uint32_t ret_ref = (uintptr_t)ret_copy;
19552         return ret_ref;
19553 }
19554
19555 uint32_t  __attribute__((export_name("TS_ClosureReason_processing_error"))) TS_ClosureReason_processing_error(jstring err) {
19556         LDKStr err_conv = str_ref_to_owned_c(err);
19557         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19558         *ret_copy = ClosureReason_processing_error(err_conv);
19559         uint32_t ret_ref = (uintptr_t)ret_copy;
19560         return ret_ref;
19561 }
19562
19563 uint32_t  __attribute__((export_name("TS_ClosureReason_disconnected_peer"))) TS_ClosureReason_disconnected_peer() {
19564         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19565         *ret_copy = ClosureReason_disconnected_peer();
19566         uint32_t ret_ref = (uintptr_t)ret_copy;
19567         return ret_ref;
19568 }
19569
19570 uint32_t  __attribute__((export_name("TS_ClosureReason_outdated_channel_manager"))) TS_ClosureReason_outdated_channel_manager() {
19571         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19572         *ret_copy = ClosureReason_outdated_channel_manager();
19573         uint32_t ret_ref = (uintptr_t)ret_copy;
19574         return ret_ref;
19575 }
19576
19577 int8_tArray  __attribute__((export_name("TS_ClosureReason_write"))) TS_ClosureReason_write(uint32_t obj) {
19578         LDKClosureReason* obj_conv = (LDKClosureReason*)obj;
19579         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
19580         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
19581         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
19582         CVec_u8Z_free(ret_var);
19583         return ret_arr;
19584 }
19585
19586 uint32_t  __attribute__((export_name("TS_ClosureReason_read"))) TS_ClosureReason_read(int8_tArray ser) {
19587         LDKu8slice ser_ref;
19588         ser_ref.datalen = ser->arr_len;
19589         ser_ref.data = ser->elems /* XXX ser leaks */;
19590         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
19591         *ret_conv = ClosureReason_read(ser_ref);
19592         return (uint32_t)ret_conv;
19593 }
19594
19595 void  __attribute__((export_name("TS_Event_free"))) TS_Event_free(uint32_t this_ptr) {
19596         if ((this_ptr & 1) != 0) return;
19597         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
19598         CHECK_ACCESS(this_ptr_ptr);
19599         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
19600         FREE((void*)this_ptr);
19601         Event_free(this_ptr_conv);
19602 }
19603
19604 static inline uintptr_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
19605         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19606         *ret_copy = Event_clone(arg);
19607 uint32_t ret_ref = (uintptr_t)ret_copy;
19608         return ret_ref;
19609 }
19610 uint32_t  __attribute__((export_name("TS_Event_clone_ptr"))) TS_Event_clone_ptr(uint32_t arg) {
19611         LDKEvent* arg_conv = (LDKEvent*)arg;
19612         uint32_t ret_conv = Event_clone_ptr(arg_conv);
19613         return ret_conv;
19614 }
19615
19616 uint32_t  __attribute__((export_name("TS_Event_clone"))) TS_Event_clone(uint32_t orig) {
19617         LDKEvent* orig_conv = (LDKEvent*)orig;
19618         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19619         *ret_copy = Event_clone(orig_conv);
19620         uint32_t ret_ref = (uintptr_t)ret_copy;
19621         return ret_ref;
19622 }
19623
19624 uint32_t  __attribute__((export_name("TS_Event_funding_generation_ready"))) TS_Event_funding_generation_ready(int8_tArray temporary_channel_id, int64_t channel_value_satoshis, int8_tArray output_script, int64_t user_channel_id) {
19625         LDKThirtyTwoBytes temporary_channel_id_ref;
19626         CHECK(temporary_channel_id->arr_len == 32);
19627         memcpy(temporary_channel_id_ref.data, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
19628         LDKCVec_u8Z output_script_ref;
19629         output_script_ref.datalen = output_script->arr_len;
19630         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
19631         memcpy(output_script_ref.data, output_script->elems, output_script_ref.datalen); FREE(output_script);
19632         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19633         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
19634         uint32_t ret_ref = (uintptr_t)ret_copy;
19635         return ret_ref;
19636 }
19637
19638 uint32_t  __attribute__((export_name("TS_Event_payment_received"))) TS_Event_payment_received(int8_tArray payment_hash, int64_t amt, uint32_t purpose) {
19639         LDKThirtyTwoBytes payment_hash_ref;
19640         CHECK(payment_hash->arr_len == 32);
19641         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
19642         void* purpose_ptr = (void*)(((uintptr_t)purpose) & ~1);
19643         CHECK_ACCESS(purpose_ptr);
19644         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
19645         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)purpose) & ~1));
19646         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19647         *ret_copy = Event_payment_received(payment_hash_ref, amt, purpose_conv);
19648         uint32_t ret_ref = (uintptr_t)ret_copy;
19649         return ret_ref;
19650 }
19651
19652 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) {
19653         LDKThirtyTwoBytes payment_id_ref;
19654         CHECK(payment_id->arr_len == 32);
19655         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
19656         LDKThirtyTwoBytes payment_preimage_ref;
19657         CHECK(payment_preimage->arr_len == 32);
19658         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
19659         LDKThirtyTwoBytes payment_hash_ref;
19660         CHECK(payment_hash->arr_len == 32);
19661         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
19662         void* fee_paid_msat_ptr = (void*)(((uintptr_t)fee_paid_msat) & ~1);
19663         CHECK_ACCESS(fee_paid_msat_ptr);
19664         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
19665         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_paid_msat) & ~1));
19666         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19667         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
19668         uint32_t ret_ref = (uintptr_t)ret_copy;
19669         return ret_ref;
19670 }
19671
19672 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) {
19673         LDKThirtyTwoBytes payment_id_ref;
19674         CHECK(payment_id->arr_len == 32);
19675         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
19676         LDKThirtyTwoBytes payment_hash_ref;
19677         CHECK(payment_hash->arr_len == 32);
19678         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
19679         void* network_update_ptr = (void*)(((uintptr_t)network_update) & ~1);
19680         CHECK_ACCESS(network_update_ptr);
19681         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
19682         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)network_update) & ~1));
19683         LDKCVec_RouteHopZ path_constr;
19684         path_constr.datalen = path->arr_len;
19685         if (path_constr.datalen > 0)
19686                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
19687         else
19688                 path_constr.data = NULL;
19689         uint32_t* path_vals = path->elems /* XXX path leaks */;
19690         for (size_t k = 0; k < path_constr.datalen; k++) {
19691                 uint32_t path_conv_10 = path_vals[k];
19692                 LDKRouteHop path_conv_10_conv;
19693                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
19694                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
19695                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
19696                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
19697                 path_constr.data[k] = path_conv_10_conv;
19698         }
19699         void* short_channel_id_ptr = (void*)(((uintptr_t)short_channel_id) & ~1);
19700         CHECK_ACCESS(short_channel_id_ptr);
19701         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
19702         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id) & ~1));
19703         LDKRouteParameters retry_conv;
19704         retry_conv.inner = (void*)(retry & (~1));
19705         retry_conv.is_owned = (retry & 1) || (retry == 0);
19706         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_conv);
19707         retry_conv = RouteParameters_clone(&retry_conv);
19708         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19709         *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);
19710         uint32_t ret_ref = (uintptr_t)ret_copy;
19711         return ret_ref;
19712 }
19713
19714 uint32_t  __attribute__((export_name("TS_Event_payment_failed"))) TS_Event_payment_failed(int8_tArray payment_id, int8_tArray payment_hash) {
19715         LDKThirtyTwoBytes payment_id_ref;
19716         CHECK(payment_id->arr_len == 32);
19717         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
19718         LDKThirtyTwoBytes payment_hash_ref;
19719         CHECK(payment_hash->arr_len == 32);
19720         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
19721         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19722         *ret_copy = Event_payment_failed(payment_id_ref, payment_hash_ref);
19723         uint32_t ret_ref = (uintptr_t)ret_copy;
19724         return ret_ref;
19725 }
19726
19727 uint32_t  __attribute__((export_name("TS_Event_pending_htlcs_forwardable"))) TS_Event_pending_htlcs_forwardable(int64_t time_forwardable) {
19728         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19729         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
19730         uint32_t ret_ref = (uintptr_t)ret_copy;
19731         return ret_ref;
19732 }
19733
19734 uint32_t  __attribute__((export_name("TS_Event_spendable_outputs"))) TS_Event_spendable_outputs(uint32_tArray outputs) {
19735         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
19736         outputs_constr.datalen = outputs->arr_len;
19737         if (outputs_constr.datalen > 0)
19738                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
19739         else
19740                 outputs_constr.data = NULL;
19741         uint32_t* outputs_vals = outputs->elems /* XXX outputs leaks */;
19742         for (size_t b = 0; b < outputs_constr.datalen; b++) {
19743                 uint32_t outputs_conv_27 = outputs_vals[b];
19744                 void* outputs_conv_27_ptr = (void*)(((uintptr_t)outputs_conv_27) & ~1);
19745                 CHECK_ACCESS(outputs_conv_27_ptr);
19746                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
19747                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)outputs_conv_27) & ~1));
19748                 outputs_constr.data[b] = outputs_conv_27_conv;
19749         }
19750         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19751         *ret_copy = Event_spendable_outputs(outputs_constr);
19752         uint32_t ret_ref = (uintptr_t)ret_copy;
19753         return ret_ref;
19754 }
19755
19756 uint32_t  __attribute__((export_name("TS_Event_payment_forwarded"))) TS_Event_payment_forwarded(uint32_t fee_earned_msat, jboolean claim_from_onchain_tx) {
19757         void* fee_earned_msat_ptr = (void*)(((uintptr_t)fee_earned_msat) & ~1);
19758         CHECK_ACCESS(fee_earned_msat_ptr);
19759         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
19760         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_earned_msat) & ~1));
19761         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19762         *ret_copy = Event_payment_forwarded(fee_earned_msat_conv, claim_from_onchain_tx);
19763         uint32_t ret_ref = (uintptr_t)ret_copy;
19764         return ret_ref;
19765 }
19766
19767 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) {
19768         LDKThirtyTwoBytes channel_id_ref;
19769         CHECK(channel_id->arr_len == 32);
19770         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
19771         void* reason_ptr = (void*)(((uintptr_t)reason) & ~1);
19772         CHECK_ACCESS(reason_ptr);
19773         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
19774         reason_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)reason) & ~1));
19775         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19776         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
19777         uint32_t ret_ref = (uintptr_t)ret_copy;
19778         return ret_ref;
19779 }
19780
19781 uint32_t  __attribute__((export_name("TS_Event_discard_funding"))) TS_Event_discard_funding(int8_tArray channel_id, int8_tArray transaction) {
19782         LDKThirtyTwoBytes channel_id_ref;
19783         CHECK(channel_id->arr_len == 32);
19784         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
19785         LDKTransaction transaction_ref;
19786         transaction_ref.datalen = transaction->arr_len;
19787         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
19788         memcpy(transaction_ref.data, transaction->elems, transaction_ref.datalen); FREE(transaction);
19789         transaction_ref.data_is_owned = true;
19790         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19791         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
19792         uint32_t ret_ref = (uintptr_t)ret_copy;
19793         return ret_ref;
19794 }
19795
19796 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) {
19797         LDKThirtyTwoBytes payment_id_ref;
19798         CHECK(payment_id->arr_len == 32);
19799         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
19800         LDKThirtyTwoBytes payment_hash_ref;
19801         CHECK(payment_hash->arr_len == 32);
19802         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
19803         LDKCVec_RouteHopZ path_constr;
19804         path_constr.datalen = path->arr_len;
19805         if (path_constr.datalen > 0)
19806                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
19807         else
19808                 path_constr.data = NULL;
19809         uint32_t* path_vals = path->elems /* XXX path leaks */;
19810         for (size_t k = 0; k < path_constr.datalen; k++) {
19811                 uint32_t path_conv_10 = path_vals[k];
19812                 LDKRouteHop path_conv_10_conv;
19813                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
19814                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
19815                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
19816                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
19817                 path_constr.data[k] = path_conv_10_conv;
19818         }
19819         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19820         *ret_copy = Event_payment_path_successful(payment_id_ref, payment_hash_ref, path_constr);
19821         uint32_t ret_ref = (uintptr_t)ret_copy;
19822         return ret_ref;
19823 }
19824
19825 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) {
19826         LDKThirtyTwoBytes temporary_channel_id_ref;
19827         CHECK(temporary_channel_id->arr_len == 32);
19828         memcpy(temporary_channel_id_ref.data, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
19829         LDKPublicKey counterparty_node_id_ref;
19830         CHECK(counterparty_node_id->arr_len == 33);
19831         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
19832         LDKChannelTypeFeatures channel_type_conv;
19833         channel_type_conv.inner = (void*)(channel_type & (~1));
19834         channel_type_conv.is_owned = (channel_type & 1) || (channel_type == 0);
19835         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_conv);
19836         channel_type_conv = ChannelTypeFeatures_clone(&channel_type_conv);
19837         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19838         *ret_copy = Event_open_channel_request(temporary_channel_id_ref, counterparty_node_id_ref, funding_satoshis, push_msat, channel_type_conv);
19839         uint32_t ret_ref = (uintptr_t)ret_copy;
19840         return ret_ref;
19841 }
19842
19843 int8_tArray  __attribute__((export_name("TS_Event_write"))) TS_Event_write(uint32_t obj) {
19844         LDKEvent* obj_conv = (LDKEvent*)obj;
19845         LDKCVec_u8Z ret_var = Event_write(obj_conv);
19846         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
19847         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
19848         CVec_u8Z_free(ret_var);
19849         return ret_arr;
19850 }
19851
19852 uint32_t  __attribute__((export_name("TS_Event_read"))) TS_Event_read(int8_tArray ser) {
19853         LDKu8slice ser_ref;
19854         ser_ref.datalen = ser->arr_len;
19855         ser_ref.data = ser->elems /* XXX ser leaks */;
19856         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
19857         *ret_conv = Event_read(ser_ref);
19858         return (uint32_t)ret_conv;
19859 }
19860
19861 void  __attribute__((export_name("TS_MessageSendEvent_free"))) TS_MessageSendEvent_free(uint32_t this_ptr) {
19862         if ((this_ptr & 1) != 0) return;
19863         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
19864         CHECK_ACCESS(this_ptr_ptr);
19865         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
19866         FREE((void*)this_ptr);
19867         MessageSendEvent_free(this_ptr_conv);
19868 }
19869
19870 static inline uintptr_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
19871         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19872         *ret_copy = MessageSendEvent_clone(arg);
19873 uint32_t ret_ref = (uintptr_t)ret_copy;
19874         return ret_ref;
19875 }
19876 uint32_t  __attribute__((export_name("TS_MessageSendEvent_clone_ptr"))) TS_MessageSendEvent_clone_ptr(uint32_t arg) {
19877         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)arg;
19878         uint32_t ret_conv = MessageSendEvent_clone_ptr(arg_conv);
19879         return ret_conv;
19880 }
19881
19882 uint32_t  __attribute__((export_name("TS_MessageSendEvent_clone"))) TS_MessageSendEvent_clone(uint32_t orig) {
19883         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
19884         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19885         *ret_copy = MessageSendEvent_clone(orig_conv);
19886         uint32_t ret_ref = (uintptr_t)ret_copy;
19887         return ret_ref;
19888 }
19889
19890 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_accept_channel"))) TS_MessageSendEvent_send_accept_channel(int8_tArray node_id, uint32_t msg) {
19891         LDKPublicKey node_id_ref;
19892         CHECK(node_id->arr_len == 33);
19893         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19894         LDKAcceptChannel msg_conv;
19895         msg_conv.inner = (void*)(msg & (~1));
19896         msg_conv.is_owned = (msg & 1) || (msg == 0);
19897         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19898         msg_conv = AcceptChannel_clone(&msg_conv);
19899         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19900         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
19901         uint32_t ret_ref = (uintptr_t)ret_copy;
19902         return ret_ref;
19903 }
19904
19905 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_open_channel"))) TS_MessageSendEvent_send_open_channel(int8_tArray node_id, uint32_t msg) {
19906         LDKPublicKey node_id_ref;
19907         CHECK(node_id->arr_len == 33);
19908         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19909         LDKOpenChannel msg_conv;
19910         msg_conv.inner = (void*)(msg & (~1));
19911         msg_conv.is_owned = (msg & 1) || (msg == 0);
19912         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19913         msg_conv = OpenChannel_clone(&msg_conv);
19914         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19915         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
19916         uint32_t ret_ref = (uintptr_t)ret_copy;
19917         return ret_ref;
19918 }
19919
19920 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_funding_created"))) TS_MessageSendEvent_send_funding_created(int8_tArray node_id, uint32_t msg) {
19921         LDKPublicKey node_id_ref;
19922         CHECK(node_id->arr_len == 33);
19923         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19924         LDKFundingCreated msg_conv;
19925         msg_conv.inner = (void*)(msg & (~1));
19926         msg_conv.is_owned = (msg & 1) || (msg == 0);
19927         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19928         msg_conv = FundingCreated_clone(&msg_conv);
19929         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19930         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
19931         uint32_t ret_ref = (uintptr_t)ret_copy;
19932         return ret_ref;
19933 }
19934
19935 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_funding_signed"))) TS_MessageSendEvent_send_funding_signed(int8_tArray node_id, uint32_t msg) {
19936         LDKPublicKey node_id_ref;
19937         CHECK(node_id->arr_len == 33);
19938         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19939         LDKFundingSigned msg_conv;
19940         msg_conv.inner = (void*)(msg & (~1));
19941         msg_conv.is_owned = (msg & 1) || (msg == 0);
19942         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19943         msg_conv = FundingSigned_clone(&msg_conv);
19944         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19945         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
19946         uint32_t ret_ref = (uintptr_t)ret_copy;
19947         return ret_ref;
19948 }
19949
19950 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_funding_locked"))) TS_MessageSendEvent_send_funding_locked(int8_tArray node_id, uint32_t msg) {
19951         LDKPublicKey node_id_ref;
19952         CHECK(node_id->arr_len == 33);
19953         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19954         LDKFundingLocked msg_conv;
19955         msg_conv.inner = (void*)(msg & (~1));
19956         msg_conv.is_owned = (msg & 1) || (msg == 0);
19957         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19958         msg_conv = FundingLocked_clone(&msg_conv);
19959         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19960         *ret_copy = MessageSendEvent_send_funding_locked(node_id_ref, msg_conv);
19961         uint32_t ret_ref = (uintptr_t)ret_copy;
19962         return ret_ref;
19963 }
19964
19965 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_announcement_signatures"))) TS_MessageSendEvent_send_announcement_signatures(int8_tArray node_id, uint32_t msg) {
19966         LDKPublicKey node_id_ref;
19967         CHECK(node_id->arr_len == 33);
19968         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19969         LDKAnnouncementSignatures msg_conv;
19970         msg_conv.inner = (void*)(msg & (~1));
19971         msg_conv.is_owned = (msg & 1) || (msg == 0);
19972         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19973         msg_conv = AnnouncementSignatures_clone(&msg_conv);
19974         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19975         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
19976         uint32_t ret_ref = (uintptr_t)ret_copy;
19977         return ret_ref;
19978 }
19979
19980 uint32_t  __attribute__((export_name("TS_MessageSendEvent_update_htlcs"))) TS_MessageSendEvent_update_htlcs(int8_tArray node_id, uint32_t updates) {
19981         LDKPublicKey node_id_ref;
19982         CHECK(node_id->arr_len == 33);
19983         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19984         LDKCommitmentUpdate updates_conv;
19985         updates_conv.inner = (void*)(updates & (~1));
19986         updates_conv.is_owned = (updates & 1) || (updates == 0);
19987         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
19988         updates_conv = CommitmentUpdate_clone(&updates_conv);
19989         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19990         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
19991         uint32_t ret_ref = (uintptr_t)ret_copy;
19992         return ret_ref;
19993 }
19994
19995 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_revoke_and_ack"))) TS_MessageSendEvent_send_revoke_and_ack(int8_tArray node_id, uint32_t msg) {
19996         LDKPublicKey node_id_ref;
19997         CHECK(node_id->arr_len == 33);
19998         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19999         LDKRevokeAndACK msg_conv;
20000         msg_conv.inner = (void*)(msg & (~1));
20001         msg_conv.is_owned = (msg & 1) || (msg == 0);
20002         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20003         msg_conv = RevokeAndACK_clone(&msg_conv);
20004         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20005         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
20006         uint32_t ret_ref = (uintptr_t)ret_copy;
20007         return ret_ref;
20008 }
20009
20010 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_closing_signed"))) TS_MessageSendEvent_send_closing_signed(int8_tArray node_id, uint32_t msg) {
20011         LDKPublicKey node_id_ref;
20012         CHECK(node_id->arr_len == 33);
20013         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20014         LDKClosingSigned msg_conv;
20015         msg_conv.inner = (void*)(msg & (~1));
20016         msg_conv.is_owned = (msg & 1) || (msg == 0);
20017         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20018         msg_conv = ClosingSigned_clone(&msg_conv);
20019         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20020         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
20021         uint32_t ret_ref = (uintptr_t)ret_copy;
20022         return ret_ref;
20023 }
20024
20025 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_shutdown"))) TS_MessageSendEvent_send_shutdown(int8_tArray node_id, uint32_t msg) {
20026         LDKPublicKey node_id_ref;
20027         CHECK(node_id->arr_len == 33);
20028         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20029         LDKShutdown msg_conv;
20030         msg_conv.inner = (void*)(msg & (~1));
20031         msg_conv.is_owned = (msg & 1) || (msg == 0);
20032         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20033         msg_conv = Shutdown_clone(&msg_conv);
20034         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20035         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
20036         uint32_t ret_ref = (uintptr_t)ret_copy;
20037         return ret_ref;
20038 }
20039
20040 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_reestablish"))) TS_MessageSendEvent_send_channel_reestablish(int8_tArray node_id, uint32_t msg) {
20041         LDKPublicKey node_id_ref;
20042         CHECK(node_id->arr_len == 33);
20043         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20044         LDKChannelReestablish msg_conv;
20045         msg_conv.inner = (void*)(msg & (~1));
20046         msg_conv.is_owned = (msg & 1) || (msg == 0);
20047         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20048         msg_conv = ChannelReestablish_clone(&msg_conv);
20049         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20050         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
20051         uint32_t ret_ref = (uintptr_t)ret_copy;
20052         return ret_ref;
20053 }
20054
20055 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_channel_announcement"))) TS_MessageSendEvent_broadcast_channel_announcement(uint32_t msg, uint32_t update_msg) {
20056         LDKChannelAnnouncement msg_conv;
20057         msg_conv.inner = (void*)(msg & (~1));
20058         msg_conv.is_owned = (msg & 1) || (msg == 0);
20059         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20060         msg_conv = ChannelAnnouncement_clone(&msg_conv);
20061         LDKChannelUpdate update_msg_conv;
20062         update_msg_conv.inner = (void*)(update_msg & (~1));
20063         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
20064         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
20065         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
20066         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20067         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
20068         uint32_t ret_ref = (uintptr_t)ret_copy;
20069         return ret_ref;
20070 }
20071
20072 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_node_announcement"))) TS_MessageSendEvent_broadcast_node_announcement(uint32_t msg) {
20073         LDKNodeAnnouncement msg_conv;
20074         msg_conv.inner = (void*)(msg & (~1));
20075         msg_conv.is_owned = (msg & 1) || (msg == 0);
20076         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20077         msg_conv = NodeAnnouncement_clone(&msg_conv);
20078         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20079         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
20080         uint32_t ret_ref = (uintptr_t)ret_copy;
20081         return ret_ref;
20082 }
20083
20084 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_channel_update"))) TS_MessageSendEvent_broadcast_channel_update(uint32_t msg) {
20085         LDKChannelUpdate msg_conv;
20086         msg_conv.inner = (void*)(msg & (~1));
20087         msg_conv.is_owned = (msg & 1) || (msg == 0);
20088         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20089         msg_conv = ChannelUpdate_clone(&msg_conv);
20090         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20091         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
20092         uint32_t ret_ref = (uintptr_t)ret_copy;
20093         return ret_ref;
20094 }
20095
20096 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_update"))) TS_MessageSendEvent_send_channel_update(int8_tArray node_id, uint32_t msg) {
20097         LDKPublicKey node_id_ref;
20098         CHECK(node_id->arr_len == 33);
20099         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20100         LDKChannelUpdate msg_conv;
20101         msg_conv.inner = (void*)(msg & (~1));
20102         msg_conv.is_owned = (msg & 1) || (msg == 0);
20103         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20104         msg_conv = ChannelUpdate_clone(&msg_conv);
20105         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20106         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
20107         uint32_t ret_ref = (uintptr_t)ret_copy;
20108         return ret_ref;
20109 }
20110
20111 uint32_t  __attribute__((export_name("TS_MessageSendEvent_handle_error"))) TS_MessageSendEvent_handle_error(int8_tArray node_id, uint32_t action) {
20112         LDKPublicKey node_id_ref;
20113         CHECK(node_id->arr_len == 33);
20114         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20115         void* action_ptr = (void*)(((uintptr_t)action) & ~1);
20116         CHECK_ACCESS(action_ptr);
20117         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
20118         action_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action) & ~1));
20119         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20120         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
20121         uint32_t ret_ref = (uintptr_t)ret_copy;
20122         return ret_ref;
20123 }
20124
20125 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_range_query"))) TS_MessageSendEvent_send_channel_range_query(int8_tArray node_id, uint32_t msg) {
20126         LDKPublicKey node_id_ref;
20127         CHECK(node_id->arr_len == 33);
20128         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20129         LDKQueryChannelRange msg_conv;
20130         msg_conv.inner = (void*)(msg & (~1));
20131         msg_conv.is_owned = (msg & 1) || (msg == 0);
20132         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20133         msg_conv = QueryChannelRange_clone(&msg_conv);
20134         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20135         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
20136         uint32_t ret_ref = (uintptr_t)ret_copy;
20137         return ret_ref;
20138 }
20139
20140 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_short_ids_query"))) TS_MessageSendEvent_send_short_ids_query(int8_tArray node_id, uint32_t msg) {
20141         LDKPublicKey node_id_ref;
20142         CHECK(node_id->arr_len == 33);
20143         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20144         LDKQueryShortChannelIds msg_conv;
20145         msg_conv.inner = (void*)(msg & (~1));
20146         msg_conv.is_owned = (msg & 1) || (msg == 0);
20147         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20148         msg_conv = QueryShortChannelIds_clone(&msg_conv);
20149         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20150         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
20151         uint32_t ret_ref = (uintptr_t)ret_copy;
20152         return ret_ref;
20153 }
20154
20155 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_reply_channel_range"))) TS_MessageSendEvent_send_reply_channel_range(int8_tArray node_id, uint32_t msg) {
20156         LDKPublicKey node_id_ref;
20157         CHECK(node_id->arr_len == 33);
20158         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20159         LDKReplyChannelRange msg_conv;
20160         msg_conv.inner = (void*)(msg & (~1));
20161         msg_conv.is_owned = (msg & 1) || (msg == 0);
20162         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20163         msg_conv = ReplyChannelRange_clone(&msg_conv);
20164         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20165         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
20166         uint32_t ret_ref = (uintptr_t)ret_copy;
20167         return ret_ref;
20168 }
20169
20170 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_gossip_timestamp_filter"))) TS_MessageSendEvent_send_gossip_timestamp_filter(int8_tArray node_id, uint32_t msg) {
20171         LDKPublicKey node_id_ref;
20172         CHECK(node_id->arr_len == 33);
20173         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20174         LDKGossipTimestampFilter msg_conv;
20175         msg_conv.inner = (void*)(msg & (~1));
20176         msg_conv.is_owned = (msg & 1) || (msg == 0);
20177         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20178         msg_conv = GossipTimestampFilter_clone(&msg_conv);
20179         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20180         *ret_copy = MessageSendEvent_send_gossip_timestamp_filter(node_id_ref, msg_conv);
20181         uint32_t ret_ref = (uintptr_t)ret_copy;
20182         return ret_ref;
20183 }
20184
20185 void  __attribute__((export_name("TS_MessageSendEventsProvider_free"))) TS_MessageSendEventsProvider_free(uint32_t this_ptr) {
20186         if ((this_ptr & 1) != 0) return;
20187         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20188         CHECK_ACCESS(this_ptr_ptr);
20189         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
20190         FREE((void*)this_ptr);
20191         MessageSendEventsProvider_free(this_ptr_conv);
20192 }
20193
20194 void  __attribute__((export_name("TS_EventsProvider_free"))) TS_EventsProvider_free(uint32_t this_ptr) {
20195         if ((this_ptr & 1) != 0) return;
20196         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20197         CHECK_ACCESS(this_ptr_ptr);
20198         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
20199         FREE((void*)this_ptr);
20200         EventsProvider_free(this_ptr_conv);
20201 }
20202
20203 void  __attribute__((export_name("TS_EventHandler_free"))) TS_EventHandler_free(uint32_t this_ptr) {
20204         if ((this_ptr & 1) != 0) return;
20205         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20206         CHECK_ACCESS(this_ptr_ptr);
20207         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
20208         FREE((void*)this_ptr);
20209         EventHandler_free(this_ptr_conv);
20210 }
20211
20212 void  __attribute__((export_name("TS_APIError_free"))) TS_APIError_free(uint32_t this_ptr) {
20213         if ((this_ptr & 1) != 0) return;
20214         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20215         CHECK_ACCESS(this_ptr_ptr);
20216         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
20217         FREE((void*)this_ptr);
20218         APIError_free(this_ptr_conv);
20219 }
20220
20221 static inline uintptr_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
20222         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20223         *ret_copy = APIError_clone(arg);
20224 uint32_t ret_ref = (uintptr_t)ret_copy;
20225         return ret_ref;
20226 }
20227 uint32_t  __attribute__((export_name("TS_APIError_clone_ptr"))) TS_APIError_clone_ptr(uint32_t arg) {
20228         LDKAPIError* arg_conv = (LDKAPIError*)arg;
20229         uint32_t ret_conv = APIError_clone_ptr(arg_conv);
20230         return ret_conv;
20231 }
20232
20233 uint32_t  __attribute__((export_name("TS_APIError_clone"))) TS_APIError_clone(uint32_t orig) {
20234         LDKAPIError* orig_conv = (LDKAPIError*)orig;
20235         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20236         *ret_copy = APIError_clone(orig_conv);
20237         uint32_t ret_ref = (uintptr_t)ret_copy;
20238         return ret_ref;
20239 }
20240
20241 uint32_t  __attribute__((export_name("TS_APIError_apimisuse_error"))) TS_APIError_apimisuse_error(jstring err) {
20242         LDKStr err_conv = str_ref_to_owned_c(err);
20243         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20244         *ret_copy = APIError_apimisuse_error(err_conv);
20245         uint32_t ret_ref = (uintptr_t)ret_copy;
20246         return ret_ref;
20247 }
20248
20249 uint32_t  __attribute__((export_name("TS_APIError_fee_rate_too_high"))) TS_APIError_fee_rate_too_high(jstring err, int32_t feerate) {
20250         LDKStr err_conv = str_ref_to_owned_c(err);
20251         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20252         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
20253         uint32_t ret_ref = (uintptr_t)ret_copy;
20254         return ret_ref;
20255 }
20256
20257 uint32_t  __attribute__((export_name("TS_APIError_route_error"))) TS_APIError_route_error(jstring err) {
20258         LDKStr err_conv = str_ref_to_owned_c(err);
20259         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20260         *ret_copy = APIError_route_error(err_conv);
20261         uint32_t ret_ref = (uintptr_t)ret_copy;
20262         return ret_ref;
20263 }
20264
20265 uint32_t  __attribute__((export_name("TS_APIError_channel_unavailable"))) TS_APIError_channel_unavailable(jstring err) {
20266         LDKStr err_conv = str_ref_to_owned_c(err);
20267         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20268         *ret_copy = APIError_channel_unavailable(err_conv);
20269         uint32_t ret_ref = (uintptr_t)ret_copy;
20270         return ret_ref;
20271 }
20272
20273 uint32_t  __attribute__((export_name("TS_APIError_monitor_update_failed"))) TS_APIError_monitor_update_failed() {
20274         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20275         *ret_copy = APIError_monitor_update_failed();
20276         uint32_t ret_ref = (uintptr_t)ret_copy;
20277         return ret_ref;
20278 }
20279
20280 uint32_t  __attribute__((export_name("TS_APIError_incompatible_shutdown_script"))) TS_APIError_incompatible_shutdown_script(uint32_t script) {
20281         LDKShutdownScript script_conv;
20282         script_conv.inner = (void*)(script & (~1));
20283         script_conv.is_owned = (script & 1) || (script == 0);
20284         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
20285         script_conv = ShutdownScript_clone(&script_conv);
20286         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20287         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
20288         uint32_t ret_ref = (uintptr_t)ret_copy;
20289         return ret_ref;
20290 }
20291
20292 uint32_t  __attribute__((export_name("TS_sign"))) TS_sign(int8_tArray msg, int8_tArray sk) {
20293         LDKu8slice msg_ref;
20294         msg_ref.datalen = msg->arr_len;
20295         msg_ref.data = msg->elems /* XXX msg leaks */;
20296         unsigned char sk_arr[32];
20297         CHECK(sk->arr_len == 32);
20298         memcpy(sk_arr, sk->elems, 32); FREE(sk);
20299         unsigned char (*sk_ref)[32] = &sk_arr;
20300         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
20301         *ret_conv = sign(msg_ref, sk_ref);
20302         return (uint32_t)ret_conv;
20303 }
20304
20305 uint32_t  __attribute__((export_name("TS_recover_pk"))) TS_recover_pk(int8_tArray msg, jstring sig) {
20306         LDKu8slice msg_ref;
20307         msg_ref.datalen = msg->arr_len;
20308         msg_ref.data = msg->elems /* XXX msg leaks */;
20309         LDKStr sig_conv = str_ref_to_owned_c(sig);
20310         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
20311         *ret_conv = recover_pk(msg_ref, sig_conv);
20312         return (uint32_t)ret_conv;
20313 }
20314
20315 jboolean  __attribute__((export_name("TS_verify"))) TS_verify(int8_tArray msg, jstring sig, int8_tArray pk) {
20316         LDKu8slice msg_ref;
20317         msg_ref.datalen = msg->arr_len;
20318         msg_ref.data = msg->elems /* XXX msg leaks */;
20319         LDKStr sig_conv = str_ref_to_owned_c(sig);
20320         LDKPublicKey pk_ref;
20321         CHECK(pk->arr_len == 33);
20322         memcpy(pk_ref.compressed_form, pk->elems, 33); FREE(pk);
20323         jboolean ret_conv = verify(msg_ref, sig_conv, pk_ref);
20324         return ret_conv;
20325 }
20326
20327 int8_tArray  __attribute__((export_name("TS_construct_invoice_preimage"))) TS_construct_invoice_preimage(int8_tArray hrp_bytes, ptrArray data_without_signature) {
20328         LDKu8slice hrp_bytes_ref;
20329         hrp_bytes_ref.datalen = hrp_bytes->arr_len;
20330         hrp_bytes_ref.data = hrp_bytes->elems /* XXX hrp_bytes leaks */;
20331         LDKCVec_u5Z data_without_signature_constr;
20332         data_without_signature_constr.datalen = data_without_signature->arr_len;
20333         if (data_without_signature_constr.datalen > 0)
20334                 data_without_signature_constr.data = MALLOC(data_without_signature_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
20335         else
20336                 data_without_signature_constr.data = NULL;
20337         int8_t* data_without_signature_vals = (void*) data_without_signature->elems /* XXX data_without_signature leaks */;
20338         for (size_t h = 0; h < data_without_signature_constr.datalen; h++) {
20339                 int8_t data_without_signature_conv_7 = data_without_signature_vals[h];
20340                 
20341                 data_without_signature_constr.data[h] = (LDKu5){ ._0 = data_without_signature_conv_7 };
20342         }
20343         LDKCVec_u8Z ret_var = construct_invoice_preimage(hrp_bytes_ref, data_without_signature_constr);
20344         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
20345         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
20346         CVec_u8Z_free(ret_var);
20347         return ret_arr;
20348 }
20349
20350 uint32_t  __attribute__((export_name("TS_Level_clone"))) TS_Level_clone(uint32_t orig) {
20351         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
20352         uint32_t ret_conv = LDKLevel_to_js(Level_clone(orig_conv));
20353         return ret_conv;
20354 }
20355
20356 uint32_t  __attribute__((export_name("TS_Level_gossip"))) TS_Level_gossip() {
20357         uint32_t ret_conv = LDKLevel_to_js(Level_gossip());
20358         return ret_conv;
20359 }
20360
20361 uint32_t  __attribute__((export_name("TS_Level_trace"))) TS_Level_trace() {
20362         uint32_t ret_conv = LDKLevel_to_js(Level_trace());
20363         return ret_conv;
20364 }
20365
20366 uint32_t  __attribute__((export_name("TS_Level_debug"))) TS_Level_debug() {
20367         uint32_t ret_conv = LDKLevel_to_js(Level_debug());
20368         return ret_conv;
20369 }
20370
20371 uint32_t  __attribute__((export_name("TS_Level_info"))) TS_Level_info() {
20372         uint32_t ret_conv = LDKLevel_to_js(Level_info());
20373         return ret_conv;
20374 }
20375
20376 uint32_t  __attribute__((export_name("TS_Level_warn"))) TS_Level_warn() {
20377         uint32_t ret_conv = LDKLevel_to_js(Level_warn());
20378         return ret_conv;
20379 }
20380
20381 uint32_t  __attribute__((export_name("TS_Level_error"))) TS_Level_error() {
20382         uint32_t ret_conv = LDKLevel_to_js(Level_error());
20383         return ret_conv;
20384 }
20385
20386 jboolean  __attribute__((export_name("TS_Level_eq"))) TS_Level_eq(uint32_t a, uint32_t b) {
20387         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
20388         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
20389         jboolean ret_conv = Level_eq(a_conv, b_conv);
20390         return ret_conv;
20391 }
20392
20393 int64_t  __attribute__((export_name("TS_Level_hash"))) TS_Level_hash(uint32_t o) {
20394         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
20395         int64_t ret_conv = Level_hash(o_conv);
20396         return ret_conv;
20397 }
20398
20399 uint32_t  __attribute__((export_name("TS_Level_max"))) TS_Level_max() {
20400         uint32_t ret_conv = LDKLevel_to_js(Level_max());
20401         return ret_conv;
20402 }
20403
20404 void  __attribute__((export_name("TS_Record_free"))) TS_Record_free(uint32_t this_obj) {
20405         LDKRecord this_obj_conv;
20406         this_obj_conv.inner = (void*)(this_obj & (~1));
20407         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20409         Record_free(this_obj_conv);
20410 }
20411
20412 uint32_t  __attribute__((export_name("TS_Record_get_level"))) TS_Record_get_level(uint32_t this_ptr) {
20413         LDKRecord this_ptr_conv;
20414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20415         this_ptr_conv.is_owned = false;
20416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20417         uint32_t ret_conv = LDKLevel_to_js(Record_get_level(&this_ptr_conv));
20418         return ret_conv;
20419 }
20420
20421 void  __attribute__((export_name("TS_Record_set_level"))) TS_Record_set_level(uint32_t this_ptr, uint32_t val) {
20422         LDKRecord this_ptr_conv;
20423         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20424         this_ptr_conv.is_owned = false;
20425         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20426         LDKLevel val_conv = LDKLevel_from_js(val);
20427         Record_set_level(&this_ptr_conv, val_conv);
20428 }
20429
20430 jstring  __attribute__((export_name("TS_Record_get_args"))) TS_Record_get_args(uint32_t this_ptr) {
20431         LDKRecord this_ptr_conv;
20432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20433         this_ptr_conv.is_owned = false;
20434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20435         LDKStr ret_str = Record_get_args(&this_ptr_conv);
20436         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
20437         Str_free(ret_str);
20438         return ret_conv;
20439 }
20440
20441 void  __attribute__((export_name("TS_Record_set_args"))) TS_Record_set_args(uint32_t this_ptr, jstring val) {
20442         LDKRecord this_ptr_conv;
20443         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20444         this_ptr_conv.is_owned = false;
20445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20446         LDKStr val_conv = str_ref_to_owned_c(val);
20447         Record_set_args(&this_ptr_conv, val_conv);
20448 }
20449
20450 jstring  __attribute__((export_name("TS_Record_get_module_path"))) TS_Record_get_module_path(uint32_t this_ptr) {
20451         LDKRecord this_ptr_conv;
20452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20453         this_ptr_conv.is_owned = false;
20454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20455         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
20456         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
20457         Str_free(ret_str);
20458         return ret_conv;
20459 }
20460
20461 void  __attribute__((export_name("TS_Record_set_module_path"))) TS_Record_set_module_path(uint32_t this_ptr, jstring val) {
20462         LDKRecord this_ptr_conv;
20463         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20464         this_ptr_conv.is_owned = false;
20465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20466         LDKStr val_conv = str_ref_to_owned_c(val);
20467         Record_set_module_path(&this_ptr_conv, val_conv);
20468 }
20469
20470 jstring  __attribute__((export_name("TS_Record_get_file"))) TS_Record_get_file(uint32_t this_ptr) {
20471         LDKRecord this_ptr_conv;
20472         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20473         this_ptr_conv.is_owned = false;
20474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20475         LDKStr ret_str = Record_get_file(&this_ptr_conv);
20476         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
20477         Str_free(ret_str);
20478         return ret_conv;
20479 }
20480
20481 void  __attribute__((export_name("TS_Record_set_file"))) TS_Record_set_file(uint32_t this_ptr, jstring val) {
20482         LDKRecord this_ptr_conv;
20483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20484         this_ptr_conv.is_owned = false;
20485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20486         LDKStr val_conv = str_ref_to_owned_c(val);
20487         Record_set_file(&this_ptr_conv, val_conv);
20488 }
20489
20490 int32_t  __attribute__((export_name("TS_Record_get_line"))) TS_Record_get_line(uint32_t this_ptr) {
20491         LDKRecord this_ptr_conv;
20492         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20493         this_ptr_conv.is_owned = false;
20494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20495         int32_t ret_conv = Record_get_line(&this_ptr_conv);
20496         return ret_conv;
20497 }
20498
20499 void  __attribute__((export_name("TS_Record_set_line"))) TS_Record_set_line(uint32_t this_ptr, int32_t val) {
20500         LDKRecord this_ptr_conv;
20501         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20502         this_ptr_conv.is_owned = false;
20503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20504         Record_set_line(&this_ptr_conv, val);
20505 }
20506
20507 static inline uintptr_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
20508         LDKRecord ret_var = Record_clone(arg);
20509 uint32_t ret_ref = 0;
20510 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20511 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20512 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20513 ret_ref = (uintptr_t)ret_var.inner;
20514 if (ret_var.is_owned) {
20515         ret_ref |= 1;
20516 }
20517         return ret_ref;
20518 }
20519 uint32_t  __attribute__((export_name("TS_Record_clone_ptr"))) TS_Record_clone_ptr(uint32_t arg) {
20520         LDKRecord arg_conv;
20521         arg_conv.inner = (void*)(arg & (~1));
20522         arg_conv.is_owned = false;
20523         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20524         uint32_t ret_conv = Record_clone_ptr(&arg_conv);
20525         return ret_conv;
20526 }
20527
20528 uint32_t  __attribute__((export_name("TS_Record_clone"))) TS_Record_clone(uint32_t orig) {
20529         LDKRecord orig_conv;
20530         orig_conv.inner = (void*)(orig & (~1));
20531         orig_conv.is_owned = false;
20532         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20533         LDKRecord ret_var = Record_clone(&orig_conv);
20534         uint32_t ret_ref = 0;
20535         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20536         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20537         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20538         ret_ref = (uintptr_t)ret_var.inner;
20539         if (ret_var.is_owned) {
20540                 ret_ref |= 1;
20541         }
20542         return ret_ref;
20543 }
20544
20545 void  __attribute__((export_name("TS_Logger_free"))) TS_Logger_free(uint32_t this_ptr) {
20546         if ((this_ptr & 1) != 0) return;
20547         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20548         CHECK_ACCESS(this_ptr_ptr);
20549         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
20550         FREE((void*)this_ptr);
20551         Logger_free(this_ptr_conv);
20552 }
20553
20554 void  __attribute__((export_name("TS_ChannelHandshakeConfig_free"))) TS_ChannelHandshakeConfig_free(uint32_t this_obj) {
20555         LDKChannelHandshakeConfig this_obj_conv;
20556         this_obj_conv.inner = (void*)(this_obj & (~1));
20557         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20559         ChannelHandshakeConfig_free(this_obj_conv);
20560 }
20561
20562 int32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_minimum_depth"))) TS_ChannelHandshakeConfig_get_minimum_depth(uint32_t this_ptr) {
20563         LDKChannelHandshakeConfig this_ptr_conv;
20564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20565         this_ptr_conv.is_owned = false;
20566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20567         int32_t ret_conv = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
20568         return ret_conv;
20569 }
20570
20571 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_minimum_depth"))) TS_ChannelHandshakeConfig_set_minimum_depth(uint32_t this_ptr, int32_t val) {
20572         LDKChannelHandshakeConfig this_ptr_conv;
20573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20574         this_ptr_conv.is_owned = false;
20575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20576         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
20577 }
20578
20579 int16_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_our_to_self_delay"))) TS_ChannelHandshakeConfig_get_our_to_self_delay(uint32_t this_ptr) {
20580         LDKChannelHandshakeConfig this_ptr_conv;
20581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20582         this_ptr_conv.is_owned = false;
20583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20584         int16_t ret_conv = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
20585         return ret_conv;
20586 }
20587
20588 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) {
20589         LDKChannelHandshakeConfig this_ptr_conv;
20590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20591         this_ptr_conv.is_owned = false;
20592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20593         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
20594 }
20595
20596 int64_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat"))) TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat(uint32_t this_ptr) {
20597         LDKChannelHandshakeConfig this_ptr_conv;
20598         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20599         this_ptr_conv.is_owned = false;
20600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20601         int64_t ret_conv = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
20602         return ret_conv;
20603 }
20604
20605 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) {
20606         LDKChannelHandshakeConfig this_ptr_conv;
20607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20608         this_ptr_conv.is_owned = false;
20609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20610         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
20611 }
20612
20613 jboolean  __attribute__((export_name("TS_ChannelHandshakeConfig_get_negotiate_scid_privacy"))) TS_ChannelHandshakeConfig_get_negotiate_scid_privacy(uint32_t this_ptr) {
20614         LDKChannelHandshakeConfig this_ptr_conv;
20615         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20616         this_ptr_conv.is_owned = false;
20617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20618         jboolean ret_conv = ChannelHandshakeConfig_get_negotiate_scid_privacy(&this_ptr_conv);
20619         return ret_conv;
20620 }
20621
20622 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_negotiate_scid_privacy"))) TS_ChannelHandshakeConfig_set_negotiate_scid_privacy(uint32_t this_ptr, jboolean val) {
20623         LDKChannelHandshakeConfig this_ptr_conv;
20624         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20625         this_ptr_conv.is_owned = false;
20626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20627         ChannelHandshakeConfig_set_negotiate_scid_privacy(&this_ptr_conv, val);
20628 }
20629
20630 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, jboolean negotiate_scid_privacy_arg) {
20631         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg, negotiate_scid_privacy_arg);
20632         uint32_t ret_ref = 0;
20633         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20634         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20635         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20636         ret_ref = (uintptr_t)ret_var.inner;
20637         if (ret_var.is_owned) {
20638                 ret_ref |= 1;
20639         }
20640         return ret_ref;
20641 }
20642
20643 static inline uintptr_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
20644         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
20645 uint32_t ret_ref = 0;
20646 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20647 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20648 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20649 ret_ref = (uintptr_t)ret_var.inner;
20650 if (ret_var.is_owned) {
20651         ret_ref |= 1;
20652 }
20653         return ret_ref;
20654 }
20655 uint32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_clone_ptr"))) TS_ChannelHandshakeConfig_clone_ptr(uint32_t arg) {
20656         LDKChannelHandshakeConfig arg_conv;
20657         arg_conv.inner = (void*)(arg & (~1));
20658         arg_conv.is_owned = false;
20659         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20660         uint32_t ret_conv = ChannelHandshakeConfig_clone_ptr(&arg_conv);
20661         return ret_conv;
20662 }
20663
20664 uint32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_clone"))) TS_ChannelHandshakeConfig_clone(uint32_t orig) {
20665         LDKChannelHandshakeConfig orig_conv;
20666         orig_conv.inner = (void*)(orig & (~1));
20667         orig_conv.is_owned = false;
20668         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20669         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
20670         uint32_t ret_ref = 0;
20671         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20672         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20673         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20674         ret_ref = (uintptr_t)ret_var.inner;
20675         if (ret_var.is_owned) {
20676                 ret_ref |= 1;
20677         }
20678         return ret_ref;
20679 }
20680
20681 uint32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_default"))) TS_ChannelHandshakeConfig_default() {
20682         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
20683         uint32_t ret_ref = 0;
20684         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20685         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20686         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20687         ret_ref = (uintptr_t)ret_var.inner;
20688         if (ret_var.is_owned) {
20689                 ret_ref |= 1;
20690         }
20691         return ret_ref;
20692 }
20693
20694 void  __attribute__((export_name("TS_ChannelHandshakeLimits_free"))) TS_ChannelHandshakeLimits_free(uint32_t this_obj) {
20695         LDKChannelHandshakeLimits this_obj_conv;
20696         this_obj_conv.inner = (void*)(this_obj & (~1));
20697         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20699         ChannelHandshakeLimits_free(this_obj_conv);
20700 }
20701
20702 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_min_funding_satoshis"))) TS_ChannelHandshakeLimits_get_min_funding_satoshis(uint32_t this_ptr) {
20703         LDKChannelHandshakeLimits this_ptr_conv;
20704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20705         this_ptr_conv.is_owned = false;
20706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20707         int64_t ret_conv = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
20708         return ret_conv;
20709 }
20710
20711 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_min_funding_satoshis"))) TS_ChannelHandshakeLimits_set_min_funding_satoshis(uint32_t this_ptr, int64_t val) {
20712         LDKChannelHandshakeLimits this_ptr_conv;
20713         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20714         this_ptr_conv.is_owned = false;
20715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20716         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
20717 }
20718
20719 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat"))) TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat(uint32_t this_ptr) {
20720         LDKChannelHandshakeLimits this_ptr_conv;
20721         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20722         this_ptr_conv.is_owned = false;
20723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20724         int64_t ret_conv = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
20725         return ret_conv;
20726 }
20727
20728 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) {
20729         LDKChannelHandshakeLimits this_ptr_conv;
20730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20731         this_ptr_conv.is_owned = false;
20732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20733         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
20734 }
20735
20736 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) {
20737         LDKChannelHandshakeLimits this_ptr_conv;
20738         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20739         this_ptr_conv.is_owned = false;
20740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20741         int64_t ret_conv = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
20742         return ret_conv;
20743 }
20744
20745 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) {
20746         LDKChannelHandshakeLimits this_ptr_conv;
20747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20748         this_ptr_conv.is_owned = false;
20749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20750         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
20751 }
20752
20753 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis"))) TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis(uint32_t this_ptr) {
20754         LDKChannelHandshakeLimits this_ptr_conv;
20755         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20756         this_ptr_conv.is_owned = false;
20757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20758         int64_t ret_conv = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
20759         return ret_conv;
20760 }
20761
20762 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) {
20763         LDKChannelHandshakeLimits this_ptr_conv;
20764         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20765         this_ptr_conv.is_owned = false;
20766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20767         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
20768 }
20769
20770 int16_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs"))) TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs(uint32_t this_ptr) {
20771         LDKChannelHandshakeLimits this_ptr_conv;
20772         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20773         this_ptr_conv.is_owned = false;
20774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20775         int16_t ret_conv = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
20776         return ret_conv;
20777 }
20778
20779 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) {
20780         LDKChannelHandshakeLimits this_ptr_conv;
20781         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20782         this_ptr_conv.is_owned = false;
20783         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20784         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
20785 }
20786
20787 int32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_minimum_depth"))) TS_ChannelHandshakeLimits_get_max_minimum_depth(uint32_t this_ptr) {
20788         LDKChannelHandshakeLimits this_ptr_conv;
20789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20790         this_ptr_conv.is_owned = false;
20791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20792         int32_t ret_conv = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
20793         return ret_conv;
20794 }
20795
20796 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_max_minimum_depth"))) TS_ChannelHandshakeLimits_set_max_minimum_depth(uint32_t this_ptr, int32_t val) {
20797         LDKChannelHandshakeLimits this_ptr_conv;
20798         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20799         this_ptr_conv.is_owned = false;
20800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20801         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
20802 }
20803
20804 jboolean  __attribute__((export_name("TS_ChannelHandshakeLimits_get_force_announced_channel_preference"))) TS_ChannelHandshakeLimits_get_force_announced_channel_preference(uint32_t this_ptr) {
20805         LDKChannelHandshakeLimits this_ptr_conv;
20806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20807         this_ptr_conv.is_owned = false;
20808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20809         jboolean ret_conv = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
20810         return ret_conv;
20811 }
20812
20813 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_force_announced_channel_preference"))) TS_ChannelHandshakeLimits_set_force_announced_channel_preference(uint32_t this_ptr, jboolean val) {
20814         LDKChannelHandshakeLimits this_ptr_conv;
20815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20816         this_ptr_conv.is_owned = false;
20817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20818         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
20819 }
20820
20821 int16_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_their_to_self_delay"))) TS_ChannelHandshakeLimits_get_their_to_self_delay(uint32_t this_ptr) {
20822         LDKChannelHandshakeLimits 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         int16_t ret_conv = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
20827         return ret_conv;
20828 }
20829
20830 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) {
20831         LDKChannelHandshakeLimits 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         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
20836 }
20837
20838 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_new"))) TS_ChannelHandshakeLimits_new(int64_t min_funding_satoshis_arg, int64_t max_htlc_minimum_msat_arg, int64_t min_max_htlc_value_in_flight_msat_arg, int64_t max_channel_reserve_satoshis_arg, int16_t min_max_accepted_htlcs_arg, int32_t max_minimum_depth_arg, jboolean force_announced_channel_preference_arg, int16_t their_to_self_delay_arg) {
20839         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_new(min_funding_satoshis_arg, max_htlc_minimum_msat_arg, min_max_htlc_value_in_flight_msat_arg, max_channel_reserve_satoshis_arg, min_max_accepted_htlcs_arg, max_minimum_depth_arg, force_announced_channel_preference_arg, their_to_self_delay_arg);
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 static inline uintptr_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
20852         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
20853 uint32_t ret_ref = 0;
20854 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20855 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20856 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20857 ret_ref = (uintptr_t)ret_var.inner;
20858 if (ret_var.is_owned) {
20859         ret_ref |= 1;
20860 }
20861         return ret_ref;
20862 }
20863 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_clone_ptr"))) TS_ChannelHandshakeLimits_clone_ptr(uint32_t arg) {
20864         LDKChannelHandshakeLimits arg_conv;
20865         arg_conv.inner = (void*)(arg & (~1));
20866         arg_conv.is_owned = false;
20867         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20868         uint32_t ret_conv = ChannelHandshakeLimits_clone_ptr(&arg_conv);
20869         return ret_conv;
20870 }
20871
20872 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_clone"))) TS_ChannelHandshakeLimits_clone(uint32_t orig) {
20873         LDKChannelHandshakeLimits orig_conv;
20874         orig_conv.inner = (void*)(orig & (~1));
20875         orig_conv.is_owned = false;
20876         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20877         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
20878         uint32_t ret_ref = 0;
20879         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20880         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20881         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20882         ret_ref = (uintptr_t)ret_var.inner;
20883         if (ret_var.is_owned) {
20884                 ret_ref |= 1;
20885         }
20886         return ret_ref;
20887 }
20888
20889 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_default"))) TS_ChannelHandshakeLimits_default() {
20890         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
20891         uint32_t ret_ref = 0;
20892         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20893         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20894         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20895         ret_ref = (uintptr_t)ret_var.inner;
20896         if (ret_var.is_owned) {
20897                 ret_ref |= 1;
20898         }
20899         return ret_ref;
20900 }
20901
20902 void  __attribute__((export_name("TS_ChannelConfig_free"))) TS_ChannelConfig_free(uint32_t this_obj) {
20903         LDKChannelConfig this_obj_conv;
20904         this_obj_conv.inner = (void*)(this_obj & (~1));
20905         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20907         ChannelConfig_free(this_obj_conv);
20908 }
20909
20910 int32_t  __attribute__((export_name("TS_ChannelConfig_get_forwarding_fee_proportional_millionths"))) TS_ChannelConfig_get_forwarding_fee_proportional_millionths(uint32_t this_ptr) {
20911         LDKChannelConfig this_ptr_conv;
20912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20913         this_ptr_conv.is_owned = false;
20914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20915         int32_t ret_conv = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
20916         return ret_conv;
20917 }
20918
20919 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) {
20920         LDKChannelConfig this_ptr_conv;
20921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20922         this_ptr_conv.is_owned = false;
20923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20924         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
20925 }
20926
20927 int32_t  __attribute__((export_name("TS_ChannelConfig_get_forwarding_fee_base_msat"))) TS_ChannelConfig_get_forwarding_fee_base_msat(uint32_t this_ptr) {
20928         LDKChannelConfig this_ptr_conv;
20929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20930         this_ptr_conv.is_owned = false;
20931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20932         int32_t ret_conv = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
20933         return ret_conv;
20934 }
20935
20936 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) {
20937         LDKChannelConfig this_ptr_conv;
20938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20939         this_ptr_conv.is_owned = false;
20940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20941         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
20942 }
20943
20944 int16_t  __attribute__((export_name("TS_ChannelConfig_get_cltv_expiry_delta"))) TS_ChannelConfig_get_cltv_expiry_delta(uint32_t this_ptr) {
20945         LDKChannelConfig this_ptr_conv;
20946         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20947         this_ptr_conv.is_owned = false;
20948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20949         int16_t ret_conv = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
20950         return ret_conv;
20951 }
20952
20953 void  __attribute__((export_name("TS_ChannelConfig_set_cltv_expiry_delta"))) TS_ChannelConfig_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
20954         LDKChannelConfig this_ptr_conv;
20955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20956         this_ptr_conv.is_owned = false;
20957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20958         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
20959 }
20960
20961 jboolean  __attribute__((export_name("TS_ChannelConfig_get_announced_channel"))) TS_ChannelConfig_get_announced_channel(uint32_t this_ptr) {
20962         LDKChannelConfig this_ptr_conv;
20963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20964         this_ptr_conv.is_owned = false;
20965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20966         jboolean ret_conv = ChannelConfig_get_announced_channel(&this_ptr_conv);
20967         return ret_conv;
20968 }
20969
20970 void  __attribute__((export_name("TS_ChannelConfig_set_announced_channel"))) TS_ChannelConfig_set_announced_channel(uint32_t this_ptr, jboolean val) {
20971         LDKChannelConfig this_ptr_conv;
20972         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20973         this_ptr_conv.is_owned = false;
20974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20975         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
20976 }
20977
20978 jboolean  __attribute__((export_name("TS_ChannelConfig_get_commit_upfront_shutdown_pubkey"))) TS_ChannelConfig_get_commit_upfront_shutdown_pubkey(uint32_t this_ptr) {
20979         LDKChannelConfig this_ptr_conv;
20980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20981         this_ptr_conv.is_owned = false;
20982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20983         jboolean ret_conv = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
20984         return ret_conv;
20985 }
20986
20987 void  __attribute__((export_name("TS_ChannelConfig_set_commit_upfront_shutdown_pubkey"))) TS_ChannelConfig_set_commit_upfront_shutdown_pubkey(uint32_t this_ptr, jboolean val) {
20988         LDKChannelConfig this_ptr_conv;
20989         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20990         this_ptr_conv.is_owned = false;
20991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20992         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
20993 }
20994
20995 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) {
20996         LDKChannelConfig this_ptr_conv;
20997         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20998         this_ptr_conv.is_owned = false;
20999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21000         int64_t ret_conv = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
21001         return ret_conv;
21002 }
21003
21004 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) {
21005         LDKChannelConfig this_ptr_conv;
21006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21007         this_ptr_conv.is_owned = false;
21008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21009         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
21010 }
21011
21012 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) {
21013         LDKChannelConfig this_ptr_conv;
21014         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21015         this_ptr_conv.is_owned = false;
21016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21017         int64_t ret_conv = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
21018         return ret_conv;
21019 }
21020
21021 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) {
21022         LDKChannelConfig this_ptr_conv;
21023         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21024         this_ptr_conv.is_owned = false;
21025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21026         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
21027 }
21028
21029 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) {
21030         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);
21031         uint32_t ret_ref = 0;
21032         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21033         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21034         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21035         ret_ref = (uintptr_t)ret_var.inner;
21036         if (ret_var.is_owned) {
21037                 ret_ref |= 1;
21038         }
21039         return ret_ref;
21040 }
21041
21042 static inline uintptr_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
21043         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
21044 uint32_t ret_ref = 0;
21045 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21046 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21047 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21048 ret_ref = (uintptr_t)ret_var.inner;
21049 if (ret_var.is_owned) {
21050         ret_ref |= 1;
21051 }
21052         return ret_ref;
21053 }
21054 uint32_t  __attribute__((export_name("TS_ChannelConfig_clone_ptr"))) TS_ChannelConfig_clone_ptr(uint32_t arg) {
21055         LDKChannelConfig arg_conv;
21056         arg_conv.inner = (void*)(arg & (~1));
21057         arg_conv.is_owned = false;
21058         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21059         uint32_t ret_conv = ChannelConfig_clone_ptr(&arg_conv);
21060         return ret_conv;
21061 }
21062
21063 uint32_t  __attribute__((export_name("TS_ChannelConfig_clone"))) TS_ChannelConfig_clone(uint32_t orig) {
21064         LDKChannelConfig orig_conv;
21065         orig_conv.inner = (void*)(orig & (~1));
21066         orig_conv.is_owned = false;
21067         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21068         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
21069         uint32_t ret_ref = 0;
21070         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21071         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21072         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21073         ret_ref = (uintptr_t)ret_var.inner;
21074         if (ret_var.is_owned) {
21075                 ret_ref |= 1;
21076         }
21077         return ret_ref;
21078 }
21079
21080 uint32_t  __attribute__((export_name("TS_ChannelConfig_default"))) TS_ChannelConfig_default() {
21081         LDKChannelConfig ret_var = ChannelConfig_default();
21082         uint32_t ret_ref = 0;
21083         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21084         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21085         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21086         ret_ref = (uintptr_t)ret_var.inner;
21087         if (ret_var.is_owned) {
21088                 ret_ref |= 1;
21089         }
21090         return ret_ref;
21091 }
21092
21093 int8_tArray  __attribute__((export_name("TS_ChannelConfig_write"))) TS_ChannelConfig_write(uint32_t obj) {
21094         LDKChannelConfig obj_conv;
21095         obj_conv.inner = (void*)(obj & (~1));
21096         obj_conv.is_owned = false;
21097         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
21098         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
21099         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
21100         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
21101         CVec_u8Z_free(ret_var);
21102         return ret_arr;
21103 }
21104
21105 uint32_t  __attribute__((export_name("TS_ChannelConfig_read"))) TS_ChannelConfig_read(int8_tArray ser) {
21106         LDKu8slice ser_ref;
21107         ser_ref.datalen = ser->arr_len;
21108         ser_ref.data = ser->elems /* XXX ser leaks */;
21109         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
21110         *ret_conv = ChannelConfig_read(ser_ref);
21111         return (uint32_t)ret_conv;
21112 }
21113
21114 void  __attribute__((export_name("TS_UserConfig_free"))) TS_UserConfig_free(uint32_t this_obj) {
21115         LDKUserConfig this_obj_conv;
21116         this_obj_conv.inner = (void*)(this_obj & (~1));
21117         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21119         UserConfig_free(this_obj_conv);
21120 }
21121
21122 uint32_t  __attribute__((export_name("TS_UserConfig_get_own_channel_config"))) TS_UserConfig_get_own_channel_config(uint32_t this_ptr) {
21123         LDKUserConfig this_ptr_conv;
21124         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21125         this_ptr_conv.is_owned = false;
21126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21127         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
21128         uint32_t ret_ref = 0;
21129         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21130         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21131         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21132         ret_ref = (uintptr_t)ret_var.inner;
21133         if (ret_var.is_owned) {
21134                 ret_ref |= 1;
21135         }
21136         return ret_ref;
21137 }
21138
21139 void  __attribute__((export_name("TS_UserConfig_set_own_channel_config"))) TS_UserConfig_set_own_channel_config(uint32_t this_ptr, uint32_t val) {
21140         LDKUserConfig 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         LDKChannelHandshakeConfig val_conv;
21145         val_conv.inner = (void*)(val & (~1));
21146         val_conv.is_owned = (val & 1) || (val == 0);
21147         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
21148         val_conv = ChannelHandshakeConfig_clone(&val_conv);
21149         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
21150 }
21151
21152 uint32_t  __attribute__((export_name("TS_UserConfig_get_peer_channel_config_limits"))) TS_UserConfig_get_peer_channel_config_limits(uint32_t this_ptr) {
21153         LDKUserConfig this_ptr_conv;
21154         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21155         this_ptr_conv.is_owned = false;
21156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21157         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
21158         uint32_t ret_ref = 0;
21159         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21160         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21161         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21162         ret_ref = (uintptr_t)ret_var.inner;
21163         if (ret_var.is_owned) {
21164                 ret_ref |= 1;
21165         }
21166         return ret_ref;
21167 }
21168
21169 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) {
21170         LDKUserConfig this_ptr_conv;
21171         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21172         this_ptr_conv.is_owned = false;
21173         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21174         LDKChannelHandshakeLimits val_conv;
21175         val_conv.inner = (void*)(val & (~1));
21176         val_conv.is_owned = (val & 1) || (val == 0);
21177         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
21178         val_conv = ChannelHandshakeLimits_clone(&val_conv);
21179         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
21180 }
21181
21182 uint32_t  __attribute__((export_name("TS_UserConfig_get_channel_options"))) TS_UserConfig_get_channel_options(uint32_t this_ptr) {
21183         LDKUserConfig this_ptr_conv;
21184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21185         this_ptr_conv.is_owned = false;
21186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21187         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
21188         uint32_t ret_ref = 0;
21189         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21190         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21191         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21192         ret_ref = (uintptr_t)ret_var.inner;
21193         if (ret_var.is_owned) {
21194                 ret_ref |= 1;
21195         }
21196         return ret_ref;
21197 }
21198
21199 void  __attribute__((export_name("TS_UserConfig_set_channel_options"))) TS_UserConfig_set_channel_options(uint32_t this_ptr, uint32_t val) {
21200         LDKUserConfig this_ptr_conv;
21201         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21202         this_ptr_conv.is_owned = false;
21203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21204         LDKChannelConfig val_conv;
21205         val_conv.inner = (void*)(val & (~1));
21206         val_conv.is_owned = (val & 1) || (val == 0);
21207         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
21208         val_conv = ChannelConfig_clone(&val_conv);
21209         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
21210 }
21211
21212 jboolean  __attribute__((export_name("TS_UserConfig_get_accept_forwards_to_priv_channels"))) TS_UserConfig_get_accept_forwards_to_priv_channels(uint32_t this_ptr) {
21213         LDKUserConfig this_ptr_conv;
21214         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21215         this_ptr_conv.is_owned = false;
21216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21217         jboolean ret_conv = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
21218         return ret_conv;
21219 }
21220
21221 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) {
21222         LDKUserConfig this_ptr_conv;
21223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21224         this_ptr_conv.is_owned = false;
21225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21226         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
21227 }
21228
21229 jboolean  __attribute__((export_name("TS_UserConfig_get_accept_inbound_channels"))) TS_UserConfig_get_accept_inbound_channels(uint32_t this_ptr) {
21230         LDKUserConfig this_ptr_conv;
21231         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21232         this_ptr_conv.is_owned = false;
21233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21234         jboolean ret_conv = UserConfig_get_accept_inbound_channels(&this_ptr_conv);
21235         return ret_conv;
21236 }
21237
21238 void  __attribute__((export_name("TS_UserConfig_set_accept_inbound_channels"))) TS_UserConfig_set_accept_inbound_channels(uint32_t this_ptr, jboolean val) {
21239         LDKUserConfig this_ptr_conv;
21240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21241         this_ptr_conv.is_owned = false;
21242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21243         UserConfig_set_accept_inbound_channels(&this_ptr_conv, val);
21244 }
21245
21246 jboolean  __attribute__((export_name("TS_UserConfig_get_manually_accept_inbound_channels"))) TS_UserConfig_get_manually_accept_inbound_channels(uint32_t this_ptr) {
21247         LDKUserConfig this_ptr_conv;
21248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21249         this_ptr_conv.is_owned = false;
21250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21251         jboolean ret_conv = UserConfig_get_manually_accept_inbound_channels(&this_ptr_conv);
21252         return ret_conv;
21253 }
21254
21255 void  __attribute__((export_name("TS_UserConfig_set_manually_accept_inbound_channels"))) TS_UserConfig_set_manually_accept_inbound_channels(uint32_t this_ptr, jboolean val) {
21256         LDKUserConfig this_ptr_conv;
21257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21258         this_ptr_conv.is_owned = false;
21259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21260         UserConfig_set_manually_accept_inbound_channels(&this_ptr_conv, val);
21261 }
21262
21263 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) {
21264         LDKChannelHandshakeConfig own_channel_config_arg_conv;
21265         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
21266         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
21267         CHECK_INNER_FIELD_ACCESS_OR_NULL(own_channel_config_arg_conv);
21268         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
21269         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
21270         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
21271         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
21272         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_channel_config_limits_arg_conv);
21273         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
21274         LDKChannelConfig channel_options_arg_conv;
21275         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
21276         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
21277         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_options_arg_conv);
21278         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
21279         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);
21280         uint32_t ret_ref = 0;
21281         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21282         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21283         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21284         ret_ref = (uintptr_t)ret_var.inner;
21285         if (ret_var.is_owned) {
21286                 ret_ref |= 1;
21287         }
21288         return ret_ref;
21289 }
21290
21291 static inline uintptr_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
21292         LDKUserConfig ret_var = UserConfig_clone(arg);
21293 uint32_t ret_ref = 0;
21294 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21295 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21296 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21297 ret_ref = (uintptr_t)ret_var.inner;
21298 if (ret_var.is_owned) {
21299         ret_ref |= 1;
21300 }
21301         return ret_ref;
21302 }
21303 uint32_t  __attribute__((export_name("TS_UserConfig_clone_ptr"))) TS_UserConfig_clone_ptr(uint32_t arg) {
21304         LDKUserConfig arg_conv;
21305         arg_conv.inner = (void*)(arg & (~1));
21306         arg_conv.is_owned = false;
21307         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21308         uint32_t ret_conv = UserConfig_clone_ptr(&arg_conv);
21309         return ret_conv;
21310 }
21311
21312 uint32_t  __attribute__((export_name("TS_UserConfig_clone"))) TS_UserConfig_clone(uint32_t orig) {
21313         LDKUserConfig orig_conv;
21314         orig_conv.inner = (void*)(orig & (~1));
21315         orig_conv.is_owned = false;
21316         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21317         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
21318         uint32_t ret_ref = 0;
21319         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21320         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21321         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21322         ret_ref = (uintptr_t)ret_var.inner;
21323         if (ret_var.is_owned) {
21324                 ret_ref |= 1;
21325         }
21326         return ret_ref;
21327 }
21328
21329 uint32_t  __attribute__((export_name("TS_UserConfig_default"))) TS_UserConfig_default() {
21330         LDKUserConfig ret_var = UserConfig_default();
21331         uint32_t ret_ref = 0;
21332         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21333         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21334         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21335         ret_ref = (uintptr_t)ret_var.inner;
21336         if (ret_var.is_owned) {
21337                 ret_ref |= 1;
21338         }
21339         return ret_ref;
21340 }
21341
21342 void  __attribute__((export_name("TS_BestBlock_free"))) TS_BestBlock_free(uint32_t this_obj) {
21343         LDKBestBlock this_obj_conv;
21344         this_obj_conv.inner = (void*)(this_obj & (~1));
21345         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21347         BestBlock_free(this_obj_conv);
21348 }
21349
21350 static inline uintptr_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
21351         LDKBestBlock ret_var = BestBlock_clone(arg);
21352 uint32_t ret_ref = 0;
21353 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21354 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21355 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21356 ret_ref = (uintptr_t)ret_var.inner;
21357 if (ret_var.is_owned) {
21358         ret_ref |= 1;
21359 }
21360         return ret_ref;
21361 }
21362 uint32_t  __attribute__((export_name("TS_BestBlock_clone_ptr"))) TS_BestBlock_clone_ptr(uint32_t arg) {
21363         LDKBestBlock arg_conv;
21364         arg_conv.inner = (void*)(arg & (~1));
21365         arg_conv.is_owned = false;
21366         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21367         uint32_t ret_conv = BestBlock_clone_ptr(&arg_conv);
21368         return ret_conv;
21369 }
21370
21371 uint32_t  __attribute__((export_name("TS_BestBlock_clone"))) TS_BestBlock_clone(uint32_t orig) {
21372         LDKBestBlock orig_conv;
21373         orig_conv.inner = (void*)(orig & (~1));
21374         orig_conv.is_owned = false;
21375         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21376         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
21377         uint32_t ret_ref = 0;
21378         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21379         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21380         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21381         ret_ref = (uintptr_t)ret_var.inner;
21382         if (ret_var.is_owned) {
21383                 ret_ref |= 1;
21384         }
21385         return ret_ref;
21386 }
21387
21388 uint32_t  __attribute__((export_name("TS_BestBlock_from_genesis"))) TS_BestBlock_from_genesis(uint32_t network) {
21389         LDKNetwork network_conv = LDKNetwork_from_js(network);
21390         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
21391         uint32_t ret_ref = 0;
21392         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21393         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21394         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21395         ret_ref = (uintptr_t)ret_var.inner;
21396         if (ret_var.is_owned) {
21397                 ret_ref |= 1;
21398         }
21399         return ret_ref;
21400 }
21401
21402 uint32_t  __attribute__((export_name("TS_BestBlock_new"))) TS_BestBlock_new(int8_tArray block_hash, int32_t height) {
21403         LDKThirtyTwoBytes block_hash_ref;
21404         CHECK(block_hash->arr_len == 32);
21405         memcpy(block_hash_ref.data, block_hash->elems, 32); FREE(block_hash);
21406         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
21407         uint32_t ret_ref = 0;
21408         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21409         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21410         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21411         ret_ref = (uintptr_t)ret_var.inner;
21412         if (ret_var.is_owned) {
21413                 ret_ref |= 1;
21414         }
21415         return ret_ref;
21416 }
21417
21418 int8_tArray  __attribute__((export_name("TS_BestBlock_block_hash"))) TS_BestBlock_block_hash(uint32_t this_arg) {
21419         LDKBestBlock this_arg_conv;
21420         this_arg_conv.inner = (void*)(this_arg & (~1));
21421         this_arg_conv.is_owned = false;
21422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21423         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
21424         memcpy(ret_arr->elems, BestBlock_block_hash(&this_arg_conv).data, 32);
21425         return ret_arr;
21426 }
21427
21428 int32_t  __attribute__((export_name("TS_BestBlock_height"))) TS_BestBlock_height(uint32_t this_arg) {
21429         LDKBestBlock this_arg_conv;
21430         this_arg_conv.inner = (void*)(this_arg & (~1));
21431         this_arg_conv.is_owned = false;
21432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21433         int32_t ret_conv = BestBlock_height(&this_arg_conv);
21434         return ret_conv;
21435 }
21436
21437 uint32_t  __attribute__((export_name("TS_AccessError_clone"))) TS_AccessError_clone(uint32_t orig) {
21438         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
21439         uint32_t ret_conv = LDKAccessError_to_js(AccessError_clone(orig_conv));
21440         return ret_conv;
21441 }
21442
21443 uint32_t  __attribute__((export_name("TS_AccessError_unknown_chain"))) TS_AccessError_unknown_chain() {
21444         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_chain());
21445         return ret_conv;
21446 }
21447
21448 uint32_t  __attribute__((export_name("TS_AccessError_unknown_tx"))) TS_AccessError_unknown_tx() {
21449         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_tx());
21450         return ret_conv;
21451 }
21452
21453 void  __attribute__((export_name("TS_Access_free"))) TS_Access_free(uint32_t this_ptr) {
21454         if ((this_ptr & 1) != 0) return;
21455         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21456         CHECK_ACCESS(this_ptr_ptr);
21457         LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
21458         FREE((void*)this_ptr);
21459         Access_free(this_ptr_conv);
21460 }
21461
21462 void  __attribute__((export_name("TS_Listen_free"))) TS_Listen_free(uint32_t this_ptr) {
21463         if ((this_ptr & 1) != 0) return;
21464         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21465         CHECK_ACCESS(this_ptr_ptr);
21466         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
21467         FREE((void*)this_ptr);
21468         Listen_free(this_ptr_conv);
21469 }
21470
21471 void  __attribute__((export_name("TS_Confirm_free"))) TS_Confirm_free(uint32_t this_ptr) {
21472         if ((this_ptr & 1) != 0) return;
21473         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21474         CHECK_ACCESS(this_ptr_ptr);
21475         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
21476         FREE((void*)this_ptr);
21477         Confirm_free(this_ptr_conv);
21478 }
21479
21480 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_clone"))) TS_ChannelMonitorUpdateErr_clone(uint32_t orig) {
21481         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
21482         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_clone(orig_conv));
21483         return ret_conv;
21484 }
21485
21486 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_temporary_failure"))) TS_ChannelMonitorUpdateErr_temporary_failure() {
21487         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_temporary_failure());
21488         return ret_conv;
21489 }
21490
21491 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_permanent_failure"))) TS_ChannelMonitorUpdateErr_permanent_failure() {
21492         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_permanent_failure());
21493         return ret_conv;
21494 }
21495
21496 void  __attribute__((export_name("TS_Watch_free"))) TS_Watch_free(uint32_t this_ptr) {
21497         if ((this_ptr & 1) != 0) return;
21498         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21499         CHECK_ACCESS(this_ptr_ptr);
21500         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
21501         FREE((void*)this_ptr);
21502         Watch_free(this_ptr_conv);
21503 }
21504
21505 void  __attribute__((export_name("TS_Filter_free"))) TS_Filter_free(uint32_t this_ptr) {
21506         if ((this_ptr & 1) != 0) return;
21507         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21508         CHECK_ACCESS(this_ptr_ptr);
21509         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
21510         FREE((void*)this_ptr);
21511         Filter_free(this_ptr_conv);
21512 }
21513
21514 void  __attribute__((export_name("TS_WatchedOutput_free"))) TS_WatchedOutput_free(uint32_t this_obj) {
21515         LDKWatchedOutput this_obj_conv;
21516         this_obj_conv.inner = (void*)(this_obj & (~1));
21517         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21519         WatchedOutput_free(this_obj_conv);
21520 }
21521
21522 int8_tArray  __attribute__((export_name("TS_WatchedOutput_get_block_hash"))) TS_WatchedOutput_get_block_hash(uint32_t this_ptr) {
21523         LDKWatchedOutput this_ptr_conv;
21524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21525         this_ptr_conv.is_owned = false;
21526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21527         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
21528         memcpy(ret_arr->elems, WatchedOutput_get_block_hash(&this_ptr_conv).data, 32);
21529         return ret_arr;
21530 }
21531
21532 void  __attribute__((export_name("TS_WatchedOutput_set_block_hash"))) TS_WatchedOutput_set_block_hash(uint32_t this_ptr, int8_tArray val) {
21533         LDKWatchedOutput this_ptr_conv;
21534         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21535         this_ptr_conv.is_owned = false;
21536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21537         LDKThirtyTwoBytes val_ref;
21538         CHECK(val->arr_len == 32);
21539         memcpy(val_ref.data, val->elems, 32); FREE(val);
21540         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
21541 }
21542
21543 uint32_t  __attribute__((export_name("TS_WatchedOutput_get_outpoint"))) TS_WatchedOutput_get_outpoint(uint32_t this_ptr) {
21544         LDKWatchedOutput this_ptr_conv;
21545         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21546         this_ptr_conv.is_owned = false;
21547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21548         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
21549         uint32_t ret_ref = 0;
21550         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21551         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21552         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21553         ret_ref = (uintptr_t)ret_var.inner;
21554         if (ret_var.is_owned) {
21555                 ret_ref |= 1;
21556         }
21557         return ret_ref;
21558 }
21559
21560 void  __attribute__((export_name("TS_WatchedOutput_set_outpoint"))) TS_WatchedOutput_set_outpoint(uint32_t this_ptr, uint32_t val) {
21561         LDKWatchedOutput this_ptr_conv;
21562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21563         this_ptr_conv.is_owned = false;
21564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21565         LDKOutPoint val_conv;
21566         val_conv.inner = (void*)(val & (~1));
21567         val_conv.is_owned = (val & 1) || (val == 0);
21568         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
21569         val_conv = OutPoint_clone(&val_conv);
21570         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
21571 }
21572
21573 int8_tArray  __attribute__((export_name("TS_WatchedOutput_get_script_pubkey"))) TS_WatchedOutput_get_script_pubkey(uint32_t this_ptr) {
21574         LDKWatchedOutput this_ptr_conv;
21575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21576         this_ptr_conv.is_owned = false;
21577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21578         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
21579         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
21580         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
21581         return ret_arr;
21582 }
21583
21584 void  __attribute__((export_name("TS_WatchedOutput_set_script_pubkey"))) TS_WatchedOutput_set_script_pubkey(uint32_t this_ptr, int8_tArray val) {
21585         LDKWatchedOutput this_ptr_conv;
21586         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21587         this_ptr_conv.is_owned = false;
21588         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21589         LDKCVec_u8Z val_ref;
21590         val_ref.datalen = val->arr_len;
21591         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
21592         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
21593         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
21594 }
21595
21596 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) {
21597         LDKThirtyTwoBytes block_hash_arg_ref;
21598         CHECK(block_hash_arg->arr_len == 32);
21599         memcpy(block_hash_arg_ref.data, block_hash_arg->elems, 32); FREE(block_hash_arg);
21600         LDKOutPoint outpoint_arg_conv;
21601         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
21602         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
21603         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
21604         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
21605         LDKCVec_u8Z script_pubkey_arg_ref;
21606         script_pubkey_arg_ref.datalen = script_pubkey_arg->arr_len;
21607         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
21608         memcpy(script_pubkey_arg_ref.data, script_pubkey_arg->elems, script_pubkey_arg_ref.datalen); FREE(script_pubkey_arg);
21609         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
21610         uint32_t ret_ref = 0;
21611         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21612         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21613         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21614         ret_ref = (uintptr_t)ret_var.inner;
21615         if (ret_var.is_owned) {
21616                 ret_ref |= 1;
21617         }
21618         return ret_ref;
21619 }
21620
21621 static inline uintptr_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
21622         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
21623 uint32_t ret_ref = 0;
21624 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21625 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21626 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21627 ret_ref = (uintptr_t)ret_var.inner;
21628 if (ret_var.is_owned) {
21629         ret_ref |= 1;
21630 }
21631         return ret_ref;
21632 }
21633 uint32_t  __attribute__((export_name("TS_WatchedOutput_clone_ptr"))) TS_WatchedOutput_clone_ptr(uint32_t arg) {
21634         LDKWatchedOutput arg_conv;
21635         arg_conv.inner = (void*)(arg & (~1));
21636         arg_conv.is_owned = false;
21637         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21638         uint32_t ret_conv = WatchedOutput_clone_ptr(&arg_conv);
21639         return ret_conv;
21640 }
21641
21642 uint32_t  __attribute__((export_name("TS_WatchedOutput_clone"))) TS_WatchedOutput_clone(uint32_t orig) {
21643         LDKWatchedOutput orig_conv;
21644         orig_conv.inner = (void*)(orig & (~1));
21645         orig_conv.is_owned = false;
21646         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21647         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
21648         uint32_t ret_ref = 0;
21649         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21650         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21651         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21652         ret_ref = (uintptr_t)ret_var.inner;
21653         if (ret_var.is_owned) {
21654                 ret_ref |= 1;
21655         }
21656         return ret_ref;
21657 }
21658
21659 int64_t  __attribute__((export_name("TS_WatchedOutput_hash"))) TS_WatchedOutput_hash(uint32_t o) {
21660         LDKWatchedOutput o_conv;
21661         o_conv.inner = (void*)(o & (~1));
21662         o_conv.is_owned = false;
21663         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21664         int64_t ret_conv = WatchedOutput_hash(&o_conv);
21665         return ret_conv;
21666 }
21667
21668 void  __attribute__((export_name("TS_BroadcasterInterface_free"))) TS_BroadcasterInterface_free(uint32_t this_ptr) {
21669         if ((this_ptr & 1) != 0) return;
21670         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21671         CHECK_ACCESS(this_ptr_ptr);
21672         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
21673         FREE((void*)this_ptr);
21674         BroadcasterInterface_free(this_ptr_conv);
21675 }
21676
21677 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_clone"))) TS_ConfirmationTarget_clone(uint32_t orig) {
21678         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
21679         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_clone(orig_conv));
21680         return ret_conv;
21681 }
21682
21683 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_background"))) TS_ConfirmationTarget_background() {
21684         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_background());
21685         return ret_conv;
21686 }
21687
21688 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_normal"))) TS_ConfirmationTarget_normal() {
21689         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_normal());
21690         return ret_conv;
21691 }
21692
21693 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_high_priority"))) TS_ConfirmationTarget_high_priority() {
21694         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_high_priority());
21695         return ret_conv;
21696 }
21697
21698 jboolean  __attribute__((export_name("TS_ConfirmationTarget_eq"))) TS_ConfirmationTarget_eq(uint32_t a, uint32_t b) {
21699         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1);
21700         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1);
21701         jboolean ret_conv = ConfirmationTarget_eq(a_conv, b_conv);
21702         return ret_conv;
21703 }
21704
21705 void  __attribute__((export_name("TS_FeeEstimator_free"))) TS_FeeEstimator_free(uint32_t this_ptr) {
21706         if ((this_ptr & 1) != 0) return;
21707         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21708         CHECK_ACCESS(this_ptr_ptr);
21709         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
21710         FREE((void*)this_ptr);
21711         FeeEstimator_free(this_ptr_conv);
21712 }
21713
21714 void  __attribute__((export_name("TS_MonitorUpdateId_free"))) TS_MonitorUpdateId_free(uint32_t this_obj) {
21715         LDKMonitorUpdateId this_obj_conv;
21716         this_obj_conv.inner = (void*)(this_obj & (~1));
21717         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21719         MonitorUpdateId_free(this_obj_conv);
21720 }
21721
21722 static inline uintptr_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
21723         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
21724 uint32_t ret_ref = 0;
21725 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21726 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21727 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21728 ret_ref = (uintptr_t)ret_var.inner;
21729 if (ret_var.is_owned) {
21730         ret_ref |= 1;
21731 }
21732         return ret_ref;
21733 }
21734 uint32_t  __attribute__((export_name("TS_MonitorUpdateId_clone_ptr"))) TS_MonitorUpdateId_clone_ptr(uint32_t arg) {
21735         LDKMonitorUpdateId arg_conv;
21736         arg_conv.inner = (void*)(arg & (~1));
21737         arg_conv.is_owned = false;
21738         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21739         uint32_t ret_conv = MonitorUpdateId_clone_ptr(&arg_conv);
21740         return ret_conv;
21741 }
21742
21743 uint32_t  __attribute__((export_name("TS_MonitorUpdateId_clone"))) TS_MonitorUpdateId_clone(uint32_t orig) {
21744         LDKMonitorUpdateId orig_conv;
21745         orig_conv.inner = (void*)(orig & (~1));
21746         orig_conv.is_owned = false;
21747         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21748         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
21749         uint32_t ret_ref = 0;
21750         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21751         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21752         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21753         ret_ref = (uintptr_t)ret_var.inner;
21754         if (ret_var.is_owned) {
21755                 ret_ref |= 1;
21756         }
21757         return ret_ref;
21758 }
21759
21760 int64_t  __attribute__((export_name("TS_MonitorUpdateId_hash"))) TS_MonitorUpdateId_hash(uint32_t o) {
21761         LDKMonitorUpdateId o_conv;
21762         o_conv.inner = (void*)(o & (~1));
21763         o_conv.is_owned = false;
21764         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21765         int64_t ret_conv = MonitorUpdateId_hash(&o_conv);
21766         return ret_conv;
21767 }
21768
21769 jboolean  __attribute__((export_name("TS_MonitorUpdateId_eq"))) TS_MonitorUpdateId_eq(uint32_t a, uint32_t b) {
21770         LDKMonitorUpdateId a_conv;
21771         a_conv.inner = (void*)(a & (~1));
21772         a_conv.is_owned = false;
21773         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
21774         LDKMonitorUpdateId b_conv;
21775         b_conv.inner = (void*)(b & (~1));
21776         b_conv.is_owned = false;
21777         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
21778         jboolean ret_conv = MonitorUpdateId_eq(&a_conv, &b_conv);
21779         return ret_conv;
21780 }
21781
21782 void  __attribute__((export_name("TS_Persist_free"))) TS_Persist_free(uint32_t this_ptr) {
21783         if ((this_ptr & 1) != 0) return;
21784         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21785         CHECK_ACCESS(this_ptr_ptr);
21786         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
21787         FREE((void*)this_ptr);
21788         Persist_free(this_ptr_conv);
21789 }
21790
21791 void  __attribute__((export_name("TS_LockedChannelMonitor_free"))) TS_LockedChannelMonitor_free(uint32_t this_obj) {
21792         LDKLockedChannelMonitor this_obj_conv;
21793         this_obj_conv.inner = (void*)(this_obj & (~1));
21794         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21796         LockedChannelMonitor_free(this_obj_conv);
21797 }
21798
21799 void  __attribute__((export_name("TS_ChainMonitor_free"))) TS_ChainMonitor_free(uint32_t this_obj) {
21800         LDKChainMonitor this_obj_conv;
21801         this_obj_conv.inner = (void*)(this_obj & (~1));
21802         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21804         ChainMonitor_free(this_obj_conv);
21805 }
21806
21807 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) {
21808         void* chain_source_ptr = (void*)(((uintptr_t)chain_source) & ~1);
21809         CHECK_ACCESS(chain_source_ptr);
21810         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
21811         // WARNING: we may need a move here but no clone is available for LDKCOption_FilterZ
21812         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
21813                 // Manually implement clone for Java trait instances
21814                 if (chain_source_conv.some.free == LDKFilter_JCalls_free) {
21815                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21816                         LDKFilter_JCalls_cloned(&chain_source_conv.some);
21817                 }
21818         }
21819         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
21820         CHECK_ACCESS(broadcaster_ptr);
21821         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
21822         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
21823                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21824                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
21825         }
21826         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
21827         CHECK_ACCESS(logger_ptr);
21828         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
21829         if (logger_conv.free == LDKLogger_JCalls_free) {
21830                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21831                 LDKLogger_JCalls_cloned(&logger_conv);
21832         }
21833         void* feeest_ptr = (void*)(((uintptr_t)feeest) & ~1);
21834         CHECK_ACCESS(feeest_ptr);
21835         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
21836         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
21837                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21838                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
21839         }
21840         void* persister_ptr = (void*)(((uintptr_t)persister) & ~1);
21841         CHECK_ACCESS(persister_ptr);
21842         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
21843         if (persister_conv.free == LDKPersist_JCalls_free) {
21844                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21845                 LDKPersist_JCalls_cloned(&persister_conv);
21846         }
21847         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
21848         uint32_t ret_ref = 0;
21849         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21850         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21851         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21852         ret_ref = (uintptr_t)ret_var.inner;
21853         if (ret_var.is_owned) {
21854                 ret_ref |= 1;
21855         }
21856         return ret_ref;
21857 }
21858
21859 uint32_tArray  __attribute__((export_name("TS_ChainMonitor_get_claimable_balances"))) TS_ChainMonitor_get_claimable_balances(uint32_t this_arg, uint32_tArray ignored_channels) {
21860         LDKChainMonitor this_arg_conv;
21861         this_arg_conv.inner = (void*)(this_arg & (~1));
21862         this_arg_conv.is_owned = false;
21863         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21864         LDKCVec_ChannelDetailsZ ignored_channels_constr;
21865         ignored_channels_constr.datalen = ignored_channels->arr_len;
21866         if (ignored_channels_constr.datalen > 0)
21867                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
21868         else
21869                 ignored_channels_constr.data = NULL;
21870         uint32_t* ignored_channels_vals = ignored_channels->elems /* XXX ignored_channels leaks */;
21871         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
21872                 uint32_t ignored_channels_conv_16 = ignored_channels_vals[q];
21873                 LDKChannelDetails ignored_channels_conv_16_conv;
21874                 ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1));
21875                 ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0);
21876                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
21877                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
21878                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
21879         }
21880         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
21881         uint32_tArray ret_arr = NULL;
21882         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
21883         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
21884         for (size_t j = 0; j < ret_var.datalen; j++) {
21885                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
21886                 *ret_conv_9_copy = ret_var.data[j];
21887                 uint32_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
21888                 ret_arr_ptr[j] = ret_conv_9_ref;
21889         }
21890         
21891         FREE(ret_var.data);
21892         return ret_arr;
21893 }
21894
21895 uint32_t  __attribute__((export_name("TS_ChainMonitor_get_monitor"))) TS_ChainMonitor_get_monitor(uint32_t this_arg, uint32_t funding_txo) {
21896         LDKChainMonitor this_arg_conv;
21897         this_arg_conv.inner = (void*)(this_arg & (~1));
21898         this_arg_conv.is_owned = false;
21899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21900         LDKOutPoint funding_txo_conv;
21901         funding_txo_conv.inner = (void*)(funding_txo & (~1));
21902         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
21903         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
21904         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
21905         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
21906         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
21907         return (uint32_t)ret_conv;
21908 }
21909
21910 uint32_tArray  __attribute__((export_name("TS_ChainMonitor_list_monitors"))) TS_ChainMonitor_list_monitors(uint32_t this_arg) {
21911         LDKChainMonitor this_arg_conv;
21912         this_arg_conv.inner = (void*)(this_arg & (~1));
21913         this_arg_conv.is_owned = false;
21914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21915         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
21916         uint32_tArray ret_arr = NULL;
21917         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
21918         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
21919         for (size_t k = 0; k < ret_var.datalen; k++) {
21920                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
21921                 uint32_t ret_conv_10_ref = 0;
21922                 CHECK((((uintptr_t)ret_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21923                 CHECK((((uintptr_t)&ret_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21924                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
21925                 ret_conv_10_ref = (uintptr_t)ret_conv_10_var.inner;
21926                 if (ret_conv_10_var.is_owned) {
21927                         ret_conv_10_ref |= 1;
21928                 }
21929                 ret_arr_ptr[k] = ret_conv_10_ref;
21930         }
21931         
21932         FREE(ret_var.data);
21933         return ret_arr;
21934 }
21935
21936 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) {
21937         LDKChainMonitor this_arg_conv;
21938         this_arg_conv.inner = (void*)(this_arg & (~1));
21939         this_arg_conv.is_owned = false;
21940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21941         LDKOutPoint funding_txo_conv;
21942         funding_txo_conv.inner = (void*)(funding_txo & (~1));
21943         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
21944         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
21945         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
21946         LDKMonitorUpdateId completed_update_id_conv;
21947         completed_update_id_conv.inner = (void*)(completed_update_id & (~1));
21948         completed_update_id_conv.is_owned = (completed_update_id & 1) || (completed_update_id == 0);
21949         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
21950         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
21951         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
21952         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
21953         return (uint32_t)ret_conv;
21954 }
21955
21956 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Listen"))) TS_ChainMonitor_as_Listen(uint32_t this_arg) {
21957         LDKChainMonitor this_arg_conv;
21958         this_arg_conv.inner = (void*)(this_arg & (~1));
21959         this_arg_conv.is_owned = false;
21960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21961         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
21962         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
21963         return (uint32_t)ret_ret;
21964 }
21965
21966 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Confirm"))) TS_ChainMonitor_as_Confirm(uint32_t this_arg) {
21967         LDKChainMonitor this_arg_conv;
21968         this_arg_conv.inner = (void*)(this_arg & (~1));
21969         this_arg_conv.is_owned = false;
21970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21971         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
21972         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
21973         return (uint32_t)ret_ret;
21974 }
21975
21976 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Watch"))) TS_ChainMonitor_as_Watch(uint32_t this_arg) {
21977         LDKChainMonitor this_arg_conv;
21978         this_arg_conv.inner = (void*)(this_arg & (~1));
21979         this_arg_conv.is_owned = false;
21980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21981         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
21982         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
21983         return (uint32_t)ret_ret;
21984 }
21985
21986 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_EventsProvider"))) TS_ChainMonitor_as_EventsProvider(uint32_t this_arg) {
21987         LDKChainMonitor this_arg_conv;
21988         this_arg_conv.inner = (void*)(this_arg & (~1));
21989         this_arg_conv.is_owned = false;
21990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21991         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
21992         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
21993         return (uint32_t)ret_ret;
21994 }
21995
21996 void  __attribute__((export_name("TS_ChannelMonitorUpdate_free"))) TS_ChannelMonitorUpdate_free(uint32_t this_obj) {
21997         LDKChannelMonitorUpdate this_obj_conv;
21998         this_obj_conv.inner = (void*)(this_obj & (~1));
21999         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22001         ChannelMonitorUpdate_free(this_obj_conv);
22002 }
22003
22004 int64_t  __attribute__((export_name("TS_ChannelMonitorUpdate_get_update_id"))) TS_ChannelMonitorUpdate_get_update_id(uint32_t this_ptr) {
22005         LDKChannelMonitorUpdate this_ptr_conv;
22006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22007         this_ptr_conv.is_owned = false;
22008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22009         int64_t ret_conv = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
22010         return ret_conv;
22011 }
22012
22013 void  __attribute__((export_name("TS_ChannelMonitorUpdate_set_update_id"))) TS_ChannelMonitorUpdate_set_update_id(uint32_t this_ptr, int64_t val) {
22014         LDKChannelMonitorUpdate this_ptr_conv;
22015         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22016         this_ptr_conv.is_owned = false;
22017         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22018         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
22019 }
22020
22021 static inline uintptr_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
22022         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
22023 uint32_t ret_ref = 0;
22024 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22025 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22026 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22027 ret_ref = (uintptr_t)ret_var.inner;
22028 if (ret_var.is_owned) {
22029         ret_ref |= 1;
22030 }
22031         return ret_ref;
22032 }
22033 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdate_clone_ptr"))) TS_ChannelMonitorUpdate_clone_ptr(uint32_t arg) {
22034         LDKChannelMonitorUpdate arg_conv;
22035         arg_conv.inner = (void*)(arg & (~1));
22036         arg_conv.is_owned = false;
22037         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22038         uint32_t ret_conv = ChannelMonitorUpdate_clone_ptr(&arg_conv);
22039         return ret_conv;
22040 }
22041
22042 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdate_clone"))) TS_ChannelMonitorUpdate_clone(uint32_t orig) {
22043         LDKChannelMonitorUpdate orig_conv;
22044         orig_conv.inner = (void*)(orig & (~1));
22045         orig_conv.is_owned = false;
22046         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22047         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
22048         uint32_t ret_ref = 0;
22049         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22050         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22051         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22052         ret_ref = (uintptr_t)ret_var.inner;
22053         if (ret_var.is_owned) {
22054                 ret_ref |= 1;
22055         }
22056         return ret_ref;
22057 }
22058
22059 int8_tArray  __attribute__((export_name("TS_ChannelMonitorUpdate_write"))) TS_ChannelMonitorUpdate_write(uint32_t obj) {
22060         LDKChannelMonitorUpdate obj_conv;
22061         obj_conv.inner = (void*)(obj & (~1));
22062         obj_conv.is_owned = false;
22063         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22064         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
22065         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22066         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22067         CVec_u8Z_free(ret_var);
22068         return ret_arr;
22069 }
22070
22071 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdate_read"))) TS_ChannelMonitorUpdate_read(int8_tArray ser) {
22072         LDKu8slice ser_ref;
22073         ser_ref.datalen = ser->arr_len;
22074         ser_ref.data = ser->elems /* XXX ser leaks */;
22075         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
22076         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
22077         return (uint32_t)ret_conv;
22078 }
22079
22080 void  __attribute__((export_name("TS_MonitorEvent_free"))) TS_MonitorEvent_free(uint32_t this_ptr) {
22081         if ((this_ptr & 1) != 0) return;
22082         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22083         CHECK_ACCESS(this_ptr_ptr);
22084         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
22085         FREE((void*)this_ptr);
22086         MonitorEvent_free(this_ptr_conv);
22087 }
22088
22089 static inline uintptr_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
22090         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22091         *ret_copy = MonitorEvent_clone(arg);
22092 uint32_t ret_ref = (uintptr_t)ret_copy;
22093         return ret_ref;
22094 }
22095 uint32_t  __attribute__((export_name("TS_MonitorEvent_clone_ptr"))) TS_MonitorEvent_clone_ptr(uint32_t arg) {
22096         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)arg;
22097         uint32_t ret_conv = MonitorEvent_clone_ptr(arg_conv);
22098         return ret_conv;
22099 }
22100
22101 uint32_t  __attribute__((export_name("TS_MonitorEvent_clone"))) TS_MonitorEvent_clone(uint32_t orig) {
22102         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
22103         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22104         *ret_copy = MonitorEvent_clone(orig_conv);
22105         uint32_t ret_ref = (uintptr_t)ret_copy;
22106         return ret_ref;
22107 }
22108
22109 uint32_t  __attribute__((export_name("TS_MonitorEvent_htlcevent"))) TS_MonitorEvent_htlcevent(uint32_t a) {
22110         LDKHTLCUpdate a_conv;
22111         a_conv.inner = (void*)(a & (~1));
22112         a_conv.is_owned = (a & 1) || (a == 0);
22113         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
22114         a_conv = HTLCUpdate_clone(&a_conv);
22115         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22116         *ret_copy = MonitorEvent_htlcevent(a_conv);
22117         uint32_t ret_ref = (uintptr_t)ret_copy;
22118         return ret_ref;
22119 }
22120
22121 uint32_t  __attribute__((export_name("TS_MonitorEvent_commitment_tx_confirmed"))) TS_MonitorEvent_commitment_tx_confirmed(uint32_t a) {
22122         LDKOutPoint a_conv;
22123         a_conv.inner = (void*)(a & (~1));
22124         a_conv.is_owned = (a & 1) || (a == 0);
22125         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
22126         a_conv = OutPoint_clone(&a_conv);
22127         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22128         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
22129         uint32_t ret_ref = (uintptr_t)ret_copy;
22130         return ret_ref;
22131 }
22132
22133 uint32_t  __attribute__((export_name("TS_MonitorEvent_update_completed"))) TS_MonitorEvent_update_completed(uint32_t funding_txo, int64_t monitor_update_id) {
22134         LDKOutPoint funding_txo_conv;
22135         funding_txo_conv.inner = (void*)(funding_txo & (~1));
22136         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
22137         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
22138         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
22139         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22140         *ret_copy = MonitorEvent_update_completed(funding_txo_conv, monitor_update_id);
22141         uint32_t ret_ref = (uintptr_t)ret_copy;
22142         return ret_ref;
22143 }
22144
22145 uint32_t  __attribute__((export_name("TS_MonitorEvent_update_failed"))) TS_MonitorEvent_update_failed(uint32_t a) {
22146         LDKOutPoint a_conv;
22147         a_conv.inner = (void*)(a & (~1));
22148         a_conv.is_owned = (a & 1) || (a == 0);
22149         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
22150         a_conv = OutPoint_clone(&a_conv);
22151         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22152         *ret_copy = MonitorEvent_update_failed(a_conv);
22153         uint32_t ret_ref = (uintptr_t)ret_copy;
22154         return ret_ref;
22155 }
22156
22157 int8_tArray  __attribute__((export_name("TS_MonitorEvent_write"))) TS_MonitorEvent_write(uint32_t obj) {
22158         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)obj;
22159         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
22160         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22161         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22162         CVec_u8Z_free(ret_var);
22163         return ret_arr;
22164 }
22165
22166 uint32_t  __attribute__((export_name("TS_MonitorEvent_read"))) TS_MonitorEvent_read(int8_tArray ser) {
22167         LDKu8slice ser_ref;
22168         ser_ref.datalen = ser->arr_len;
22169         ser_ref.data = ser->elems /* XXX ser leaks */;
22170         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
22171         *ret_conv = MonitorEvent_read(ser_ref);
22172         return (uint32_t)ret_conv;
22173 }
22174
22175 void  __attribute__((export_name("TS_HTLCUpdate_free"))) TS_HTLCUpdate_free(uint32_t this_obj) {
22176         LDKHTLCUpdate this_obj_conv;
22177         this_obj_conv.inner = (void*)(this_obj & (~1));
22178         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22180         HTLCUpdate_free(this_obj_conv);
22181 }
22182
22183 static inline uintptr_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
22184         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
22185 uint32_t ret_ref = 0;
22186 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22187 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22188 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22189 ret_ref = (uintptr_t)ret_var.inner;
22190 if (ret_var.is_owned) {
22191         ret_ref |= 1;
22192 }
22193         return ret_ref;
22194 }
22195 uint32_t  __attribute__((export_name("TS_HTLCUpdate_clone_ptr"))) TS_HTLCUpdate_clone_ptr(uint32_t arg) {
22196         LDKHTLCUpdate arg_conv;
22197         arg_conv.inner = (void*)(arg & (~1));
22198         arg_conv.is_owned = false;
22199         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22200         uint32_t ret_conv = HTLCUpdate_clone_ptr(&arg_conv);
22201         return ret_conv;
22202 }
22203
22204 uint32_t  __attribute__((export_name("TS_HTLCUpdate_clone"))) TS_HTLCUpdate_clone(uint32_t orig) {
22205         LDKHTLCUpdate orig_conv;
22206         orig_conv.inner = (void*)(orig & (~1));
22207         orig_conv.is_owned = false;
22208         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22209         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
22210         uint32_t ret_ref = 0;
22211         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22212         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22213         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22214         ret_ref = (uintptr_t)ret_var.inner;
22215         if (ret_var.is_owned) {
22216                 ret_ref |= 1;
22217         }
22218         return ret_ref;
22219 }
22220
22221 int8_tArray  __attribute__((export_name("TS_HTLCUpdate_write"))) TS_HTLCUpdate_write(uint32_t obj) {
22222         LDKHTLCUpdate obj_conv;
22223         obj_conv.inner = (void*)(obj & (~1));
22224         obj_conv.is_owned = false;
22225         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22226         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
22227         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22228         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22229         CVec_u8Z_free(ret_var);
22230         return ret_arr;
22231 }
22232
22233 uint32_t  __attribute__((export_name("TS_HTLCUpdate_read"))) TS_HTLCUpdate_read(int8_tArray ser) {
22234         LDKu8slice ser_ref;
22235         ser_ref.datalen = ser->arr_len;
22236         ser_ref.data = ser->elems /* XXX ser leaks */;
22237         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
22238         *ret_conv = HTLCUpdate_read(ser_ref);
22239         return (uint32_t)ret_conv;
22240 }
22241
22242 void  __attribute__((export_name("TS_Balance_free"))) TS_Balance_free(uint32_t this_ptr) {
22243         if ((this_ptr & 1) != 0) return;
22244         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22245         CHECK_ACCESS(this_ptr_ptr);
22246         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
22247         FREE((void*)this_ptr);
22248         Balance_free(this_ptr_conv);
22249 }
22250
22251 static inline uintptr_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
22252         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22253         *ret_copy = Balance_clone(arg);
22254 uint32_t ret_ref = (uintptr_t)ret_copy;
22255         return ret_ref;
22256 }
22257 uint32_t  __attribute__((export_name("TS_Balance_clone_ptr"))) TS_Balance_clone_ptr(uint32_t arg) {
22258         LDKBalance* arg_conv = (LDKBalance*)arg;
22259         uint32_t ret_conv = Balance_clone_ptr(arg_conv);
22260         return ret_conv;
22261 }
22262
22263 uint32_t  __attribute__((export_name("TS_Balance_clone"))) TS_Balance_clone(uint32_t orig) {
22264         LDKBalance* orig_conv = (LDKBalance*)orig;
22265         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22266         *ret_copy = Balance_clone(orig_conv);
22267         uint32_t ret_ref = (uintptr_t)ret_copy;
22268         return ret_ref;
22269 }
22270
22271 uint32_t  __attribute__((export_name("TS_Balance_claimable_on_channel_close"))) TS_Balance_claimable_on_channel_close(int64_t claimable_amount_satoshis) {
22272         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22273         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
22274         uint32_t ret_ref = (uintptr_t)ret_copy;
22275         return ret_ref;
22276 }
22277
22278 uint32_t  __attribute__((export_name("TS_Balance_claimable_awaiting_confirmations"))) TS_Balance_claimable_awaiting_confirmations(int64_t claimable_amount_satoshis, int32_t confirmation_height) {
22279         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22280         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
22281         uint32_t ret_ref = (uintptr_t)ret_copy;
22282         return ret_ref;
22283 }
22284
22285 uint32_t  __attribute__((export_name("TS_Balance_contentious_claimable"))) TS_Balance_contentious_claimable(int64_t claimable_amount_satoshis, int32_t timeout_height) {
22286         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22287         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
22288         uint32_t ret_ref = (uintptr_t)ret_copy;
22289         return ret_ref;
22290 }
22291
22292 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) {
22293         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22294         *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
22295         uint32_t ret_ref = (uintptr_t)ret_copy;
22296         return ret_ref;
22297 }
22298
22299 jboolean  __attribute__((export_name("TS_Balance_eq"))) TS_Balance_eq(uint32_t a, uint32_t b) {
22300         LDKBalance* a_conv = (LDKBalance*)a;
22301         LDKBalance* b_conv = (LDKBalance*)b;
22302         jboolean ret_conv = Balance_eq(a_conv, b_conv);
22303         return ret_conv;
22304 }
22305
22306 void  __attribute__((export_name("TS_ChannelMonitor_free"))) TS_ChannelMonitor_free(uint32_t this_obj) {
22307         LDKChannelMonitor this_obj_conv;
22308         this_obj_conv.inner = (void*)(this_obj & (~1));
22309         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22311         ChannelMonitor_free(this_obj_conv);
22312 }
22313
22314 static inline uintptr_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
22315         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
22316 uint32_t ret_ref = 0;
22317 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22318 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22319 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22320 ret_ref = (uintptr_t)ret_var.inner;
22321 if (ret_var.is_owned) {
22322         ret_ref |= 1;
22323 }
22324         return ret_ref;
22325 }
22326 uint32_t  __attribute__((export_name("TS_ChannelMonitor_clone_ptr"))) TS_ChannelMonitor_clone_ptr(uint32_t arg) {
22327         LDKChannelMonitor arg_conv;
22328         arg_conv.inner = (void*)(arg & (~1));
22329         arg_conv.is_owned = false;
22330         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22331         uint32_t ret_conv = ChannelMonitor_clone_ptr(&arg_conv);
22332         return ret_conv;
22333 }
22334
22335 uint32_t  __attribute__((export_name("TS_ChannelMonitor_clone"))) TS_ChannelMonitor_clone(uint32_t orig) {
22336         LDKChannelMonitor orig_conv;
22337         orig_conv.inner = (void*)(orig & (~1));
22338         orig_conv.is_owned = false;
22339         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22340         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
22341         uint32_t ret_ref = 0;
22342         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22343         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22344         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22345         ret_ref = (uintptr_t)ret_var.inner;
22346         if (ret_var.is_owned) {
22347                 ret_ref |= 1;
22348         }
22349         return ret_ref;
22350 }
22351
22352 int8_tArray  __attribute__((export_name("TS_ChannelMonitor_write"))) TS_ChannelMonitor_write(uint32_t obj) {
22353         LDKChannelMonitor obj_conv;
22354         obj_conv.inner = (void*)(obj & (~1));
22355         obj_conv.is_owned = false;
22356         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22357         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
22358         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22359         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22360         CVec_u8Z_free(ret_var);
22361         return ret_arr;
22362 }
22363
22364 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) {
22365         LDKChannelMonitor this_arg_conv;
22366         this_arg_conv.inner = (void*)(this_arg & (~1));
22367         this_arg_conv.is_owned = false;
22368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22369         LDKChannelMonitorUpdate updates_conv;
22370         updates_conv.inner = (void*)(updates & (~1));
22371         updates_conv.is_owned = false;
22372         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
22373         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22374         if (!(broadcaster & 1)) { CHECK_ACCESS(broadcaster_ptr); }
22375         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
22376         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22377         if (!(fee_estimator & 1)) { CHECK_ACCESS(fee_estimator_ptr); }
22378         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator_ptr;
22379         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22380         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
22381         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
22382         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
22383         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
22384         return (uint32_t)ret_conv;
22385 }
22386
22387 int64_t  __attribute__((export_name("TS_ChannelMonitor_get_latest_update_id"))) TS_ChannelMonitor_get_latest_update_id(uint32_t this_arg) {
22388         LDKChannelMonitor this_arg_conv;
22389         this_arg_conv.inner = (void*)(this_arg & (~1));
22390         this_arg_conv.is_owned = false;
22391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22392         int64_t ret_conv = ChannelMonitor_get_latest_update_id(&this_arg_conv);
22393         return ret_conv;
22394 }
22395
22396 uint32_t  __attribute__((export_name("TS_ChannelMonitor_get_funding_txo"))) TS_ChannelMonitor_get_funding_txo(uint32_t this_arg) {
22397         LDKChannelMonitor this_arg_conv;
22398         this_arg_conv.inner = (void*)(this_arg & (~1));
22399         this_arg_conv.is_owned = false;
22400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22401         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
22402         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
22403         return ((uint32_t)ret_conv);
22404 }
22405
22406 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_outputs_to_watch"))) TS_ChannelMonitor_get_outputs_to_watch(uint32_t this_arg) {
22407         LDKChannelMonitor this_arg_conv;
22408         this_arg_conv.inner = (void*)(this_arg & (~1));
22409         this_arg_conv.is_owned = false;
22410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22411         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
22412         uint32_tArray ret_arr = NULL;
22413         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22414         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22415         for (size_t o = 0; o < ret_var.datalen; o++) {
22416                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
22417                 *ret_conv_40_conv = ret_var.data[o];
22418                 ret_arr_ptr[o] = ((uint32_t)ret_conv_40_conv);
22419         }
22420         
22421         FREE(ret_var.data);
22422         return ret_arr;
22423 }
22424
22425 void  __attribute__((export_name("TS_ChannelMonitor_load_outputs_to_watch"))) TS_ChannelMonitor_load_outputs_to_watch(uint32_t this_arg, uint32_t filter) {
22426         LDKChannelMonitor this_arg_conv;
22427         this_arg_conv.inner = (void*)(this_arg & (~1));
22428         this_arg_conv.is_owned = false;
22429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22430         void* filter_ptr = (void*)(((uintptr_t)filter) & ~1);
22431         if (!(filter & 1)) { CHECK_ACCESS(filter_ptr); }
22432         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
22433         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
22434 }
22435
22436 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) {
22437         LDKChannelMonitor this_arg_conv;
22438         this_arg_conv.inner = (void*)(this_arg & (~1));
22439         this_arg_conv.is_owned = false;
22440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22441         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
22442         uint32_tArray ret_arr = NULL;
22443         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22444         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22445         for (size_t o = 0; o < ret_var.datalen; o++) {
22446                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22447                 *ret_conv_14_copy = ret_var.data[o];
22448                 uint32_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
22449                 ret_arr_ptr[o] = ret_conv_14_ref;
22450         }
22451         
22452         FREE(ret_var.data);
22453         return ret_arr;
22454 }
22455
22456 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_and_clear_pending_events"))) TS_ChannelMonitor_get_and_clear_pending_events(uint32_t this_arg) {
22457         LDKChannelMonitor this_arg_conv;
22458         this_arg_conv.inner = (void*)(this_arg & (~1));
22459         this_arg_conv.is_owned = false;
22460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22461         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
22462         uint32_tArray ret_arr = NULL;
22463         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22464         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22465         for (size_t h = 0; h < ret_var.datalen; h++) {
22466                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
22467                 *ret_conv_7_copy = ret_var.data[h];
22468                 uint32_t ret_conv_7_ref = (uintptr_t)ret_conv_7_copy;
22469                 ret_arr_ptr[h] = ret_conv_7_ref;
22470         }
22471         
22472         FREE(ret_var.data);
22473         return ret_arr;
22474 }
22475
22476 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) {
22477         LDKChannelMonitor this_arg_conv;
22478         this_arg_conv.inner = (void*)(this_arg & (~1));
22479         this_arg_conv.is_owned = false;
22480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22481         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22482         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
22483         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
22484         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
22485         ptrArray ret_arr = NULL;
22486         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
22487         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
22488         for (size_t m = 0; m < ret_var.datalen; m++) {
22489                 LDKTransaction ret_conv_12_var = ret_var.data[m];
22490                 int8_tArray ret_conv_12_arr = init_int8_tArray(ret_conv_12_var.datalen, __LINE__);
22491                 memcpy(ret_conv_12_arr->elems, ret_conv_12_var.data, ret_conv_12_var.datalen);
22492                 Transaction_free(ret_conv_12_var);
22493                 ret_arr_ptr[m] = ret_conv_12_arr;
22494         }
22495         
22496         FREE(ret_var.data);
22497         return ret_arr;
22498 }
22499
22500 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) {
22501         LDKChannelMonitor this_arg_conv;
22502         this_arg_conv.inner = (void*)(this_arg & (~1));
22503         this_arg_conv.is_owned = false;
22504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22505         unsigned char header_arr[80];
22506         CHECK(header->arr_len == 80);
22507         memcpy(header_arr, header->elems, 80); FREE(header);
22508         unsigned char (*header_ref)[80] = &header_arr;
22509         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
22510         txdata_constr.datalen = txdata->arr_len;
22511         if (txdata_constr.datalen > 0)
22512                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
22513         else
22514                 txdata_constr.data = NULL;
22515         uint32_t* txdata_vals = txdata->elems /* XXX txdata leaks */;
22516         for (size_t c = 0; c < txdata_constr.datalen; c++) {
22517                 uint32_t txdata_conv_28 = txdata_vals[c];
22518                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
22519                 CHECK_ACCESS(txdata_conv_28_ptr);
22520                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
22521                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
22522                 txdata_constr.data[c] = txdata_conv_28_conv;
22523         }
22524         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22525         CHECK_ACCESS(broadcaster_ptr);
22526         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22527         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
22528                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22529                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
22530         }
22531         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22532         CHECK_ACCESS(fee_estimator_ptr);
22533         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22534         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
22535                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22536                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
22537         }
22538         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22539         CHECK_ACCESS(logger_ptr);
22540         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22541         if (logger_conv.free == LDKLogger_JCalls_free) {
22542                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22543                 LDKLogger_JCalls_cloned(&logger_conv);
22544         }
22545         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);
22546         uint32_tArray ret_arr = NULL;
22547         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22548         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22549         for (size_t n = 0; n < ret_var.datalen; n++) {
22550                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22551                 *ret_conv_39_conv = ret_var.data[n];
22552                 ret_arr_ptr[n] = ((uint32_t)ret_conv_39_conv);
22553         }
22554         
22555         FREE(ret_var.data);
22556         return ret_arr;
22557 }
22558
22559 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) {
22560         LDKChannelMonitor this_arg_conv;
22561         this_arg_conv.inner = (void*)(this_arg & (~1));
22562         this_arg_conv.is_owned = false;
22563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22564         unsigned char header_arr[80];
22565         CHECK(header->arr_len == 80);
22566         memcpy(header_arr, header->elems, 80); FREE(header);
22567         unsigned char (*header_ref)[80] = &header_arr;
22568         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22569         CHECK_ACCESS(broadcaster_ptr);
22570         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22571         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
22572                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22573                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
22574         }
22575         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22576         CHECK_ACCESS(fee_estimator_ptr);
22577         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22578         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
22579                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22580                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
22581         }
22582         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22583         CHECK_ACCESS(logger_ptr);
22584         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22585         if (logger_conv.free == LDKLogger_JCalls_free) {
22586                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22587                 LDKLogger_JCalls_cloned(&logger_conv);
22588         }
22589         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
22590 }
22591
22592 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) {
22593         LDKChannelMonitor this_arg_conv;
22594         this_arg_conv.inner = (void*)(this_arg & (~1));
22595         this_arg_conv.is_owned = false;
22596         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22597         unsigned char header_arr[80];
22598         CHECK(header->arr_len == 80);
22599         memcpy(header_arr, header->elems, 80); FREE(header);
22600         unsigned char (*header_ref)[80] = &header_arr;
22601         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
22602         txdata_constr.datalen = txdata->arr_len;
22603         if (txdata_constr.datalen > 0)
22604                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
22605         else
22606                 txdata_constr.data = NULL;
22607         uint32_t* txdata_vals = txdata->elems /* XXX txdata leaks */;
22608         for (size_t c = 0; c < txdata_constr.datalen; c++) {
22609                 uint32_t txdata_conv_28 = txdata_vals[c];
22610                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
22611                 CHECK_ACCESS(txdata_conv_28_ptr);
22612                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
22613                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
22614                 txdata_constr.data[c] = txdata_conv_28_conv;
22615         }
22616         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22617         CHECK_ACCESS(broadcaster_ptr);
22618         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22619         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
22620                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22621                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
22622         }
22623         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22624         CHECK_ACCESS(fee_estimator_ptr);
22625         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22626         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
22627                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22628                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
22629         }
22630         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22631         CHECK_ACCESS(logger_ptr);
22632         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22633         if (logger_conv.free == LDKLogger_JCalls_free) {
22634                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22635                 LDKLogger_JCalls_cloned(&logger_conv);
22636         }
22637         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);
22638         uint32_tArray ret_arr = NULL;
22639         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22640         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22641         for (size_t n = 0; n < ret_var.datalen; n++) {
22642                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22643                 *ret_conv_39_conv = ret_var.data[n];
22644                 ret_arr_ptr[n] = ((uint32_t)ret_conv_39_conv);
22645         }
22646         
22647         FREE(ret_var.data);
22648         return ret_arr;
22649 }
22650
22651 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) {
22652         LDKChannelMonitor this_arg_conv;
22653         this_arg_conv.inner = (void*)(this_arg & (~1));
22654         this_arg_conv.is_owned = false;
22655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22656         unsigned char txid_arr[32];
22657         CHECK(txid->arr_len == 32);
22658         memcpy(txid_arr, txid->elems, 32); FREE(txid);
22659         unsigned char (*txid_ref)[32] = &txid_arr;
22660         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22661         CHECK_ACCESS(broadcaster_ptr);
22662         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22663         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
22664                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22665                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
22666         }
22667         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22668         CHECK_ACCESS(fee_estimator_ptr);
22669         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22670         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
22671                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22672                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
22673         }
22674         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22675         CHECK_ACCESS(logger_ptr);
22676         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22677         if (logger_conv.free == LDKLogger_JCalls_free) {
22678                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22679                 LDKLogger_JCalls_cloned(&logger_conv);
22680         }
22681         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
22682 }
22683
22684 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) {
22685         LDKChannelMonitor this_arg_conv;
22686         this_arg_conv.inner = (void*)(this_arg & (~1));
22687         this_arg_conv.is_owned = false;
22688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22689         unsigned char header_arr[80];
22690         CHECK(header->arr_len == 80);
22691         memcpy(header_arr, header->elems, 80); FREE(header);
22692         unsigned char (*header_ref)[80] = &header_arr;
22693         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22694         CHECK_ACCESS(broadcaster_ptr);
22695         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22696         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
22697                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22698                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
22699         }
22700         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22701         CHECK_ACCESS(fee_estimator_ptr);
22702         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22703         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
22704                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22705                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
22706         }
22707         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22708         CHECK_ACCESS(logger_ptr);
22709         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22710         if (logger_conv.free == LDKLogger_JCalls_free) {
22711                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22712                 LDKLogger_JCalls_cloned(&logger_conv);
22713         }
22714         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
22715         uint32_tArray ret_arr = NULL;
22716         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22717         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22718         for (size_t n = 0; n < ret_var.datalen; n++) {
22719                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22720                 *ret_conv_39_conv = ret_var.data[n];
22721                 ret_arr_ptr[n] = ((uint32_t)ret_conv_39_conv);
22722         }
22723         
22724         FREE(ret_var.data);
22725         return ret_arr;
22726 }
22727
22728 ptrArray  __attribute__((export_name("TS_ChannelMonitor_get_relevant_txids"))) TS_ChannelMonitor_get_relevant_txids(uint32_t this_arg) {
22729         LDKChannelMonitor this_arg_conv;
22730         this_arg_conv.inner = (void*)(this_arg & (~1));
22731         this_arg_conv.is_owned = false;
22732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22733         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
22734         ptrArray ret_arr = NULL;
22735         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
22736         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
22737         for (size_t m = 0; m < ret_var.datalen; m++) {
22738                 int8_tArray ret_conv_12_arr = init_int8_tArray(32, __LINE__);
22739                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].data, 32);
22740                 ret_arr_ptr[m] = ret_conv_12_arr;
22741         }
22742         
22743         FREE(ret_var.data);
22744         return ret_arr;
22745 }
22746
22747 uint32_t  __attribute__((export_name("TS_ChannelMonitor_current_best_block"))) TS_ChannelMonitor_current_best_block(uint32_t this_arg) {
22748         LDKChannelMonitor this_arg_conv;
22749         this_arg_conv.inner = (void*)(this_arg & (~1));
22750         this_arg_conv.is_owned = false;
22751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22752         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
22753         uint32_t ret_ref = 0;
22754         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22755         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22756         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22757         ret_ref = (uintptr_t)ret_var.inner;
22758         if (ret_var.is_owned) {
22759                 ret_ref |= 1;
22760         }
22761         return ret_ref;
22762 }
22763
22764 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_claimable_balances"))) TS_ChannelMonitor_get_claimable_balances(uint32_t this_arg) {
22765         LDKChannelMonitor this_arg_conv;
22766         this_arg_conv.inner = (void*)(this_arg & (~1));
22767         this_arg_conv.is_owned = false;
22768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22769         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
22770         uint32_tArray ret_arr = NULL;
22771         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22772         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22773         for (size_t j = 0; j < ret_var.datalen; j++) {
22774                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22775                 *ret_conv_9_copy = ret_var.data[j];
22776                 uint32_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
22777                 ret_arr_ptr[j] = ret_conv_9_ref;
22778         }
22779         
22780         FREE(ret_var.data);
22781         return ret_arr;
22782 }
22783
22784 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_read"))) TS_C2Tuple_BlockHashChannelMonitorZ_read(int8_tArray ser, uint32_t arg) {
22785         LDKu8slice ser_ref;
22786         ser_ref.datalen = ser->arr_len;
22787         ser_ref.data = ser->elems /* XXX ser leaks */;
22788         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
22789         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
22790         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
22791         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
22792         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
22793         return (uint32_t)ret_conv;
22794 }
22795
22796 void  __attribute__((export_name("TS_OutPoint_free"))) TS_OutPoint_free(uint32_t this_obj) {
22797         LDKOutPoint this_obj_conv;
22798         this_obj_conv.inner = (void*)(this_obj & (~1));
22799         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22801         OutPoint_free(this_obj_conv);
22802 }
22803
22804 int8_tArray  __attribute__((export_name("TS_OutPoint_get_txid"))) TS_OutPoint_get_txid(uint32_t this_ptr) {
22805         LDKOutPoint this_ptr_conv;
22806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22807         this_ptr_conv.is_owned = false;
22808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22809         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
22810         memcpy(ret_arr->elems, *OutPoint_get_txid(&this_ptr_conv), 32);
22811         return ret_arr;
22812 }
22813
22814 void  __attribute__((export_name("TS_OutPoint_set_txid"))) TS_OutPoint_set_txid(uint32_t this_ptr, int8_tArray val) {
22815         LDKOutPoint this_ptr_conv;
22816         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22817         this_ptr_conv.is_owned = false;
22818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22819         LDKThirtyTwoBytes val_ref;
22820         CHECK(val->arr_len == 32);
22821         memcpy(val_ref.data, val->elems, 32); FREE(val);
22822         OutPoint_set_txid(&this_ptr_conv, val_ref);
22823 }
22824
22825 int16_t  __attribute__((export_name("TS_OutPoint_get_index"))) TS_OutPoint_get_index(uint32_t this_ptr) {
22826         LDKOutPoint this_ptr_conv;
22827         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22828         this_ptr_conv.is_owned = false;
22829         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22830         int16_t ret_conv = OutPoint_get_index(&this_ptr_conv);
22831         return ret_conv;
22832 }
22833
22834 void  __attribute__((export_name("TS_OutPoint_set_index"))) TS_OutPoint_set_index(uint32_t this_ptr, int16_t val) {
22835         LDKOutPoint this_ptr_conv;
22836         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22837         this_ptr_conv.is_owned = false;
22838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22839         OutPoint_set_index(&this_ptr_conv, val);
22840 }
22841
22842 uint32_t  __attribute__((export_name("TS_OutPoint_new"))) TS_OutPoint_new(int8_tArray txid_arg, int16_t index_arg) {
22843         LDKThirtyTwoBytes txid_arg_ref;
22844         CHECK(txid_arg->arr_len == 32);
22845         memcpy(txid_arg_ref.data, txid_arg->elems, 32); FREE(txid_arg);
22846         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
22847         uint32_t ret_ref = 0;
22848         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22849         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22850         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22851         ret_ref = (uintptr_t)ret_var.inner;
22852         if (ret_var.is_owned) {
22853                 ret_ref |= 1;
22854         }
22855         return ret_ref;
22856 }
22857
22858 static inline uintptr_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
22859         LDKOutPoint ret_var = OutPoint_clone(arg);
22860 uint32_t ret_ref = 0;
22861 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22862 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22863 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22864 ret_ref = (uintptr_t)ret_var.inner;
22865 if (ret_var.is_owned) {
22866         ret_ref |= 1;
22867 }
22868         return ret_ref;
22869 }
22870 uint32_t  __attribute__((export_name("TS_OutPoint_clone_ptr"))) TS_OutPoint_clone_ptr(uint32_t arg) {
22871         LDKOutPoint arg_conv;
22872         arg_conv.inner = (void*)(arg & (~1));
22873         arg_conv.is_owned = false;
22874         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22875         uint32_t ret_conv = OutPoint_clone_ptr(&arg_conv);
22876         return ret_conv;
22877 }
22878
22879 uint32_t  __attribute__((export_name("TS_OutPoint_clone"))) TS_OutPoint_clone(uint32_t orig) {
22880         LDKOutPoint orig_conv;
22881         orig_conv.inner = (void*)(orig & (~1));
22882         orig_conv.is_owned = false;
22883         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22884         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
22885         uint32_t ret_ref = 0;
22886         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22887         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22888         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22889         ret_ref = (uintptr_t)ret_var.inner;
22890         if (ret_var.is_owned) {
22891                 ret_ref |= 1;
22892         }
22893         return ret_ref;
22894 }
22895
22896 jboolean  __attribute__((export_name("TS_OutPoint_eq"))) TS_OutPoint_eq(uint32_t a, uint32_t b) {
22897         LDKOutPoint a_conv;
22898         a_conv.inner = (void*)(a & (~1));
22899         a_conv.is_owned = false;
22900         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
22901         LDKOutPoint b_conv;
22902         b_conv.inner = (void*)(b & (~1));
22903         b_conv.is_owned = false;
22904         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
22905         jboolean ret_conv = OutPoint_eq(&a_conv, &b_conv);
22906         return ret_conv;
22907 }
22908
22909 int64_t  __attribute__((export_name("TS_OutPoint_hash"))) TS_OutPoint_hash(uint32_t o) {
22910         LDKOutPoint o_conv;
22911         o_conv.inner = (void*)(o & (~1));
22912         o_conv.is_owned = false;
22913         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22914         int64_t ret_conv = OutPoint_hash(&o_conv);
22915         return ret_conv;
22916 }
22917
22918 int8_tArray  __attribute__((export_name("TS_OutPoint_to_channel_id"))) TS_OutPoint_to_channel_id(uint32_t this_arg) {
22919         LDKOutPoint this_arg_conv;
22920         this_arg_conv.inner = (void*)(this_arg & (~1));
22921         this_arg_conv.is_owned = false;
22922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22923         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
22924         memcpy(ret_arr->elems, OutPoint_to_channel_id(&this_arg_conv).data, 32);
22925         return ret_arr;
22926 }
22927
22928 int8_tArray  __attribute__((export_name("TS_OutPoint_write"))) TS_OutPoint_write(uint32_t obj) {
22929         LDKOutPoint obj_conv;
22930         obj_conv.inner = (void*)(obj & (~1));
22931         obj_conv.is_owned = false;
22932         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22933         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
22934         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22935         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22936         CVec_u8Z_free(ret_var);
22937         return ret_arr;
22938 }
22939
22940 uint32_t  __attribute__((export_name("TS_OutPoint_read"))) TS_OutPoint_read(int8_tArray ser) {
22941         LDKu8slice ser_ref;
22942         ser_ref.datalen = ser->arr_len;
22943         ser_ref.data = ser->elems /* XXX ser leaks */;
22944         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
22945         *ret_conv = OutPoint_read(ser_ref);
22946         return (uint32_t)ret_conv;
22947 }
22948
22949 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_free"))) TS_DelayedPaymentOutputDescriptor_free(uint32_t this_obj) {
22950         LDKDelayedPaymentOutputDescriptor this_obj_conv;
22951         this_obj_conv.inner = (void*)(this_obj & (~1));
22952         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22953         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22954         DelayedPaymentOutputDescriptor_free(this_obj_conv);
22955 }
22956
22957 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_outpoint"))) TS_DelayedPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
22958         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22960         this_ptr_conv.is_owned = false;
22961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22962         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
22963         uint32_t ret_ref = 0;
22964         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22965         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22966         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22967         ret_ref = (uintptr_t)ret_var.inner;
22968         if (ret_var.is_owned) {
22969                 ret_ref |= 1;
22970         }
22971         return ret_ref;
22972 }
22973
22974 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_outpoint"))) TS_DelayedPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
22975         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22977         this_ptr_conv.is_owned = false;
22978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22979         LDKOutPoint val_conv;
22980         val_conv.inner = (void*)(val & (~1));
22981         val_conv.is_owned = (val & 1) || (val == 0);
22982         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
22983         val_conv = OutPoint_clone(&val_conv);
22984         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
22985 }
22986
22987 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_per_commitment_point"))) TS_DelayedPaymentOutputDescriptor_get_per_commitment_point(uint32_t this_ptr) {
22988         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22989         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22990         this_ptr_conv.is_owned = false;
22991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22992         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
22993         memcpy(ret_arr->elems, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
22994         return ret_arr;
22995 }
22996
22997 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_per_commitment_point"))) TS_DelayedPaymentOutputDescriptor_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
22998         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23000         this_ptr_conv.is_owned = false;
23001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23002         LDKPublicKey val_ref;
23003         CHECK(val->arr_len == 33);
23004         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
23005         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
23006 }
23007
23008 int16_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_to_self_delay"))) TS_DelayedPaymentOutputDescriptor_get_to_self_delay(uint32_t this_ptr) {
23009         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23011         this_ptr_conv.is_owned = false;
23012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23013         int16_t ret_conv = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
23014         return ret_conv;
23015 }
23016
23017 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_to_self_delay"))) TS_DelayedPaymentOutputDescriptor_set_to_self_delay(uint32_t this_ptr, int16_t val) {
23018         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23020         this_ptr_conv.is_owned = false;
23021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23022         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
23023 }
23024
23025 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_output"))) TS_DelayedPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
23026         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23027         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23028         this_ptr_conv.is_owned = false;
23029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23030         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
23031         CHECK_ACCESS(val_ptr);
23032         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
23033         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
23034         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
23035 }
23036
23037 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey"))) TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey(uint32_t this_ptr) {
23038         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23040         this_ptr_conv.is_owned = false;
23041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23042         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
23043         memcpy(ret_arr->elems, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form, 33);
23044         return ret_arr;
23045 }
23046
23047 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey"))) TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey(uint32_t this_ptr, int8_tArray val) {
23048         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23050         this_ptr_conv.is_owned = false;
23051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23052         LDKPublicKey val_ref;
23053         CHECK(val->arr_len == 33);
23054         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
23055         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
23056 }
23057
23058 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_channel_keys_id"))) TS_DelayedPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
23059         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23061         this_ptr_conv.is_owned = false;
23062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23063         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23064         memcpy(ret_arr->elems, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
23065         return ret_arr;
23066 }
23067
23068 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_channel_keys_id"))) TS_DelayedPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
23069         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23070         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23071         this_ptr_conv.is_owned = false;
23072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23073         LDKThirtyTwoBytes val_ref;
23074         CHECK(val->arr_len == 32);
23075         memcpy(val_ref.data, val->elems, 32); FREE(val);
23076         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
23077 }
23078
23079 int64_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis"))) TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
23080         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23082         this_ptr_conv.is_owned = false;
23083         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23084         int64_t ret_conv = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
23085         return ret_conv;
23086 }
23087
23088 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis"))) TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
23089         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23090         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23091         this_ptr_conv.is_owned = false;
23092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23093         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
23094 }
23095
23096 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) {
23097         LDKOutPoint outpoint_arg_conv;
23098         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
23099         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
23100         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
23101         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
23102         LDKPublicKey per_commitment_point_arg_ref;
23103         CHECK(per_commitment_point_arg->arr_len == 33);
23104         memcpy(per_commitment_point_arg_ref.compressed_form, per_commitment_point_arg->elems, 33); FREE(per_commitment_point_arg);
23105         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
23106         CHECK_ACCESS(output_arg_ptr);
23107         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
23108         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
23109         LDKPublicKey revocation_pubkey_arg_ref;
23110         CHECK(revocation_pubkey_arg->arr_len == 33);
23111         memcpy(revocation_pubkey_arg_ref.compressed_form, revocation_pubkey_arg->elems, 33); FREE(revocation_pubkey_arg);
23112         LDKThirtyTwoBytes channel_keys_id_arg_ref;
23113         CHECK(channel_keys_id_arg->arr_len == 32);
23114         memcpy(channel_keys_id_arg_ref.data, channel_keys_id_arg->elems, 32); FREE(channel_keys_id_arg);
23115         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);
23116         uint32_t ret_ref = 0;
23117         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23118         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23119         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23120         ret_ref = (uintptr_t)ret_var.inner;
23121         if (ret_var.is_owned) {
23122                 ret_ref |= 1;
23123         }
23124         return ret_ref;
23125 }
23126
23127 static inline uintptr_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
23128         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
23129 uint32_t ret_ref = 0;
23130 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23131 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23132 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23133 ret_ref = (uintptr_t)ret_var.inner;
23134 if (ret_var.is_owned) {
23135         ret_ref |= 1;
23136 }
23137         return ret_ref;
23138 }
23139 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_clone_ptr"))) TS_DelayedPaymentOutputDescriptor_clone_ptr(uint32_t arg) {
23140         LDKDelayedPaymentOutputDescriptor arg_conv;
23141         arg_conv.inner = (void*)(arg & (~1));
23142         arg_conv.is_owned = false;
23143         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23144         uint32_t ret_conv = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
23145         return ret_conv;
23146 }
23147
23148 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_clone"))) TS_DelayedPaymentOutputDescriptor_clone(uint32_t orig) {
23149         LDKDelayedPaymentOutputDescriptor orig_conv;
23150         orig_conv.inner = (void*)(orig & (~1));
23151         orig_conv.is_owned = false;
23152         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23153         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
23154         uint32_t ret_ref = 0;
23155         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23156         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23157         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23158         ret_ref = (uintptr_t)ret_var.inner;
23159         if (ret_var.is_owned) {
23160                 ret_ref |= 1;
23161         }
23162         return ret_ref;
23163 }
23164
23165 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_write"))) TS_DelayedPaymentOutputDescriptor_write(uint32_t obj) {
23166         LDKDelayedPaymentOutputDescriptor obj_conv;
23167         obj_conv.inner = (void*)(obj & (~1));
23168         obj_conv.is_owned = false;
23169         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23170         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
23171         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23172         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23173         CVec_u8Z_free(ret_var);
23174         return ret_arr;
23175 }
23176
23177 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_read"))) TS_DelayedPaymentOutputDescriptor_read(int8_tArray ser) {
23178         LDKu8slice ser_ref;
23179         ser_ref.datalen = ser->arr_len;
23180         ser_ref.data = ser->elems /* XXX ser leaks */;
23181         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
23182         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
23183         return (uint32_t)ret_conv;
23184 }
23185
23186 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_free"))) TS_StaticPaymentOutputDescriptor_free(uint32_t this_obj) {
23187         LDKStaticPaymentOutputDescriptor this_obj_conv;
23188         this_obj_conv.inner = (void*)(this_obj & (~1));
23189         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23191         StaticPaymentOutputDescriptor_free(this_obj_conv);
23192 }
23193
23194 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_outpoint"))) TS_StaticPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
23195         LDKStaticPaymentOutputDescriptor this_ptr_conv;
23196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23197         this_ptr_conv.is_owned = false;
23198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23199         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
23200         uint32_t ret_ref = 0;
23201         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23202         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23203         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23204         ret_ref = (uintptr_t)ret_var.inner;
23205         if (ret_var.is_owned) {
23206                 ret_ref |= 1;
23207         }
23208         return ret_ref;
23209 }
23210
23211 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_outpoint"))) TS_StaticPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
23212         LDKStaticPaymentOutputDescriptor this_ptr_conv;
23213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23214         this_ptr_conv.is_owned = false;
23215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23216         LDKOutPoint val_conv;
23217         val_conv.inner = (void*)(val & (~1));
23218         val_conv.is_owned = (val & 1) || (val == 0);
23219         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
23220         val_conv = OutPoint_clone(&val_conv);
23221         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
23222 }
23223
23224 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_output"))) TS_StaticPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
23225         LDKStaticPaymentOutputDescriptor this_ptr_conv;
23226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23227         this_ptr_conv.is_owned = false;
23228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23229         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
23230         CHECK_ACCESS(val_ptr);
23231         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
23232         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
23233         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
23234 }
23235
23236 int8_tArray  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_channel_keys_id"))) TS_StaticPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
23237         LDKStaticPaymentOutputDescriptor this_ptr_conv;
23238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23239         this_ptr_conv.is_owned = false;
23240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23241         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23242         memcpy(ret_arr->elems, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
23243         return ret_arr;
23244 }
23245
23246 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_channel_keys_id"))) TS_StaticPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
23247         LDKStaticPaymentOutputDescriptor this_ptr_conv;
23248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23249         this_ptr_conv.is_owned = false;
23250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23251         LDKThirtyTwoBytes val_ref;
23252         CHECK(val->arr_len == 32);
23253         memcpy(val_ref.data, val->elems, 32); FREE(val);
23254         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
23255 }
23256
23257 int64_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis"))) TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
23258         LDKStaticPaymentOutputDescriptor this_ptr_conv;
23259         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23260         this_ptr_conv.is_owned = false;
23261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23262         int64_t ret_conv = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
23263         return ret_conv;
23264 }
23265
23266 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis"))) TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
23267         LDKStaticPaymentOutputDescriptor this_ptr_conv;
23268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23269         this_ptr_conv.is_owned = false;
23270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23271         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
23272 }
23273
23274 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) {
23275         LDKOutPoint outpoint_arg_conv;
23276         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
23277         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
23278         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
23279         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
23280         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
23281         CHECK_ACCESS(output_arg_ptr);
23282         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
23283         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
23284         LDKThirtyTwoBytes channel_keys_id_arg_ref;
23285         CHECK(channel_keys_id_arg->arr_len == 32);
23286         memcpy(channel_keys_id_arg_ref.data, channel_keys_id_arg->elems, 32); FREE(channel_keys_id_arg);
23287         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
23288         uint32_t ret_ref = 0;
23289         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23290         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23291         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23292         ret_ref = (uintptr_t)ret_var.inner;
23293         if (ret_var.is_owned) {
23294                 ret_ref |= 1;
23295         }
23296         return ret_ref;
23297 }
23298
23299 static inline uintptr_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
23300         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
23301 uint32_t ret_ref = 0;
23302 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23303 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23304 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23305 ret_ref = (uintptr_t)ret_var.inner;
23306 if (ret_var.is_owned) {
23307         ret_ref |= 1;
23308 }
23309         return ret_ref;
23310 }
23311 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_clone_ptr"))) TS_StaticPaymentOutputDescriptor_clone_ptr(uint32_t arg) {
23312         LDKStaticPaymentOutputDescriptor arg_conv;
23313         arg_conv.inner = (void*)(arg & (~1));
23314         arg_conv.is_owned = false;
23315         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23316         uint32_t ret_conv = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
23317         return ret_conv;
23318 }
23319
23320 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_clone"))) TS_StaticPaymentOutputDescriptor_clone(uint32_t orig) {
23321         LDKStaticPaymentOutputDescriptor orig_conv;
23322         orig_conv.inner = (void*)(orig & (~1));
23323         orig_conv.is_owned = false;
23324         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23325         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
23326         uint32_t ret_ref = 0;
23327         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23328         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23329         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23330         ret_ref = (uintptr_t)ret_var.inner;
23331         if (ret_var.is_owned) {
23332                 ret_ref |= 1;
23333         }
23334         return ret_ref;
23335 }
23336
23337 int8_tArray  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_write"))) TS_StaticPaymentOutputDescriptor_write(uint32_t obj) {
23338         LDKStaticPaymentOutputDescriptor obj_conv;
23339         obj_conv.inner = (void*)(obj & (~1));
23340         obj_conv.is_owned = false;
23341         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23342         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
23343         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23344         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23345         CVec_u8Z_free(ret_var);
23346         return ret_arr;
23347 }
23348
23349 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_read"))) TS_StaticPaymentOutputDescriptor_read(int8_tArray ser) {
23350         LDKu8slice ser_ref;
23351         ser_ref.datalen = ser->arr_len;
23352         ser_ref.data = ser->elems /* XXX ser leaks */;
23353         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
23354         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
23355         return (uint32_t)ret_conv;
23356 }
23357
23358 void  __attribute__((export_name("TS_SpendableOutputDescriptor_free"))) TS_SpendableOutputDescriptor_free(uint32_t this_ptr) {
23359         if ((this_ptr & 1) != 0) return;
23360         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23361         CHECK_ACCESS(this_ptr_ptr);
23362         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
23363         FREE((void*)this_ptr);
23364         SpendableOutputDescriptor_free(this_ptr_conv);
23365 }
23366
23367 static inline uintptr_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
23368         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
23369         *ret_copy = SpendableOutputDescriptor_clone(arg);
23370 uint32_t ret_ref = (uintptr_t)ret_copy;
23371         return ret_ref;
23372 }
23373 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_clone_ptr"))) TS_SpendableOutputDescriptor_clone_ptr(uint32_t arg) {
23374         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)arg;
23375         uint32_t ret_conv = SpendableOutputDescriptor_clone_ptr(arg_conv);
23376         return ret_conv;
23377 }
23378
23379 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_clone"))) TS_SpendableOutputDescriptor_clone(uint32_t orig) {
23380         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
23381         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
23382         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
23383         uint32_t ret_ref = (uintptr_t)ret_copy;
23384         return ret_ref;
23385 }
23386
23387 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_static_output"))) TS_SpendableOutputDescriptor_static_output(uint32_t outpoint, uint32_t output) {
23388         LDKOutPoint outpoint_conv;
23389         outpoint_conv.inner = (void*)(outpoint & (~1));
23390         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
23391         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
23392         outpoint_conv = OutPoint_clone(&outpoint_conv);
23393         void* output_ptr = (void*)(((uintptr_t)output) & ~1);
23394         CHECK_ACCESS(output_ptr);
23395         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
23396         output_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output) & ~1));
23397         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
23398         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
23399         uint32_t ret_ref = (uintptr_t)ret_copy;
23400         return ret_ref;
23401 }
23402
23403 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_delayed_payment_output"))) TS_SpendableOutputDescriptor_delayed_payment_output(uint32_t a) {
23404         LDKDelayedPaymentOutputDescriptor a_conv;
23405         a_conv.inner = (void*)(a & (~1));
23406         a_conv.is_owned = (a & 1) || (a == 0);
23407         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23408         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
23409         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
23410         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
23411         uint32_t ret_ref = (uintptr_t)ret_copy;
23412         return ret_ref;
23413 }
23414
23415 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_static_payment_output"))) TS_SpendableOutputDescriptor_static_payment_output(uint32_t a) {
23416         LDKStaticPaymentOutputDescriptor a_conv;
23417         a_conv.inner = (void*)(a & (~1));
23418         a_conv.is_owned = (a & 1) || (a == 0);
23419         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23420         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
23421         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
23422         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
23423         uint32_t ret_ref = (uintptr_t)ret_copy;
23424         return ret_ref;
23425 }
23426
23427 int8_tArray  __attribute__((export_name("TS_SpendableOutputDescriptor_write"))) TS_SpendableOutputDescriptor_write(uint32_t obj) {
23428         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
23429         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
23430         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23431         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23432         CVec_u8Z_free(ret_var);
23433         return ret_arr;
23434 }
23435
23436 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_read"))) TS_SpendableOutputDescriptor_read(int8_tArray ser) {
23437         LDKu8slice ser_ref;
23438         ser_ref.datalen = ser->arr_len;
23439         ser_ref.data = ser->elems /* XXX ser leaks */;
23440         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
23441         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
23442         return (uint32_t)ret_conv;
23443 }
23444
23445 void  __attribute__((export_name("TS_BaseSign_free"))) TS_BaseSign_free(uint32_t this_ptr) {
23446         if ((this_ptr & 1) != 0) return;
23447         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23448         CHECK_ACCESS(this_ptr_ptr);
23449         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
23450         FREE((void*)this_ptr);
23451         BaseSign_free(this_ptr_conv);
23452 }
23453
23454 static inline uintptr_t Sign_clone_ptr(LDKSign *NONNULL_PTR arg) {
23455         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
23456         *ret_ret = Sign_clone(arg);
23457         return (uint32_t)ret_ret;
23458 }
23459 uint32_t  __attribute__((export_name("TS_Sign_clone_ptr"))) TS_Sign_clone_ptr(uint32_t arg) {
23460         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
23461         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
23462         LDKSign* arg_conv = (LDKSign*)arg_ptr;
23463         uint32_t ret_conv = Sign_clone_ptr(arg_conv);
23464         return ret_conv;
23465 }
23466
23467 uint32_t  __attribute__((export_name("TS_Sign_clone"))) TS_Sign_clone(uint32_t orig) {
23468         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
23469         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
23470         LDKSign* orig_conv = (LDKSign*)orig_ptr;
23471         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
23472         *ret_ret = Sign_clone(orig_conv);
23473         return (uint32_t)ret_ret;
23474 }
23475
23476 void  __attribute__((export_name("TS_Sign_free"))) TS_Sign_free(uint32_t this_ptr) {
23477         if ((this_ptr & 1) != 0) return;
23478         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23479         CHECK_ACCESS(this_ptr_ptr);
23480         LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
23481         FREE((void*)this_ptr);
23482         Sign_free(this_ptr_conv);
23483 }
23484
23485 uint32_t  __attribute__((export_name("TS_Recipient_clone"))) TS_Recipient_clone(uint32_t orig) {
23486         LDKRecipient* orig_conv = (LDKRecipient*)(orig & ~1);
23487         uint32_t ret_conv = LDKRecipient_to_js(Recipient_clone(orig_conv));
23488         return ret_conv;
23489 }
23490
23491 uint32_t  __attribute__((export_name("TS_Recipient_node"))) TS_Recipient_node() {
23492         uint32_t ret_conv = LDKRecipient_to_js(Recipient_node());
23493         return ret_conv;
23494 }
23495
23496 uint32_t  __attribute__((export_name("TS_Recipient_phantom_node"))) TS_Recipient_phantom_node() {
23497         uint32_t ret_conv = LDKRecipient_to_js(Recipient_phantom_node());
23498         return ret_conv;
23499 }
23500
23501 void  __attribute__((export_name("TS_KeysInterface_free"))) TS_KeysInterface_free(uint32_t this_ptr) {
23502         if ((this_ptr & 1) != 0) return;
23503         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23504         CHECK_ACCESS(this_ptr_ptr);
23505         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
23506         FREE((void*)this_ptr);
23507         KeysInterface_free(this_ptr_conv);
23508 }
23509
23510 void  __attribute__((export_name("TS_InMemorySigner_free"))) TS_InMemorySigner_free(uint32_t this_obj) {
23511         LDKInMemorySigner this_obj_conv;
23512         this_obj_conv.inner = (void*)(this_obj & (~1));
23513         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23515         InMemorySigner_free(this_obj_conv);
23516 }
23517
23518 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_funding_key"))) TS_InMemorySigner_get_funding_key(uint32_t this_ptr) {
23519         LDKInMemorySigner this_ptr_conv;
23520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23521         this_ptr_conv.is_owned = false;
23522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23523         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23524         memcpy(ret_arr->elems, *InMemorySigner_get_funding_key(&this_ptr_conv), 32);
23525         return ret_arr;
23526 }
23527
23528 void  __attribute__((export_name("TS_InMemorySigner_set_funding_key"))) TS_InMemorySigner_set_funding_key(uint32_t this_ptr, int8_tArray val) {
23529         LDKInMemorySigner this_ptr_conv;
23530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23531         this_ptr_conv.is_owned = false;
23532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23533         LDKSecretKey val_ref;
23534         CHECK(val->arr_len == 32);
23535         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
23536         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
23537 }
23538
23539 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_revocation_base_key"))) TS_InMemorySigner_get_revocation_base_key(uint32_t this_ptr) {
23540         LDKInMemorySigner this_ptr_conv;
23541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23542         this_ptr_conv.is_owned = false;
23543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23544         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23545         memcpy(ret_arr->elems, *InMemorySigner_get_revocation_base_key(&this_ptr_conv), 32);
23546         return ret_arr;
23547 }
23548
23549 void  __attribute__((export_name("TS_InMemorySigner_set_revocation_base_key"))) TS_InMemorySigner_set_revocation_base_key(uint32_t this_ptr, int8_tArray val) {
23550         LDKInMemorySigner this_ptr_conv;
23551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23552         this_ptr_conv.is_owned = false;
23553         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23554         LDKSecretKey val_ref;
23555         CHECK(val->arr_len == 32);
23556         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
23557         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
23558 }
23559
23560 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_payment_key"))) TS_InMemorySigner_get_payment_key(uint32_t this_ptr) {
23561         LDKInMemorySigner this_ptr_conv;
23562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23563         this_ptr_conv.is_owned = false;
23564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23565         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23566         memcpy(ret_arr->elems, *InMemorySigner_get_payment_key(&this_ptr_conv), 32);
23567         return ret_arr;
23568 }
23569
23570 void  __attribute__((export_name("TS_InMemorySigner_set_payment_key"))) TS_InMemorySigner_set_payment_key(uint32_t this_ptr, int8_tArray val) {
23571         LDKInMemorySigner this_ptr_conv;
23572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23573         this_ptr_conv.is_owned = false;
23574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23575         LDKSecretKey val_ref;
23576         CHECK(val->arr_len == 32);
23577         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
23578         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
23579 }
23580
23581 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_delayed_payment_base_key"))) TS_InMemorySigner_get_delayed_payment_base_key(uint32_t this_ptr) {
23582         LDKInMemorySigner this_ptr_conv;
23583         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23584         this_ptr_conv.is_owned = false;
23585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23586         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23587         memcpy(ret_arr->elems, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv), 32);
23588         return ret_arr;
23589 }
23590
23591 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) {
23592         LDKInMemorySigner this_ptr_conv;
23593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23594         this_ptr_conv.is_owned = false;
23595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23596         LDKSecretKey val_ref;
23597         CHECK(val->arr_len == 32);
23598         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
23599         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
23600 }
23601
23602 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_htlc_base_key"))) TS_InMemorySigner_get_htlc_base_key(uint32_t this_ptr) {
23603         LDKInMemorySigner this_ptr_conv;
23604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23605         this_ptr_conv.is_owned = false;
23606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23607         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23608         memcpy(ret_arr->elems, *InMemorySigner_get_htlc_base_key(&this_ptr_conv), 32);
23609         return ret_arr;
23610 }
23611
23612 void  __attribute__((export_name("TS_InMemorySigner_set_htlc_base_key"))) TS_InMemorySigner_set_htlc_base_key(uint32_t this_ptr, int8_tArray val) {
23613         LDKInMemorySigner this_ptr_conv;
23614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23615         this_ptr_conv.is_owned = false;
23616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23617         LDKSecretKey val_ref;
23618         CHECK(val->arr_len == 32);
23619         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
23620         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
23621 }
23622
23623 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_commitment_seed"))) TS_InMemorySigner_get_commitment_seed(uint32_t this_ptr) {
23624         LDKInMemorySigner this_ptr_conv;
23625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23626         this_ptr_conv.is_owned = false;
23627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23628         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23629         memcpy(ret_arr->elems, *InMemorySigner_get_commitment_seed(&this_ptr_conv), 32);
23630         return ret_arr;
23631 }
23632
23633 void  __attribute__((export_name("TS_InMemorySigner_set_commitment_seed"))) TS_InMemorySigner_set_commitment_seed(uint32_t this_ptr, int8_tArray val) {
23634         LDKInMemorySigner this_ptr_conv;
23635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23636         this_ptr_conv.is_owned = false;
23637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23638         LDKThirtyTwoBytes val_ref;
23639         CHECK(val->arr_len == 32);
23640         memcpy(val_ref.data, val->elems, 32); FREE(val);
23641         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
23642 }
23643
23644 static inline uintptr_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
23645         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
23646 uint32_t ret_ref = 0;
23647 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23648 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23649 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23650 ret_ref = (uintptr_t)ret_var.inner;
23651 if (ret_var.is_owned) {
23652         ret_ref |= 1;
23653 }
23654         return ret_ref;
23655 }
23656 uint32_t  __attribute__((export_name("TS_InMemorySigner_clone_ptr"))) TS_InMemorySigner_clone_ptr(uint32_t arg) {
23657         LDKInMemorySigner arg_conv;
23658         arg_conv.inner = (void*)(arg & (~1));
23659         arg_conv.is_owned = false;
23660         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23661         uint32_t ret_conv = InMemorySigner_clone_ptr(&arg_conv);
23662         return ret_conv;
23663 }
23664
23665 uint32_t  __attribute__((export_name("TS_InMemorySigner_clone"))) TS_InMemorySigner_clone(uint32_t orig) {
23666         LDKInMemorySigner orig_conv;
23667         orig_conv.inner = (void*)(orig & (~1));
23668         orig_conv.is_owned = false;
23669         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23670         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
23671         uint32_t ret_ref = 0;
23672         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23673         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23674         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23675         ret_ref = (uintptr_t)ret_var.inner;
23676         if (ret_var.is_owned) {
23677                 ret_ref |= 1;
23678         }
23679         return ret_ref;
23680 }
23681
23682 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) {
23683         LDKSecretKey node_secret_ref;
23684         CHECK(node_secret->arr_len == 32);
23685         memcpy(node_secret_ref.bytes, node_secret->elems, 32); FREE(node_secret);
23686         LDKSecretKey funding_key_ref;
23687         CHECK(funding_key->arr_len == 32);
23688         memcpy(funding_key_ref.bytes, funding_key->elems, 32); FREE(funding_key);
23689         LDKSecretKey revocation_base_key_ref;
23690         CHECK(revocation_base_key->arr_len == 32);
23691         memcpy(revocation_base_key_ref.bytes, revocation_base_key->elems, 32); FREE(revocation_base_key);
23692         LDKSecretKey payment_key_ref;
23693         CHECK(payment_key->arr_len == 32);
23694         memcpy(payment_key_ref.bytes, payment_key->elems, 32); FREE(payment_key);
23695         LDKSecretKey delayed_payment_base_key_ref;
23696         CHECK(delayed_payment_base_key->arr_len == 32);
23697         memcpy(delayed_payment_base_key_ref.bytes, delayed_payment_base_key->elems, 32); FREE(delayed_payment_base_key);
23698         LDKSecretKey htlc_base_key_ref;
23699         CHECK(htlc_base_key->arr_len == 32);
23700         memcpy(htlc_base_key_ref.bytes, htlc_base_key->elems, 32); FREE(htlc_base_key);
23701         LDKThirtyTwoBytes commitment_seed_ref;
23702         CHECK(commitment_seed->arr_len == 32);
23703         memcpy(commitment_seed_ref.data, commitment_seed->elems, 32); FREE(commitment_seed);
23704         LDKThirtyTwoBytes channel_keys_id_ref;
23705         CHECK(channel_keys_id->arr_len == 32);
23706         memcpy(channel_keys_id_ref.data, channel_keys_id->elems, 32); FREE(channel_keys_id);
23707         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);
23708         uint32_t ret_ref = 0;
23709         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23710         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23711         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23712         ret_ref = (uintptr_t)ret_var.inner;
23713         if (ret_var.is_owned) {
23714                 ret_ref |= 1;
23715         }
23716         return ret_ref;
23717 }
23718
23719 uint32_t  __attribute__((export_name("TS_InMemorySigner_counterparty_pubkeys"))) TS_InMemorySigner_counterparty_pubkeys(uint32_t this_arg) {
23720         LDKInMemorySigner this_arg_conv;
23721         this_arg_conv.inner = (void*)(this_arg & (~1));
23722         this_arg_conv.is_owned = false;
23723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23724         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
23725         uint32_t ret_ref = 0;
23726         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23727         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23728         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23729         ret_ref = (uintptr_t)ret_var.inner;
23730         if (ret_var.is_owned) {
23731                 ret_ref |= 1;
23732         }
23733         return ret_ref;
23734 }
23735
23736 int16_t  __attribute__((export_name("TS_InMemorySigner_counterparty_selected_contest_delay"))) TS_InMemorySigner_counterparty_selected_contest_delay(uint32_t this_arg) {
23737         LDKInMemorySigner this_arg_conv;
23738         this_arg_conv.inner = (void*)(this_arg & (~1));
23739         this_arg_conv.is_owned = false;
23740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23741         int16_t ret_conv = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
23742         return ret_conv;
23743 }
23744
23745 int16_t  __attribute__((export_name("TS_InMemorySigner_holder_selected_contest_delay"))) TS_InMemorySigner_holder_selected_contest_delay(uint32_t this_arg) {
23746         LDKInMemorySigner this_arg_conv;
23747         this_arg_conv.inner = (void*)(this_arg & (~1));
23748         this_arg_conv.is_owned = false;
23749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23750         int16_t ret_conv = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
23751         return ret_conv;
23752 }
23753
23754 jboolean  __attribute__((export_name("TS_InMemorySigner_is_outbound"))) TS_InMemorySigner_is_outbound(uint32_t this_arg) {
23755         LDKInMemorySigner this_arg_conv;
23756         this_arg_conv.inner = (void*)(this_arg & (~1));
23757         this_arg_conv.is_owned = false;
23758         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23759         jboolean ret_conv = InMemorySigner_is_outbound(&this_arg_conv);
23760         return ret_conv;
23761 }
23762
23763 uint32_t  __attribute__((export_name("TS_InMemorySigner_funding_outpoint"))) TS_InMemorySigner_funding_outpoint(uint32_t this_arg) {
23764         LDKInMemorySigner this_arg_conv;
23765         this_arg_conv.inner = (void*)(this_arg & (~1));
23766         this_arg_conv.is_owned = false;
23767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23768         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
23769         uint32_t ret_ref = 0;
23770         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23771         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23772         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23773         ret_ref = (uintptr_t)ret_var.inner;
23774         if (ret_var.is_owned) {
23775                 ret_ref |= 1;
23776         }
23777         return ret_ref;
23778 }
23779
23780 uint32_t  __attribute__((export_name("TS_InMemorySigner_get_channel_parameters"))) TS_InMemorySigner_get_channel_parameters(uint32_t this_arg) {
23781         LDKInMemorySigner this_arg_conv;
23782         this_arg_conv.inner = (void*)(this_arg & (~1));
23783         this_arg_conv.is_owned = false;
23784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23785         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
23786         uint32_t ret_ref = 0;
23787         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23788         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23789         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23790         ret_ref = (uintptr_t)ret_var.inner;
23791         if (ret_var.is_owned) {
23792                 ret_ref |= 1;
23793         }
23794         return ret_ref;
23795 }
23796
23797 jboolean  __attribute__((export_name("TS_InMemorySigner_opt_anchors"))) TS_InMemorySigner_opt_anchors(uint32_t this_arg) {
23798         LDKInMemorySigner this_arg_conv;
23799         this_arg_conv.inner = (void*)(this_arg & (~1));
23800         this_arg_conv.is_owned = false;
23801         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23802         jboolean ret_conv = InMemorySigner_opt_anchors(&this_arg_conv);
23803         return ret_conv;
23804 }
23805
23806 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) {
23807         LDKInMemorySigner this_arg_conv;
23808         this_arg_conv.inner = (void*)(this_arg & (~1));
23809         this_arg_conv.is_owned = false;
23810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23811         LDKTransaction spend_tx_ref;
23812         spend_tx_ref.datalen = spend_tx->arr_len;
23813         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
23814         memcpy(spend_tx_ref.data, spend_tx->elems, spend_tx_ref.datalen); FREE(spend_tx);
23815         spend_tx_ref.data_is_owned = true;
23816         LDKStaticPaymentOutputDescriptor descriptor_conv;
23817         descriptor_conv.inner = (void*)(descriptor & (~1));
23818         descriptor_conv.is_owned = false;
23819         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
23820         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
23821         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
23822         return (uint32_t)ret_conv;
23823 }
23824
23825 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) {
23826         LDKInMemorySigner this_arg_conv;
23827         this_arg_conv.inner = (void*)(this_arg & (~1));
23828         this_arg_conv.is_owned = false;
23829         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23830         LDKTransaction spend_tx_ref;
23831         spend_tx_ref.datalen = spend_tx->arr_len;
23832         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
23833         memcpy(spend_tx_ref.data, spend_tx->elems, spend_tx_ref.datalen); FREE(spend_tx);
23834         spend_tx_ref.data_is_owned = true;
23835         LDKDelayedPaymentOutputDescriptor descriptor_conv;
23836         descriptor_conv.inner = (void*)(descriptor & (~1));
23837         descriptor_conv.is_owned = false;
23838         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
23839         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
23840         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
23841         return (uint32_t)ret_conv;
23842 }
23843
23844 uint32_t  __attribute__((export_name("TS_InMemorySigner_as_BaseSign"))) TS_InMemorySigner_as_BaseSign(uint32_t this_arg) {
23845         LDKInMemorySigner this_arg_conv;
23846         this_arg_conv.inner = (void*)(this_arg & (~1));
23847         this_arg_conv.is_owned = false;
23848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23849         LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
23850         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
23851         return (uint32_t)ret_ret;
23852 }
23853
23854 uint32_t  __attribute__((export_name("TS_InMemorySigner_as_Sign"))) TS_InMemorySigner_as_Sign(uint32_t this_arg) {
23855         LDKInMemorySigner this_arg_conv;
23856         this_arg_conv.inner = (void*)(this_arg & (~1));
23857         this_arg_conv.is_owned = false;
23858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23859         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
23860         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
23861         return (uint32_t)ret_ret;
23862 }
23863
23864 int8_tArray  __attribute__((export_name("TS_InMemorySigner_write"))) TS_InMemorySigner_write(uint32_t obj) {
23865         LDKInMemorySigner obj_conv;
23866         obj_conv.inner = (void*)(obj & (~1));
23867         obj_conv.is_owned = false;
23868         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23869         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
23870         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23871         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23872         CVec_u8Z_free(ret_var);
23873         return ret_arr;
23874 }
23875
23876 uint32_t  __attribute__((export_name("TS_InMemorySigner_read"))) TS_InMemorySigner_read(int8_tArray ser, int8_tArray arg) {
23877         LDKu8slice ser_ref;
23878         ser_ref.datalen = ser->arr_len;
23879         ser_ref.data = ser->elems /* XXX ser leaks */;
23880         LDKSecretKey arg_ref;
23881         CHECK(arg->arr_len == 32);
23882         memcpy(arg_ref.bytes, arg->elems, 32); FREE(arg);
23883         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
23884         *ret_conv = InMemorySigner_read(ser_ref, arg_ref);
23885         return (uint32_t)ret_conv;
23886 }
23887
23888 void  __attribute__((export_name("TS_KeysManager_free"))) TS_KeysManager_free(uint32_t this_obj) {
23889         LDKKeysManager this_obj_conv;
23890         this_obj_conv.inner = (void*)(this_obj & (~1));
23891         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23893         KeysManager_free(this_obj_conv);
23894 }
23895
23896 uint32_t  __attribute__((export_name("TS_KeysManager_new"))) TS_KeysManager_new(int8_tArray seed, int64_t starting_time_secs, int32_t starting_time_nanos) {
23897         unsigned char seed_arr[32];
23898         CHECK(seed->arr_len == 32);
23899         memcpy(seed_arr, seed->elems, 32); FREE(seed);
23900         unsigned char (*seed_ref)[32] = &seed_arr;
23901         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
23902         uint32_t ret_ref = 0;
23903         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23904         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23905         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23906         ret_ref = (uintptr_t)ret_var.inner;
23907         if (ret_var.is_owned) {
23908                 ret_ref |= 1;
23909         }
23910         return ret_ref;
23911 }
23912
23913 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) {
23914         LDKKeysManager this_arg_conv;
23915         this_arg_conv.inner = (void*)(this_arg & (~1));
23916         this_arg_conv.is_owned = false;
23917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23918         unsigned char params_arr[32];
23919         CHECK(params->arr_len == 32);
23920         memcpy(params_arr, params->elems, 32); FREE(params);
23921         unsigned char (*params_ref)[32] = &params_arr;
23922         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
23923         uint32_t ret_ref = 0;
23924         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23925         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23926         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23927         ret_ref = (uintptr_t)ret_var.inner;
23928         if (ret_var.is_owned) {
23929                 ret_ref |= 1;
23930         }
23931         return ret_ref;
23932 }
23933
23934 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) {
23935         LDKKeysManager this_arg_conv;
23936         this_arg_conv.inner = (void*)(this_arg & (~1));
23937         this_arg_conv.is_owned = false;
23938         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23939         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
23940         descriptors_constr.datalen = descriptors->arr_len;
23941         if (descriptors_constr.datalen > 0)
23942                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
23943         else
23944                 descriptors_constr.data = NULL;
23945         uint32_t* descriptors_vals = descriptors->elems /* XXX descriptors leaks */;
23946         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
23947                 uint32_t descriptors_conv_27 = descriptors_vals[b];
23948                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
23949                 CHECK_ACCESS(descriptors_conv_27_ptr);
23950                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
23951                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
23952                 descriptors_constr.data[b] = descriptors_conv_27_conv;
23953         }
23954         LDKCVec_TxOutZ outputs_constr;
23955         outputs_constr.datalen = outputs->arr_len;
23956         if (outputs_constr.datalen > 0)
23957                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
23958         else
23959                 outputs_constr.data = NULL;
23960         uint32_t* outputs_vals = outputs->elems /* XXX outputs leaks */;
23961         for (size_t h = 0; h < outputs_constr.datalen; h++) {
23962                 uint32_t outputs_conv_7 = outputs_vals[h];
23963                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
23964                 CHECK_ACCESS(outputs_conv_7_ptr);
23965                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
23966                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
23967                 outputs_constr.data[h] = outputs_conv_7_conv;
23968         }
23969         LDKCVec_u8Z change_destination_script_ref;
23970         change_destination_script_ref.datalen = change_destination_script->arr_len;
23971         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
23972         memcpy(change_destination_script_ref.data, change_destination_script->elems, change_destination_script_ref.datalen); FREE(change_destination_script);
23973         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
23974         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
23975         return (uint32_t)ret_conv;
23976 }
23977
23978 uint32_t  __attribute__((export_name("TS_KeysManager_as_KeysInterface"))) TS_KeysManager_as_KeysInterface(uint32_t this_arg) {
23979         LDKKeysManager this_arg_conv;
23980         this_arg_conv.inner = (void*)(this_arg & (~1));
23981         this_arg_conv.is_owned = false;
23982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23983         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
23984         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
23985         return (uint32_t)ret_ret;
23986 }
23987
23988 void  __attribute__((export_name("TS_PhantomKeysManager_free"))) TS_PhantomKeysManager_free(uint32_t this_obj) {
23989         LDKPhantomKeysManager this_obj_conv;
23990         this_obj_conv.inner = (void*)(this_obj & (~1));
23991         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23993         PhantomKeysManager_free(this_obj_conv);
23994 }
23995
23996 uint32_t  __attribute__((export_name("TS_PhantomKeysManager_as_KeysInterface"))) TS_PhantomKeysManager_as_KeysInterface(uint32_t this_arg) {
23997         LDKPhantomKeysManager this_arg_conv;
23998         this_arg_conv.inner = (void*)(this_arg & (~1));
23999         this_arg_conv.is_owned = false;
24000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24001         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
24002         *ret_ret = PhantomKeysManager_as_KeysInterface(&this_arg_conv);
24003         return (uint32_t)ret_ret;
24004 }
24005
24006 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) {
24007         unsigned char seed_arr[32];
24008         CHECK(seed->arr_len == 32);
24009         memcpy(seed_arr, seed->elems, 32); FREE(seed);
24010         unsigned char (*seed_ref)[32] = &seed_arr;
24011         unsigned char cross_node_seed_arr[32];
24012         CHECK(cross_node_seed->arr_len == 32);
24013         memcpy(cross_node_seed_arr, cross_node_seed->elems, 32); FREE(cross_node_seed);
24014         unsigned char (*cross_node_seed_ref)[32] = &cross_node_seed_arr;
24015         LDKPhantomKeysManager ret_var = PhantomKeysManager_new(seed_ref, starting_time_secs, starting_time_nanos, cross_node_seed_ref);
24016         uint32_t ret_ref = 0;
24017         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24018         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24019         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24020         ret_ref = (uintptr_t)ret_var.inner;
24021         if (ret_var.is_owned) {
24022                 ret_ref |= 1;
24023         }
24024         return ret_ref;
24025 }
24026
24027 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) {
24028         LDKPhantomKeysManager this_arg_conv;
24029         this_arg_conv.inner = (void*)(this_arg & (~1));
24030         this_arg_conv.is_owned = false;
24031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24032         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
24033         descriptors_constr.datalen = descriptors->arr_len;
24034         if (descriptors_constr.datalen > 0)
24035                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
24036         else
24037                 descriptors_constr.data = NULL;
24038         uint32_t* descriptors_vals = descriptors->elems /* XXX descriptors leaks */;
24039         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
24040                 uint32_t descriptors_conv_27 = descriptors_vals[b];
24041                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
24042                 CHECK_ACCESS(descriptors_conv_27_ptr);
24043                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
24044                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
24045                 descriptors_constr.data[b] = descriptors_conv_27_conv;
24046         }
24047         LDKCVec_TxOutZ outputs_constr;
24048         outputs_constr.datalen = outputs->arr_len;
24049         if (outputs_constr.datalen > 0)
24050                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
24051         else
24052                 outputs_constr.data = NULL;
24053         uint32_t* outputs_vals = outputs->elems /* XXX outputs leaks */;
24054         for (size_t h = 0; h < outputs_constr.datalen; h++) {
24055                 uint32_t outputs_conv_7 = outputs_vals[h];
24056                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
24057                 CHECK_ACCESS(outputs_conv_7_ptr);
24058                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
24059                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
24060                 outputs_constr.data[h] = outputs_conv_7_conv;
24061         }
24062         LDKCVec_u8Z change_destination_script_ref;
24063         change_destination_script_ref.datalen = change_destination_script->arr_len;
24064         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
24065         memcpy(change_destination_script_ref.data, change_destination_script->elems, change_destination_script_ref.datalen); FREE(change_destination_script);
24066         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
24067         *ret_conv = PhantomKeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
24068         return (uint32_t)ret_conv;
24069 }
24070
24071 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) {
24072         LDKPhantomKeysManager this_arg_conv;
24073         this_arg_conv.inner = (void*)(this_arg & (~1));
24074         this_arg_conv.is_owned = false;
24075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24076         unsigned char params_arr[32];
24077         CHECK(params->arr_len == 32);
24078         memcpy(params_arr, params->elems, 32); FREE(params);
24079         unsigned char (*params_ref)[32] = &params_arr;
24080         LDKInMemorySigner ret_var = PhantomKeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
24081         uint32_t ret_ref = 0;
24082         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24083         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24084         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24085         ret_ref = (uintptr_t)ret_var.inner;
24086         if (ret_var.is_owned) {
24087                 ret_ref |= 1;
24088         }
24089         return ret_ref;
24090 }
24091
24092 void  __attribute__((export_name("TS_ChannelManager_free"))) TS_ChannelManager_free(uint32_t this_obj) {
24093         LDKChannelManager this_obj_conv;
24094         this_obj_conv.inner = (void*)(this_obj & (~1));
24095         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24096         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24097         ChannelManager_free(this_obj_conv);
24098 }
24099
24100 void  __attribute__((export_name("TS_ChainParameters_free"))) TS_ChainParameters_free(uint32_t this_obj) {
24101         LDKChainParameters this_obj_conv;
24102         this_obj_conv.inner = (void*)(this_obj & (~1));
24103         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24105         ChainParameters_free(this_obj_conv);
24106 }
24107
24108 uint32_t  __attribute__((export_name("TS_ChainParameters_get_network"))) TS_ChainParameters_get_network(uint32_t this_ptr) {
24109         LDKChainParameters this_ptr_conv;
24110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24111         this_ptr_conv.is_owned = false;
24112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24113         uint32_t ret_conv = LDKNetwork_to_js(ChainParameters_get_network(&this_ptr_conv));
24114         return ret_conv;
24115 }
24116
24117 void  __attribute__((export_name("TS_ChainParameters_set_network"))) TS_ChainParameters_set_network(uint32_t this_ptr, uint32_t val) {
24118         LDKChainParameters this_ptr_conv;
24119         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24120         this_ptr_conv.is_owned = false;
24121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24122         LDKNetwork val_conv = LDKNetwork_from_js(val);
24123         ChainParameters_set_network(&this_ptr_conv, val_conv);
24124 }
24125
24126 uint32_t  __attribute__((export_name("TS_ChainParameters_get_best_block"))) TS_ChainParameters_get_best_block(uint32_t this_ptr) {
24127         LDKChainParameters this_ptr_conv;
24128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24129         this_ptr_conv.is_owned = false;
24130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24131         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
24132         uint32_t ret_ref = 0;
24133         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24134         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24135         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24136         ret_ref = (uintptr_t)ret_var.inner;
24137         if (ret_var.is_owned) {
24138                 ret_ref |= 1;
24139         }
24140         return ret_ref;
24141 }
24142
24143 void  __attribute__((export_name("TS_ChainParameters_set_best_block"))) TS_ChainParameters_set_best_block(uint32_t this_ptr, uint32_t val) {
24144         LDKChainParameters this_ptr_conv;
24145         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24146         this_ptr_conv.is_owned = false;
24147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24148         LDKBestBlock val_conv;
24149         val_conv.inner = (void*)(val & (~1));
24150         val_conv.is_owned = (val & 1) || (val == 0);
24151         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24152         val_conv = BestBlock_clone(&val_conv);
24153         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
24154 }
24155
24156 uint32_t  __attribute__((export_name("TS_ChainParameters_new"))) TS_ChainParameters_new(uint32_t network_arg, uint32_t best_block_arg) {
24157         LDKNetwork network_arg_conv = LDKNetwork_from_js(network_arg);
24158         LDKBestBlock best_block_arg_conv;
24159         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
24160         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
24161         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
24162         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
24163         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
24164         uint32_t ret_ref = 0;
24165         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24166         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24167         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24168         ret_ref = (uintptr_t)ret_var.inner;
24169         if (ret_var.is_owned) {
24170                 ret_ref |= 1;
24171         }
24172         return ret_ref;
24173 }
24174
24175 static inline uintptr_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
24176         LDKChainParameters ret_var = ChainParameters_clone(arg);
24177 uint32_t ret_ref = 0;
24178 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24179 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24180 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24181 ret_ref = (uintptr_t)ret_var.inner;
24182 if (ret_var.is_owned) {
24183         ret_ref |= 1;
24184 }
24185         return ret_ref;
24186 }
24187 uint32_t  __attribute__((export_name("TS_ChainParameters_clone_ptr"))) TS_ChainParameters_clone_ptr(uint32_t arg) {
24188         LDKChainParameters arg_conv;
24189         arg_conv.inner = (void*)(arg & (~1));
24190         arg_conv.is_owned = false;
24191         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24192         uint32_t ret_conv = ChainParameters_clone_ptr(&arg_conv);
24193         return ret_conv;
24194 }
24195
24196 uint32_t  __attribute__((export_name("TS_ChainParameters_clone"))) TS_ChainParameters_clone(uint32_t orig) {
24197         LDKChainParameters orig_conv;
24198         orig_conv.inner = (void*)(orig & (~1));
24199         orig_conv.is_owned = false;
24200         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24201         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
24202         uint32_t ret_ref = 0;
24203         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24204         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24205         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24206         ret_ref = (uintptr_t)ret_var.inner;
24207         if (ret_var.is_owned) {
24208                 ret_ref |= 1;
24209         }
24210         return ret_ref;
24211 }
24212
24213 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_free"))) TS_CounterpartyForwardingInfo_free(uint32_t this_obj) {
24214         LDKCounterpartyForwardingInfo this_obj_conv;
24215         this_obj_conv.inner = (void*)(this_obj & (~1));
24216         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24218         CounterpartyForwardingInfo_free(this_obj_conv);
24219 }
24220
24221 int32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_fee_base_msat"))) TS_CounterpartyForwardingInfo_get_fee_base_msat(uint32_t this_ptr) {
24222         LDKCounterpartyForwardingInfo 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         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
24227         return ret_conv;
24228 }
24229
24230 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_fee_base_msat"))) TS_CounterpartyForwardingInfo_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
24231         LDKCounterpartyForwardingInfo this_ptr_conv;
24232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24233         this_ptr_conv.is_owned = false;
24234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24235         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
24236 }
24237
24238 int32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_fee_proportional_millionths"))) TS_CounterpartyForwardingInfo_get_fee_proportional_millionths(uint32_t this_ptr) {
24239         LDKCounterpartyForwardingInfo this_ptr_conv;
24240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24241         this_ptr_conv.is_owned = false;
24242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24243         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
24244         return ret_conv;
24245 }
24246
24247 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_fee_proportional_millionths"))) TS_CounterpartyForwardingInfo_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
24248         LDKCounterpartyForwardingInfo this_ptr_conv;
24249         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24250         this_ptr_conv.is_owned = false;
24251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24252         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
24253 }
24254
24255 int16_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_cltv_expiry_delta"))) TS_CounterpartyForwardingInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
24256         LDKCounterpartyForwardingInfo this_ptr_conv;
24257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24258         this_ptr_conv.is_owned = false;
24259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24260         int16_t ret_conv = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
24261         return ret_conv;
24262 }
24263
24264 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_cltv_expiry_delta"))) TS_CounterpartyForwardingInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
24265         LDKCounterpartyForwardingInfo this_ptr_conv;
24266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24267         this_ptr_conv.is_owned = false;
24268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24269         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
24270 }
24271
24272 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) {
24273         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
24274         uint32_t ret_ref = 0;
24275         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24276         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24277         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24278         ret_ref = (uintptr_t)ret_var.inner;
24279         if (ret_var.is_owned) {
24280                 ret_ref |= 1;
24281         }
24282         return ret_ref;
24283 }
24284
24285 static inline uintptr_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
24286         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
24287 uint32_t ret_ref = 0;
24288 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24289 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24290 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24291 ret_ref = (uintptr_t)ret_var.inner;
24292 if (ret_var.is_owned) {
24293         ret_ref |= 1;
24294 }
24295         return ret_ref;
24296 }
24297 uint32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_clone_ptr"))) TS_CounterpartyForwardingInfo_clone_ptr(uint32_t arg) {
24298         LDKCounterpartyForwardingInfo arg_conv;
24299         arg_conv.inner = (void*)(arg & (~1));
24300         arg_conv.is_owned = false;
24301         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24302         uint32_t ret_conv = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
24303         return ret_conv;
24304 }
24305
24306 uint32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_clone"))) TS_CounterpartyForwardingInfo_clone(uint32_t orig) {
24307         LDKCounterpartyForwardingInfo orig_conv;
24308         orig_conv.inner = (void*)(orig & (~1));
24309         orig_conv.is_owned = false;
24310         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24311         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
24312         uint32_t ret_ref = 0;
24313         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24314         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24315         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24316         ret_ref = (uintptr_t)ret_var.inner;
24317         if (ret_var.is_owned) {
24318                 ret_ref |= 1;
24319         }
24320         return ret_ref;
24321 }
24322
24323 void  __attribute__((export_name("TS_ChannelCounterparty_free"))) TS_ChannelCounterparty_free(uint32_t this_obj) {
24324         LDKChannelCounterparty this_obj_conv;
24325         this_obj_conv.inner = (void*)(this_obj & (~1));
24326         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24328         ChannelCounterparty_free(this_obj_conv);
24329 }
24330
24331 int8_tArray  __attribute__((export_name("TS_ChannelCounterparty_get_node_id"))) TS_ChannelCounterparty_get_node_id(uint32_t this_ptr) {
24332         LDKChannelCounterparty this_ptr_conv;
24333         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24334         this_ptr_conv.is_owned = false;
24335         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24336         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
24337         memcpy(ret_arr->elems, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form, 33);
24338         return ret_arr;
24339 }
24340
24341 void  __attribute__((export_name("TS_ChannelCounterparty_set_node_id"))) TS_ChannelCounterparty_set_node_id(uint32_t this_ptr, int8_tArray val) {
24342         LDKChannelCounterparty this_ptr_conv;
24343         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24344         this_ptr_conv.is_owned = false;
24345         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24346         LDKPublicKey val_ref;
24347         CHECK(val->arr_len == 33);
24348         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
24349         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
24350 }
24351
24352 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_get_features"))) TS_ChannelCounterparty_get_features(uint32_t this_ptr) {
24353         LDKChannelCounterparty this_ptr_conv;
24354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24355         this_ptr_conv.is_owned = false;
24356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24357         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
24358         uint32_t ret_ref = 0;
24359         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24360         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24361         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24362         ret_ref = (uintptr_t)ret_var.inner;
24363         if (ret_var.is_owned) {
24364                 ret_ref |= 1;
24365         }
24366         return ret_ref;
24367 }
24368
24369 void  __attribute__((export_name("TS_ChannelCounterparty_set_features"))) TS_ChannelCounterparty_set_features(uint32_t this_ptr, uint32_t val) {
24370         LDKChannelCounterparty this_ptr_conv;
24371         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24372         this_ptr_conv.is_owned = false;
24373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24374         LDKInitFeatures val_conv;
24375         val_conv.inner = (void*)(val & (~1));
24376         val_conv.is_owned = (val & 1) || (val == 0);
24377         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24378         val_conv = InitFeatures_clone(&val_conv);
24379         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
24380 }
24381
24382 int64_t  __attribute__((export_name("TS_ChannelCounterparty_get_unspendable_punishment_reserve"))) TS_ChannelCounterparty_get_unspendable_punishment_reserve(uint32_t this_ptr) {
24383         LDKChannelCounterparty this_ptr_conv;
24384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24385         this_ptr_conv.is_owned = false;
24386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24387         int64_t ret_conv = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
24388         return ret_conv;
24389 }
24390
24391 void  __attribute__((export_name("TS_ChannelCounterparty_set_unspendable_punishment_reserve"))) TS_ChannelCounterparty_set_unspendable_punishment_reserve(uint32_t this_ptr, int64_t val) {
24392         LDKChannelCounterparty this_ptr_conv;
24393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24394         this_ptr_conv.is_owned = false;
24395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24396         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
24397 }
24398
24399 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_get_forwarding_info"))) TS_ChannelCounterparty_get_forwarding_info(uint32_t this_ptr) {
24400         LDKChannelCounterparty this_ptr_conv;
24401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24402         this_ptr_conv.is_owned = false;
24403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24404         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
24405         uint32_t ret_ref = 0;
24406         if ((uintptr_t)ret_var.inner > 4096) {
24407                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24408                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24409         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24410                 ret_ref = (uintptr_t)ret_var.inner;
24411                 if (ret_var.is_owned) {
24412                         ret_ref |= 1;
24413                 }
24414         }
24415         return ret_ref;
24416 }
24417
24418 void  __attribute__((export_name("TS_ChannelCounterparty_set_forwarding_info"))) TS_ChannelCounterparty_set_forwarding_info(uint32_t this_ptr, uint32_t val) {
24419         LDKChannelCounterparty this_ptr_conv;
24420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24421         this_ptr_conv.is_owned = false;
24422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24423         LDKCounterpartyForwardingInfo val_conv;
24424         val_conv.inner = (void*)(val & (~1));
24425         val_conv.is_owned = (val & 1) || (val == 0);
24426         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24427         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
24428         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
24429 }
24430
24431 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) {
24432         LDKPublicKey node_id_arg_ref;
24433         CHECK(node_id_arg->arr_len == 33);
24434         memcpy(node_id_arg_ref.compressed_form, node_id_arg->elems, 33); FREE(node_id_arg);
24435         LDKInitFeatures features_arg_conv;
24436         features_arg_conv.inner = (void*)(features_arg & (~1));
24437         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
24438         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
24439         features_arg_conv = InitFeatures_clone(&features_arg_conv);
24440         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
24441         forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1));
24442         forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0);
24443         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
24444         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
24445         LDKChannelCounterparty ret_var = ChannelCounterparty_new(node_id_arg_ref, features_arg_conv, unspendable_punishment_reserve_arg, forwarding_info_arg_conv);
24446         uint32_t ret_ref = 0;
24447         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24448         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24449         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24450         ret_ref = (uintptr_t)ret_var.inner;
24451         if (ret_var.is_owned) {
24452                 ret_ref |= 1;
24453         }
24454         return ret_ref;
24455 }
24456
24457 static inline uintptr_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
24458         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
24459 uint32_t ret_ref = 0;
24460 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24461 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24462 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24463 ret_ref = (uintptr_t)ret_var.inner;
24464 if (ret_var.is_owned) {
24465         ret_ref |= 1;
24466 }
24467         return ret_ref;
24468 }
24469 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_clone_ptr"))) TS_ChannelCounterparty_clone_ptr(uint32_t arg) {
24470         LDKChannelCounterparty arg_conv;
24471         arg_conv.inner = (void*)(arg & (~1));
24472         arg_conv.is_owned = false;
24473         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24474         uint32_t ret_conv = ChannelCounterparty_clone_ptr(&arg_conv);
24475         return ret_conv;
24476 }
24477
24478 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_clone"))) TS_ChannelCounterparty_clone(uint32_t orig) {
24479         LDKChannelCounterparty orig_conv;
24480         orig_conv.inner = (void*)(orig & (~1));
24481         orig_conv.is_owned = false;
24482         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24483         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
24484         uint32_t ret_ref = 0;
24485         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24486         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24487         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24488         ret_ref = (uintptr_t)ret_var.inner;
24489         if (ret_var.is_owned) {
24490                 ret_ref |= 1;
24491         }
24492         return ret_ref;
24493 }
24494
24495 void  __attribute__((export_name("TS_ChannelDetails_free"))) TS_ChannelDetails_free(uint32_t this_obj) {
24496         LDKChannelDetails this_obj_conv;
24497         this_obj_conv.inner = (void*)(this_obj & (~1));
24498         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24500         ChannelDetails_free(this_obj_conv);
24501 }
24502
24503 int8_tArray  __attribute__((export_name("TS_ChannelDetails_get_channel_id"))) TS_ChannelDetails_get_channel_id(uint32_t this_ptr) {
24504         LDKChannelDetails this_ptr_conv;
24505         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24506         this_ptr_conv.is_owned = false;
24507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24508         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24509         memcpy(ret_arr->elems, *ChannelDetails_get_channel_id(&this_ptr_conv), 32);
24510         return ret_arr;
24511 }
24512
24513 void  __attribute__((export_name("TS_ChannelDetails_set_channel_id"))) TS_ChannelDetails_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24514         LDKChannelDetails this_ptr_conv;
24515         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24516         this_ptr_conv.is_owned = false;
24517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24518         LDKThirtyTwoBytes val_ref;
24519         CHECK(val->arr_len == 32);
24520         memcpy(val_ref.data, val->elems, 32); FREE(val);
24521         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
24522 }
24523
24524 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_counterparty"))) TS_ChannelDetails_get_counterparty(uint32_t this_ptr) {
24525         LDKChannelDetails this_ptr_conv;
24526         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24527         this_ptr_conv.is_owned = false;
24528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24529         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
24530         uint32_t ret_ref = 0;
24531         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24532         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24533         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24534         ret_ref = (uintptr_t)ret_var.inner;
24535         if (ret_var.is_owned) {
24536                 ret_ref |= 1;
24537         }
24538         return ret_ref;
24539 }
24540
24541 void  __attribute__((export_name("TS_ChannelDetails_set_counterparty"))) TS_ChannelDetails_set_counterparty(uint32_t this_ptr, uint32_t val) {
24542         LDKChannelDetails this_ptr_conv;
24543         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24544         this_ptr_conv.is_owned = false;
24545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24546         LDKChannelCounterparty val_conv;
24547         val_conv.inner = (void*)(val & (~1));
24548         val_conv.is_owned = (val & 1) || (val == 0);
24549         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24550         val_conv = ChannelCounterparty_clone(&val_conv);
24551         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
24552 }
24553
24554 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_funding_txo"))) TS_ChannelDetails_get_funding_txo(uint32_t this_ptr) {
24555         LDKChannelDetails this_ptr_conv;
24556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24557         this_ptr_conv.is_owned = false;
24558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24559         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
24560         uint32_t ret_ref = 0;
24561         if ((uintptr_t)ret_var.inner > 4096) {
24562                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24563                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24564         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24565                 ret_ref = (uintptr_t)ret_var.inner;
24566                 if (ret_var.is_owned) {
24567                         ret_ref |= 1;
24568                 }
24569         }
24570         return ret_ref;
24571 }
24572
24573 void  __attribute__((export_name("TS_ChannelDetails_set_funding_txo"))) TS_ChannelDetails_set_funding_txo(uint32_t this_ptr, uint32_t val) {
24574         LDKChannelDetails this_ptr_conv;
24575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24576         this_ptr_conv.is_owned = false;
24577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24578         LDKOutPoint val_conv;
24579         val_conv.inner = (void*)(val & (~1));
24580         val_conv.is_owned = (val & 1) || (val == 0);
24581         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24582         val_conv = OutPoint_clone(&val_conv);
24583         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
24584 }
24585
24586 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_channel_type"))) TS_ChannelDetails_get_channel_type(uint32_t this_ptr) {
24587         LDKChannelDetails this_ptr_conv;
24588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24589         this_ptr_conv.is_owned = false;
24590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24591         LDKChannelTypeFeatures ret_var = ChannelDetails_get_channel_type(&this_ptr_conv);
24592         uint32_t ret_ref = 0;
24593         if ((uintptr_t)ret_var.inner > 4096) {
24594                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24595                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24596         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24597                 ret_ref = (uintptr_t)ret_var.inner;
24598                 if (ret_var.is_owned) {
24599                         ret_ref |= 1;
24600                 }
24601         }
24602         return ret_ref;
24603 }
24604
24605 void  __attribute__((export_name("TS_ChannelDetails_set_channel_type"))) TS_ChannelDetails_set_channel_type(uint32_t this_ptr, uint32_t val) {
24606         LDKChannelDetails this_ptr_conv;
24607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24608         this_ptr_conv.is_owned = false;
24609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24610         LDKChannelTypeFeatures val_conv;
24611         val_conv.inner = (void*)(val & (~1));
24612         val_conv.is_owned = (val & 1) || (val == 0);
24613         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24614         val_conv = ChannelTypeFeatures_clone(&val_conv);
24615         ChannelDetails_set_channel_type(&this_ptr_conv, val_conv);
24616 }
24617
24618 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_short_channel_id"))) TS_ChannelDetails_get_short_channel_id(uint32_t this_ptr) {
24619         LDKChannelDetails this_ptr_conv;
24620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24621         this_ptr_conv.is_owned = false;
24622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24623         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24624         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
24625         uint32_t ret_ref = (uintptr_t)ret_copy;
24626         return ret_ref;
24627 }
24628
24629 void  __attribute__((export_name("TS_ChannelDetails_set_short_channel_id"))) TS_ChannelDetails_set_short_channel_id(uint32_t this_ptr, uint32_t val) {
24630         LDKChannelDetails this_ptr_conv;
24631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24632         this_ptr_conv.is_owned = false;
24633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24634         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
24635         CHECK_ACCESS(val_ptr);
24636         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
24637         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
24638         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
24639 }
24640
24641 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_scid_alias"))) TS_ChannelDetails_get_inbound_scid_alias(uint32_t this_ptr) {
24642         LDKChannelDetails this_ptr_conv;
24643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24644         this_ptr_conv.is_owned = false;
24645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24646         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24647         *ret_copy = ChannelDetails_get_inbound_scid_alias(&this_ptr_conv);
24648         uint32_t ret_ref = (uintptr_t)ret_copy;
24649         return ret_ref;
24650 }
24651
24652 void  __attribute__((export_name("TS_ChannelDetails_set_inbound_scid_alias"))) TS_ChannelDetails_set_inbound_scid_alias(uint32_t this_ptr, uint32_t val) {
24653         LDKChannelDetails this_ptr_conv;
24654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24655         this_ptr_conv.is_owned = false;
24656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24657         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
24658         CHECK_ACCESS(val_ptr);
24659         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
24660         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
24661         ChannelDetails_set_inbound_scid_alias(&this_ptr_conv, val_conv);
24662 }
24663
24664 int64_t  __attribute__((export_name("TS_ChannelDetails_get_channel_value_satoshis"))) TS_ChannelDetails_get_channel_value_satoshis(uint32_t this_ptr) {
24665         LDKChannelDetails this_ptr_conv;
24666         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24667         this_ptr_conv.is_owned = false;
24668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24669         int64_t ret_conv = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
24670         return ret_conv;
24671 }
24672
24673 void  __attribute__((export_name("TS_ChannelDetails_set_channel_value_satoshis"))) TS_ChannelDetails_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
24674         LDKChannelDetails this_ptr_conv;
24675         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24676         this_ptr_conv.is_owned = false;
24677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24678         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
24679 }
24680
24681 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_unspendable_punishment_reserve"))) TS_ChannelDetails_get_unspendable_punishment_reserve(uint32_t this_ptr) {
24682         LDKChannelDetails this_ptr_conv;
24683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24684         this_ptr_conv.is_owned = false;
24685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24686         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24687         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
24688         uint32_t ret_ref = (uintptr_t)ret_copy;
24689         return ret_ref;
24690 }
24691
24692 void  __attribute__((export_name("TS_ChannelDetails_set_unspendable_punishment_reserve"))) TS_ChannelDetails_set_unspendable_punishment_reserve(uint32_t this_ptr, uint32_t val) {
24693         LDKChannelDetails this_ptr_conv;
24694         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24695         this_ptr_conv.is_owned = false;
24696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24697         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
24698         CHECK_ACCESS(val_ptr);
24699         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
24700         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
24701         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
24702 }
24703
24704 int64_t  __attribute__((export_name("TS_ChannelDetails_get_user_channel_id"))) TS_ChannelDetails_get_user_channel_id(uint32_t this_ptr) {
24705         LDKChannelDetails this_ptr_conv;
24706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24707         this_ptr_conv.is_owned = false;
24708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24709         int64_t ret_conv = ChannelDetails_get_user_channel_id(&this_ptr_conv);
24710         return ret_conv;
24711 }
24712
24713 void  __attribute__((export_name("TS_ChannelDetails_set_user_channel_id"))) TS_ChannelDetails_set_user_channel_id(uint32_t this_ptr, int64_t val) {
24714         LDKChannelDetails this_ptr_conv;
24715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24716         this_ptr_conv.is_owned = false;
24717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24718         ChannelDetails_set_user_channel_id(&this_ptr_conv, val);
24719 }
24720
24721 int64_t  __attribute__((export_name("TS_ChannelDetails_get_balance_msat"))) TS_ChannelDetails_get_balance_msat(uint32_t this_ptr) {
24722         LDKChannelDetails this_ptr_conv;
24723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24724         this_ptr_conv.is_owned = false;
24725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24726         int64_t ret_conv = ChannelDetails_get_balance_msat(&this_ptr_conv);
24727         return ret_conv;
24728 }
24729
24730 void  __attribute__((export_name("TS_ChannelDetails_set_balance_msat"))) TS_ChannelDetails_set_balance_msat(uint32_t this_ptr, int64_t val) {
24731         LDKChannelDetails this_ptr_conv;
24732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24733         this_ptr_conv.is_owned = false;
24734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24735         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
24736 }
24737
24738 int64_t  __attribute__((export_name("TS_ChannelDetails_get_outbound_capacity_msat"))) TS_ChannelDetails_get_outbound_capacity_msat(uint32_t this_ptr) {
24739         LDKChannelDetails this_ptr_conv;
24740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24741         this_ptr_conv.is_owned = false;
24742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24743         int64_t ret_conv = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
24744         return ret_conv;
24745 }
24746
24747 void  __attribute__((export_name("TS_ChannelDetails_set_outbound_capacity_msat"))) TS_ChannelDetails_set_outbound_capacity_msat(uint32_t this_ptr, int64_t val) {
24748         LDKChannelDetails this_ptr_conv;
24749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24750         this_ptr_conv.is_owned = false;
24751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24752         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
24753 }
24754
24755 int64_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_capacity_msat"))) TS_ChannelDetails_get_inbound_capacity_msat(uint32_t this_ptr) {
24756         LDKChannelDetails this_ptr_conv;
24757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24758         this_ptr_conv.is_owned = false;
24759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24760         int64_t ret_conv = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
24761         return ret_conv;
24762 }
24763
24764 void  __attribute__((export_name("TS_ChannelDetails_set_inbound_capacity_msat"))) TS_ChannelDetails_set_inbound_capacity_msat(uint32_t this_ptr, int64_t val) {
24765         LDKChannelDetails this_ptr_conv;
24766         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24767         this_ptr_conv.is_owned = false;
24768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24769         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
24770 }
24771
24772 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_confirmations_required"))) TS_ChannelDetails_get_confirmations_required(uint32_t this_ptr) {
24773         LDKChannelDetails this_ptr_conv;
24774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24775         this_ptr_conv.is_owned = false;
24776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24777         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
24778         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
24779         uint32_t ret_ref = (uintptr_t)ret_copy;
24780         return ret_ref;
24781 }
24782
24783 void  __attribute__((export_name("TS_ChannelDetails_set_confirmations_required"))) TS_ChannelDetails_set_confirmations_required(uint32_t this_ptr, uint32_t val) {
24784         LDKChannelDetails this_ptr_conv;
24785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24786         this_ptr_conv.is_owned = false;
24787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24788         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
24789         CHECK_ACCESS(val_ptr);
24790         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
24791         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
24792         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
24793 }
24794
24795 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_force_close_spend_delay"))) TS_ChannelDetails_get_force_close_spend_delay(uint32_t this_ptr) {
24796         LDKChannelDetails this_ptr_conv;
24797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24798         this_ptr_conv.is_owned = false;
24799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24800         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
24801         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
24802         uint32_t ret_ref = (uintptr_t)ret_copy;
24803         return ret_ref;
24804 }
24805
24806 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) {
24807         LDKChannelDetails this_ptr_conv;
24808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24809         this_ptr_conv.is_owned = false;
24810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24811         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
24812         CHECK_ACCESS(val_ptr);
24813         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
24814         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)val) & ~1));
24815         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
24816 }
24817
24818 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_outbound"))) TS_ChannelDetails_get_is_outbound(uint32_t this_ptr) {
24819         LDKChannelDetails this_ptr_conv;
24820         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24821         this_ptr_conv.is_owned = false;
24822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24823         jboolean ret_conv = ChannelDetails_get_is_outbound(&this_ptr_conv);
24824         return ret_conv;
24825 }
24826
24827 void  __attribute__((export_name("TS_ChannelDetails_set_is_outbound"))) TS_ChannelDetails_set_is_outbound(uint32_t this_ptr, jboolean val) {
24828         LDKChannelDetails this_ptr_conv;
24829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24830         this_ptr_conv.is_owned = false;
24831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24832         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
24833 }
24834
24835 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_funding_locked"))) TS_ChannelDetails_get_is_funding_locked(uint32_t this_ptr) {
24836         LDKChannelDetails this_ptr_conv;
24837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24838         this_ptr_conv.is_owned = false;
24839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24840         jboolean ret_conv = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
24841         return ret_conv;
24842 }
24843
24844 void  __attribute__((export_name("TS_ChannelDetails_set_is_funding_locked"))) TS_ChannelDetails_set_is_funding_locked(uint32_t this_ptr, jboolean val) {
24845         LDKChannelDetails this_ptr_conv;
24846         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24847         this_ptr_conv.is_owned = false;
24848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24849         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
24850 }
24851
24852 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_usable"))) TS_ChannelDetails_get_is_usable(uint32_t this_ptr) {
24853         LDKChannelDetails this_ptr_conv;
24854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24855         this_ptr_conv.is_owned = false;
24856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24857         jboolean ret_conv = ChannelDetails_get_is_usable(&this_ptr_conv);
24858         return ret_conv;
24859 }
24860
24861 void  __attribute__((export_name("TS_ChannelDetails_set_is_usable"))) TS_ChannelDetails_set_is_usable(uint32_t this_ptr, jboolean val) {
24862         LDKChannelDetails this_ptr_conv;
24863         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24864         this_ptr_conv.is_owned = false;
24865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24866         ChannelDetails_set_is_usable(&this_ptr_conv, val);
24867 }
24868
24869 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_public"))) TS_ChannelDetails_get_is_public(uint32_t this_ptr) {
24870         LDKChannelDetails this_ptr_conv;
24871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24872         this_ptr_conv.is_owned = false;
24873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24874         jboolean ret_conv = ChannelDetails_get_is_public(&this_ptr_conv);
24875         return ret_conv;
24876 }
24877
24878 void  __attribute__((export_name("TS_ChannelDetails_set_is_public"))) TS_ChannelDetails_set_is_public(uint32_t this_ptr, jboolean val) {
24879         LDKChannelDetails this_ptr_conv;
24880         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24881         this_ptr_conv.is_owned = false;
24882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24883         ChannelDetails_set_is_public(&this_ptr_conv, val);
24884 }
24885
24886 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 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 inbound_capacity_msat_arg, uint32_t confirmations_required_arg, uint32_t force_close_spend_delay_arg, jboolean is_outbound_arg, jboolean is_funding_locked_arg, jboolean is_usable_arg, jboolean is_public_arg) {
24887         LDKThirtyTwoBytes channel_id_arg_ref;
24888         CHECK(channel_id_arg->arr_len == 32);
24889         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
24890         LDKChannelCounterparty counterparty_arg_conv;
24891         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
24892         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
24893         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
24894         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
24895         LDKOutPoint funding_txo_arg_conv;
24896         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
24897         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
24898         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
24899         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
24900         LDKChannelTypeFeatures channel_type_arg_conv;
24901         channel_type_arg_conv.inner = (void*)(channel_type_arg & (~1));
24902         channel_type_arg_conv.is_owned = (channel_type_arg & 1) || (channel_type_arg == 0);
24903         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_arg_conv);
24904         channel_type_arg_conv = ChannelTypeFeatures_clone(&channel_type_arg_conv);
24905         void* short_channel_id_arg_ptr = (void*)(((uintptr_t)short_channel_id_arg) & ~1);
24906         CHECK_ACCESS(short_channel_id_arg_ptr);
24907         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
24908         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_arg) & ~1));
24909         void* inbound_scid_alias_arg_ptr = (void*)(((uintptr_t)inbound_scid_alias_arg) & ~1);
24910         CHECK_ACCESS(inbound_scid_alias_arg_ptr);
24911         LDKCOption_u64Z inbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(inbound_scid_alias_arg_ptr);
24912         inbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_scid_alias_arg) & ~1));
24913         void* unspendable_punishment_reserve_arg_ptr = (void*)(((uintptr_t)unspendable_punishment_reserve_arg) & ~1);
24914         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
24915         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
24916         void* confirmations_required_arg_ptr = (void*)(((uintptr_t)confirmations_required_arg) & ~1);
24917         CHECK_ACCESS(confirmations_required_arg_ptr);
24918         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
24919         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)confirmations_required_arg) & ~1));
24920         void* force_close_spend_delay_arg_ptr = (void*)(((uintptr_t)force_close_spend_delay_arg) & ~1);
24921         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
24922         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
24923         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)force_close_spend_delay_arg) & ~1));
24924         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, 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, inbound_capacity_msat_arg, confirmations_required_arg_conv, force_close_spend_delay_arg_conv, is_outbound_arg, is_funding_locked_arg, is_usable_arg, is_public_arg);
24925         uint32_t ret_ref = 0;
24926         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24927         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24928         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24929         ret_ref = (uintptr_t)ret_var.inner;
24930         if (ret_var.is_owned) {
24931                 ret_ref |= 1;
24932         }
24933         return ret_ref;
24934 }
24935
24936 static inline uintptr_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
24937         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
24938 uint32_t ret_ref = 0;
24939 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24940 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24941 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24942 ret_ref = (uintptr_t)ret_var.inner;
24943 if (ret_var.is_owned) {
24944         ret_ref |= 1;
24945 }
24946         return ret_ref;
24947 }
24948 uint32_t  __attribute__((export_name("TS_ChannelDetails_clone_ptr"))) TS_ChannelDetails_clone_ptr(uint32_t arg) {
24949         LDKChannelDetails arg_conv;
24950         arg_conv.inner = (void*)(arg & (~1));
24951         arg_conv.is_owned = false;
24952         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24953         uint32_t ret_conv = ChannelDetails_clone_ptr(&arg_conv);
24954         return ret_conv;
24955 }
24956
24957 uint32_t  __attribute__((export_name("TS_ChannelDetails_clone"))) TS_ChannelDetails_clone(uint32_t orig) {
24958         LDKChannelDetails orig_conv;
24959         orig_conv.inner = (void*)(orig & (~1));
24960         orig_conv.is_owned = false;
24961         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24962         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
24963         uint32_t ret_ref = 0;
24964         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24965         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24966         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24967         ret_ref = (uintptr_t)ret_var.inner;
24968         if (ret_var.is_owned) {
24969                 ret_ref |= 1;
24970         }
24971         return ret_ref;
24972 }
24973
24974 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_payment_scid"))) TS_ChannelDetails_get_inbound_payment_scid(uint32_t this_arg) {
24975         LDKChannelDetails this_arg_conv;
24976         this_arg_conv.inner = (void*)(this_arg & (~1));
24977         this_arg_conv.is_owned = false;
24978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24979         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24980         *ret_copy = ChannelDetails_get_inbound_payment_scid(&this_arg_conv);
24981         uint32_t ret_ref = (uintptr_t)ret_copy;
24982         return ret_ref;
24983 }
24984
24985 void  __attribute__((export_name("TS_PaymentSendFailure_free"))) TS_PaymentSendFailure_free(uint32_t this_ptr) {
24986         if ((this_ptr & 1) != 0) return;
24987         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24988         CHECK_ACCESS(this_ptr_ptr);
24989         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
24990         FREE((void*)this_ptr);
24991         PaymentSendFailure_free(this_ptr_conv);
24992 }
24993
24994 static inline uintptr_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
24995         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
24996         *ret_copy = PaymentSendFailure_clone(arg);
24997 uint32_t ret_ref = (uintptr_t)ret_copy;
24998         return ret_ref;
24999 }
25000 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_clone_ptr"))) TS_PaymentSendFailure_clone_ptr(uint32_t arg) {
25001         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)arg;
25002         uint32_t ret_conv = PaymentSendFailure_clone_ptr(arg_conv);
25003         return ret_conv;
25004 }
25005
25006 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_clone"))) TS_PaymentSendFailure_clone(uint32_t orig) {
25007         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
25008         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
25009         *ret_copy = PaymentSendFailure_clone(orig_conv);
25010         uint32_t ret_ref = (uintptr_t)ret_copy;
25011         return ret_ref;
25012 }
25013
25014 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_parameter_error"))) TS_PaymentSendFailure_parameter_error(uint32_t a) {
25015         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
25016         CHECK_ACCESS(a_ptr);
25017         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
25018         a_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a) & ~1));
25019         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
25020         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
25021         uint32_t ret_ref = (uintptr_t)ret_copy;
25022         return ret_ref;
25023 }
25024
25025 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_path_parameter_error"))) TS_PaymentSendFailure_path_parameter_error(uint32_tArray a) {
25026         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
25027         a_constr.datalen = a->arr_len;
25028         if (a_constr.datalen > 0)
25029                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
25030         else
25031                 a_constr.data = NULL;
25032         uint32_t* a_vals = a->elems /* XXX a leaks */;
25033         for (size_t w = 0; w < a_constr.datalen; w++) {
25034                 uint32_t a_conv_22 = a_vals[w];
25035                 void* a_conv_22_ptr = (void*)(((uintptr_t)a_conv_22) & ~1);
25036                 CHECK_ACCESS(a_conv_22_ptr);
25037                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
25038                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uintptr_t)a_conv_22) & ~1));
25039                 a_constr.data[w] = a_conv_22_conv;
25040         }
25041         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
25042         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
25043         uint32_t ret_ref = (uintptr_t)ret_copy;
25044         return ret_ref;
25045 }
25046
25047 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_all_failed_retry_safe"))) TS_PaymentSendFailure_all_failed_retry_safe(uint32_tArray a) {
25048         LDKCVec_APIErrorZ a_constr;
25049         a_constr.datalen = a->arr_len;
25050         if (a_constr.datalen > 0)
25051                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
25052         else
25053                 a_constr.data = NULL;
25054         uint32_t* a_vals = a->elems /* XXX a leaks */;
25055         for (size_t k = 0; k < a_constr.datalen; k++) {
25056                 uint32_t a_conv_10 = a_vals[k];
25057                 void* a_conv_10_ptr = (void*)(((uintptr_t)a_conv_10) & ~1);
25058                 CHECK_ACCESS(a_conv_10_ptr);
25059                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
25060                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a_conv_10) & ~1));
25061                 a_constr.data[k] = a_conv_10_conv;
25062         }
25063         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
25064         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
25065         uint32_t ret_ref = (uintptr_t)ret_copy;
25066         return ret_ref;
25067 }
25068
25069 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) {
25070         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
25071         results_constr.datalen = results->arr_len;
25072         if (results_constr.datalen > 0)
25073                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
25074         else
25075                 results_constr.data = NULL;
25076         uint32_t* results_vals = results->elems /* XXX results leaks */;
25077         for (size_t w = 0; w < results_constr.datalen; w++) {
25078                 uint32_t results_conv_22 = results_vals[w];
25079                 void* results_conv_22_ptr = (void*)(((uintptr_t)results_conv_22) & ~1);
25080                 CHECK_ACCESS(results_conv_22_ptr);
25081                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
25082                 results_constr.data[w] = results_conv_22_conv;
25083         }
25084         LDKRouteParameters failed_paths_retry_conv;
25085         failed_paths_retry_conv.inner = (void*)(failed_paths_retry & (~1));
25086         failed_paths_retry_conv.is_owned = (failed_paths_retry & 1) || (failed_paths_retry == 0);
25087         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
25088         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
25089         LDKThirtyTwoBytes payment_id_ref;
25090         CHECK(payment_id->arr_len == 32);
25091         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
25092         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
25093         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
25094         uint32_t ret_ref = (uintptr_t)ret_copy;
25095         return ret_ref;
25096 }
25097
25098 void  __attribute__((export_name("TS_PhantomRouteHints_free"))) TS_PhantomRouteHints_free(uint32_t this_obj) {
25099         LDKPhantomRouteHints this_obj_conv;
25100         this_obj_conv.inner = (void*)(this_obj & (~1));
25101         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25103         PhantomRouteHints_free(this_obj_conv);
25104 }
25105
25106 uint32_tArray  __attribute__((export_name("TS_PhantomRouteHints_get_channels"))) TS_PhantomRouteHints_get_channels(uint32_t this_ptr) {
25107         LDKPhantomRouteHints this_ptr_conv;
25108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25109         this_ptr_conv.is_owned = false;
25110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25111         LDKCVec_ChannelDetailsZ ret_var = PhantomRouteHints_get_channels(&this_ptr_conv);
25112         uint32_tArray ret_arr = NULL;
25113         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
25114         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
25115         for (size_t q = 0; q < ret_var.datalen; q++) {
25116                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
25117                 uint32_t ret_conv_16_ref = 0;
25118                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25119                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25120                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
25121                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
25122                 if (ret_conv_16_var.is_owned) {
25123                         ret_conv_16_ref |= 1;
25124                 }
25125                 ret_arr_ptr[q] = ret_conv_16_ref;
25126         }
25127         
25128         FREE(ret_var.data);
25129         return ret_arr;
25130 }
25131
25132 void  __attribute__((export_name("TS_PhantomRouteHints_set_channels"))) TS_PhantomRouteHints_set_channels(uint32_t this_ptr, uint32_tArray val) {
25133         LDKPhantomRouteHints this_ptr_conv;
25134         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25135         this_ptr_conv.is_owned = false;
25136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25137         LDKCVec_ChannelDetailsZ val_constr;
25138         val_constr.datalen = val->arr_len;
25139         if (val_constr.datalen > 0)
25140                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
25141         else
25142                 val_constr.data = NULL;
25143         uint32_t* val_vals = val->elems /* XXX val leaks */;
25144         for (size_t q = 0; q < val_constr.datalen; q++) {
25145                 uint32_t val_conv_16 = val_vals[q];
25146                 LDKChannelDetails val_conv_16_conv;
25147                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
25148                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
25149                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
25150                 val_conv_16_conv = ChannelDetails_clone(&val_conv_16_conv);
25151                 val_constr.data[q] = val_conv_16_conv;
25152         }
25153         PhantomRouteHints_set_channels(&this_ptr_conv, val_constr);
25154 }
25155
25156 int64_t  __attribute__((export_name("TS_PhantomRouteHints_get_phantom_scid"))) TS_PhantomRouteHints_get_phantom_scid(uint32_t this_ptr) {
25157         LDKPhantomRouteHints this_ptr_conv;
25158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25159         this_ptr_conv.is_owned = false;
25160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25161         int64_t ret_conv = PhantomRouteHints_get_phantom_scid(&this_ptr_conv);
25162         return ret_conv;
25163 }
25164
25165 void  __attribute__((export_name("TS_PhantomRouteHints_set_phantom_scid"))) TS_PhantomRouteHints_set_phantom_scid(uint32_t this_ptr, int64_t val) {
25166         LDKPhantomRouteHints this_ptr_conv;
25167         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25168         this_ptr_conv.is_owned = false;
25169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25170         PhantomRouteHints_set_phantom_scid(&this_ptr_conv, val);
25171 }
25172
25173 int8_tArray  __attribute__((export_name("TS_PhantomRouteHints_get_real_node_pubkey"))) TS_PhantomRouteHints_get_real_node_pubkey(uint32_t this_ptr) {
25174         LDKPhantomRouteHints this_ptr_conv;
25175         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25176         this_ptr_conv.is_owned = false;
25177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25178         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
25179         memcpy(ret_arr->elems, PhantomRouteHints_get_real_node_pubkey(&this_ptr_conv).compressed_form, 33);
25180         return ret_arr;
25181 }
25182
25183 void  __attribute__((export_name("TS_PhantomRouteHints_set_real_node_pubkey"))) TS_PhantomRouteHints_set_real_node_pubkey(uint32_t this_ptr, int8_tArray val) {
25184         LDKPhantomRouteHints this_ptr_conv;
25185         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25186         this_ptr_conv.is_owned = false;
25187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25188         LDKPublicKey val_ref;
25189         CHECK(val->arr_len == 33);
25190         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
25191         PhantomRouteHints_set_real_node_pubkey(&this_ptr_conv, val_ref);
25192 }
25193
25194 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) {
25195         LDKCVec_ChannelDetailsZ channels_arg_constr;
25196         channels_arg_constr.datalen = channels_arg->arr_len;
25197         if (channels_arg_constr.datalen > 0)
25198                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
25199         else
25200                 channels_arg_constr.data = NULL;
25201         uint32_t* channels_arg_vals = channels_arg->elems /* XXX channels_arg leaks */;
25202         for (size_t q = 0; q < channels_arg_constr.datalen; q++) {
25203                 uint32_t channels_arg_conv_16 = channels_arg_vals[q];
25204                 LDKChannelDetails channels_arg_conv_16_conv;
25205                 channels_arg_conv_16_conv.inner = (void*)(channels_arg_conv_16 & (~1));
25206                 channels_arg_conv_16_conv.is_owned = (channels_arg_conv_16 & 1) || (channels_arg_conv_16 == 0);
25207                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channels_arg_conv_16_conv);
25208                 channels_arg_conv_16_conv = ChannelDetails_clone(&channels_arg_conv_16_conv);
25209                 channels_arg_constr.data[q] = channels_arg_conv_16_conv;
25210         }
25211         LDKPublicKey real_node_pubkey_arg_ref;
25212         CHECK(real_node_pubkey_arg->arr_len == 33);
25213         memcpy(real_node_pubkey_arg_ref.compressed_form, real_node_pubkey_arg->elems, 33); FREE(real_node_pubkey_arg);
25214         LDKPhantomRouteHints ret_var = PhantomRouteHints_new(channels_arg_constr, phantom_scid_arg, real_node_pubkey_arg_ref);
25215         uint32_t ret_ref = 0;
25216         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25217         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25218         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25219         ret_ref = (uintptr_t)ret_var.inner;
25220         if (ret_var.is_owned) {
25221                 ret_ref |= 1;
25222         }
25223         return ret_ref;
25224 }
25225
25226 static inline uintptr_t PhantomRouteHints_clone_ptr(LDKPhantomRouteHints *NONNULL_PTR arg) {
25227         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(arg);
25228 uint32_t ret_ref = 0;
25229 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25230 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25231 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25232 ret_ref = (uintptr_t)ret_var.inner;
25233 if (ret_var.is_owned) {
25234         ret_ref |= 1;
25235 }
25236         return ret_ref;
25237 }
25238 uint32_t  __attribute__((export_name("TS_PhantomRouteHints_clone_ptr"))) TS_PhantomRouteHints_clone_ptr(uint32_t arg) {
25239         LDKPhantomRouteHints arg_conv;
25240         arg_conv.inner = (void*)(arg & (~1));
25241         arg_conv.is_owned = false;
25242         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25243         uint32_t ret_conv = PhantomRouteHints_clone_ptr(&arg_conv);
25244         return ret_conv;
25245 }
25246
25247 uint32_t  __attribute__((export_name("TS_PhantomRouteHints_clone"))) TS_PhantomRouteHints_clone(uint32_t orig) {
25248         LDKPhantomRouteHints orig_conv;
25249         orig_conv.inner = (void*)(orig & (~1));
25250         orig_conv.is_owned = false;
25251         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25252         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(&orig_conv);
25253         uint32_t ret_ref = 0;
25254         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25255         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25256         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25257         ret_ref = (uintptr_t)ret_var.inner;
25258         if (ret_var.is_owned) {
25259                 ret_ref |= 1;
25260         }
25261         return ret_ref;
25262 }
25263
25264 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) {
25265         void* fee_est_ptr = (void*)(((uintptr_t)fee_est) & ~1);
25266         CHECK_ACCESS(fee_est_ptr);
25267         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
25268         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
25269                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25270                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
25271         }
25272         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
25273         CHECK_ACCESS(chain_monitor_ptr);
25274         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
25275         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
25276                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25277                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
25278         }
25279         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
25280         CHECK_ACCESS(tx_broadcaster_ptr);
25281         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
25282         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
25283                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25284                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
25285         }
25286         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
25287         CHECK_ACCESS(logger_ptr);
25288         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
25289         if (logger_conv.free == LDKLogger_JCalls_free) {
25290                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25291                 LDKLogger_JCalls_cloned(&logger_conv);
25292         }
25293         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
25294         CHECK_ACCESS(keys_manager_ptr);
25295         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
25296         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
25297                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25298                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
25299         }
25300         LDKUserConfig config_conv;
25301         config_conv.inner = (void*)(config & (~1));
25302         config_conv.is_owned = (config & 1) || (config == 0);
25303         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
25304         config_conv = UserConfig_clone(&config_conv);
25305         LDKChainParameters params_conv;
25306         params_conv.inner = (void*)(params & (~1));
25307         params_conv.is_owned = (params & 1) || (params == 0);
25308         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
25309         params_conv = ChainParameters_clone(&params_conv);
25310         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
25311         uint32_t ret_ref = 0;
25312         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25313         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25314         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25315         ret_ref = (uintptr_t)ret_var.inner;
25316         if (ret_var.is_owned) {
25317                 ret_ref |= 1;
25318         }
25319         return ret_ref;
25320 }
25321
25322 uint32_t  __attribute__((export_name("TS_ChannelManager_get_current_default_configuration"))) TS_ChannelManager_get_current_default_configuration(uint32_t this_arg) {
25323         LDKChannelManager this_arg_conv;
25324         this_arg_conv.inner = (void*)(this_arg & (~1));
25325         this_arg_conv.is_owned = false;
25326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25327         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
25328         uint32_t ret_ref = 0;
25329         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25330         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25331         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25332         ret_ref = (uintptr_t)ret_var.inner;
25333         if (ret_var.is_owned) {
25334                 ret_ref |= 1;
25335         }
25336         return ret_ref;
25337 }
25338
25339 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) {
25340         LDKChannelManager this_arg_conv;
25341         this_arg_conv.inner = (void*)(this_arg & (~1));
25342         this_arg_conv.is_owned = false;
25343         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25344         LDKPublicKey their_network_key_ref;
25345         CHECK(their_network_key->arr_len == 33);
25346         memcpy(their_network_key_ref.compressed_form, their_network_key->elems, 33); FREE(their_network_key);
25347         LDKUserConfig override_config_conv;
25348         override_config_conv.inner = (void*)(override_config & (~1));
25349         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
25350         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
25351         override_config_conv = UserConfig_clone(&override_config_conv);
25352         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
25353         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id, override_config_conv);
25354         return (uint32_t)ret_conv;
25355 }
25356
25357 uint32_tArray  __attribute__((export_name("TS_ChannelManager_list_channels"))) TS_ChannelManager_list_channels(uint32_t this_arg) {
25358         LDKChannelManager this_arg_conv;
25359         this_arg_conv.inner = (void*)(this_arg & (~1));
25360         this_arg_conv.is_owned = false;
25361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25362         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
25363         uint32_tArray ret_arr = NULL;
25364         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
25365         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
25366         for (size_t q = 0; q < ret_var.datalen; q++) {
25367                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
25368                 uint32_t ret_conv_16_ref = 0;
25369                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25370                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25371                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
25372                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
25373                 if (ret_conv_16_var.is_owned) {
25374                         ret_conv_16_ref |= 1;
25375                 }
25376                 ret_arr_ptr[q] = ret_conv_16_ref;
25377         }
25378         
25379         FREE(ret_var.data);
25380         return ret_arr;
25381 }
25382
25383 uint32_tArray  __attribute__((export_name("TS_ChannelManager_list_usable_channels"))) TS_ChannelManager_list_usable_channels(uint32_t this_arg) {
25384         LDKChannelManager this_arg_conv;
25385         this_arg_conv.inner = (void*)(this_arg & (~1));
25386         this_arg_conv.is_owned = false;
25387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25388         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
25389         uint32_tArray ret_arr = NULL;
25390         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
25391         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
25392         for (size_t q = 0; q < ret_var.datalen; q++) {
25393                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
25394                 uint32_t ret_conv_16_ref = 0;
25395                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25396                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25397                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
25398                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
25399                 if (ret_conv_16_var.is_owned) {
25400                         ret_conv_16_ref |= 1;
25401                 }
25402                 ret_arr_ptr[q] = ret_conv_16_ref;
25403         }
25404         
25405         FREE(ret_var.data);
25406         return ret_arr;
25407 }
25408
25409 uint32_t  __attribute__((export_name("TS_ChannelManager_close_channel"))) TS_ChannelManager_close_channel(uint32_t this_arg, int8_tArray channel_id) {
25410         LDKChannelManager this_arg_conv;
25411         this_arg_conv.inner = (void*)(this_arg & (~1));
25412         this_arg_conv.is_owned = false;
25413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25414         unsigned char channel_id_arr[32];
25415         CHECK(channel_id->arr_len == 32);
25416         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
25417         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
25418         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
25419         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
25420         return (uint32_t)ret_conv;
25421 }
25422
25423 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, int32_t target_feerate_sats_per_1000_weight) {
25424         LDKChannelManager this_arg_conv;
25425         this_arg_conv.inner = (void*)(this_arg & (~1));
25426         this_arg_conv.is_owned = false;
25427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25428         unsigned char channel_id_arr[32];
25429         CHECK(channel_id->arr_len == 32);
25430         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
25431         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
25432         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
25433         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, target_feerate_sats_per_1000_weight);
25434         return (uint32_t)ret_conv;
25435 }
25436
25437 uint32_t  __attribute__((export_name("TS_ChannelManager_force_close_channel"))) TS_ChannelManager_force_close_channel(uint32_t this_arg, int8_tArray channel_id) {
25438         LDKChannelManager this_arg_conv;
25439         this_arg_conv.inner = (void*)(this_arg & (~1));
25440         this_arg_conv.is_owned = false;
25441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25442         unsigned char channel_id_arr[32];
25443         CHECK(channel_id->arr_len == 32);
25444         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
25445         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
25446         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
25447         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
25448         return (uint32_t)ret_conv;
25449 }
25450
25451 void  __attribute__((export_name("TS_ChannelManager_force_close_all_channels"))) TS_ChannelManager_force_close_all_channels(uint32_t this_arg) {
25452         LDKChannelManager this_arg_conv;
25453         this_arg_conv.inner = (void*)(this_arg & (~1));
25454         this_arg_conv.is_owned = false;
25455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25456         ChannelManager_force_close_all_channels(&this_arg_conv);
25457 }
25458
25459 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) {
25460         LDKChannelManager this_arg_conv;
25461         this_arg_conv.inner = (void*)(this_arg & (~1));
25462         this_arg_conv.is_owned = false;
25463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25464         LDKRoute route_conv;
25465         route_conv.inner = (void*)(route & (~1));
25466         route_conv.is_owned = false;
25467         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
25468         LDKThirtyTwoBytes payment_hash_ref;
25469         CHECK(payment_hash->arr_len == 32);
25470         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
25471         LDKThirtyTwoBytes payment_secret_ref;
25472         CHECK(payment_secret->arr_len == 32);
25473         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
25474         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
25475         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
25476         return (uint32_t)ret_conv;
25477 }
25478
25479 uint32_t  __attribute__((export_name("TS_ChannelManager_retry_payment"))) TS_ChannelManager_retry_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_id) {
25480         LDKChannelManager this_arg_conv;
25481         this_arg_conv.inner = (void*)(this_arg & (~1));
25482         this_arg_conv.is_owned = false;
25483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25484         LDKRoute route_conv;
25485         route_conv.inner = (void*)(route & (~1));
25486         route_conv.is_owned = false;
25487         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
25488         LDKThirtyTwoBytes payment_id_ref;
25489         CHECK(payment_id->arr_len == 32);
25490         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
25491         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
25492         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
25493         return (uint32_t)ret_conv;
25494 }
25495
25496 void  __attribute__((export_name("TS_ChannelManager_abandon_payment"))) TS_ChannelManager_abandon_payment(uint32_t this_arg, int8_tArray payment_id) {
25497         LDKChannelManager this_arg_conv;
25498         this_arg_conv.inner = (void*)(this_arg & (~1));
25499         this_arg_conv.is_owned = false;
25500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25501         LDKThirtyTwoBytes payment_id_ref;
25502         CHECK(payment_id->arr_len == 32);
25503         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
25504         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
25505 }
25506
25507 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) {
25508         LDKChannelManager this_arg_conv;
25509         this_arg_conv.inner = (void*)(this_arg & (~1));
25510         this_arg_conv.is_owned = false;
25511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25512         LDKRoute route_conv;
25513         route_conv.inner = (void*)(route & (~1));
25514         route_conv.is_owned = false;
25515         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
25516         LDKThirtyTwoBytes payment_preimage_ref;
25517         CHECK(payment_preimage->arr_len == 32);
25518         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
25519         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
25520         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
25521         return (uint32_t)ret_conv;
25522 }
25523
25524 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 funding_transaction) {
25525         LDKChannelManager this_arg_conv;
25526         this_arg_conv.inner = (void*)(this_arg & (~1));
25527         this_arg_conv.is_owned = false;
25528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25529         unsigned char temporary_channel_id_arr[32];
25530         CHECK(temporary_channel_id->arr_len == 32);
25531         memcpy(temporary_channel_id_arr, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
25532         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
25533         LDKTransaction funding_transaction_ref;
25534         funding_transaction_ref.datalen = funding_transaction->arr_len;
25535         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
25536         memcpy(funding_transaction_ref.data, funding_transaction->elems, funding_transaction_ref.datalen); FREE(funding_transaction);
25537         funding_transaction_ref.data_is_owned = true;
25538         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
25539         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
25540         return (uint32_t)ret_conv;
25541 }
25542
25543 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) {
25544         LDKChannelManager this_arg_conv;
25545         this_arg_conv.inner = (void*)(this_arg & (~1));
25546         this_arg_conv.is_owned = false;
25547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25548         LDKThreeBytes rgb_ref;
25549         CHECK(rgb->arr_len == 3);
25550         memcpy(rgb_ref.data, rgb->elems, 3); FREE(rgb);
25551         LDKThirtyTwoBytes alias_ref;
25552         CHECK(alias->arr_len == 32);
25553         memcpy(alias_ref.data, alias->elems, 32); FREE(alias);
25554         LDKCVec_NetAddressZ addresses_constr;
25555         addresses_constr.datalen = addresses->arr_len;
25556         if (addresses_constr.datalen > 0)
25557                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
25558         else
25559                 addresses_constr.data = NULL;
25560         uint32_t* addresses_vals = addresses->elems /* XXX addresses leaks */;
25561         for (size_t m = 0; m < addresses_constr.datalen; m++) {
25562                 uint32_t addresses_conv_12 = addresses_vals[m];
25563                 void* addresses_conv_12_ptr = (void*)(((uintptr_t)addresses_conv_12) & ~1);
25564                 CHECK_ACCESS(addresses_conv_12_ptr);
25565                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
25566                 addresses_constr.data[m] = addresses_conv_12_conv;
25567         }
25568         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
25569 }
25570
25571 void  __attribute__((export_name("TS_ChannelManager_process_pending_htlc_forwards"))) TS_ChannelManager_process_pending_htlc_forwards(uint32_t this_arg) {
25572         LDKChannelManager this_arg_conv;
25573         this_arg_conv.inner = (void*)(this_arg & (~1));
25574         this_arg_conv.is_owned = false;
25575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25576         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
25577 }
25578
25579 void  __attribute__((export_name("TS_ChannelManager_timer_tick_occurred"))) TS_ChannelManager_timer_tick_occurred(uint32_t this_arg) {
25580         LDKChannelManager this_arg_conv;
25581         this_arg_conv.inner = (void*)(this_arg & (~1));
25582         this_arg_conv.is_owned = false;
25583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25584         ChannelManager_timer_tick_occurred(&this_arg_conv);
25585 }
25586
25587 jboolean  __attribute__((export_name("TS_ChannelManager_fail_htlc_backwards"))) TS_ChannelManager_fail_htlc_backwards(uint32_t this_arg, int8_tArray payment_hash) {
25588         LDKChannelManager this_arg_conv;
25589         this_arg_conv.inner = (void*)(this_arg & (~1));
25590         this_arg_conv.is_owned = false;
25591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25592         unsigned char payment_hash_arr[32];
25593         CHECK(payment_hash->arr_len == 32);
25594         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
25595         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
25596         jboolean ret_conv = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
25597         return ret_conv;
25598 }
25599
25600 jboolean  __attribute__((export_name("TS_ChannelManager_claim_funds"))) TS_ChannelManager_claim_funds(uint32_t this_arg, int8_tArray payment_preimage) {
25601         LDKChannelManager this_arg_conv;
25602         this_arg_conv.inner = (void*)(this_arg & (~1));
25603         this_arg_conv.is_owned = false;
25604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25605         LDKThirtyTwoBytes payment_preimage_ref;
25606         CHECK(payment_preimage->arr_len == 32);
25607         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
25608         jboolean ret_conv = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
25609         return ret_conv;
25610 }
25611
25612 int8_tArray  __attribute__((export_name("TS_ChannelManager_get_our_node_id"))) TS_ChannelManager_get_our_node_id(uint32_t this_arg) {
25613         LDKChannelManager this_arg_conv;
25614         this_arg_conv.inner = (void*)(this_arg & (~1));
25615         this_arg_conv.is_owned = false;
25616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25617         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
25618         memcpy(ret_arr->elems, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form, 33);
25619         return ret_arr;
25620 }
25621
25622 uint32_t  __attribute__((export_name("TS_ChannelManager_accept_inbound_channel"))) TS_ChannelManager_accept_inbound_channel(uint32_t this_arg, int8_tArray temporary_channel_id, int64_t user_channel_id) {
25623         LDKChannelManager this_arg_conv;
25624         this_arg_conv.inner = (void*)(this_arg & (~1));
25625         this_arg_conv.is_owned = false;
25626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25627         unsigned char temporary_channel_id_arr[32];
25628         CHECK(temporary_channel_id->arr_len == 32);
25629         memcpy(temporary_channel_id_arr, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
25630         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
25631         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
25632         *ret_conv = ChannelManager_accept_inbound_channel(&this_arg_conv, temporary_channel_id_ref, user_channel_id);
25633         return (uint32_t)ret_conv;
25634 }
25635
25636 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) {
25637         LDKChannelManager this_arg_conv;
25638         this_arg_conv.inner = (void*)(this_arg & (~1));
25639         this_arg_conv.is_owned = false;
25640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25641         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
25642         CHECK_ACCESS(min_value_msat_ptr);
25643         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
25644         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
25645         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
25646         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
25647         return (uint32_t)ret_conv;
25648 }
25649
25650 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) {
25651         LDKChannelManager this_arg_conv;
25652         this_arg_conv.inner = (void*)(this_arg & (~1));
25653         this_arg_conv.is_owned = false;
25654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25655         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
25656         CHECK_ACCESS(min_value_msat_ptr);
25657         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
25658         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
25659         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
25660         *ret_conv = ChannelManager_create_inbound_payment_legacy(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
25661         return (uint32_t)ret_conv;
25662 }
25663
25664 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) {
25665         LDKChannelManager this_arg_conv;
25666         this_arg_conv.inner = (void*)(this_arg & (~1));
25667         this_arg_conv.is_owned = false;
25668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25669         LDKThirtyTwoBytes payment_hash_ref;
25670         CHECK(payment_hash->arr_len == 32);
25671         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
25672         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
25673         CHECK_ACCESS(min_value_msat_ptr);
25674         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
25675         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
25676         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
25677         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
25678         return (uint32_t)ret_conv;
25679 }
25680
25681 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) {
25682         LDKChannelManager this_arg_conv;
25683         this_arg_conv.inner = (void*)(this_arg & (~1));
25684         this_arg_conv.is_owned = false;
25685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25686         LDKThirtyTwoBytes payment_hash_ref;
25687         CHECK(payment_hash->arr_len == 32);
25688         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
25689         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
25690         CHECK_ACCESS(min_value_msat_ptr);
25691         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
25692         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
25693         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
25694         *ret_conv = ChannelManager_create_inbound_payment_for_hash_legacy(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
25695         return (uint32_t)ret_conv;
25696 }
25697
25698 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) {
25699         LDKChannelManager this_arg_conv;
25700         this_arg_conv.inner = (void*)(this_arg & (~1));
25701         this_arg_conv.is_owned = false;
25702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25703         LDKThirtyTwoBytes payment_hash_ref;
25704         CHECK(payment_hash->arr_len == 32);
25705         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
25706         LDKThirtyTwoBytes payment_secret_ref;
25707         CHECK(payment_secret->arr_len == 32);
25708         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
25709         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
25710         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
25711         return (uint32_t)ret_conv;
25712 }
25713
25714 int64_t  __attribute__((export_name("TS_ChannelManager_get_phantom_scid"))) TS_ChannelManager_get_phantom_scid(uint32_t this_arg) {
25715         LDKChannelManager this_arg_conv;
25716         this_arg_conv.inner = (void*)(this_arg & (~1));
25717         this_arg_conv.is_owned = false;
25718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25719         int64_t ret_conv = ChannelManager_get_phantom_scid(&this_arg_conv);
25720         return ret_conv;
25721 }
25722
25723 uint32_t  __attribute__((export_name("TS_ChannelManager_get_phantom_route_hints"))) TS_ChannelManager_get_phantom_route_hints(uint32_t this_arg) {
25724         LDKChannelManager this_arg_conv;
25725         this_arg_conv.inner = (void*)(this_arg & (~1));
25726         this_arg_conv.is_owned = false;
25727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25728         LDKPhantomRouteHints ret_var = ChannelManager_get_phantom_route_hints(&this_arg_conv);
25729         uint32_t ret_ref = 0;
25730         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25731         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25732         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25733         ret_ref = (uintptr_t)ret_var.inner;
25734         if (ret_var.is_owned) {
25735                 ret_ref |= 1;
25736         }
25737         return ret_ref;
25738 }
25739
25740 uint32_t  __attribute__((export_name("TS_ChannelManager_as_MessageSendEventsProvider"))) TS_ChannelManager_as_MessageSendEventsProvider(uint32_t this_arg) {
25741         LDKChannelManager this_arg_conv;
25742         this_arg_conv.inner = (void*)(this_arg & (~1));
25743         this_arg_conv.is_owned = false;
25744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25745         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
25746         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
25747         return (uint32_t)ret_ret;
25748 }
25749
25750 uint32_t  __attribute__((export_name("TS_ChannelManager_as_EventsProvider"))) TS_ChannelManager_as_EventsProvider(uint32_t this_arg) {
25751         LDKChannelManager this_arg_conv;
25752         this_arg_conv.inner = (void*)(this_arg & (~1));
25753         this_arg_conv.is_owned = false;
25754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25755         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
25756         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
25757         return (uint32_t)ret_ret;
25758 }
25759
25760 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Listen"))) TS_ChannelManager_as_Listen(uint32_t this_arg) {
25761         LDKChannelManager this_arg_conv;
25762         this_arg_conv.inner = (void*)(this_arg & (~1));
25763         this_arg_conv.is_owned = false;
25764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25765         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
25766         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
25767         return (uint32_t)ret_ret;
25768 }
25769
25770 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Confirm"))) TS_ChannelManager_as_Confirm(uint32_t this_arg) {
25771         LDKChannelManager this_arg_conv;
25772         this_arg_conv.inner = (void*)(this_arg & (~1));
25773         this_arg_conv.is_owned = false;
25774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25775         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
25776         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
25777         return (uint32_t)ret_ret;
25778 }
25779
25780 void  __attribute__((export_name("TS_ChannelManager_await_persistable_update"))) TS_ChannelManager_await_persistable_update(uint32_t this_arg) {
25781         LDKChannelManager this_arg_conv;
25782         this_arg_conv.inner = (void*)(this_arg & (~1));
25783         this_arg_conv.is_owned = false;
25784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25785         ChannelManager_await_persistable_update(&this_arg_conv);
25786 }
25787
25788 uint32_t  __attribute__((export_name("TS_ChannelManager_current_best_block"))) TS_ChannelManager_current_best_block(uint32_t this_arg) {
25789         LDKChannelManager this_arg_conv;
25790         this_arg_conv.inner = (void*)(this_arg & (~1));
25791         this_arg_conv.is_owned = false;
25792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25793         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
25794         uint32_t ret_ref = 0;
25795         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25796         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25797         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25798         ret_ref = (uintptr_t)ret_var.inner;
25799         if (ret_var.is_owned) {
25800                 ret_ref |= 1;
25801         }
25802         return ret_ref;
25803 }
25804
25805 uint32_t  __attribute__((export_name("TS_ChannelManager_as_ChannelMessageHandler"))) TS_ChannelManager_as_ChannelMessageHandler(uint32_t this_arg) {
25806         LDKChannelManager this_arg_conv;
25807         this_arg_conv.inner = (void*)(this_arg & (~1));
25808         this_arg_conv.is_owned = false;
25809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25810         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
25811         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
25812         return (uint32_t)ret_ret;
25813 }
25814
25815 int8_tArray  __attribute__((export_name("TS_CounterpartyForwardingInfo_write"))) TS_CounterpartyForwardingInfo_write(uint32_t obj) {
25816         LDKCounterpartyForwardingInfo obj_conv;
25817         obj_conv.inner = (void*)(obj & (~1));
25818         obj_conv.is_owned = false;
25819         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25820         LDKCVec_u8Z ret_var = CounterpartyForwardingInfo_write(&obj_conv);
25821         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
25822         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
25823         CVec_u8Z_free(ret_var);
25824         return ret_arr;
25825 }
25826
25827 uint32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_read"))) TS_CounterpartyForwardingInfo_read(int8_tArray ser) {
25828         LDKu8slice ser_ref;
25829         ser_ref.datalen = ser->arr_len;
25830         ser_ref.data = ser->elems /* XXX ser leaks */;
25831         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
25832         *ret_conv = CounterpartyForwardingInfo_read(ser_ref);
25833         return (uint32_t)ret_conv;
25834 }
25835
25836 int8_tArray  __attribute__((export_name("TS_ChannelCounterparty_write"))) TS_ChannelCounterparty_write(uint32_t obj) {
25837         LDKChannelCounterparty obj_conv;
25838         obj_conv.inner = (void*)(obj & (~1));
25839         obj_conv.is_owned = false;
25840         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25841         LDKCVec_u8Z ret_var = ChannelCounterparty_write(&obj_conv);
25842         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
25843         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
25844         CVec_u8Z_free(ret_var);
25845         return ret_arr;
25846 }
25847
25848 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_read"))) TS_ChannelCounterparty_read(int8_tArray ser) {
25849         LDKu8slice ser_ref;
25850         ser_ref.datalen = ser->arr_len;
25851         ser_ref.data = ser->elems /* XXX ser leaks */;
25852         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
25853         *ret_conv = ChannelCounterparty_read(ser_ref);
25854         return (uint32_t)ret_conv;
25855 }
25856
25857 int8_tArray  __attribute__((export_name("TS_ChannelDetails_write"))) TS_ChannelDetails_write(uint32_t obj) {
25858         LDKChannelDetails obj_conv;
25859         obj_conv.inner = (void*)(obj & (~1));
25860         obj_conv.is_owned = false;
25861         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25862         LDKCVec_u8Z ret_var = ChannelDetails_write(&obj_conv);
25863         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
25864         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
25865         CVec_u8Z_free(ret_var);
25866         return ret_arr;
25867 }
25868
25869 uint32_t  __attribute__((export_name("TS_ChannelDetails_read"))) TS_ChannelDetails_read(int8_tArray ser) {
25870         LDKu8slice ser_ref;
25871         ser_ref.datalen = ser->arr_len;
25872         ser_ref.data = ser->elems /* XXX ser leaks */;
25873         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
25874         *ret_conv = ChannelDetails_read(ser_ref);
25875         return (uint32_t)ret_conv;
25876 }
25877
25878 int8_tArray  __attribute__((export_name("TS_PhantomRouteHints_write"))) TS_PhantomRouteHints_write(uint32_t obj) {
25879         LDKPhantomRouteHints obj_conv;
25880         obj_conv.inner = (void*)(obj & (~1));
25881         obj_conv.is_owned = false;
25882         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25883         LDKCVec_u8Z ret_var = PhantomRouteHints_write(&obj_conv);
25884         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
25885         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
25886         CVec_u8Z_free(ret_var);
25887         return ret_arr;
25888 }
25889
25890 uint32_t  __attribute__((export_name("TS_PhantomRouteHints_read"))) TS_PhantomRouteHints_read(int8_tArray ser) {
25891         LDKu8slice ser_ref;
25892         ser_ref.datalen = ser->arr_len;
25893         ser_ref.data = ser->elems /* XXX ser leaks */;
25894         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
25895         *ret_conv = PhantomRouteHints_read(ser_ref);
25896         return (uint32_t)ret_conv;
25897 }
25898
25899 int8_tArray  __attribute__((export_name("TS_ChannelManager_write"))) TS_ChannelManager_write(uint32_t obj) {
25900         LDKChannelManager obj_conv;
25901         obj_conv.inner = (void*)(obj & (~1));
25902         obj_conv.is_owned = false;
25903         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25904         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
25905         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
25906         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
25907         CVec_u8Z_free(ret_var);
25908         return ret_arr;
25909 }
25910
25911 void  __attribute__((export_name("TS_ChannelManagerReadArgs_free"))) TS_ChannelManagerReadArgs_free(uint32_t this_obj) {
25912         LDKChannelManagerReadArgs this_obj_conv;
25913         this_obj_conv.inner = (void*)(this_obj & (~1));
25914         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25916         ChannelManagerReadArgs_free(this_obj_conv);
25917 }
25918
25919 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_keys_manager"))) TS_ChannelManagerReadArgs_get_keys_manager(uint32_t this_ptr) {
25920         LDKChannelManagerReadArgs this_ptr_conv;
25921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25922         this_ptr_conv.is_owned = false;
25923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25924         // WARNING: This object doesn't live past this scope, needs clone!
25925         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv)) | 1;
25926         return ret_ret;
25927 }
25928
25929 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_keys_manager"))) TS_ChannelManagerReadArgs_set_keys_manager(uint32_t this_ptr, uint32_t val) {
25930         LDKChannelManagerReadArgs this_ptr_conv;
25931         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25932         this_ptr_conv.is_owned = false;
25933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25934         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25935         CHECK_ACCESS(val_ptr);
25936         LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
25937         if (val_conv.free == LDKKeysInterface_JCalls_free) {
25938                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25939                 LDKKeysInterface_JCalls_cloned(&val_conv);
25940         }
25941         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
25942 }
25943
25944 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_fee_estimator"))) TS_ChannelManagerReadArgs_get_fee_estimator(uint32_t this_ptr) {
25945         LDKChannelManagerReadArgs this_ptr_conv;
25946         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25947         this_ptr_conv.is_owned = false;
25948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25949         // WARNING: This object doesn't live past this scope, needs clone!
25950         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv)) | 1;
25951         return ret_ret;
25952 }
25953
25954 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_fee_estimator"))) TS_ChannelManagerReadArgs_set_fee_estimator(uint32_t this_ptr, uint32_t val) {
25955         LDKChannelManagerReadArgs this_ptr_conv;
25956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25957         this_ptr_conv.is_owned = false;
25958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25959         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25960         CHECK_ACCESS(val_ptr);
25961         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
25962         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
25963                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25964                 LDKFeeEstimator_JCalls_cloned(&val_conv);
25965         }
25966         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
25967 }
25968
25969 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_chain_monitor"))) TS_ChannelManagerReadArgs_get_chain_monitor(uint32_t this_ptr) {
25970         LDKChannelManagerReadArgs this_ptr_conv;
25971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25972         this_ptr_conv.is_owned = false;
25973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25974         // WARNING: This object doesn't live past this scope, needs clone!
25975         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv)) | 1;
25976         return ret_ret;
25977 }
25978
25979 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_chain_monitor"))) TS_ChannelManagerReadArgs_set_chain_monitor(uint32_t this_ptr, uint32_t val) {
25980         LDKChannelManagerReadArgs this_ptr_conv;
25981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25982         this_ptr_conv.is_owned = false;
25983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25984         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25985         CHECK_ACCESS(val_ptr);
25986         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
25987         if (val_conv.free == LDKWatch_JCalls_free) {
25988                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25989                 LDKWatch_JCalls_cloned(&val_conv);
25990         }
25991         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
25992 }
25993
25994 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_tx_broadcaster"))) TS_ChannelManagerReadArgs_get_tx_broadcaster(uint32_t this_ptr) {
25995         LDKChannelManagerReadArgs this_ptr_conv;
25996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25997         this_ptr_conv.is_owned = false;
25998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25999         // WARNING: This object doesn't live past this scope, needs clone!
26000         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv)) | 1;
26001         return ret_ret;
26002 }
26003
26004 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_tx_broadcaster"))) TS_ChannelManagerReadArgs_set_tx_broadcaster(uint32_t this_ptr, uint32_t val) {
26005         LDKChannelManagerReadArgs this_ptr_conv;
26006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26007         this_ptr_conv.is_owned = false;
26008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26009         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26010         CHECK_ACCESS(val_ptr);
26011         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
26012         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
26013                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26014                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
26015         }
26016         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
26017 }
26018
26019 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_logger"))) TS_ChannelManagerReadArgs_get_logger(uint32_t this_ptr) {
26020         LDKChannelManagerReadArgs this_ptr_conv;
26021         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26022         this_ptr_conv.is_owned = false;
26023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26024         // WARNING: This object doesn't live past this scope, needs clone!
26025         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv)) | 1;
26026         return ret_ret;
26027 }
26028
26029 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_logger"))) TS_ChannelManagerReadArgs_set_logger(uint32_t this_ptr, uint32_t val) {
26030         LDKChannelManagerReadArgs this_ptr_conv;
26031         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26032         this_ptr_conv.is_owned = false;
26033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26034         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26035         CHECK_ACCESS(val_ptr);
26036         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
26037         if (val_conv.free == LDKLogger_JCalls_free) {
26038                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26039                 LDKLogger_JCalls_cloned(&val_conv);
26040         }
26041         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
26042 }
26043
26044 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_default_config"))) TS_ChannelManagerReadArgs_get_default_config(uint32_t this_ptr) {
26045         LDKChannelManagerReadArgs this_ptr_conv;
26046         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26047         this_ptr_conv.is_owned = false;
26048         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26049         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
26050         uint32_t ret_ref = 0;
26051         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26052         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26053         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26054         ret_ref = (uintptr_t)ret_var.inner;
26055         if (ret_var.is_owned) {
26056                 ret_ref |= 1;
26057         }
26058         return ret_ref;
26059 }
26060
26061 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_default_config"))) TS_ChannelManagerReadArgs_set_default_config(uint32_t this_ptr, uint32_t val) {
26062         LDKChannelManagerReadArgs this_ptr_conv;
26063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26064         this_ptr_conv.is_owned = false;
26065         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26066         LDKUserConfig val_conv;
26067         val_conv.inner = (void*)(val & (~1));
26068         val_conv.is_owned = (val & 1) || (val == 0);
26069         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26070         val_conv = UserConfig_clone(&val_conv);
26071         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
26072 }
26073
26074 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) {
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         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
26083         CHECK_ACCESS(fee_estimator_ptr);
26084         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
26085         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
26086                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26087                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
26088         }
26089         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
26090         CHECK_ACCESS(chain_monitor_ptr);
26091         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
26092         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
26093                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26094                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
26095         }
26096         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
26097         CHECK_ACCESS(tx_broadcaster_ptr);
26098         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
26099         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
26100                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26101                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
26102         }
26103         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
26104         CHECK_ACCESS(logger_ptr);
26105         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
26106         if (logger_conv.free == LDKLogger_JCalls_free) {
26107                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26108                 LDKLogger_JCalls_cloned(&logger_conv);
26109         }
26110         LDKUserConfig default_config_conv;
26111         default_config_conv.inner = (void*)(default_config & (~1));
26112         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
26113         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
26114         default_config_conv = UserConfig_clone(&default_config_conv);
26115         LDKCVec_ChannelMonitorZ channel_monitors_constr;
26116         channel_monitors_constr.datalen = channel_monitors->arr_len;
26117         if (channel_monitors_constr.datalen > 0)
26118                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
26119         else
26120                 channel_monitors_constr.data = NULL;
26121         uint32_t* channel_monitors_vals = channel_monitors->elems /* XXX channel_monitors leaks */;
26122         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
26123                 uint32_t channel_monitors_conv_16 = channel_monitors_vals[q];
26124                 LDKChannelMonitor channel_monitors_conv_16_conv;
26125                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
26126                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
26127                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
26128                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
26129         }
26130         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);
26131         uint32_t ret_ref = 0;
26132         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26133         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26134         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26135         ret_ref = (uintptr_t)ret_var.inner;
26136         if (ret_var.is_owned) {
26137                 ret_ref |= 1;
26138         }
26139         return ret_ref;
26140 }
26141
26142 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_read"))) TS_C2Tuple_BlockHashChannelManagerZ_read(int8_tArray ser, uint32_t arg) {
26143         LDKu8slice ser_ref;
26144         ser_ref.datalen = ser->arr_len;
26145         ser_ref.data = ser->elems /* XXX ser leaks */;
26146         LDKChannelManagerReadArgs arg_conv;
26147         arg_conv.inner = (void*)(arg & (~1));
26148         arg_conv.is_owned = (arg & 1) || (arg == 0);
26149         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26150         // WARNING: we need a move here but no clone is available for LDKChannelManagerReadArgs
26151         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
26152         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
26153         return (uint32_t)ret_conv;
26154 }
26155
26156 void  __attribute__((export_name("TS_DecodeError_free"))) TS_DecodeError_free(uint32_t this_obj) {
26157         LDKDecodeError this_obj_conv;
26158         this_obj_conv.inner = (void*)(this_obj & (~1));
26159         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26161         DecodeError_free(this_obj_conv);
26162 }
26163
26164 static inline uintptr_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
26165         LDKDecodeError ret_var = DecodeError_clone(arg);
26166 uint32_t ret_ref = 0;
26167 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26168 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26169 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26170 ret_ref = (uintptr_t)ret_var.inner;
26171 if (ret_var.is_owned) {
26172         ret_ref |= 1;
26173 }
26174         return ret_ref;
26175 }
26176 uint32_t  __attribute__((export_name("TS_DecodeError_clone_ptr"))) TS_DecodeError_clone_ptr(uint32_t arg) {
26177         LDKDecodeError arg_conv;
26178         arg_conv.inner = (void*)(arg & (~1));
26179         arg_conv.is_owned = false;
26180         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26181         uint32_t ret_conv = DecodeError_clone_ptr(&arg_conv);
26182         return ret_conv;
26183 }
26184
26185 uint32_t  __attribute__((export_name("TS_DecodeError_clone"))) TS_DecodeError_clone(uint32_t orig) {
26186         LDKDecodeError orig_conv;
26187         orig_conv.inner = (void*)(orig & (~1));
26188         orig_conv.is_owned = false;
26189         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26190         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
26191         uint32_t ret_ref = 0;
26192         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26193         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26194         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26195         ret_ref = (uintptr_t)ret_var.inner;
26196         if (ret_var.is_owned) {
26197                 ret_ref |= 1;
26198         }
26199         return ret_ref;
26200 }
26201
26202 void  __attribute__((export_name("TS_Init_free"))) TS_Init_free(uint32_t this_obj) {
26203         LDKInit this_obj_conv;
26204         this_obj_conv.inner = (void*)(this_obj & (~1));
26205         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26207         Init_free(this_obj_conv);
26208 }
26209
26210 uint32_t  __attribute__((export_name("TS_Init_get_features"))) TS_Init_get_features(uint32_t this_ptr) {
26211         LDKInit this_ptr_conv;
26212         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26213         this_ptr_conv.is_owned = false;
26214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26215         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
26216         uint32_t ret_ref = 0;
26217         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26218         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26219         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26220         ret_ref = (uintptr_t)ret_var.inner;
26221         if (ret_var.is_owned) {
26222                 ret_ref |= 1;
26223         }
26224         return ret_ref;
26225 }
26226
26227 void  __attribute__((export_name("TS_Init_set_features"))) TS_Init_set_features(uint32_t this_ptr, uint32_t val) {
26228         LDKInit this_ptr_conv;
26229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26230         this_ptr_conv.is_owned = false;
26231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26232         LDKInitFeatures val_conv;
26233         val_conv.inner = (void*)(val & (~1));
26234         val_conv.is_owned = (val & 1) || (val == 0);
26235         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26236         val_conv = InitFeatures_clone(&val_conv);
26237         Init_set_features(&this_ptr_conv, val_conv);
26238 }
26239
26240 uint32_t  __attribute__((export_name("TS_Init_get_remote_network_address"))) TS_Init_get_remote_network_address(uint32_t this_ptr) {
26241         LDKInit this_ptr_conv;
26242         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26243         this_ptr_conv.is_owned = false;
26244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26245         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
26246         *ret_copy = Init_get_remote_network_address(&this_ptr_conv);
26247         uint32_t ret_ref = (uintptr_t)ret_copy;
26248         return ret_ref;
26249 }
26250
26251 void  __attribute__((export_name("TS_Init_set_remote_network_address"))) TS_Init_set_remote_network_address(uint32_t this_ptr, uint32_t val) {
26252         LDKInit this_ptr_conv;
26253         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26254         this_ptr_conv.is_owned = false;
26255         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26256         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26257         CHECK_ACCESS(val_ptr);
26258         LDKCOption_NetAddressZ val_conv = *(LDKCOption_NetAddressZ*)(val_ptr);
26259         val_conv = COption_NetAddressZ_clone((LDKCOption_NetAddressZ*)(((uintptr_t)val) & ~1));
26260         Init_set_remote_network_address(&this_ptr_conv, val_conv);
26261 }
26262
26263 uint32_t  __attribute__((export_name("TS_Init_new"))) TS_Init_new(uint32_t features_arg, uint32_t remote_network_address_arg) {
26264         LDKInitFeatures features_arg_conv;
26265         features_arg_conv.inner = (void*)(features_arg & (~1));
26266         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
26267         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
26268         features_arg_conv = InitFeatures_clone(&features_arg_conv);
26269         void* remote_network_address_arg_ptr = (void*)(((uintptr_t)remote_network_address_arg) & ~1);
26270         CHECK_ACCESS(remote_network_address_arg_ptr);
26271         LDKCOption_NetAddressZ remote_network_address_arg_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_arg_ptr);
26272         LDKInit ret_var = Init_new(features_arg_conv, remote_network_address_arg_conv);
26273         uint32_t ret_ref = 0;
26274         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26275         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26276         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26277         ret_ref = (uintptr_t)ret_var.inner;
26278         if (ret_var.is_owned) {
26279                 ret_ref |= 1;
26280         }
26281         return ret_ref;
26282 }
26283
26284 static inline uintptr_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
26285         LDKInit ret_var = Init_clone(arg);
26286 uint32_t ret_ref = 0;
26287 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26288 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26289 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26290 ret_ref = (uintptr_t)ret_var.inner;
26291 if (ret_var.is_owned) {
26292         ret_ref |= 1;
26293 }
26294         return ret_ref;
26295 }
26296 uint32_t  __attribute__((export_name("TS_Init_clone_ptr"))) TS_Init_clone_ptr(uint32_t arg) {
26297         LDKInit arg_conv;
26298         arg_conv.inner = (void*)(arg & (~1));
26299         arg_conv.is_owned = false;
26300         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26301         uint32_t ret_conv = Init_clone_ptr(&arg_conv);
26302         return ret_conv;
26303 }
26304
26305 uint32_t  __attribute__((export_name("TS_Init_clone"))) TS_Init_clone(uint32_t orig) {
26306         LDKInit orig_conv;
26307         orig_conv.inner = (void*)(orig & (~1));
26308         orig_conv.is_owned = false;
26309         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26310         LDKInit ret_var = Init_clone(&orig_conv);
26311         uint32_t ret_ref = 0;
26312         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26313         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26314         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26315         ret_ref = (uintptr_t)ret_var.inner;
26316         if (ret_var.is_owned) {
26317                 ret_ref |= 1;
26318         }
26319         return ret_ref;
26320 }
26321
26322 void  __attribute__((export_name("TS_ErrorMessage_free"))) TS_ErrorMessage_free(uint32_t this_obj) {
26323         LDKErrorMessage this_obj_conv;
26324         this_obj_conv.inner = (void*)(this_obj & (~1));
26325         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26327         ErrorMessage_free(this_obj_conv);
26328 }
26329
26330 int8_tArray  __attribute__((export_name("TS_ErrorMessage_get_channel_id"))) TS_ErrorMessage_get_channel_id(uint32_t this_ptr) {
26331         LDKErrorMessage this_ptr_conv;
26332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26333         this_ptr_conv.is_owned = false;
26334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26335         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26336         memcpy(ret_arr->elems, *ErrorMessage_get_channel_id(&this_ptr_conv), 32);
26337         return ret_arr;
26338 }
26339
26340 void  __attribute__((export_name("TS_ErrorMessage_set_channel_id"))) TS_ErrorMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
26341         LDKErrorMessage this_ptr_conv;
26342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26343         this_ptr_conv.is_owned = false;
26344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26345         LDKThirtyTwoBytes val_ref;
26346         CHECK(val->arr_len == 32);
26347         memcpy(val_ref.data, val->elems, 32); FREE(val);
26348         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
26349 }
26350
26351 jstring  __attribute__((export_name("TS_ErrorMessage_get_data"))) TS_ErrorMessage_get_data(uint32_t this_ptr) {
26352         LDKErrorMessage this_ptr_conv;
26353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26354         this_ptr_conv.is_owned = false;
26355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26356         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
26357         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
26358         Str_free(ret_str);
26359         return ret_conv;
26360 }
26361
26362 void  __attribute__((export_name("TS_ErrorMessage_set_data"))) TS_ErrorMessage_set_data(uint32_t this_ptr, jstring val) {
26363         LDKErrorMessage this_ptr_conv;
26364         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26365         this_ptr_conv.is_owned = false;
26366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26367         LDKStr val_conv = str_ref_to_owned_c(val);
26368         ErrorMessage_set_data(&this_ptr_conv, val_conv);
26369 }
26370
26371 uint32_t  __attribute__((export_name("TS_ErrorMessage_new"))) TS_ErrorMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
26372         LDKThirtyTwoBytes channel_id_arg_ref;
26373         CHECK(channel_id_arg->arr_len == 32);
26374         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
26375         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
26376         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
26377         uint32_t ret_ref = 0;
26378         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26379         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26380         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26381         ret_ref = (uintptr_t)ret_var.inner;
26382         if (ret_var.is_owned) {
26383                 ret_ref |= 1;
26384         }
26385         return ret_ref;
26386 }
26387
26388 static inline uintptr_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
26389         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
26390 uint32_t ret_ref = 0;
26391 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26392 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26393 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26394 ret_ref = (uintptr_t)ret_var.inner;
26395 if (ret_var.is_owned) {
26396         ret_ref |= 1;
26397 }
26398         return ret_ref;
26399 }
26400 uint32_t  __attribute__((export_name("TS_ErrorMessage_clone_ptr"))) TS_ErrorMessage_clone_ptr(uint32_t arg) {
26401         LDKErrorMessage arg_conv;
26402         arg_conv.inner = (void*)(arg & (~1));
26403         arg_conv.is_owned = false;
26404         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26405         uint32_t ret_conv = ErrorMessage_clone_ptr(&arg_conv);
26406         return ret_conv;
26407 }
26408
26409 uint32_t  __attribute__((export_name("TS_ErrorMessage_clone"))) TS_ErrorMessage_clone(uint32_t orig) {
26410         LDKErrorMessage orig_conv;
26411         orig_conv.inner = (void*)(orig & (~1));
26412         orig_conv.is_owned = false;
26413         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26414         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
26415         uint32_t ret_ref = 0;
26416         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26417         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26418         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26419         ret_ref = (uintptr_t)ret_var.inner;
26420         if (ret_var.is_owned) {
26421                 ret_ref |= 1;
26422         }
26423         return ret_ref;
26424 }
26425
26426 void  __attribute__((export_name("TS_WarningMessage_free"))) TS_WarningMessage_free(uint32_t this_obj) {
26427         LDKWarningMessage this_obj_conv;
26428         this_obj_conv.inner = (void*)(this_obj & (~1));
26429         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26431         WarningMessage_free(this_obj_conv);
26432 }
26433
26434 int8_tArray  __attribute__((export_name("TS_WarningMessage_get_channel_id"))) TS_WarningMessage_get_channel_id(uint32_t this_ptr) {
26435         LDKWarningMessage this_ptr_conv;
26436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26437         this_ptr_conv.is_owned = false;
26438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26439         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26440         memcpy(ret_arr->elems, *WarningMessage_get_channel_id(&this_ptr_conv), 32);
26441         return ret_arr;
26442 }
26443
26444 void  __attribute__((export_name("TS_WarningMessage_set_channel_id"))) TS_WarningMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
26445         LDKWarningMessage this_ptr_conv;
26446         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26447         this_ptr_conv.is_owned = false;
26448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26449         LDKThirtyTwoBytes val_ref;
26450         CHECK(val->arr_len == 32);
26451         memcpy(val_ref.data, val->elems, 32); FREE(val);
26452         WarningMessage_set_channel_id(&this_ptr_conv, val_ref);
26453 }
26454
26455 jstring  __attribute__((export_name("TS_WarningMessage_get_data"))) TS_WarningMessage_get_data(uint32_t this_ptr) {
26456         LDKWarningMessage this_ptr_conv;
26457         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26458         this_ptr_conv.is_owned = false;
26459         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26460         LDKStr ret_str = WarningMessage_get_data(&this_ptr_conv);
26461         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
26462         Str_free(ret_str);
26463         return ret_conv;
26464 }
26465
26466 void  __attribute__((export_name("TS_WarningMessage_set_data"))) TS_WarningMessage_set_data(uint32_t this_ptr, jstring val) {
26467         LDKWarningMessage this_ptr_conv;
26468         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26469         this_ptr_conv.is_owned = false;
26470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26471         LDKStr val_conv = str_ref_to_owned_c(val);
26472         WarningMessage_set_data(&this_ptr_conv, val_conv);
26473 }
26474
26475 uint32_t  __attribute__((export_name("TS_WarningMessage_new"))) TS_WarningMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
26476         LDKThirtyTwoBytes channel_id_arg_ref;
26477         CHECK(channel_id_arg->arr_len == 32);
26478         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
26479         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
26480         LDKWarningMessage ret_var = WarningMessage_new(channel_id_arg_ref, data_arg_conv);
26481         uint32_t ret_ref = 0;
26482         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26483         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26484         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26485         ret_ref = (uintptr_t)ret_var.inner;
26486         if (ret_var.is_owned) {
26487                 ret_ref |= 1;
26488         }
26489         return ret_ref;
26490 }
26491
26492 static inline uintptr_t WarningMessage_clone_ptr(LDKWarningMessage *NONNULL_PTR arg) {
26493         LDKWarningMessage ret_var = WarningMessage_clone(arg);
26494 uint32_t ret_ref = 0;
26495 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26496 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26497 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26498 ret_ref = (uintptr_t)ret_var.inner;
26499 if (ret_var.is_owned) {
26500         ret_ref |= 1;
26501 }
26502         return ret_ref;
26503 }
26504 uint32_t  __attribute__((export_name("TS_WarningMessage_clone_ptr"))) TS_WarningMessage_clone_ptr(uint32_t arg) {
26505         LDKWarningMessage arg_conv;
26506         arg_conv.inner = (void*)(arg & (~1));
26507         arg_conv.is_owned = false;
26508         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26509         uint32_t ret_conv = WarningMessage_clone_ptr(&arg_conv);
26510         return ret_conv;
26511 }
26512
26513 uint32_t  __attribute__((export_name("TS_WarningMessage_clone"))) TS_WarningMessage_clone(uint32_t orig) {
26514         LDKWarningMessage orig_conv;
26515         orig_conv.inner = (void*)(orig & (~1));
26516         orig_conv.is_owned = false;
26517         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26518         LDKWarningMessage ret_var = WarningMessage_clone(&orig_conv);
26519         uint32_t ret_ref = 0;
26520         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26521         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26522         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26523         ret_ref = (uintptr_t)ret_var.inner;
26524         if (ret_var.is_owned) {
26525                 ret_ref |= 1;
26526         }
26527         return ret_ref;
26528 }
26529
26530 void  __attribute__((export_name("TS_Ping_free"))) TS_Ping_free(uint32_t this_obj) {
26531         LDKPing this_obj_conv;
26532         this_obj_conv.inner = (void*)(this_obj & (~1));
26533         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26535         Ping_free(this_obj_conv);
26536 }
26537
26538 int16_t  __attribute__((export_name("TS_Ping_get_ponglen"))) TS_Ping_get_ponglen(uint32_t this_ptr) {
26539         LDKPing this_ptr_conv;
26540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26541         this_ptr_conv.is_owned = false;
26542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26543         int16_t ret_conv = Ping_get_ponglen(&this_ptr_conv);
26544         return ret_conv;
26545 }
26546
26547 void  __attribute__((export_name("TS_Ping_set_ponglen"))) TS_Ping_set_ponglen(uint32_t this_ptr, int16_t val) {
26548         LDKPing this_ptr_conv;
26549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26550         this_ptr_conv.is_owned = false;
26551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26552         Ping_set_ponglen(&this_ptr_conv, val);
26553 }
26554
26555 int16_t  __attribute__((export_name("TS_Ping_get_byteslen"))) TS_Ping_get_byteslen(uint32_t this_ptr) {
26556         LDKPing this_ptr_conv;
26557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26558         this_ptr_conv.is_owned = false;
26559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26560         int16_t ret_conv = Ping_get_byteslen(&this_ptr_conv);
26561         return ret_conv;
26562 }
26563
26564 void  __attribute__((export_name("TS_Ping_set_byteslen"))) TS_Ping_set_byteslen(uint32_t this_ptr, int16_t val) {
26565         LDKPing this_ptr_conv;
26566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26567         this_ptr_conv.is_owned = false;
26568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26569         Ping_set_byteslen(&this_ptr_conv, val);
26570 }
26571
26572 uint32_t  __attribute__((export_name("TS_Ping_new"))) TS_Ping_new(int16_t ponglen_arg, int16_t byteslen_arg) {
26573         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
26574         uint32_t ret_ref = 0;
26575         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26576         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26577         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26578         ret_ref = (uintptr_t)ret_var.inner;
26579         if (ret_var.is_owned) {
26580                 ret_ref |= 1;
26581         }
26582         return ret_ref;
26583 }
26584
26585 static inline uintptr_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
26586         LDKPing ret_var = Ping_clone(arg);
26587 uint32_t ret_ref = 0;
26588 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26589 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26590 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26591 ret_ref = (uintptr_t)ret_var.inner;
26592 if (ret_var.is_owned) {
26593         ret_ref |= 1;
26594 }
26595         return ret_ref;
26596 }
26597 uint32_t  __attribute__((export_name("TS_Ping_clone_ptr"))) TS_Ping_clone_ptr(uint32_t arg) {
26598         LDKPing arg_conv;
26599         arg_conv.inner = (void*)(arg & (~1));
26600         arg_conv.is_owned = false;
26601         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26602         uint32_t ret_conv = Ping_clone_ptr(&arg_conv);
26603         return ret_conv;
26604 }
26605
26606 uint32_t  __attribute__((export_name("TS_Ping_clone"))) TS_Ping_clone(uint32_t orig) {
26607         LDKPing orig_conv;
26608         orig_conv.inner = (void*)(orig & (~1));
26609         orig_conv.is_owned = false;
26610         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26611         LDKPing ret_var = Ping_clone(&orig_conv);
26612         uint32_t ret_ref = 0;
26613         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26614         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26615         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26616         ret_ref = (uintptr_t)ret_var.inner;
26617         if (ret_var.is_owned) {
26618                 ret_ref |= 1;
26619         }
26620         return ret_ref;
26621 }
26622
26623 void  __attribute__((export_name("TS_Pong_free"))) TS_Pong_free(uint32_t this_obj) {
26624         LDKPong this_obj_conv;
26625         this_obj_conv.inner = (void*)(this_obj & (~1));
26626         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26628         Pong_free(this_obj_conv);
26629 }
26630
26631 int16_t  __attribute__((export_name("TS_Pong_get_byteslen"))) TS_Pong_get_byteslen(uint32_t this_ptr) {
26632         LDKPong this_ptr_conv;
26633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26634         this_ptr_conv.is_owned = false;
26635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26636         int16_t ret_conv = Pong_get_byteslen(&this_ptr_conv);
26637         return ret_conv;
26638 }
26639
26640 void  __attribute__((export_name("TS_Pong_set_byteslen"))) TS_Pong_set_byteslen(uint32_t this_ptr, int16_t val) {
26641         LDKPong this_ptr_conv;
26642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26643         this_ptr_conv.is_owned = false;
26644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26645         Pong_set_byteslen(&this_ptr_conv, val);
26646 }
26647
26648 uint32_t  __attribute__((export_name("TS_Pong_new"))) TS_Pong_new(int16_t byteslen_arg) {
26649         LDKPong ret_var = Pong_new(byteslen_arg);
26650         uint32_t ret_ref = 0;
26651         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26652         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26653         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26654         ret_ref = (uintptr_t)ret_var.inner;
26655         if (ret_var.is_owned) {
26656                 ret_ref |= 1;
26657         }
26658         return ret_ref;
26659 }
26660
26661 static inline uintptr_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
26662         LDKPong ret_var = Pong_clone(arg);
26663 uint32_t ret_ref = 0;
26664 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26665 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26666 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26667 ret_ref = (uintptr_t)ret_var.inner;
26668 if (ret_var.is_owned) {
26669         ret_ref |= 1;
26670 }
26671         return ret_ref;
26672 }
26673 uint32_t  __attribute__((export_name("TS_Pong_clone_ptr"))) TS_Pong_clone_ptr(uint32_t arg) {
26674         LDKPong arg_conv;
26675         arg_conv.inner = (void*)(arg & (~1));
26676         arg_conv.is_owned = false;
26677         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26678         uint32_t ret_conv = Pong_clone_ptr(&arg_conv);
26679         return ret_conv;
26680 }
26681
26682 uint32_t  __attribute__((export_name("TS_Pong_clone"))) TS_Pong_clone(uint32_t orig) {
26683         LDKPong orig_conv;
26684         orig_conv.inner = (void*)(orig & (~1));
26685         orig_conv.is_owned = false;
26686         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26687         LDKPong ret_var = Pong_clone(&orig_conv);
26688         uint32_t ret_ref = 0;
26689         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26690         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26691         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26692         ret_ref = (uintptr_t)ret_var.inner;
26693         if (ret_var.is_owned) {
26694                 ret_ref |= 1;
26695         }
26696         return ret_ref;
26697 }
26698
26699 void  __attribute__((export_name("TS_OpenChannel_free"))) TS_OpenChannel_free(uint32_t this_obj) {
26700         LDKOpenChannel this_obj_conv;
26701         this_obj_conv.inner = (void*)(this_obj & (~1));
26702         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26704         OpenChannel_free(this_obj_conv);
26705 }
26706
26707 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_chain_hash"))) TS_OpenChannel_get_chain_hash(uint32_t this_ptr) {
26708         LDKOpenChannel this_ptr_conv;
26709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26710         this_ptr_conv.is_owned = false;
26711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26712         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26713         memcpy(ret_arr->elems, *OpenChannel_get_chain_hash(&this_ptr_conv), 32);
26714         return ret_arr;
26715 }
26716
26717 void  __attribute__((export_name("TS_OpenChannel_set_chain_hash"))) TS_OpenChannel_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
26718         LDKOpenChannel this_ptr_conv;
26719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26720         this_ptr_conv.is_owned = false;
26721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26722         LDKThirtyTwoBytes val_ref;
26723         CHECK(val->arr_len == 32);
26724         memcpy(val_ref.data, val->elems, 32); FREE(val);
26725         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
26726 }
26727
26728 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_temporary_channel_id"))) TS_OpenChannel_get_temporary_channel_id(uint32_t this_ptr) {
26729         LDKOpenChannel this_ptr_conv;
26730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26731         this_ptr_conv.is_owned = false;
26732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26733         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26734         memcpy(ret_arr->elems, *OpenChannel_get_temporary_channel_id(&this_ptr_conv), 32);
26735         return ret_arr;
26736 }
26737
26738 void  __attribute__((export_name("TS_OpenChannel_set_temporary_channel_id"))) TS_OpenChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
26739         LDKOpenChannel this_ptr_conv;
26740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26741         this_ptr_conv.is_owned = false;
26742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26743         LDKThirtyTwoBytes val_ref;
26744         CHECK(val->arr_len == 32);
26745         memcpy(val_ref.data, val->elems, 32); FREE(val);
26746         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
26747 }
26748
26749 int64_t  __attribute__((export_name("TS_OpenChannel_get_funding_satoshis"))) TS_OpenChannel_get_funding_satoshis(uint32_t this_ptr) {
26750         LDKOpenChannel this_ptr_conv;
26751         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26752         this_ptr_conv.is_owned = false;
26753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26754         int64_t ret_conv = OpenChannel_get_funding_satoshis(&this_ptr_conv);
26755         return ret_conv;
26756 }
26757
26758 void  __attribute__((export_name("TS_OpenChannel_set_funding_satoshis"))) TS_OpenChannel_set_funding_satoshis(uint32_t this_ptr, int64_t val) {
26759         LDKOpenChannel this_ptr_conv;
26760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26761         this_ptr_conv.is_owned = false;
26762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26763         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
26764 }
26765
26766 int64_t  __attribute__((export_name("TS_OpenChannel_get_push_msat"))) TS_OpenChannel_get_push_msat(uint32_t this_ptr) {
26767         LDKOpenChannel 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         int64_t ret_conv = OpenChannel_get_push_msat(&this_ptr_conv);
26772         return ret_conv;
26773 }
26774
26775 void  __attribute__((export_name("TS_OpenChannel_set_push_msat"))) TS_OpenChannel_set_push_msat(uint32_t this_ptr, int64_t val) {
26776         LDKOpenChannel this_ptr_conv;
26777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26778         this_ptr_conv.is_owned = false;
26779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26780         OpenChannel_set_push_msat(&this_ptr_conv, val);
26781 }
26782
26783 int64_t  __attribute__((export_name("TS_OpenChannel_get_dust_limit_satoshis"))) TS_OpenChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
26784         LDKOpenChannel this_ptr_conv;
26785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26786         this_ptr_conv.is_owned = false;
26787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26788         int64_t ret_conv = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
26789         return ret_conv;
26790 }
26791
26792 void  __attribute__((export_name("TS_OpenChannel_set_dust_limit_satoshis"))) TS_OpenChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
26793         LDKOpenChannel this_ptr_conv;
26794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26795         this_ptr_conv.is_owned = false;
26796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26797         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
26798 }
26799
26800 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) {
26801         LDKOpenChannel this_ptr_conv;
26802         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26803         this_ptr_conv.is_owned = false;
26804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26805         int64_t ret_conv = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
26806         return ret_conv;
26807 }
26808
26809 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) {
26810         LDKOpenChannel this_ptr_conv;
26811         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26812         this_ptr_conv.is_owned = false;
26813         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26814         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
26815 }
26816
26817 int64_t  __attribute__((export_name("TS_OpenChannel_get_channel_reserve_satoshis"))) TS_OpenChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
26818         LDKOpenChannel this_ptr_conv;
26819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26820         this_ptr_conv.is_owned = false;
26821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26822         int64_t ret_conv = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
26823         return ret_conv;
26824 }
26825
26826 void  __attribute__((export_name("TS_OpenChannel_set_channel_reserve_satoshis"))) TS_OpenChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
26827         LDKOpenChannel this_ptr_conv;
26828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26829         this_ptr_conv.is_owned = false;
26830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26831         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
26832 }
26833
26834 int64_t  __attribute__((export_name("TS_OpenChannel_get_htlc_minimum_msat"))) TS_OpenChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
26835         LDKOpenChannel this_ptr_conv;
26836         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26837         this_ptr_conv.is_owned = false;
26838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26839         int64_t ret_conv = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
26840         return ret_conv;
26841 }
26842
26843 void  __attribute__((export_name("TS_OpenChannel_set_htlc_minimum_msat"))) TS_OpenChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
26844         LDKOpenChannel this_ptr_conv;
26845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26846         this_ptr_conv.is_owned = false;
26847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26848         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
26849 }
26850
26851 int32_t  __attribute__((export_name("TS_OpenChannel_get_feerate_per_kw"))) TS_OpenChannel_get_feerate_per_kw(uint32_t this_ptr) {
26852         LDKOpenChannel this_ptr_conv;
26853         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26854         this_ptr_conv.is_owned = false;
26855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26856         int32_t ret_conv = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
26857         return ret_conv;
26858 }
26859
26860 void  __attribute__((export_name("TS_OpenChannel_set_feerate_per_kw"))) TS_OpenChannel_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
26861         LDKOpenChannel this_ptr_conv;
26862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26863         this_ptr_conv.is_owned = false;
26864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26865         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
26866 }
26867
26868 int16_t  __attribute__((export_name("TS_OpenChannel_get_to_self_delay"))) TS_OpenChannel_get_to_self_delay(uint32_t this_ptr) {
26869         LDKOpenChannel this_ptr_conv;
26870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26871         this_ptr_conv.is_owned = false;
26872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26873         int16_t ret_conv = OpenChannel_get_to_self_delay(&this_ptr_conv);
26874         return ret_conv;
26875 }
26876
26877 void  __attribute__((export_name("TS_OpenChannel_set_to_self_delay"))) TS_OpenChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
26878         LDKOpenChannel this_ptr_conv;
26879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26880         this_ptr_conv.is_owned = false;
26881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26882         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
26883 }
26884
26885 int16_t  __attribute__((export_name("TS_OpenChannel_get_max_accepted_htlcs"))) TS_OpenChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
26886         LDKOpenChannel this_ptr_conv;
26887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26888         this_ptr_conv.is_owned = false;
26889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26890         int16_t ret_conv = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
26891         return ret_conv;
26892 }
26893
26894 void  __attribute__((export_name("TS_OpenChannel_set_max_accepted_htlcs"))) TS_OpenChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
26895         LDKOpenChannel this_ptr_conv;
26896         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26897         this_ptr_conv.is_owned = false;
26898         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26899         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
26900 }
26901
26902 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_funding_pubkey"))) TS_OpenChannel_get_funding_pubkey(uint32_t this_ptr) {
26903         LDKOpenChannel this_ptr_conv;
26904         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26905         this_ptr_conv.is_owned = false;
26906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26907         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26908         memcpy(ret_arr->elems, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
26909         return ret_arr;
26910 }
26911
26912 void  __attribute__((export_name("TS_OpenChannel_set_funding_pubkey"))) TS_OpenChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
26913         LDKOpenChannel this_ptr_conv;
26914         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26915         this_ptr_conv.is_owned = false;
26916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26917         LDKPublicKey val_ref;
26918         CHECK(val->arr_len == 33);
26919         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26920         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
26921 }
26922
26923 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_revocation_basepoint"))) TS_OpenChannel_get_revocation_basepoint(uint32_t this_ptr) {
26924         LDKOpenChannel this_ptr_conv;
26925         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26926         this_ptr_conv.is_owned = false;
26927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26928         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26929         memcpy(ret_arr->elems, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
26930         return ret_arr;
26931 }
26932
26933 void  __attribute__((export_name("TS_OpenChannel_set_revocation_basepoint"))) TS_OpenChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
26934         LDKOpenChannel this_ptr_conv;
26935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26936         this_ptr_conv.is_owned = false;
26937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26938         LDKPublicKey val_ref;
26939         CHECK(val->arr_len == 33);
26940         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26941         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
26942 }
26943
26944 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_payment_point"))) TS_OpenChannel_get_payment_point(uint32_t this_ptr) {
26945         LDKOpenChannel this_ptr_conv;
26946         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26947         this_ptr_conv.is_owned = false;
26948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26949         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26950         memcpy(ret_arr->elems, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
26951         return ret_arr;
26952 }
26953
26954 void  __attribute__((export_name("TS_OpenChannel_set_payment_point"))) TS_OpenChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
26955         LDKOpenChannel this_ptr_conv;
26956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26957         this_ptr_conv.is_owned = false;
26958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26959         LDKPublicKey val_ref;
26960         CHECK(val->arr_len == 33);
26961         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26962         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
26963 }
26964
26965 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_delayed_payment_basepoint"))) TS_OpenChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
26966         LDKOpenChannel this_ptr_conv;
26967         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26968         this_ptr_conv.is_owned = false;
26969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26970         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26971         memcpy(ret_arr->elems, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
26972         return ret_arr;
26973 }
26974
26975 void  __attribute__((export_name("TS_OpenChannel_set_delayed_payment_basepoint"))) TS_OpenChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
26976         LDKOpenChannel this_ptr_conv;
26977         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26978         this_ptr_conv.is_owned = false;
26979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26980         LDKPublicKey val_ref;
26981         CHECK(val->arr_len == 33);
26982         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26983         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
26984 }
26985
26986 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_htlc_basepoint"))) TS_OpenChannel_get_htlc_basepoint(uint32_t this_ptr) {
26987         LDKOpenChannel this_ptr_conv;
26988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26989         this_ptr_conv.is_owned = false;
26990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26991         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26992         memcpy(ret_arr->elems, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
26993         return ret_arr;
26994 }
26995
26996 void  __attribute__((export_name("TS_OpenChannel_set_htlc_basepoint"))) TS_OpenChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
26997         LDKOpenChannel this_ptr_conv;
26998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26999         this_ptr_conv.is_owned = false;
27000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27001         LDKPublicKey val_ref;
27002         CHECK(val->arr_len == 33);
27003         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
27004         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
27005 }
27006
27007 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_first_per_commitment_point"))) TS_OpenChannel_get_first_per_commitment_point(uint32_t this_ptr) {
27008         LDKOpenChannel this_ptr_conv;
27009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27010         this_ptr_conv.is_owned = false;
27011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27012         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
27013         memcpy(ret_arr->elems, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
27014         return ret_arr;
27015 }
27016
27017 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) {
27018         LDKOpenChannel this_ptr_conv;
27019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27020         this_ptr_conv.is_owned = false;
27021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27022         LDKPublicKey val_ref;
27023         CHECK(val->arr_len == 33);
27024         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
27025         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
27026 }
27027
27028 int8_t  __attribute__((export_name("TS_OpenChannel_get_channel_flags"))) TS_OpenChannel_get_channel_flags(uint32_t this_ptr) {
27029         LDKOpenChannel this_ptr_conv;
27030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27031         this_ptr_conv.is_owned = false;
27032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27033         int8_t ret_conv = OpenChannel_get_channel_flags(&this_ptr_conv);
27034         return ret_conv;
27035 }
27036
27037 void  __attribute__((export_name("TS_OpenChannel_set_channel_flags"))) TS_OpenChannel_set_channel_flags(uint32_t this_ptr, int8_t val) {
27038         LDKOpenChannel this_ptr_conv;
27039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27040         this_ptr_conv.is_owned = false;
27041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27042         OpenChannel_set_channel_flags(&this_ptr_conv, val);
27043 }
27044
27045 uint32_t  __attribute__((export_name("TS_OpenChannel_get_channel_type"))) TS_OpenChannel_get_channel_type(uint32_t this_ptr) {
27046         LDKOpenChannel this_ptr_conv;
27047         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27048         this_ptr_conv.is_owned = false;
27049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27050         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
27051         uint32_t ret_ref = 0;
27052         if ((uintptr_t)ret_var.inner > 4096) {
27053                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27054                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27055         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27056                 ret_ref = (uintptr_t)ret_var.inner;
27057                 if (ret_var.is_owned) {
27058                         ret_ref |= 1;
27059                 }
27060         }
27061         return ret_ref;
27062 }
27063
27064 void  __attribute__((export_name("TS_OpenChannel_set_channel_type"))) TS_OpenChannel_set_channel_type(uint32_t this_ptr, uint32_t val) {
27065         LDKOpenChannel this_ptr_conv;
27066         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27067         this_ptr_conv.is_owned = false;
27068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27069         LDKChannelTypeFeatures val_conv;
27070         val_conv.inner = (void*)(val & (~1));
27071         val_conv.is_owned = (val & 1) || (val == 0);
27072         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27073         val_conv = ChannelTypeFeatures_clone(&val_conv);
27074         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
27075 }
27076
27077 static inline uintptr_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
27078         LDKOpenChannel ret_var = OpenChannel_clone(arg);
27079 uint32_t ret_ref = 0;
27080 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27081 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27082 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27083 ret_ref = (uintptr_t)ret_var.inner;
27084 if (ret_var.is_owned) {
27085         ret_ref |= 1;
27086 }
27087         return ret_ref;
27088 }
27089 uint32_t  __attribute__((export_name("TS_OpenChannel_clone_ptr"))) TS_OpenChannel_clone_ptr(uint32_t arg) {
27090         LDKOpenChannel arg_conv;
27091         arg_conv.inner = (void*)(arg & (~1));
27092         arg_conv.is_owned = false;
27093         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27094         uint32_t ret_conv = OpenChannel_clone_ptr(&arg_conv);
27095         return ret_conv;
27096 }
27097
27098 uint32_t  __attribute__((export_name("TS_OpenChannel_clone"))) TS_OpenChannel_clone(uint32_t orig) {
27099         LDKOpenChannel orig_conv;
27100         orig_conv.inner = (void*)(orig & (~1));
27101         orig_conv.is_owned = false;
27102         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27103         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
27104         uint32_t ret_ref = 0;
27105         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27106         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27107         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27108         ret_ref = (uintptr_t)ret_var.inner;
27109         if (ret_var.is_owned) {
27110                 ret_ref |= 1;
27111         }
27112         return ret_ref;
27113 }
27114
27115 void  __attribute__((export_name("TS_AcceptChannel_free"))) TS_AcceptChannel_free(uint32_t this_obj) {
27116         LDKAcceptChannel this_obj_conv;
27117         this_obj_conv.inner = (void*)(this_obj & (~1));
27118         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27120         AcceptChannel_free(this_obj_conv);
27121 }
27122
27123 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_temporary_channel_id"))) TS_AcceptChannel_get_temporary_channel_id(uint32_t this_ptr) {
27124         LDKAcceptChannel this_ptr_conv;
27125         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27126         this_ptr_conv.is_owned = false;
27127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27128         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27129         memcpy(ret_arr->elems, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv), 32);
27130         return ret_arr;
27131 }
27132
27133 void  __attribute__((export_name("TS_AcceptChannel_set_temporary_channel_id"))) TS_AcceptChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
27134         LDKAcceptChannel this_ptr_conv;
27135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27136         this_ptr_conv.is_owned = false;
27137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27138         LDKThirtyTwoBytes val_ref;
27139         CHECK(val->arr_len == 32);
27140         memcpy(val_ref.data, val->elems, 32); FREE(val);
27141         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
27142 }
27143
27144 int64_t  __attribute__((export_name("TS_AcceptChannel_get_dust_limit_satoshis"))) TS_AcceptChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
27145         LDKAcceptChannel this_ptr_conv;
27146         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27147         this_ptr_conv.is_owned = false;
27148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27149         int64_t ret_conv = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
27150         return ret_conv;
27151 }
27152
27153 void  __attribute__((export_name("TS_AcceptChannel_set_dust_limit_satoshis"))) TS_AcceptChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
27154         LDKAcceptChannel this_ptr_conv;
27155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27156         this_ptr_conv.is_owned = false;
27157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27158         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
27159 }
27160
27161 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) {
27162         LDKAcceptChannel this_ptr_conv;
27163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27164         this_ptr_conv.is_owned = false;
27165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27166         int64_t ret_conv = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
27167         return ret_conv;
27168 }
27169
27170 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) {
27171         LDKAcceptChannel this_ptr_conv;
27172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27173         this_ptr_conv.is_owned = false;
27174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27175         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
27176 }
27177
27178 int64_t  __attribute__((export_name("TS_AcceptChannel_get_channel_reserve_satoshis"))) TS_AcceptChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
27179         LDKAcceptChannel this_ptr_conv;
27180         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27181         this_ptr_conv.is_owned = false;
27182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27183         int64_t ret_conv = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
27184         return ret_conv;
27185 }
27186
27187 void  __attribute__((export_name("TS_AcceptChannel_set_channel_reserve_satoshis"))) TS_AcceptChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
27188         LDKAcceptChannel this_ptr_conv;
27189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27190         this_ptr_conv.is_owned = false;
27191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27192         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
27193 }
27194
27195 int64_t  __attribute__((export_name("TS_AcceptChannel_get_htlc_minimum_msat"))) TS_AcceptChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
27196         LDKAcceptChannel this_ptr_conv;
27197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27198         this_ptr_conv.is_owned = false;
27199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27200         int64_t ret_conv = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
27201         return ret_conv;
27202 }
27203
27204 void  __attribute__((export_name("TS_AcceptChannel_set_htlc_minimum_msat"))) TS_AcceptChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
27205         LDKAcceptChannel this_ptr_conv;
27206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27207         this_ptr_conv.is_owned = false;
27208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27209         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
27210 }
27211
27212 int32_t  __attribute__((export_name("TS_AcceptChannel_get_minimum_depth"))) TS_AcceptChannel_get_minimum_depth(uint32_t this_ptr) {
27213         LDKAcceptChannel this_ptr_conv;
27214         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27215         this_ptr_conv.is_owned = false;
27216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27217         int32_t ret_conv = AcceptChannel_get_minimum_depth(&this_ptr_conv);
27218         return ret_conv;
27219 }
27220
27221 void  __attribute__((export_name("TS_AcceptChannel_set_minimum_depth"))) TS_AcceptChannel_set_minimum_depth(uint32_t this_ptr, int32_t val) {
27222         LDKAcceptChannel this_ptr_conv;
27223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27224         this_ptr_conv.is_owned = false;
27225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27226         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
27227 }
27228
27229 int16_t  __attribute__((export_name("TS_AcceptChannel_get_to_self_delay"))) TS_AcceptChannel_get_to_self_delay(uint32_t this_ptr) {
27230         LDKAcceptChannel this_ptr_conv;
27231         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27232         this_ptr_conv.is_owned = false;
27233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27234         int16_t ret_conv = AcceptChannel_get_to_self_delay(&this_ptr_conv);
27235         return ret_conv;
27236 }
27237
27238 void  __attribute__((export_name("TS_AcceptChannel_set_to_self_delay"))) TS_AcceptChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
27239         LDKAcceptChannel this_ptr_conv;
27240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27241         this_ptr_conv.is_owned = false;
27242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27243         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
27244 }
27245
27246 int16_t  __attribute__((export_name("TS_AcceptChannel_get_max_accepted_htlcs"))) TS_AcceptChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
27247         LDKAcceptChannel this_ptr_conv;
27248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27249         this_ptr_conv.is_owned = false;
27250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27251         int16_t ret_conv = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
27252         return ret_conv;
27253 }
27254
27255 void  __attribute__((export_name("TS_AcceptChannel_set_max_accepted_htlcs"))) TS_AcceptChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
27256         LDKAcceptChannel this_ptr_conv;
27257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27258         this_ptr_conv.is_owned = false;
27259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27260         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
27261 }
27262
27263 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_funding_pubkey"))) TS_AcceptChannel_get_funding_pubkey(uint32_t this_ptr) {
27264         LDKAcceptChannel this_ptr_conv;
27265         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27266         this_ptr_conv.is_owned = false;
27267         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27268         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
27269         memcpy(ret_arr->elems, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
27270         return ret_arr;
27271 }
27272
27273 void  __attribute__((export_name("TS_AcceptChannel_set_funding_pubkey"))) TS_AcceptChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
27274         LDKAcceptChannel this_ptr_conv;
27275         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27276         this_ptr_conv.is_owned = false;
27277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27278         LDKPublicKey val_ref;
27279         CHECK(val->arr_len == 33);
27280         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
27281         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
27282 }
27283
27284 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_revocation_basepoint"))) TS_AcceptChannel_get_revocation_basepoint(uint32_t this_ptr) {
27285         LDKAcceptChannel this_ptr_conv;
27286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27287         this_ptr_conv.is_owned = false;
27288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27289         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
27290         memcpy(ret_arr->elems, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
27291         return ret_arr;
27292 }
27293
27294 void  __attribute__((export_name("TS_AcceptChannel_set_revocation_basepoint"))) TS_AcceptChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
27295         LDKAcceptChannel this_ptr_conv;
27296         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27297         this_ptr_conv.is_owned = false;
27298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27299         LDKPublicKey val_ref;
27300         CHECK(val->arr_len == 33);
27301         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
27302         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
27303 }
27304
27305 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_payment_point"))) TS_AcceptChannel_get_payment_point(uint32_t this_ptr) {
27306         LDKAcceptChannel 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(33, __LINE__);
27311         memcpy(ret_arr->elems, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
27312         return ret_arr;
27313 }
27314
27315 void  __attribute__((export_name("TS_AcceptChannel_set_payment_point"))) TS_AcceptChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
27316         LDKAcceptChannel 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         LDKPublicKey val_ref;
27321         CHECK(val->arr_len == 33);
27322         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
27323         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
27324 }
27325
27326 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_delayed_payment_basepoint"))) TS_AcceptChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
27327         LDKAcceptChannel 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         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
27332         memcpy(ret_arr->elems, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
27333         return ret_arr;
27334 }
27335
27336 void  __attribute__((export_name("TS_AcceptChannel_set_delayed_payment_basepoint"))) TS_AcceptChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
27337         LDKAcceptChannel this_ptr_conv;
27338         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27339         this_ptr_conv.is_owned = false;
27340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27341         LDKPublicKey val_ref;
27342         CHECK(val->arr_len == 33);
27343         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
27344         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
27345 }
27346
27347 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_htlc_basepoint"))) TS_AcceptChannel_get_htlc_basepoint(uint32_t this_ptr) {
27348         LDKAcceptChannel this_ptr_conv;
27349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27350         this_ptr_conv.is_owned = false;
27351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27352         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
27353         memcpy(ret_arr->elems, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
27354         return ret_arr;
27355 }
27356
27357 void  __attribute__((export_name("TS_AcceptChannel_set_htlc_basepoint"))) TS_AcceptChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
27358         LDKAcceptChannel this_ptr_conv;
27359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27360         this_ptr_conv.is_owned = false;
27361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27362         LDKPublicKey val_ref;
27363         CHECK(val->arr_len == 33);
27364         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
27365         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
27366 }
27367
27368 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_first_per_commitment_point"))) TS_AcceptChannel_get_first_per_commitment_point(uint32_t this_ptr) {
27369         LDKAcceptChannel this_ptr_conv;
27370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27371         this_ptr_conv.is_owned = false;
27372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27373         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
27374         memcpy(ret_arr->elems, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
27375         return ret_arr;
27376 }
27377
27378 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) {
27379         LDKAcceptChannel this_ptr_conv;
27380         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27381         this_ptr_conv.is_owned = false;
27382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27383         LDKPublicKey val_ref;
27384         CHECK(val->arr_len == 33);
27385         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
27386         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
27387 }
27388
27389 uint32_t  __attribute__((export_name("TS_AcceptChannel_get_channel_type"))) TS_AcceptChannel_get_channel_type(uint32_t this_ptr) {
27390         LDKAcceptChannel this_ptr_conv;
27391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27392         this_ptr_conv.is_owned = false;
27393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27394         LDKChannelTypeFeatures ret_var = AcceptChannel_get_channel_type(&this_ptr_conv);
27395         uint32_t ret_ref = 0;
27396         if ((uintptr_t)ret_var.inner > 4096) {
27397                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27398                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27399         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27400                 ret_ref = (uintptr_t)ret_var.inner;
27401                 if (ret_var.is_owned) {
27402                         ret_ref |= 1;
27403                 }
27404         }
27405         return ret_ref;
27406 }
27407
27408 void  __attribute__((export_name("TS_AcceptChannel_set_channel_type"))) TS_AcceptChannel_set_channel_type(uint32_t this_ptr, uint32_t val) {
27409         LDKAcceptChannel this_ptr_conv;
27410         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27411         this_ptr_conv.is_owned = false;
27412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27413         LDKChannelTypeFeatures val_conv;
27414         val_conv.inner = (void*)(val & (~1));
27415         val_conv.is_owned = (val & 1) || (val == 0);
27416         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27417         val_conv = ChannelTypeFeatures_clone(&val_conv);
27418         AcceptChannel_set_channel_type(&this_ptr_conv, val_conv);
27419 }
27420
27421 static inline uintptr_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
27422         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
27423 uint32_t ret_ref = 0;
27424 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27425 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27426 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27427 ret_ref = (uintptr_t)ret_var.inner;
27428 if (ret_var.is_owned) {
27429         ret_ref |= 1;
27430 }
27431         return ret_ref;
27432 }
27433 uint32_t  __attribute__((export_name("TS_AcceptChannel_clone_ptr"))) TS_AcceptChannel_clone_ptr(uint32_t arg) {
27434         LDKAcceptChannel arg_conv;
27435         arg_conv.inner = (void*)(arg & (~1));
27436         arg_conv.is_owned = false;
27437         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27438         uint32_t ret_conv = AcceptChannel_clone_ptr(&arg_conv);
27439         return ret_conv;
27440 }
27441
27442 uint32_t  __attribute__((export_name("TS_AcceptChannel_clone"))) TS_AcceptChannel_clone(uint32_t orig) {
27443         LDKAcceptChannel orig_conv;
27444         orig_conv.inner = (void*)(orig & (~1));
27445         orig_conv.is_owned = false;
27446         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27447         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
27448         uint32_t ret_ref = 0;
27449         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27450         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27451         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27452         ret_ref = (uintptr_t)ret_var.inner;
27453         if (ret_var.is_owned) {
27454                 ret_ref |= 1;
27455         }
27456         return ret_ref;
27457 }
27458
27459 void  __attribute__((export_name("TS_FundingCreated_free"))) TS_FundingCreated_free(uint32_t this_obj) {
27460         LDKFundingCreated this_obj_conv;
27461         this_obj_conv.inner = (void*)(this_obj & (~1));
27462         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27464         FundingCreated_free(this_obj_conv);
27465 }
27466
27467 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_temporary_channel_id"))) TS_FundingCreated_get_temporary_channel_id(uint32_t this_ptr) {
27468         LDKFundingCreated this_ptr_conv;
27469         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27470         this_ptr_conv.is_owned = false;
27471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27472         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27473         memcpy(ret_arr->elems, *FundingCreated_get_temporary_channel_id(&this_ptr_conv), 32);
27474         return ret_arr;
27475 }
27476
27477 void  __attribute__((export_name("TS_FundingCreated_set_temporary_channel_id"))) TS_FundingCreated_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
27478         LDKFundingCreated this_ptr_conv;
27479         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27480         this_ptr_conv.is_owned = false;
27481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27482         LDKThirtyTwoBytes val_ref;
27483         CHECK(val->arr_len == 32);
27484         memcpy(val_ref.data, val->elems, 32); FREE(val);
27485         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
27486 }
27487
27488 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_funding_txid"))) TS_FundingCreated_get_funding_txid(uint32_t this_ptr) {
27489         LDKFundingCreated this_ptr_conv;
27490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27491         this_ptr_conv.is_owned = false;
27492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27493         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27494         memcpy(ret_arr->elems, *FundingCreated_get_funding_txid(&this_ptr_conv), 32);
27495         return ret_arr;
27496 }
27497
27498 void  __attribute__((export_name("TS_FundingCreated_set_funding_txid"))) TS_FundingCreated_set_funding_txid(uint32_t this_ptr, int8_tArray val) {
27499         LDKFundingCreated this_ptr_conv;
27500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27501         this_ptr_conv.is_owned = false;
27502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27503         LDKThirtyTwoBytes val_ref;
27504         CHECK(val->arr_len == 32);
27505         memcpy(val_ref.data, val->elems, 32); FREE(val);
27506         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
27507 }
27508
27509 int16_t  __attribute__((export_name("TS_FundingCreated_get_funding_output_index"))) TS_FundingCreated_get_funding_output_index(uint32_t this_ptr) {
27510         LDKFundingCreated this_ptr_conv;
27511         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27512         this_ptr_conv.is_owned = false;
27513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27514         int16_t ret_conv = FundingCreated_get_funding_output_index(&this_ptr_conv);
27515         return ret_conv;
27516 }
27517
27518 void  __attribute__((export_name("TS_FundingCreated_set_funding_output_index"))) TS_FundingCreated_set_funding_output_index(uint32_t this_ptr, int16_t val) {
27519         LDKFundingCreated this_ptr_conv;
27520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27521         this_ptr_conv.is_owned = false;
27522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27523         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
27524 }
27525
27526 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_signature"))) TS_FundingCreated_get_signature(uint32_t this_ptr) {
27527         LDKFundingCreated this_ptr_conv;
27528         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27529         this_ptr_conv.is_owned = false;
27530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27531         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
27532         memcpy(ret_arr->elems, FundingCreated_get_signature(&this_ptr_conv).compact_form, 64);
27533         return ret_arr;
27534 }
27535
27536 void  __attribute__((export_name("TS_FundingCreated_set_signature"))) TS_FundingCreated_set_signature(uint32_t this_ptr, int8_tArray val) {
27537         LDKFundingCreated this_ptr_conv;
27538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27539         this_ptr_conv.is_owned = false;
27540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27541         LDKSignature val_ref;
27542         CHECK(val->arr_len == 64);
27543         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
27544         FundingCreated_set_signature(&this_ptr_conv, val_ref);
27545 }
27546
27547 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) {
27548         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
27549         CHECK(temporary_channel_id_arg->arr_len == 32);
27550         memcpy(temporary_channel_id_arg_ref.data, temporary_channel_id_arg->elems, 32); FREE(temporary_channel_id_arg);
27551         LDKThirtyTwoBytes funding_txid_arg_ref;
27552         CHECK(funding_txid_arg->arr_len == 32);
27553         memcpy(funding_txid_arg_ref.data, funding_txid_arg->elems, 32); FREE(funding_txid_arg);
27554         LDKSignature signature_arg_ref;
27555         CHECK(signature_arg->arr_len == 64);
27556         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
27557         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
27558         uint32_t ret_ref = 0;
27559         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27560         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27561         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27562         ret_ref = (uintptr_t)ret_var.inner;
27563         if (ret_var.is_owned) {
27564                 ret_ref |= 1;
27565         }
27566         return ret_ref;
27567 }
27568
27569 static inline uintptr_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
27570         LDKFundingCreated ret_var = FundingCreated_clone(arg);
27571 uint32_t ret_ref = 0;
27572 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27573 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27574 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27575 ret_ref = (uintptr_t)ret_var.inner;
27576 if (ret_var.is_owned) {
27577         ret_ref |= 1;
27578 }
27579         return ret_ref;
27580 }
27581 uint32_t  __attribute__((export_name("TS_FundingCreated_clone_ptr"))) TS_FundingCreated_clone_ptr(uint32_t arg) {
27582         LDKFundingCreated arg_conv;
27583         arg_conv.inner = (void*)(arg & (~1));
27584         arg_conv.is_owned = false;
27585         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27586         uint32_t ret_conv = FundingCreated_clone_ptr(&arg_conv);
27587         return ret_conv;
27588 }
27589
27590 uint32_t  __attribute__((export_name("TS_FundingCreated_clone"))) TS_FundingCreated_clone(uint32_t orig) {
27591         LDKFundingCreated orig_conv;
27592         orig_conv.inner = (void*)(orig & (~1));
27593         orig_conv.is_owned = false;
27594         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27595         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
27596         uint32_t ret_ref = 0;
27597         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27598         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27599         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27600         ret_ref = (uintptr_t)ret_var.inner;
27601         if (ret_var.is_owned) {
27602                 ret_ref |= 1;
27603         }
27604         return ret_ref;
27605 }
27606
27607 void  __attribute__((export_name("TS_FundingSigned_free"))) TS_FundingSigned_free(uint32_t this_obj) {
27608         LDKFundingSigned this_obj_conv;
27609         this_obj_conv.inner = (void*)(this_obj & (~1));
27610         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27612         FundingSigned_free(this_obj_conv);
27613 }
27614
27615 int8_tArray  __attribute__((export_name("TS_FundingSigned_get_channel_id"))) TS_FundingSigned_get_channel_id(uint32_t this_ptr) {
27616         LDKFundingSigned this_ptr_conv;
27617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27618         this_ptr_conv.is_owned = false;
27619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27620         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27621         memcpy(ret_arr->elems, *FundingSigned_get_channel_id(&this_ptr_conv), 32);
27622         return ret_arr;
27623 }
27624
27625 void  __attribute__((export_name("TS_FundingSigned_set_channel_id"))) TS_FundingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
27626         LDKFundingSigned this_ptr_conv;
27627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27628         this_ptr_conv.is_owned = false;
27629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27630         LDKThirtyTwoBytes val_ref;
27631         CHECK(val->arr_len == 32);
27632         memcpy(val_ref.data, val->elems, 32); FREE(val);
27633         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
27634 }
27635
27636 int8_tArray  __attribute__((export_name("TS_FundingSigned_get_signature"))) TS_FundingSigned_get_signature(uint32_t this_ptr) {
27637         LDKFundingSigned this_ptr_conv;
27638         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27639         this_ptr_conv.is_owned = false;
27640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27641         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
27642         memcpy(ret_arr->elems, FundingSigned_get_signature(&this_ptr_conv).compact_form, 64);
27643         return ret_arr;
27644 }
27645
27646 void  __attribute__((export_name("TS_FundingSigned_set_signature"))) TS_FundingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
27647         LDKFundingSigned 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         LDKSignature val_ref;
27652         CHECK(val->arr_len == 64);
27653         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
27654         FundingSigned_set_signature(&this_ptr_conv, val_ref);
27655 }
27656
27657 uint32_t  __attribute__((export_name("TS_FundingSigned_new"))) TS_FundingSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg) {
27658         LDKThirtyTwoBytes channel_id_arg_ref;
27659         CHECK(channel_id_arg->arr_len == 32);
27660         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
27661         LDKSignature signature_arg_ref;
27662         CHECK(signature_arg->arr_len == 64);
27663         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
27664         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
27665         uint32_t ret_ref = 0;
27666         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27667         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27668         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27669         ret_ref = (uintptr_t)ret_var.inner;
27670         if (ret_var.is_owned) {
27671                 ret_ref |= 1;
27672         }
27673         return ret_ref;
27674 }
27675
27676 static inline uintptr_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
27677         LDKFundingSigned ret_var = FundingSigned_clone(arg);
27678 uint32_t ret_ref = 0;
27679 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27680 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27681 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27682 ret_ref = (uintptr_t)ret_var.inner;
27683 if (ret_var.is_owned) {
27684         ret_ref |= 1;
27685 }
27686         return ret_ref;
27687 }
27688 uint32_t  __attribute__((export_name("TS_FundingSigned_clone_ptr"))) TS_FundingSigned_clone_ptr(uint32_t arg) {
27689         LDKFundingSigned arg_conv;
27690         arg_conv.inner = (void*)(arg & (~1));
27691         arg_conv.is_owned = false;
27692         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27693         uint32_t ret_conv = FundingSigned_clone_ptr(&arg_conv);
27694         return ret_conv;
27695 }
27696
27697 uint32_t  __attribute__((export_name("TS_FundingSigned_clone"))) TS_FundingSigned_clone(uint32_t orig) {
27698         LDKFundingSigned orig_conv;
27699         orig_conv.inner = (void*)(orig & (~1));
27700         orig_conv.is_owned = false;
27701         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27702         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
27703         uint32_t ret_ref = 0;
27704         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27705         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27706         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27707         ret_ref = (uintptr_t)ret_var.inner;
27708         if (ret_var.is_owned) {
27709                 ret_ref |= 1;
27710         }
27711         return ret_ref;
27712 }
27713
27714 void  __attribute__((export_name("TS_FundingLocked_free"))) TS_FundingLocked_free(uint32_t this_obj) {
27715         LDKFundingLocked this_obj_conv;
27716         this_obj_conv.inner = (void*)(this_obj & (~1));
27717         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27719         FundingLocked_free(this_obj_conv);
27720 }
27721
27722 int8_tArray  __attribute__((export_name("TS_FundingLocked_get_channel_id"))) TS_FundingLocked_get_channel_id(uint32_t this_ptr) {
27723         LDKFundingLocked 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         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27728         memcpy(ret_arr->elems, *FundingLocked_get_channel_id(&this_ptr_conv), 32);
27729         return ret_arr;
27730 }
27731
27732 void  __attribute__((export_name("TS_FundingLocked_set_channel_id"))) TS_FundingLocked_set_channel_id(uint32_t this_ptr, int8_tArray val) {
27733         LDKFundingLocked this_ptr_conv;
27734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27735         this_ptr_conv.is_owned = false;
27736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27737         LDKThirtyTwoBytes val_ref;
27738         CHECK(val->arr_len == 32);
27739         memcpy(val_ref.data, val->elems, 32); FREE(val);
27740         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
27741 }
27742
27743 int8_tArray  __attribute__((export_name("TS_FundingLocked_get_next_per_commitment_point"))) TS_FundingLocked_get_next_per_commitment_point(uint32_t this_ptr) {
27744         LDKFundingLocked this_ptr_conv;
27745         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27746         this_ptr_conv.is_owned = false;
27747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27748         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
27749         memcpy(ret_arr->elems, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
27750         return ret_arr;
27751 }
27752
27753 void  __attribute__((export_name("TS_FundingLocked_set_next_per_commitment_point"))) TS_FundingLocked_set_next_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
27754         LDKFundingLocked this_ptr_conv;
27755         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27756         this_ptr_conv.is_owned = false;
27757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27758         LDKPublicKey val_ref;
27759         CHECK(val->arr_len == 33);
27760         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
27761         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
27762 }
27763
27764 uint32_t  __attribute__((export_name("TS_FundingLocked_get_short_channel_id_alias"))) TS_FundingLocked_get_short_channel_id_alias(uint32_t this_ptr) {
27765         LDKFundingLocked this_ptr_conv;
27766         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27767         this_ptr_conv.is_owned = false;
27768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27769         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
27770         *ret_copy = FundingLocked_get_short_channel_id_alias(&this_ptr_conv);
27771         uint32_t ret_ref = (uintptr_t)ret_copy;
27772         return ret_ref;
27773 }
27774
27775 void  __attribute__((export_name("TS_FundingLocked_set_short_channel_id_alias"))) TS_FundingLocked_set_short_channel_id_alias(uint32_t this_ptr, uint32_t val) {
27776         LDKFundingLocked this_ptr_conv;
27777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27778         this_ptr_conv.is_owned = false;
27779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27780         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27781         CHECK_ACCESS(val_ptr);
27782         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
27783         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
27784         FundingLocked_set_short_channel_id_alias(&this_ptr_conv, val_conv);
27785 }
27786
27787 uint32_t  __attribute__((export_name("TS_FundingLocked_new"))) TS_FundingLocked_new(int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg, uint32_t short_channel_id_alias_arg) {
27788         LDKThirtyTwoBytes channel_id_arg_ref;
27789         CHECK(channel_id_arg->arr_len == 32);
27790         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
27791         LDKPublicKey next_per_commitment_point_arg_ref;
27792         CHECK(next_per_commitment_point_arg->arr_len == 33);
27793         memcpy(next_per_commitment_point_arg_ref.compressed_form, next_per_commitment_point_arg->elems, 33); FREE(next_per_commitment_point_arg);
27794         void* short_channel_id_alias_arg_ptr = (void*)(((uintptr_t)short_channel_id_alias_arg) & ~1);
27795         CHECK_ACCESS(short_channel_id_alias_arg_ptr);
27796         LDKCOption_u64Z short_channel_id_alias_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_alias_arg_ptr);
27797         short_channel_id_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_alias_arg) & ~1));
27798         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref, short_channel_id_alias_arg_conv);
27799         uint32_t ret_ref = 0;
27800         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27801         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27802         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27803         ret_ref = (uintptr_t)ret_var.inner;
27804         if (ret_var.is_owned) {
27805                 ret_ref |= 1;
27806         }
27807         return ret_ref;
27808 }
27809
27810 static inline uintptr_t FundingLocked_clone_ptr(LDKFundingLocked *NONNULL_PTR arg) {
27811         LDKFundingLocked ret_var = FundingLocked_clone(arg);
27812 uint32_t ret_ref = 0;
27813 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27814 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27815 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27816 ret_ref = (uintptr_t)ret_var.inner;
27817 if (ret_var.is_owned) {
27818         ret_ref |= 1;
27819 }
27820         return ret_ref;
27821 }
27822 uint32_t  __attribute__((export_name("TS_FundingLocked_clone_ptr"))) TS_FundingLocked_clone_ptr(uint32_t arg) {
27823         LDKFundingLocked arg_conv;
27824         arg_conv.inner = (void*)(arg & (~1));
27825         arg_conv.is_owned = false;
27826         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27827         uint32_t ret_conv = FundingLocked_clone_ptr(&arg_conv);
27828         return ret_conv;
27829 }
27830
27831 uint32_t  __attribute__((export_name("TS_FundingLocked_clone"))) TS_FundingLocked_clone(uint32_t orig) {
27832         LDKFundingLocked orig_conv;
27833         orig_conv.inner = (void*)(orig & (~1));
27834         orig_conv.is_owned = false;
27835         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27836         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
27837         uint32_t ret_ref = 0;
27838         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27839         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27840         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27841         ret_ref = (uintptr_t)ret_var.inner;
27842         if (ret_var.is_owned) {
27843                 ret_ref |= 1;
27844         }
27845         return ret_ref;
27846 }
27847
27848 void  __attribute__((export_name("TS_Shutdown_free"))) TS_Shutdown_free(uint32_t this_obj) {
27849         LDKShutdown this_obj_conv;
27850         this_obj_conv.inner = (void*)(this_obj & (~1));
27851         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27852         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27853         Shutdown_free(this_obj_conv);
27854 }
27855
27856 int8_tArray  __attribute__((export_name("TS_Shutdown_get_channel_id"))) TS_Shutdown_get_channel_id(uint32_t this_ptr) {
27857         LDKShutdown this_ptr_conv;
27858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27859         this_ptr_conv.is_owned = false;
27860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27861         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27862         memcpy(ret_arr->elems, *Shutdown_get_channel_id(&this_ptr_conv), 32);
27863         return ret_arr;
27864 }
27865
27866 void  __attribute__((export_name("TS_Shutdown_set_channel_id"))) TS_Shutdown_set_channel_id(uint32_t this_ptr, int8_tArray val) {
27867         LDKShutdown this_ptr_conv;
27868         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27869         this_ptr_conv.is_owned = false;
27870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27871         LDKThirtyTwoBytes val_ref;
27872         CHECK(val->arr_len == 32);
27873         memcpy(val_ref.data, val->elems, 32); FREE(val);
27874         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
27875 }
27876
27877 int8_tArray  __attribute__((export_name("TS_Shutdown_get_scriptpubkey"))) TS_Shutdown_get_scriptpubkey(uint32_t this_ptr) {
27878         LDKShutdown this_ptr_conv;
27879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27880         this_ptr_conv.is_owned = false;
27881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27882         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
27883         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27884         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27885         return ret_arr;
27886 }
27887
27888 void  __attribute__((export_name("TS_Shutdown_set_scriptpubkey"))) TS_Shutdown_set_scriptpubkey(uint32_t this_ptr, int8_tArray val) {
27889         LDKShutdown 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         LDKCVec_u8Z val_ref;
27894         val_ref.datalen = val->arr_len;
27895         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
27896         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
27897         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
27898 }
27899
27900 uint32_t  __attribute__((export_name("TS_Shutdown_new"))) TS_Shutdown_new(int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
27901         LDKThirtyTwoBytes channel_id_arg_ref;
27902         CHECK(channel_id_arg->arr_len == 32);
27903         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
27904         LDKCVec_u8Z scriptpubkey_arg_ref;
27905         scriptpubkey_arg_ref.datalen = scriptpubkey_arg->arr_len;
27906         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
27907         memcpy(scriptpubkey_arg_ref.data, scriptpubkey_arg->elems, scriptpubkey_arg_ref.datalen); FREE(scriptpubkey_arg);
27908         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
27909         uint32_t ret_ref = 0;
27910         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27911         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27912         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27913         ret_ref = (uintptr_t)ret_var.inner;
27914         if (ret_var.is_owned) {
27915                 ret_ref |= 1;
27916         }
27917         return ret_ref;
27918 }
27919
27920 static inline uintptr_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
27921         LDKShutdown ret_var = Shutdown_clone(arg);
27922 uint32_t ret_ref = 0;
27923 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27924 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27925 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27926 ret_ref = (uintptr_t)ret_var.inner;
27927 if (ret_var.is_owned) {
27928         ret_ref |= 1;
27929 }
27930         return ret_ref;
27931 }
27932 uint32_t  __attribute__((export_name("TS_Shutdown_clone_ptr"))) TS_Shutdown_clone_ptr(uint32_t arg) {
27933         LDKShutdown arg_conv;
27934         arg_conv.inner = (void*)(arg & (~1));
27935         arg_conv.is_owned = false;
27936         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27937         uint32_t ret_conv = Shutdown_clone_ptr(&arg_conv);
27938         return ret_conv;
27939 }
27940
27941 uint32_t  __attribute__((export_name("TS_Shutdown_clone"))) TS_Shutdown_clone(uint32_t orig) {
27942         LDKShutdown orig_conv;
27943         orig_conv.inner = (void*)(orig & (~1));
27944         orig_conv.is_owned = false;
27945         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27946         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
27947         uint32_t ret_ref = 0;
27948         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27949         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27950         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27951         ret_ref = (uintptr_t)ret_var.inner;
27952         if (ret_var.is_owned) {
27953                 ret_ref |= 1;
27954         }
27955         return ret_ref;
27956 }
27957
27958 void  __attribute__((export_name("TS_ClosingSignedFeeRange_free"))) TS_ClosingSignedFeeRange_free(uint32_t this_obj) {
27959         LDKClosingSignedFeeRange this_obj_conv;
27960         this_obj_conv.inner = (void*)(this_obj & (~1));
27961         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27963         ClosingSignedFeeRange_free(this_obj_conv);
27964 }
27965
27966 int64_t  __attribute__((export_name("TS_ClosingSignedFeeRange_get_min_fee_satoshis"))) TS_ClosingSignedFeeRange_get_min_fee_satoshis(uint32_t this_ptr) {
27967         LDKClosingSignedFeeRange this_ptr_conv;
27968         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27969         this_ptr_conv.is_owned = false;
27970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27971         int64_t ret_conv = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
27972         return ret_conv;
27973 }
27974
27975 void  __attribute__((export_name("TS_ClosingSignedFeeRange_set_min_fee_satoshis"))) TS_ClosingSignedFeeRange_set_min_fee_satoshis(uint32_t this_ptr, int64_t val) {
27976         LDKClosingSignedFeeRange this_ptr_conv;
27977         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27978         this_ptr_conv.is_owned = false;
27979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27980         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
27981 }
27982
27983 int64_t  __attribute__((export_name("TS_ClosingSignedFeeRange_get_max_fee_satoshis"))) TS_ClosingSignedFeeRange_get_max_fee_satoshis(uint32_t this_ptr) {
27984         LDKClosingSignedFeeRange this_ptr_conv;
27985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27986         this_ptr_conv.is_owned = false;
27987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27988         int64_t ret_conv = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
27989         return ret_conv;
27990 }
27991
27992 void  __attribute__((export_name("TS_ClosingSignedFeeRange_set_max_fee_satoshis"))) TS_ClosingSignedFeeRange_set_max_fee_satoshis(uint32_t this_ptr, int64_t val) {
27993         LDKClosingSignedFeeRange this_ptr_conv;
27994         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27995         this_ptr_conv.is_owned = false;
27996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27997         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
27998 }
27999
28000 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_new"))) TS_ClosingSignedFeeRange_new(int64_t min_fee_satoshis_arg, int64_t max_fee_satoshis_arg) {
28001         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
28002         uint32_t ret_ref = 0;
28003         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28004         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28005         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28006         ret_ref = (uintptr_t)ret_var.inner;
28007         if (ret_var.is_owned) {
28008                 ret_ref |= 1;
28009         }
28010         return ret_ref;
28011 }
28012
28013 static inline uintptr_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
28014         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
28015 uint32_t ret_ref = 0;
28016 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28017 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28018 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28019 ret_ref = (uintptr_t)ret_var.inner;
28020 if (ret_var.is_owned) {
28021         ret_ref |= 1;
28022 }
28023         return ret_ref;
28024 }
28025 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_clone_ptr"))) TS_ClosingSignedFeeRange_clone_ptr(uint32_t arg) {
28026         LDKClosingSignedFeeRange arg_conv;
28027         arg_conv.inner = (void*)(arg & (~1));
28028         arg_conv.is_owned = false;
28029         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28030         uint32_t ret_conv = ClosingSignedFeeRange_clone_ptr(&arg_conv);
28031         return ret_conv;
28032 }
28033
28034 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_clone"))) TS_ClosingSignedFeeRange_clone(uint32_t orig) {
28035         LDKClosingSignedFeeRange orig_conv;
28036         orig_conv.inner = (void*)(orig & (~1));
28037         orig_conv.is_owned = false;
28038         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28039         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
28040         uint32_t ret_ref = 0;
28041         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28042         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28043         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28044         ret_ref = (uintptr_t)ret_var.inner;
28045         if (ret_var.is_owned) {
28046                 ret_ref |= 1;
28047         }
28048         return ret_ref;
28049 }
28050
28051 void  __attribute__((export_name("TS_ClosingSigned_free"))) TS_ClosingSigned_free(uint32_t this_obj) {
28052         LDKClosingSigned this_obj_conv;
28053         this_obj_conv.inner = (void*)(this_obj & (~1));
28054         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28056         ClosingSigned_free(this_obj_conv);
28057 }
28058
28059 int8_tArray  __attribute__((export_name("TS_ClosingSigned_get_channel_id"))) TS_ClosingSigned_get_channel_id(uint32_t this_ptr) {
28060         LDKClosingSigned this_ptr_conv;
28061         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28062         this_ptr_conv.is_owned = false;
28063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28064         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28065         memcpy(ret_arr->elems, *ClosingSigned_get_channel_id(&this_ptr_conv), 32);
28066         return ret_arr;
28067 }
28068
28069 void  __attribute__((export_name("TS_ClosingSigned_set_channel_id"))) TS_ClosingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28070         LDKClosingSigned this_ptr_conv;
28071         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28072         this_ptr_conv.is_owned = false;
28073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28074         LDKThirtyTwoBytes val_ref;
28075         CHECK(val->arr_len == 32);
28076         memcpy(val_ref.data, val->elems, 32); FREE(val);
28077         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
28078 }
28079
28080 int64_t  __attribute__((export_name("TS_ClosingSigned_get_fee_satoshis"))) TS_ClosingSigned_get_fee_satoshis(uint32_t this_ptr) {
28081         LDKClosingSigned this_ptr_conv;
28082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28083         this_ptr_conv.is_owned = false;
28084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28085         int64_t ret_conv = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
28086         return ret_conv;
28087 }
28088
28089 void  __attribute__((export_name("TS_ClosingSigned_set_fee_satoshis"))) TS_ClosingSigned_set_fee_satoshis(uint32_t this_ptr, int64_t val) {
28090         LDKClosingSigned this_ptr_conv;
28091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28092         this_ptr_conv.is_owned = false;
28093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28094         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
28095 }
28096
28097 int8_tArray  __attribute__((export_name("TS_ClosingSigned_get_signature"))) TS_ClosingSigned_get_signature(uint32_t this_ptr) {
28098         LDKClosingSigned this_ptr_conv;
28099         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28100         this_ptr_conv.is_owned = false;
28101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28102         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
28103         memcpy(ret_arr->elems, ClosingSigned_get_signature(&this_ptr_conv).compact_form, 64);
28104         return ret_arr;
28105 }
28106
28107 void  __attribute__((export_name("TS_ClosingSigned_set_signature"))) TS_ClosingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
28108         LDKClosingSigned this_ptr_conv;
28109         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28110         this_ptr_conv.is_owned = false;
28111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28112         LDKSignature val_ref;
28113         CHECK(val->arr_len == 64);
28114         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
28115         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
28116 }
28117
28118 uint32_t  __attribute__((export_name("TS_ClosingSigned_get_fee_range"))) TS_ClosingSigned_get_fee_range(uint32_t this_ptr) {
28119         LDKClosingSigned this_ptr_conv;
28120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28121         this_ptr_conv.is_owned = false;
28122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28123         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
28124         uint32_t ret_ref = 0;
28125         if ((uintptr_t)ret_var.inner > 4096) {
28126                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28127                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28128         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28129                 ret_ref = (uintptr_t)ret_var.inner;
28130                 if (ret_var.is_owned) {
28131                         ret_ref |= 1;
28132                 }
28133         }
28134         return ret_ref;
28135 }
28136
28137 void  __attribute__((export_name("TS_ClosingSigned_set_fee_range"))) TS_ClosingSigned_set_fee_range(uint32_t this_ptr, uint32_t val) {
28138         LDKClosingSigned this_ptr_conv;
28139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28140         this_ptr_conv.is_owned = false;
28141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28142         LDKClosingSignedFeeRange val_conv;
28143         val_conv.inner = (void*)(val & (~1));
28144         val_conv.is_owned = (val & 1) || (val == 0);
28145         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28146         val_conv = ClosingSignedFeeRange_clone(&val_conv);
28147         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
28148 }
28149
28150 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) {
28151         LDKThirtyTwoBytes channel_id_arg_ref;
28152         CHECK(channel_id_arg->arr_len == 32);
28153         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28154         LDKSignature signature_arg_ref;
28155         CHECK(signature_arg->arr_len == 64);
28156         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
28157         LDKClosingSignedFeeRange fee_range_arg_conv;
28158         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
28159         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
28160         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
28161         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
28162         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
28163         uint32_t ret_ref = 0;
28164         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28165         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28166         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28167         ret_ref = (uintptr_t)ret_var.inner;
28168         if (ret_var.is_owned) {
28169                 ret_ref |= 1;
28170         }
28171         return ret_ref;
28172 }
28173
28174 static inline uintptr_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
28175         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
28176 uint32_t ret_ref = 0;
28177 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28178 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28179 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28180 ret_ref = (uintptr_t)ret_var.inner;
28181 if (ret_var.is_owned) {
28182         ret_ref |= 1;
28183 }
28184         return ret_ref;
28185 }
28186 uint32_t  __attribute__((export_name("TS_ClosingSigned_clone_ptr"))) TS_ClosingSigned_clone_ptr(uint32_t arg) {
28187         LDKClosingSigned arg_conv;
28188         arg_conv.inner = (void*)(arg & (~1));
28189         arg_conv.is_owned = false;
28190         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28191         uint32_t ret_conv = ClosingSigned_clone_ptr(&arg_conv);
28192         return ret_conv;
28193 }
28194
28195 uint32_t  __attribute__((export_name("TS_ClosingSigned_clone"))) TS_ClosingSigned_clone(uint32_t orig) {
28196         LDKClosingSigned orig_conv;
28197         orig_conv.inner = (void*)(orig & (~1));
28198         orig_conv.is_owned = false;
28199         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28200         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
28201         uint32_t ret_ref = 0;
28202         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28203         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28204         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28205         ret_ref = (uintptr_t)ret_var.inner;
28206         if (ret_var.is_owned) {
28207                 ret_ref |= 1;
28208         }
28209         return ret_ref;
28210 }
28211
28212 void  __attribute__((export_name("TS_UpdateAddHTLC_free"))) TS_UpdateAddHTLC_free(uint32_t this_obj) {
28213         LDKUpdateAddHTLC this_obj_conv;
28214         this_obj_conv.inner = (void*)(this_obj & (~1));
28215         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28217         UpdateAddHTLC_free(this_obj_conv);
28218 }
28219
28220 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_get_channel_id"))) TS_UpdateAddHTLC_get_channel_id(uint32_t this_ptr) {
28221         LDKUpdateAddHTLC this_ptr_conv;
28222         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28223         this_ptr_conv.is_owned = false;
28224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28225         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28226         memcpy(ret_arr->elems, *UpdateAddHTLC_get_channel_id(&this_ptr_conv), 32);
28227         return ret_arr;
28228 }
28229
28230 void  __attribute__((export_name("TS_UpdateAddHTLC_set_channel_id"))) TS_UpdateAddHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28231         LDKUpdateAddHTLC this_ptr_conv;
28232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28233         this_ptr_conv.is_owned = false;
28234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28235         LDKThirtyTwoBytes val_ref;
28236         CHECK(val->arr_len == 32);
28237         memcpy(val_ref.data, val->elems, 32); FREE(val);
28238         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
28239 }
28240
28241 int64_t  __attribute__((export_name("TS_UpdateAddHTLC_get_htlc_id"))) TS_UpdateAddHTLC_get_htlc_id(uint32_t this_ptr) {
28242         LDKUpdateAddHTLC this_ptr_conv;
28243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28244         this_ptr_conv.is_owned = false;
28245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28246         int64_t ret_conv = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
28247         return ret_conv;
28248 }
28249
28250 void  __attribute__((export_name("TS_UpdateAddHTLC_set_htlc_id"))) TS_UpdateAddHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
28251         LDKUpdateAddHTLC this_ptr_conv;
28252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28253         this_ptr_conv.is_owned = false;
28254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28255         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
28256 }
28257
28258 int64_t  __attribute__((export_name("TS_UpdateAddHTLC_get_amount_msat"))) TS_UpdateAddHTLC_get_amount_msat(uint32_t this_ptr) {
28259         LDKUpdateAddHTLC this_ptr_conv;
28260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28261         this_ptr_conv.is_owned = false;
28262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28263         int64_t ret_conv = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
28264         return ret_conv;
28265 }
28266
28267 void  __attribute__((export_name("TS_UpdateAddHTLC_set_amount_msat"))) TS_UpdateAddHTLC_set_amount_msat(uint32_t this_ptr, int64_t val) {
28268         LDKUpdateAddHTLC this_ptr_conv;
28269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28270         this_ptr_conv.is_owned = false;
28271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28272         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
28273 }
28274
28275 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_get_payment_hash"))) TS_UpdateAddHTLC_get_payment_hash(uint32_t this_ptr) {
28276         LDKUpdateAddHTLC this_ptr_conv;
28277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28278         this_ptr_conv.is_owned = false;
28279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28280         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28281         memcpy(ret_arr->elems, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv), 32);
28282         return ret_arr;
28283 }
28284
28285 void  __attribute__((export_name("TS_UpdateAddHTLC_set_payment_hash"))) TS_UpdateAddHTLC_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
28286         LDKUpdateAddHTLC this_ptr_conv;
28287         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28288         this_ptr_conv.is_owned = false;
28289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28290         LDKThirtyTwoBytes val_ref;
28291         CHECK(val->arr_len == 32);
28292         memcpy(val_ref.data, val->elems, 32); FREE(val);
28293         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
28294 }
28295
28296 int32_t  __attribute__((export_name("TS_UpdateAddHTLC_get_cltv_expiry"))) TS_UpdateAddHTLC_get_cltv_expiry(uint32_t this_ptr) {
28297         LDKUpdateAddHTLC this_ptr_conv;
28298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28299         this_ptr_conv.is_owned = false;
28300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28301         int32_t ret_conv = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
28302         return ret_conv;
28303 }
28304
28305 void  __attribute__((export_name("TS_UpdateAddHTLC_set_cltv_expiry"))) TS_UpdateAddHTLC_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
28306         LDKUpdateAddHTLC this_ptr_conv;
28307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28308         this_ptr_conv.is_owned = false;
28309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28310         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
28311 }
28312
28313 static inline uintptr_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
28314         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
28315 uint32_t ret_ref = 0;
28316 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28317 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28318 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28319 ret_ref = (uintptr_t)ret_var.inner;
28320 if (ret_var.is_owned) {
28321         ret_ref |= 1;
28322 }
28323         return ret_ref;
28324 }
28325 uint32_t  __attribute__((export_name("TS_UpdateAddHTLC_clone_ptr"))) TS_UpdateAddHTLC_clone_ptr(uint32_t arg) {
28326         LDKUpdateAddHTLC arg_conv;
28327         arg_conv.inner = (void*)(arg & (~1));
28328         arg_conv.is_owned = false;
28329         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28330         uint32_t ret_conv = UpdateAddHTLC_clone_ptr(&arg_conv);
28331         return ret_conv;
28332 }
28333
28334 uint32_t  __attribute__((export_name("TS_UpdateAddHTLC_clone"))) TS_UpdateAddHTLC_clone(uint32_t orig) {
28335         LDKUpdateAddHTLC orig_conv;
28336         orig_conv.inner = (void*)(orig & (~1));
28337         orig_conv.is_owned = false;
28338         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28339         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
28340         uint32_t ret_ref = 0;
28341         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28342         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28343         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28344         ret_ref = (uintptr_t)ret_var.inner;
28345         if (ret_var.is_owned) {
28346                 ret_ref |= 1;
28347         }
28348         return ret_ref;
28349 }
28350
28351 void  __attribute__((export_name("TS_UpdateFulfillHTLC_free"))) TS_UpdateFulfillHTLC_free(uint32_t this_obj) {
28352         LDKUpdateFulfillHTLC this_obj_conv;
28353         this_obj_conv.inner = (void*)(this_obj & (~1));
28354         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28356         UpdateFulfillHTLC_free(this_obj_conv);
28357 }
28358
28359 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_get_channel_id"))) TS_UpdateFulfillHTLC_get_channel_id(uint32_t this_ptr) {
28360         LDKUpdateFulfillHTLC 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, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv), 32);
28366         return ret_arr;
28367 }
28368
28369 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_channel_id"))) TS_UpdateFulfillHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28370         LDKUpdateFulfillHTLC 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         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
28378 }
28379
28380 int64_t  __attribute__((export_name("TS_UpdateFulfillHTLC_get_htlc_id"))) TS_UpdateFulfillHTLC_get_htlc_id(uint32_t this_ptr) {
28381         LDKUpdateFulfillHTLC 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         int64_t ret_conv = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
28386         return ret_conv;
28387 }
28388
28389 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_htlc_id"))) TS_UpdateFulfillHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
28390         LDKUpdateFulfillHTLC 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         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
28395 }
28396
28397 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_get_payment_preimage"))) TS_UpdateFulfillHTLC_get_payment_preimage(uint32_t this_ptr) {
28398         LDKUpdateFulfillHTLC 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(32, __LINE__);
28403         memcpy(ret_arr->elems, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv), 32);
28404         return ret_arr;
28405 }
28406
28407 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_payment_preimage"))) TS_UpdateFulfillHTLC_set_payment_preimage(uint32_t this_ptr, int8_tArray val) {
28408         LDKUpdateFulfillHTLC 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         LDKThirtyTwoBytes val_ref;
28413         CHECK(val->arr_len == 32);
28414         memcpy(val_ref.data, val->elems, 32); FREE(val);
28415         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
28416 }
28417
28418 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) {
28419         LDKThirtyTwoBytes channel_id_arg_ref;
28420         CHECK(channel_id_arg->arr_len == 32);
28421         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28422         LDKThirtyTwoBytes payment_preimage_arg_ref;
28423         CHECK(payment_preimage_arg->arr_len == 32);
28424         memcpy(payment_preimage_arg_ref.data, payment_preimage_arg->elems, 32); FREE(payment_preimage_arg);
28425         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
28426         uint32_t ret_ref = 0;
28427         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28428         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28429         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28430         ret_ref = (uintptr_t)ret_var.inner;
28431         if (ret_var.is_owned) {
28432                 ret_ref |= 1;
28433         }
28434         return ret_ref;
28435 }
28436
28437 static inline uintptr_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
28438         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
28439 uint32_t ret_ref = 0;
28440 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28441 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28442 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28443 ret_ref = (uintptr_t)ret_var.inner;
28444 if (ret_var.is_owned) {
28445         ret_ref |= 1;
28446 }
28447         return ret_ref;
28448 }
28449 uint32_t  __attribute__((export_name("TS_UpdateFulfillHTLC_clone_ptr"))) TS_UpdateFulfillHTLC_clone_ptr(uint32_t arg) {
28450         LDKUpdateFulfillHTLC arg_conv;
28451         arg_conv.inner = (void*)(arg & (~1));
28452         arg_conv.is_owned = false;
28453         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28454         uint32_t ret_conv = UpdateFulfillHTLC_clone_ptr(&arg_conv);
28455         return ret_conv;
28456 }
28457
28458 uint32_t  __attribute__((export_name("TS_UpdateFulfillHTLC_clone"))) TS_UpdateFulfillHTLC_clone(uint32_t orig) {
28459         LDKUpdateFulfillHTLC orig_conv;
28460         orig_conv.inner = (void*)(orig & (~1));
28461         orig_conv.is_owned = false;
28462         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28463         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
28464         uint32_t ret_ref = 0;
28465         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28466         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28467         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28468         ret_ref = (uintptr_t)ret_var.inner;
28469         if (ret_var.is_owned) {
28470                 ret_ref |= 1;
28471         }
28472         return ret_ref;
28473 }
28474
28475 void  __attribute__((export_name("TS_UpdateFailHTLC_free"))) TS_UpdateFailHTLC_free(uint32_t this_obj) {
28476         LDKUpdateFailHTLC this_obj_conv;
28477         this_obj_conv.inner = (void*)(this_obj & (~1));
28478         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28480         UpdateFailHTLC_free(this_obj_conv);
28481 }
28482
28483 int8_tArray  __attribute__((export_name("TS_UpdateFailHTLC_get_channel_id"))) TS_UpdateFailHTLC_get_channel_id(uint32_t this_ptr) {
28484         LDKUpdateFailHTLC this_ptr_conv;
28485         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28486         this_ptr_conv.is_owned = false;
28487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28488         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28489         memcpy(ret_arr->elems, *UpdateFailHTLC_get_channel_id(&this_ptr_conv), 32);
28490         return ret_arr;
28491 }
28492
28493 void  __attribute__((export_name("TS_UpdateFailHTLC_set_channel_id"))) TS_UpdateFailHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28494         LDKUpdateFailHTLC this_ptr_conv;
28495         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28496         this_ptr_conv.is_owned = false;
28497         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28498         LDKThirtyTwoBytes val_ref;
28499         CHECK(val->arr_len == 32);
28500         memcpy(val_ref.data, val->elems, 32); FREE(val);
28501         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
28502 }
28503
28504 int64_t  __attribute__((export_name("TS_UpdateFailHTLC_get_htlc_id"))) TS_UpdateFailHTLC_get_htlc_id(uint32_t this_ptr) {
28505         LDKUpdateFailHTLC this_ptr_conv;
28506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28507         this_ptr_conv.is_owned = false;
28508         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28509         int64_t ret_conv = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
28510         return ret_conv;
28511 }
28512
28513 void  __attribute__((export_name("TS_UpdateFailHTLC_set_htlc_id"))) TS_UpdateFailHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
28514         LDKUpdateFailHTLC this_ptr_conv;
28515         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28516         this_ptr_conv.is_owned = false;
28517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28518         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
28519 }
28520
28521 static inline uintptr_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
28522         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
28523 uint32_t ret_ref = 0;
28524 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28525 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28526 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28527 ret_ref = (uintptr_t)ret_var.inner;
28528 if (ret_var.is_owned) {
28529         ret_ref |= 1;
28530 }
28531         return ret_ref;
28532 }
28533 uint32_t  __attribute__((export_name("TS_UpdateFailHTLC_clone_ptr"))) TS_UpdateFailHTLC_clone_ptr(uint32_t arg) {
28534         LDKUpdateFailHTLC arg_conv;
28535         arg_conv.inner = (void*)(arg & (~1));
28536         arg_conv.is_owned = false;
28537         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28538         uint32_t ret_conv = UpdateFailHTLC_clone_ptr(&arg_conv);
28539         return ret_conv;
28540 }
28541
28542 uint32_t  __attribute__((export_name("TS_UpdateFailHTLC_clone"))) TS_UpdateFailHTLC_clone(uint32_t orig) {
28543         LDKUpdateFailHTLC orig_conv;
28544         orig_conv.inner = (void*)(orig & (~1));
28545         orig_conv.is_owned = false;
28546         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28547         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
28548         uint32_t ret_ref = 0;
28549         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28550         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28551         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28552         ret_ref = (uintptr_t)ret_var.inner;
28553         if (ret_var.is_owned) {
28554                 ret_ref |= 1;
28555         }
28556         return ret_ref;
28557 }
28558
28559 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_free"))) TS_UpdateFailMalformedHTLC_free(uint32_t this_obj) {
28560         LDKUpdateFailMalformedHTLC this_obj_conv;
28561         this_obj_conv.inner = (void*)(this_obj & (~1));
28562         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28564         UpdateFailMalformedHTLC_free(this_obj_conv);
28565 }
28566
28567 int8_tArray  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_channel_id"))) TS_UpdateFailMalformedHTLC_get_channel_id(uint32_t this_ptr) {
28568         LDKUpdateFailMalformedHTLC this_ptr_conv;
28569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28570         this_ptr_conv.is_owned = false;
28571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28572         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28573         memcpy(ret_arr->elems, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv), 32);
28574         return ret_arr;
28575 }
28576
28577 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_channel_id"))) TS_UpdateFailMalformedHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28578         LDKUpdateFailMalformedHTLC this_ptr_conv;
28579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28580         this_ptr_conv.is_owned = false;
28581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28582         LDKThirtyTwoBytes val_ref;
28583         CHECK(val->arr_len == 32);
28584         memcpy(val_ref.data, val->elems, 32); FREE(val);
28585         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
28586 }
28587
28588 int64_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_htlc_id"))) TS_UpdateFailMalformedHTLC_get_htlc_id(uint32_t this_ptr) {
28589         LDKUpdateFailMalformedHTLC this_ptr_conv;
28590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28591         this_ptr_conv.is_owned = false;
28592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28593         int64_t ret_conv = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
28594         return ret_conv;
28595 }
28596
28597 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_htlc_id"))) TS_UpdateFailMalformedHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
28598         LDKUpdateFailMalformedHTLC this_ptr_conv;
28599         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28600         this_ptr_conv.is_owned = false;
28601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28602         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
28603 }
28604
28605 int16_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_failure_code"))) TS_UpdateFailMalformedHTLC_get_failure_code(uint32_t this_ptr) {
28606         LDKUpdateFailMalformedHTLC this_ptr_conv;
28607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28608         this_ptr_conv.is_owned = false;
28609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28610         int16_t ret_conv = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
28611         return ret_conv;
28612 }
28613
28614 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_failure_code"))) TS_UpdateFailMalformedHTLC_set_failure_code(uint32_t this_ptr, int16_t val) {
28615         LDKUpdateFailMalformedHTLC 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         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
28620 }
28621
28622 static inline uintptr_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
28623         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
28624 uint32_t ret_ref = 0;
28625 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28626 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28627 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28628 ret_ref = (uintptr_t)ret_var.inner;
28629 if (ret_var.is_owned) {
28630         ret_ref |= 1;
28631 }
28632         return ret_ref;
28633 }
28634 uint32_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_clone_ptr"))) TS_UpdateFailMalformedHTLC_clone_ptr(uint32_t arg) {
28635         LDKUpdateFailMalformedHTLC arg_conv;
28636         arg_conv.inner = (void*)(arg & (~1));
28637         arg_conv.is_owned = false;
28638         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28639         uint32_t ret_conv = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
28640         return ret_conv;
28641 }
28642
28643 uint32_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_clone"))) TS_UpdateFailMalformedHTLC_clone(uint32_t orig) {
28644         LDKUpdateFailMalformedHTLC orig_conv;
28645         orig_conv.inner = (void*)(orig & (~1));
28646         orig_conv.is_owned = false;
28647         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28648         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
28649         uint32_t ret_ref = 0;
28650         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28651         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28652         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28653         ret_ref = (uintptr_t)ret_var.inner;
28654         if (ret_var.is_owned) {
28655                 ret_ref |= 1;
28656         }
28657         return ret_ref;
28658 }
28659
28660 void  __attribute__((export_name("TS_CommitmentSigned_free"))) TS_CommitmentSigned_free(uint32_t this_obj) {
28661         LDKCommitmentSigned this_obj_conv;
28662         this_obj_conv.inner = (void*)(this_obj & (~1));
28663         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28665         CommitmentSigned_free(this_obj_conv);
28666 }
28667
28668 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_get_channel_id"))) TS_CommitmentSigned_get_channel_id(uint32_t this_ptr) {
28669         LDKCommitmentSigned this_ptr_conv;
28670         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28671         this_ptr_conv.is_owned = false;
28672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28673         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28674         memcpy(ret_arr->elems, *CommitmentSigned_get_channel_id(&this_ptr_conv), 32);
28675         return ret_arr;
28676 }
28677
28678 void  __attribute__((export_name("TS_CommitmentSigned_set_channel_id"))) TS_CommitmentSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28679         LDKCommitmentSigned this_ptr_conv;
28680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28681         this_ptr_conv.is_owned = false;
28682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28683         LDKThirtyTwoBytes val_ref;
28684         CHECK(val->arr_len == 32);
28685         memcpy(val_ref.data, val->elems, 32); FREE(val);
28686         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
28687 }
28688
28689 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_get_signature"))) TS_CommitmentSigned_get_signature(uint32_t this_ptr) {
28690         LDKCommitmentSigned this_ptr_conv;
28691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28692         this_ptr_conv.is_owned = false;
28693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28694         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
28695         memcpy(ret_arr->elems, CommitmentSigned_get_signature(&this_ptr_conv).compact_form, 64);
28696         return ret_arr;
28697 }
28698
28699 void  __attribute__((export_name("TS_CommitmentSigned_set_signature"))) TS_CommitmentSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
28700         LDKCommitmentSigned this_ptr_conv;
28701         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28702         this_ptr_conv.is_owned = false;
28703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28704         LDKSignature val_ref;
28705         CHECK(val->arr_len == 64);
28706         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
28707         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
28708 }
28709
28710 void  __attribute__((export_name("TS_CommitmentSigned_set_htlc_signatures"))) TS_CommitmentSigned_set_htlc_signatures(uint32_t this_ptr, ptrArray val) {
28711         LDKCommitmentSigned this_ptr_conv;
28712         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28713         this_ptr_conv.is_owned = false;
28714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28715         LDKCVec_SignatureZ val_constr;
28716         val_constr.datalen = val->arr_len;
28717         if (val_constr.datalen > 0)
28718                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
28719         else
28720                 val_constr.data = NULL;
28721         int8_tArray* val_vals = (void*) val->elems /* XXX val leaks */;
28722         for (size_t m = 0; m < val_constr.datalen; m++) {
28723                 int8_tArray val_conv_12 = val_vals[m];
28724                 LDKSignature val_conv_12_ref;
28725                 CHECK(val_conv_12->arr_len == 64);
28726                 memcpy(val_conv_12_ref.compact_form, val_conv_12->elems, 64); FREE(val_conv_12);
28727                 val_constr.data[m] = val_conv_12_ref;
28728         }
28729         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
28730 }
28731
28732 uint32_t  __attribute__((export_name("TS_CommitmentSigned_new"))) TS_CommitmentSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg, ptrArray htlc_signatures_arg) {
28733         LDKThirtyTwoBytes channel_id_arg_ref;
28734         CHECK(channel_id_arg->arr_len == 32);
28735         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28736         LDKSignature signature_arg_ref;
28737         CHECK(signature_arg->arr_len == 64);
28738         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
28739         LDKCVec_SignatureZ htlc_signatures_arg_constr;
28740         htlc_signatures_arg_constr.datalen = htlc_signatures_arg->arr_len;
28741         if (htlc_signatures_arg_constr.datalen > 0)
28742                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
28743         else
28744                 htlc_signatures_arg_constr.data = NULL;
28745         int8_tArray* htlc_signatures_arg_vals = (void*) htlc_signatures_arg->elems /* XXX htlc_signatures_arg leaks */;
28746         for (size_t m = 0; m < htlc_signatures_arg_constr.datalen; m++) {
28747                 int8_tArray htlc_signatures_arg_conv_12 = htlc_signatures_arg_vals[m];
28748                 LDKSignature htlc_signatures_arg_conv_12_ref;
28749                 CHECK(htlc_signatures_arg_conv_12->arr_len == 64);
28750                 memcpy(htlc_signatures_arg_conv_12_ref.compact_form, htlc_signatures_arg_conv_12->elems, 64); FREE(htlc_signatures_arg_conv_12);
28751                 htlc_signatures_arg_constr.data[m] = htlc_signatures_arg_conv_12_ref;
28752         }
28753         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
28754         uint32_t ret_ref = 0;
28755         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28756         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28757         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28758         ret_ref = (uintptr_t)ret_var.inner;
28759         if (ret_var.is_owned) {
28760                 ret_ref |= 1;
28761         }
28762         return ret_ref;
28763 }
28764
28765 static inline uintptr_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
28766         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
28767 uint32_t ret_ref = 0;
28768 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28769 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28770 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28771 ret_ref = (uintptr_t)ret_var.inner;
28772 if (ret_var.is_owned) {
28773         ret_ref |= 1;
28774 }
28775         return ret_ref;
28776 }
28777 uint32_t  __attribute__((export_name("TS_CommitmentSigned_clone_ptr"))) TS_CommitmentSigned_clone_ptr(uint32_t arg) {
28778         LDKCommitmentSigned arg_conv;
28779         arg_conv.inner = (void*)(arg & (~1));
28780         arg_conv.is_owned = false;
28781         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28782         uint32_t ret_conv = CommitmentSigned_clone_ptr(&arg_conv);
28783         return ret_conv;
28784 }
28785
28786 uint32_t  __attribute__((export_name("TS_CommitmentSigned_clone"))) TS_CommitmentSigned_clone(uint32_t orig) {
28787         LDKCommitmentSigned orig_conv;
28788         orig_conv.inner = (void*)(orig & (~1));
28789         orig_conv.is_owned = false;
28790         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28791         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
28792         uint32_t ret_ref = 0;
28793         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28794         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28795         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28796         ret_ref = (uintptr_t)ret_var.inner;
28797         if (ret_var.is_owned) {
28798                 ret_ref |= 1;
28799         }
28800         return ret_ref;
28801 }
28802
28803 void  __attribute__((export_name("TS_RevokeAndACK_free"))) TS_RevokeAndACK_free(uint32_t this_obj) {
28804         LDKRevokeAndACK this_obj_conv;
28805         this_obj_conv.inner = (void*)(this_obj & (~1));
28806         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28808         RevokeAndACK_free(this_obj_conv);
28809 }
28810
28811 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_channel_id"))) TS_RevokeAndACK_get_channel_id(uint32_t this_ptr) {
28812         LDKRevokeAndACK this_ptr_conv;
28813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28814         this_ptr_conv.is_owned = false;
28815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28816         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28817         memcpy(ret_arr->elems, *RevokeAndACK_get_channel_id(&this_ptr_conv), 32);
28818         return ret_arr;
28819 }
28820
28821 void  __attribute__((export_name("TS_RevokeAndACK_set_channel_id"))) TS_RevokeAndACK_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28822         LDKRevokeAndACK this_ptr_conv;
28823         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28824         this_ptr_conv.is_owned = false;
28825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28826         LDKThirtyTwoBytes val_ref;
28827         CHECK(val->arr_len == 32);
28828         memcpy(val_ref.data, val->elems, 32); FREE(val);
28829         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
28830 }
28831
28832 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_per_commitment_secret"))) TS_RevokeAndACK_get_per_commitment_secret(uint32_t this_ptr) {
28833         LDKRevokeAndACK this_ptr_conv;
28834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28835         this_ptr_conv.is_owned = false;
28836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28837         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28838         memcpy(ret_arr->elems, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv), 32);
28839         return ret_arr;
28840 }
28841
28842 void  __attribute__((export_name("TS_RevokeAndACK_set_per_commitment_secret"))) TS_RevokeAndACK_set_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
28843         LDKRevokeAndACK this_ptr_conv;
28844         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28845         this_ptr_conv.is_owned = false;
28846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28847         LDKThirtyTwoBytes val_ref;
28848         CHECK(val->arr_len == 32);
28849         memcpy(val_ref.data, val->elems, 32); FREE(val);
28850         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
28851 }
28852
28853 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_next_per_commitment_point"))) TS_RevokeAndACK_get_next_per_commitment_point(uint32_t this_ptr) {
28854         LDKRevokeAndACK this_ptr_conv;
28855         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28856         this_ptr_conv.is_owned = false;
28857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28858         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28859         memcpy(ret_arr->elems, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
28860         return ret_arr;
28861 }
28862
28863 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) {
28864         LDKRevokeAndACK 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         LDKPublicKey val_ref;
28869         CHECK(val->arr_len == 33);
28870         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28871         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
28872 }
28873
28874 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) {
28875         LDKThirtyTwoBytes channel_id_arg_ref;
28876         CHECK(channel_id_arg->arr_len == 32);
28877         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28878         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
28879         CHECK(per_commitment_secret_arg->arr_len == 32);
28880         memcpy(per_commitment_secret_arg_ref.data, per_commitment_secret_arg->elems, 32); FREE(per_commitment_secret_arg);
28881         LDKPublicKey next_per_commitment_point_arg_ref;
28882         CHECK(next_per_commitment_point_arg->arr_len == 33);
28883         memcpy(next_per_commitment_point_arg_ref.compressed_form, next_per_commitment_point_arg->elems, 33); FREE(next_per_commitment_point_arg);
28884         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
28885         uint32_t ret_ref = 0;
28886         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28887         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28888         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28889         ret_ref = (uintptr_t)ret_var.inner;
28890         if (ret_var.is_owned) {
28891                 ret_ref |= 1;
28892         }
28893         return ret_ref;
28894 }
28895
28896 static inline uintptr_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
28897         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
28898 uint32_t ret_ref = 0;
28899 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28900 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28901 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28902 ret_ref = (uintptr_t)ret_var.inner;
28903 if (ret_var.is_owned) {
28904         ret_ref |= 1;
28905 }
28906         return ret_ref;
28907 }
28908 uint32_t  __attribute__((export_name("TS_RevokeAndACK_clone_ptr"))) TS_RevokeAndACK_clone_ptr(uint32_t arg) {
28909         LDKRevokeAndACK arg_conv;
28910         arg_conv.inner = (void*)(arg & (~1));
28911         arg_conv.is_owned = false;
28912         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28913         uint32_t ret_conv = RevokeAndACK_clone_ptr(&arg_conv);
28914         return ret_conv;
28915 }
28916
28917 uint32_t  __attribute__((export_name("TS_RevokeAndACK_clone"))) TS_RevokeAndACK_clone(uint32_t orig) {
28918         LDKRevokeAndACK orig_conv;
28919         orig_conv.inner = (void*)(orig & (~1));
28920         orig_conv.is_owned = false;
28921         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28922         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
28923         uint32_t ret_ref = 0;
28924         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28925         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28926         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28927         ret_ref = (uintptr_t)ret_var.inner;
28928         if (ret_var.is_owned) {
28929                 ret_ref |= 1;
28930         }
28931         return ret_ref;
28932 }
28933
28934 void  __attribute__((export_name("TS_UpdateFee_free"))) TS_UpdateFee_free(uint32_t this_obj) {
28935         LDKUpdateFee this_obj_conv;
28936         this_obj_conv.inner = (void*)(this_obj & (~1));
28937         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28938         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28939         UpdateFee_free(this_obj_conv);
28940 }
28941
28942 int8_tArray  __attribute__((export_name("TS_UpdateFee_get_channel_id"))) TS_UpdateFee_get_channel_id(uint32_t this_ptr) {
28943         LDKUpdateFee this_ptr_conv;
28944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28945         this_ptr_conv.is_owned = false;
28946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28947         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28948         memcpy(ret_arr->elems, *UpdateFee_get_channel_id(&this_ptr_conv), 32);
28949         return ret_arr;
28950 }
28951
28952 void  __attribute__((export_name("TS_UpdateFee_set_channel_id"))) TS_UpdateFee_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28953         LDKUpdateFee this_ptr_conv;
28954         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28955         this_ptr_conv.is_owned = false;
28956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28957         LDKThirtyTwoBytes val_ref;
28958         CHECK(val->arr_len == 32);
28959         memcpy(val_ref.data, val->elems, 32); FREE(val);
28960         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
28961 }
28962
28963 int32_t  __attribute__((export_name("TS_UpdateFee_get_feerate_per_kw"))) TS_UpdateFee_get_feerate_per_kw(uint32_t this_ptr) {
28964         LDKUpdateFee this_ptr_conv;
28965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28966         this_ptr_conv.is_owned = false;
28967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28968         int32_t ret_conv = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
28969         return ret_conv;
28970 }
28971
28972 void  __attribute__((export_name("TS_UpdateFee_set_feerate_per_kw"))) TS_UpdateFee_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
28973         LDKUpdateFee this_ptr_conv;
28974         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28975         this_ptr_conv.is_owned = false;
28976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28977         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
28978 }
28979
28980 uint32_t  __attribute__((export_name("TS_UpdateFee_new"))) TS_UpdateFee_new(int8_tArray channel_id_arg, int32_t feerate_per_kw_arg) {
28981         LDKThirtyTwoBytes channel_id_arg_ref;
28982         CHECK(channel_id_arg->arr_len == 32);
28983         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28984         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
28985         uint32_t ret_ref = 0;
28986         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28987         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28988         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28989         ret_ref = (uintptr_t)ret_var.inner;
28990         if (ret_var.is_owned) {
28991                 ret_ref |= 1;
28992         }
28993         return ret_ref;
28994 }
28995
28996 static inline uintptr_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
28997         LDKUpdateFee ret_var = UpdateFee_clone(arg);
28998 uint32_t ret_ref = 0;
28999 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29000 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29001 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29002 ret_ref = (uintptr_t)ret_var.inner;
29003 if (ret_var.is_owned) {
29004         ret_ref |= 1;
29005 }
29006         return ret_ref;
29007 }
29008 uint32_t  __attribute__((export_name("TS_UpdateFee_clone_ptr"))) TS_UpdateFee_clone_ptr(uint32_t arg) {
29009         LDKUpdateFee arg_conv;
29010         arg_conv.inner = (void*)(arg & (~1));
29011         arg_conv.is_owned = false;
29012         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29013         uint32_t ret_conv = UpdateFee_clone_ptr(&arg_conv);
29014         return ret_conv;
29015 }
29016
29017 uint32_t  __attribute__((export_name("TS_UpdateFee_clone"))) TS_UpdateFee_clone(uint32_t orig) {
29018         LDKUpdateFee orig_conv;
29019         orig_conv.inner = (void*)(orig & (~1));
29020         orig_conv.is_owned = false;
29021         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29022         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
29023         uint32_t ret_ref = 0;
29024         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29025         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29026         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29027         ret_ref = (uintptr_t)ret_var.inner;
29028         if (ret_var.is_owned) {
29029                 ret_ref |= 1;
29030         }
29031         return ret_ref;
29032 }
29033
29034 void  __attribute__((export_name("TS_DataLossProtect_free"))) TS_DataLossProtect_free(uint32_t this_obj) {
29035         LDKDataLossProtect this_obj_conv;
29036         this_obj_conv.inner = (void*)(this_obj & (~1));
29037         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29039         DataLossProtect_free(this_obj_conv);
29040 }
29041
29042 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) {
29043         LDKDataLossProtect this_ptr_conv;
29044         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29045         this_ptr_conv.is_owned = false;
29046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29047         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29048         memcpy(ret_arr->elems, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv), 32);
29049         return ret_arr;
29050 }
29051
29052 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) {
29053         LDKDataLossProtect this_ptr_conv;
29054         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29055         this_ptr_conv.is_owned = false;
29056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29057         LDKThirtyTwoBytes val_ref;
29058         CHECK(val->arr_len == 32);
29059         memcpy(val_ref.data, val->elems, 32); FREE(val);
29060         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
29061 }
29062
29063 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) {
29064         LDKDataLossProtect this_ptr_conv;
29065         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29066         this_ptr_conv.is_owned = false;
29067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29068         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29069         memcpy(ret_arr->elems, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form, 33);
29070         return ret_arr;
29071 }
29072
29073 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) {
29074         LDKDataLossProtect this_ptr_conv;
29075         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29076         this_ptr_conv.is_owned = false;
29077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29078         LDKPublicKey val_ref;
29079         CHECK(val->arr_len == 33);
29080         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29081         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
29082 }
29083
29084 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) {
29085         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
29086         CHECK(your_last_per_commitment_secret_arg->arr_len == 32);
29087         memcpy(your_last_per_commitment_secret_arg_ref.data, your_last_per_commitment_secret_arg->elems, 32); FREE(your_last_per_commitment_secret_arg);
29088         LDKPublicKey my_current_per_commitment_point_arg_ref;
29089         CHECK(my_current_per_commitment_point_arg->arr_len == 33);
29090         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);
29091         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
29092         uint32_t ret_ref = 0;
29093         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29094         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29095         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29096         ret_ref = (uintptr_t)ret_var.inner;
29097         if (ret_var.is_owned) {
29098                 ret_ref |= 1;
29099         }
29100         return ret_ref;
29101 }
29102
29103 static inline uintptr_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
29104         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
29105 uint32_t ret_ref = 0;
29106 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29107 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29108 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29109 ret_ref = (uintptr_t)ret_var.inner;
29110 if (ret_var.is_owned) {
29111         ret_ref |= 1;
29112 }
29113         return ret_ref;
29114 }
29115 uint32_t  __attribute__((export_name("TS_DataLossProtect_clone_ptr"))) TS_DataLossProtect_clone_ptr(uint32_t arg) {
29116         LDKDataLossProtect arg_conv;
29117         arg_conv.inner = (void*)(arg & (~1));
29118         arg_conv.is_owned = false;
29119         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29120         uint32_t ret_conv = DataLossProtect_clone_ptr(&arg_conv);
29121         return ret_conv;
29122 }
29123
29124 uint32_t  __attribute__((export_name("TS_DataLossProtect_clone"))) TS_DataLossProtect_clone(uint32_t orig) {
29125         LDKDataLossProtect orig_conv;
29126         orig_conv.inner = (void*)(orig & (~1));
29127         orig_conv.is_owned = false;
29128         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29129         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
29130         uint32_t ret_ref = 0;
29131         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29132         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29133         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29134         ret_ref = (uintptr_t)ret_var.inner;
29135         if (ret_var.is_owned) {
29136                 ret_ref |= 1;
29137         }
29138         return ret_ref;
29139 }
29140
29141 void  __attribute__((export_name("TS_ChannelReestablish_free"))) TS_ChannelReestablish_free(uint32_t this_obj) {
29142         LDKChannelReestablish this_obj_conv;
29143         this_obj_conv.inner = (void*)(this_obj & (~1));
29144         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29146         ChannelReestablish_free(this_obj_conv);
29147 }
29148
29149 int8_tArray  __attribute__((export_name("TS_ChannelReestablish_get_channel_id"))) TS_ChannelReestablish_get_channel_id(uint32_t this_ptr) {
29150         LDKChannelReestablish this_ptr_conv;
29151         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29152         this_ptr_conv.is_owned = false;
29153         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29154         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29155         memcpy(ret_arr->elems, *ChannelReestablish_get_channel_id(&this_ptr_conv), 32);
29156         return ret_arr;
29157 }
29158
29159 void  __attribute__((export_name("TS_ChannelReestablish_set_channel_id"))) TS_ChannelReestablish_set_channel_id(uint32_t this_ptr, int8_tArray val) {
29160         LDKChannelReestablish this_ptr_conv;
29161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29162         this_ptr_conv.is_owned = false;
29163         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29164         LDKThirtyTwoBytes val_ref;
29165         CHECK(val->arr_len == 32);
29166         memcpy(val_ref.data, val->elems, 32); FREE(val);
29167         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
29168 }
29169
29170 int64_t  __attribute__((export_name("TS_ChannelReestablish_get_next_local_commitment_number"))) TS_ChannelReestablish_get_next_local_commitment_number(uint32_t this_ptr) {
29171         LDKChannelReestablish this_ptr_conv;
29172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29173         this_ptr_conv.is_owned = false;
29174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29175         int64_t ret_conv = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
29176         return ret_conv;
29177 }
29178
29179 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) {
29180         LDKChannelReestablish this_ptr_conv;
29181         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29182         this_ptr_conv.is_owned = false;
29183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29184         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
29185 }
29186
29187 int64_t  __attribute__((export_name("TS_ChannelReestablish_get_next_remote_commitment_number"))) TS_ChannelReestablish_get_next_remote_commitment_number(uint32_t this_ptr) {
29188         LDKChannelReestablish this_ptr_conv;
29189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29190         this_ptr_conv.is_owned = false;
29191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29192         int64_t ret_conv = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
29193         return ret_conv;
29194 }
29195
29196 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) {
29197         LDKChannelReestablish this_ptr_conv;
29198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29199         this_ptr_conv.is_owned = false;
29200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29201         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
29202 }
29203
29204 static inline uintptr_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
29205         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
29206 uint32_t ret_ref = 0;
29207 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29208 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29209 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29210 ret_ref = (uintptr_t)ret_var.inner;
29211 if (ret_var.is_owned) {
29212         ret_ref |= 1;
29213 }
29214         return ret_ref;
29215 }
29216 uint32_t  __attribute__((export_name("TS_ChannelReestablish_clone_ptr"))) TS_ChannelReestablish_clone_ptr(uint32_t arg) {
29217         LDKChannelReestablish arg_conv;
29218         arg_conv.inner = (void*)(arg & (~1));
29219         arg_conv.is_owned = false;
29220         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29221         uint32_t ret_conv = ChannelReestablish_clone_ptr(&arg_conv);
29222         return ret_conv;
29223 }
29224
29225 uint32_t  __attribute__((export_name("TS_ChannelReestablish_clone"))) TS_ChannelReestablish_clone(uint32_t orig) {
29226         LDKChannelReestablish orig_conv;
29227         orig_conv.inner = (void*)(orig & (~1));
29228         orig_conv.is_owned = false;
29229         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29230         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
29231         uint32_t ret_ref = 0;
29232         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29233         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29234         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29235         ret_ref = (uintptr_t)ret_var.inner;
29236         if (ret_var.is_owned) {
29237                 ret_ref |= 1;
29238         }
29239         return ret_ref;
29240 }
29241
29242 void  __attribute__((export_name("TS_AnnouncementSignatures_free"))) TS_AnnouncementSignatures_free(uint32_t this_obj) {
29243         LDKAnnouncementSignatures this_obj_conv;
29244         this_obj_conv.inner = (void*)(this_obj & (~1));
29245         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29247         AnnouncementSignatures_free(this_obj_conv);
29248 }
29249
29250 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_channel_id"))) TS_AnnouncementSignatures_get_channel_id(uint32_t this_ptr) {
29251         LDKAnnouncementSignatures this_ptr_conv;
29252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29253         this_ptr_conv.is_owned = false;
29254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29255         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29256         memcpy(ret_arr->elems, *AnnouncementSignatures_get_channel_id(&this_ptr_conv), 32);
29257         return ret_arr;
29258 }
29259
29260 void  __attribute__((export_name("TS_AnnouncementSignatures_set_channel_id"))) TS_AnnouncementSignatures_set_channel_id(uint32_t this_ptr, int8_tArray val) {
29261         LDKAnnouncementSignatures 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         LDKThirtyTwoBytes val_ref;
29266         CHECK(val->arr_len == 32);
29267         memcpy(val_ref.data, val->elems, 32); FREE(val);
29268         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
29269 }
29270
29271 int64_t  __attribute__((export_name("TS_AnnouncementSignatures_get_short_channel_id"))) TS_AnnouncementSignatures_get_short_channel_id(uint32_t this_ptr) {
29272         LDKAnnouncementSignatures this_ptr_conv;
29273         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29274         this_ptr_conv.is_owned = false;
29275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29276         int64_t ret_conv = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
29277         return ret_conv;
29278 }
29279
29280 void  __attribute__((export_name("TS_AnnouncementSignatures_set_short_channel_id"))) TS_AnnouncementSignatures_set_short_channel_id(uint32_t this_ptr, int64_t val) {
29281         LDKAnnouncementSignatures this_ptr_conv;
29282         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29283         this_ptr_conv.is_owned = false;
29284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29285         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
29286 }
29287
29288 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_node_signature"))) TS_AnnouncementSignatures_get_node_signature(uint32_t this_ptr) {
29289         LDKAnnouncementSignatures this_ptr_conv;
29290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29291         this_ptr_conv.is_owned = false;
29292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29293         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29294         memcpy(ret_arr->elems, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form, 64);
29295         return ret_arr;
29296 }
29297
29298 void  __attribute__((export_name("TS_AnnouncementSignatures_set_node_signature"))) TS_AnnouncementSignatures_set_node_signature(uint32_t this_ptr, int8_tArray val) {
29299         LDKAnnouncementSignatures this_ptr_conv;
29300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29301         this_ptr_conv.is_owned = false;
29302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29303         LDKSignature val_ref;
29304         CHECK(val->arr_len == 64);
29305         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29306         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
29307 }
29308
29309 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_bitcoin_signature"))) TS_AnnouncementSignatures_get_bitcoin_signature(uint32_t this_ptr) {
29310         LDKAnnouncementSignatures this_ptr_conv;
29311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29312         this_ptr_conv.is_owned = false;
29313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29314         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29315         memcpy(ret_arr->elems, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form, 64);
29316         return ret_arr;
29317 }
29318
29319 void  __attribute__((export_name("TS_AnnouncementSignatures_set_bitcoin_signature"))) TS_AnnouncementSignatures_set_bitcoin_signature(uint32_t this_ptr, int8_tArray val) {
29320         LDKAnnouncementSignatures this_ptr_conv;
29321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29322         this_ptr_conv.is_owned = false;
29323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29324         LDKSignature val_ref;
29325         CHECK(val->arr_len == 64);
29326         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29327         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
29328 }
29329
29330 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) {
29331         LDKThirtyTwoBytes channel_id_arg_ref;
29332         CHECK(channel_id_arg->arr_len == 32);
29333         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
29334         LDKSignature node_signature_arg_ref;
29335         CHECK(node_signature_arg->arr_len == 64);
29336         memcpy(node_signature_arg_ref.compact_form, node_signature_arg->elems, 64); FREE(node_signature_arg);
29337         LDKSignature bitcoin_signature_arg_ref;
29338         CHECK(bitcoin_signature_arg->arr_len == 64);
29339         memcpy(bitcoin_signature_arg_ref.compact_form, bitcoin_signature_arg->elems, 64); FREE(bitcoin_signature_arg);
29340         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
29341         uint32_t ret_ref = 0;
29342         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29343         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29344         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29345         ret_ref = (uintptr_t)ret_var.inner;
29346         if (ret_var.is_owned) {
29347                 ret_ref |= 1;
29348         }
29349         return ret_ref;
29350 }
29351
29352 static inline uintptr_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
29353         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
29354 uint32_t ret_ref = 0;
29355 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29356 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29357 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29358 ret_ref = (uintptr_t)ret_var.inner;
29359 if (ret_var.is_owned) {
29360         ret_ref |= 1;
29361 }
29362         return ret_ref;
29363 }
29364 uint32_t  __attribute__((export_name("TS_AnnouncementSignatures_clone_ptr"))) TS_AnnouncementSignatures_clone_ptr(uint32_t arg) {
29365         LDKAnnouncementSignatures arg_conv;
29366         arg_conv.inner = (void*)(arg & (~1));
29367         arg_conv.is_owned = false;
29368         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29369         uint32_t ret_conv = AnnouncementSignatures_clone_ptr(&arg_conv);
29370         return ret_conv;
29371 }
29372
29373 uint32_t  __attribute__((export_name("TS_AnnouncementSignatures_clone"))) TS_AnnouncementSignatures_clone(uint32_t orig) {
29374         LDKAnnouncementSignatures orig_conv;
29375         orig_conv.inner = (void*)(orig & (~1));
29376         orig_conv.is_owned = false;
29377         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29378         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
29379         uint32_t ret_ref = 0;
29380         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29381         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29382         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29383         ret_ref = (uintptr_t)ret_var.inner;
29384         if (ret_var.is_owned) {
29385                 ret_ref |= 1;
29386         }
29387         return ret_ref;
29388 }
29389
29390 void  __attribute__((export_name("TS_NetAddress_free"))) TS_NetAddress_free(uint32_t this_ptr) {
29391         if ((this_ptr & 1) != 0) return;
29392         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
29393         CHECK_ACCESS(this_ptr_ptr);
29394         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
29395         FREE((void*)this_ptr);
29396         NetAddress_free(this_ptr_conv);
29397 }
29398
29399 static inline uintptr_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
29400         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
29401         *ret_copy = NetAddress_clone(arg);
29402 uint32_t ret_ref = (uintptr_t)ret_copy;
29403         return ret_ref;
29404 }
29405 uint32_t  __attribute__((export_name("TS_NetAddress_clone_ptr"))) TS_NetAddress_clone_ptr(uint32_t arg) {
29406         LDKNetAddress* arg_conv = (LDKNetAddress*)arg;
29407         uint32_t ret_conv = NetAddress_clone_ptr(arg_conv);
29408         return ret_conv;
29409 }
29410
29411 uint32_t  __attribute__((export_name("TS_NetAddress_clone"))) TS_NetAddress_clone(uint32_t orig) {
29412         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
29413         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
29414         *ret_copy = NetAddress_clone(orig_conv);
29415         uint32_t ret_ref = (uintptr_t)ret_copy;
29416         return ret_ref;
29417 }
29418
29419 uint32_t  __attribute__((export_name("TS_NetAddress_ipv4"))) TS_NetAddress_ipv4(int8_tArray addr, int16_t port) {
29420         LDKFourBytes addr_ref;
29421         CHECK(addr->arr_len == 4);
29422         memcpy(addr_ref.data, addr->elems, 4); FREE(addr);
29423         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
29424         *ret_copy = NetAddress_ipv4(addr_ref, port);
29425         uint32_t ret_ref = (uintptr_t)ret_copy;
29426         return ret_ref;
29427 }
29428
29429 uint32_t  __attribute__((export_name("TS_NetAddress_ipv6"))) TS_NetAddress_ipv6(int8_tArray addr, int16_t port) {
29430         LDKSixteenBytes addr_ref;
29431         CHECK(addr->arr_len == 16);
29432         memcpy(addr_ref.data, addr->elems, 16); FREE(addr);
29433         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
29434         *ret_copy = NetAddress_ipv6(addr_ref, port);
29435         uint32_t ret_ref = (uintptr_t)ret_copy;
29436         return ret_ref;
29437 }
29438
29439 uint32_t  __attribute__((export_name("TS_NetAddress_onion_v2"))) TS_NetAddress_onion_v2(int8_tArray a) {
29440         LDKTwelveBytes a_ref;
29441         CHECK(a->arr_len == 12);
29442         memcpy(a_ref.data, a->elems, 12); FREE(a);
29443         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
29444         *ret_copy = NetAddress_onion_v2(a_ref);
29445         uint32_t ret_ref = (uintptr_t)ret_copy;
29446         return ret_ref;
29447 }
29448
29449 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) {
29450         LDKThirtyTwoBytes ed25519_pubkey_ref;
29451         CHECK(ed25519_pubkey->arr_len == 32);
29452         memcpy(ed25519_pubkey_ref.data, ed25519_pubkey->elems, 32); FREE(ed25519_pubkey);
29453         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
29454         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
29455         uint32_t ret_ref = (uintptr_t)ret_copy;
29456         return ret_ref;
29457 }
29458
29459 int8_tArray  __attribute__((export_name("TS_NetAddress_write"))) TS_NetAddress_write(uint32_t obj) {
29460         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
29461         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
29462         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
29463         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
29464         CVec_u8Z_free(ret_var);
29465         return ret_arr;
29466 }
29467
29468 uint32_t  __attribute__((export_name("TS_NetAddress_read"))) TS_NetAddress_read(int8_tArray ser) {
29469         LDKu8slice ser_ref;
29470         ser_ref.datalen = ser->arr_len;
29471         ser_ref.data = ser->elems /* XXX ser leaks */;
29472         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
29473         *ret_conv = NetAddress_read(ser_ref);
29474         return (uint32_t)ret_conv;
29475 }
29476
29477 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_free"))) TS_UnsignedNodeAnnouncement_free(uint32_t this_obj) {
29478         LDKUnsignedNodeAnnouncement this_obj_conv;
29479         this_obj_conv.inner = (void*)(this_obj & (~1));
29480         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29482         UnsignedNodeAnnouncement_free(this_obj_conv);
29483 }
29484
29485 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_features"))) TS_UnsignedNodeAnnouncement_get_features(uint32_t this_ptr) {
29486         LDKUnsignedNodeAnnouncement 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         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
29491         uint32_t ret_ref = 0;
29492         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29493         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29494         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29495         ret_ref = (uintptr_t)ret_var.inner;
29496         if (ret_var.is_owned) {
29497                 ret_ref |= 1;
29498         }
29499         return ret_ref;
29500 }
29501
29502 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_features"))) TS_UnsignedNodeAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
29503         LDKUnsignedNodeAnnouncement this_ptr_conv;
29504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29505         this_ptr_conv.is_owned = false;
29506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29507         LDKNodeFeatures val_conv;
29508         val_conv.inner = (void*)(val & (~1));
29509         val_conv.is_owned = (val & 1) || (val == 0);
29510         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29511         val_conv = NodeFeatures_clone(&val_conv);
29512         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
29513 }
29514
29515 int32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_timestamp"))) TS_UnsignedNodeAnnouncement_get_timestamp(uint32_t this_ptr) {
29516         LDKUnsignedNodeAnnouncement this_ptr_conv;
29517         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29518         this_ptr_conv.is_owned = false;
29519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29520         int32_t ret_conv = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
29521         return ret_conv;
29522 }
29523
29524 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_timestamp"))) TS_UnsignedNodeAnnouncement_set_timestamp(uint32_t this_ptr, int32_t val) {
29525         LDKUnsignedNodeAnnouncement this_ptr_conv;
29526         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29527         this_ptr_conv.is_owned = false;
29528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29529         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
29530 }
29531
29532 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_node_id"))) TS_UnsignedNodeAnnouncement_get_node_id(uint32_t this_ptr) {
29533         LDKUnsignedNodeAnnouncement this_ptr_conv;
29534         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29535         this_ptr_conv.is_owned = false;
29536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29537         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29538         memcpy(ret_arr->elems, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form, 33);
29539         return ret_arr;
29540 }
29541
29542 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_node_id"))) TS_UnsignedNodeAnnouncement_set_node_id(uint32_t this_ptr, int8_tArray val) {
29543         LDKUnsignedNodeAnnouncement this_ptr_conv;
29544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29545         this_ptr_conv.is_owned = false;
29546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29547         LDKPublicKey val_ref;
29548         CHECK(val->arr_len == 33);
29549         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29550         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
29551 }
29552
29553 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_rgb"))) TS_UnsignedNodeAnnouncement_get_rgb(uint32_t this_ptr) {
29554         LDKUnsignedNodeAnnouncement this_ptr_conv;
29555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29556         this_ptr_conv.is_owned = false;
29557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29558         int8_tArray ret_arr = init_int8_tArray(3, __LINE__);
29559         memcpy(ret_arr->elems, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv), 3);
29560         return ret_arr;
29561 }
29562
29563 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_rgb"))) TS_UnsignedNodeAnnouncement_set_rgb(uint32_t this_ptr, int8_tArray val) {
29564         LDKUnsignedNodeAnnouncement this_ptr_conv;
29565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29566         this_ptr_conv.is_owned = false;
29567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29568         LDKThreeBytes val_ref;
29569         CHECK(val->arr_len == 3);
29570         memcpy(val_ref.data, val->elems, 3); FREE(val);
29571         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
29572 }
29573
29574 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_alias"))) TS_UnsignedNodeAnnouncement_get_alias(uint32_t this_ptr) {
29575         LDKUnsignedNodeAnnouncement this_ptr_conv;
29576         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29577         this_ptr_conv.is_owned = false;
29578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29579         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29580         memcpy(ret_arr->elems, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv), 32);
29581         return ret_arr;
29582 }
29583
29584 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_alias"))) TS_UnsignedNodeAnnouncement_set_alias(uint32_t this_ptr, int8_tArray val) {
29585         LDKUnsignedNodeAnnouncement this_ptr_conv;
29586         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29587         this_ptr_conv.is_owned = false;
29588         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29589         LDKThirtyTwoBytes val_ref;
29590         CHECK(val->arr_len == 32);
29591         memcpy(val_ref.data, val->elems, 32); FREE(val);
29592         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
29593 }
29594
29595 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_addresses"))) TS_UnsignedNodeAnnouncement_set_addresses(uint32_t this_ptr, uint32_tArray val) {
29596         LDKUnsignedNodeAnnouncement this_ptr_conv;
29597         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29598         this_ptr_conv.is_owned = false;
29599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29600         LDKCVec_NetAddressZ val_constr;
29601         val_constr.datalen = val->arr_len;
29602         if (val_constr.datalen > 0)
29603                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
29604         else
29605                 val_constr.data = NULL;
29606         uint32_t* val_vals = val->elems /* XXX val leaks */;
29607         for (size_t m = 0; m < val_constr.datalen; m++) {
29608                 uint32_t val_conv_12 = val_vals[m];
29609                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
29610                 CHECK_ACCESS(val_conv_12_ptr);
29611                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
29612                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
29613                 val_constr.data[m] = val_conv_12_conv;
29614         }
29615         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
29616 }
29617
29618 static inline uintptr_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
29619         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
29620 uint32_t ret_ref = 0;
29621 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29622 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29623 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29624 ret_ref = (uintptr_t)ret_var.inner;
29625 if (ret_var.is_owned) {
29626         ret_ref |= 1;
29627 }
29628         return ret_ref;
29629 }
29630 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_clone_ptr"))) TS_UnsignedNodeAnnouncement_clone_ptr(uint32_t arg) {
29631         LDKUnsignedNodeAnnouncement arg_conv;
29632         arg_conv.inner = (void*)(arg & (~1));
29633         arg_conv.is_owned = false;
29634         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29635         uint32_t ret_conv = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
29636         return ret_conv;
29637 }
29638
29639 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_clone"))) TS_UnsignedNodeAnnouncement_clone(uint32_t orig) {
29640         LDKUnsignedNodeAnnouncement orig_conv;
29641         orig_conv.inner = (void*)(orig & (~1));
29642         orig_conv.is_owned = false;
29643         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29644         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
29645         uint32_t ret_ref = 0;
29646         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29647         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29648         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29649         ret_ref = (uintptr_t)ret_var.inner;
29650         if (ret_var.is_owned) {
29651                 ret_ref |= 1;
29652         }
29653         return ret_ref;
29654 }
29655
29656 void  __attribute__((export_name("TS_NodeAnnouncement_free"))) TS_NodeAnnouncement_free(uint32_t this_obj) {
29657         LDKNodeAnnouncement this_obj_conv;
29658         this_obj_conv.inner = (void*)(this_obj & (~1));
29659         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29661         NodeAnnouncement_free(this_obj_conv);
29662 }
29663
29664 int8_tArray  __attribute__((export_name("TS_NodeAnnouncement_get_signature"))) TS_NodeAnnouncement_get_signature(uint32_t this_ptr) {
29665         LDKNodeAnnouncement this_ptr_conv;
29666         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29667         this_ptr_conv.is_owned = false;
29668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29669         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29670         memcpy(ret_arr->elems, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form, 64);
29671         return ret_arr;
29672 }
29673
29674 void  __attribute__((export_name("TS_NodeAnnouncement_set_signature"))) TS_NodeAnnouncement_set_signature(uint32_t this_ptr, int8_tArray val) {
29675         LDKNodeAnnouncement this_ptr_conv;
29676         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29677         this_ptr_conv.is_owned = false;
29678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29679         LDKSignature val_ref;
29680         CHECK(val->arr_len == 64);
29681         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29682         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
29683 }
29684
29685 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_get_contents"))) TS_NodeAnnouncement_get_contents(uint32_t this_ptr) {
29686         LDKNodeAnnouncement this_ptr_conv;
29687         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29688         this_ptr_conv.is_owned = false;
29689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29690         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
29691         uint32_t ret_ref = 0;
29692         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29693         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29694         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29695         ret_ref = (uintptr_t)ret_var.inner;
29696         if (ret_var.is_owned) {
29697                 ret_ref |= 1;
29698         }
29699         return ret_ref;
29700 }
29701
29702 void  __attribute__((export_name("TS_NodeAnnouncement_set_contents"))) TS_NodeAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
29703         LDKNodeAnnouncement this_ptr_conv;
29704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29705         this_ptr_conv.is_owned = false;
29706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29707         LDKUnsignedNodeAnnouncement val_conv;
29708         val_conv.inner = (void*)(val & (~1));
29709         val_conv.is_owned = (val & 1) || (val == 0);
29710         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29711         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
29712         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
29713 }
29714
29715 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_new"))) TS_NodeAnnouncement_new(int8_tArray signature_arg, uint32_t contents_arg) {
29716         LDKSignature signature_arg_ref;
29717         CHECK(signature_arg->arr_len == 64);
29718         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
29719         LDKUnsignedNodeAnnouncement contents_arg_conv;
29720         contents_arg_conv.inner = (void*)(contents_arg & (~1));
29721         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
29722         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
29723         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
29724         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
29725         uint32_t ret_ref = 0;
29726         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29727         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29728         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29729         ret_ref = (uintptr_t)ret_var.inner;
29730         if (ret_var.is_owned) {
29731                 ret_ref |= 1;
29732         }
29733         return ret_ref;
29734 }
29735
29736 static inline uintptr_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
29737         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
29738 uint32_t ret_ref = 0;
29739 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29740 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29741 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29742 ret_ref = (uintptr_t)ret_var.inner;
29743 if (ret_var.is_owned) {
29744         ret_ref |= 1;
29745 }
29746         return ret_ref;
29747 }
29748 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_clone_ptr"))) TS_NodeAnnouncement_clone_ptr(uint32_t arg) {
29749         LDKNodeAnnouncement arg_conv;
29750         arg_conv.inner = (void*)(arg & (~1));
29751         arg_conv.is_owned = false;
29752         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29753         uint32_t ret_conv = NodeAnnouncement_clone_ptr(&arg_conv);
29754         return ret_conv;
29755 }
29756
29757 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_clone"))) TS_NodeAnnouncement_clone(uint32_t orig) {
29758         LDKNodeAnnouncement orig_conv;
29759         orig_conv.inner = (void*)(orig & (~1));
29760         orig_conv.is_owned = false;
29761         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29762         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
29763         uint32_t ret_ref = 0;
29764         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29765         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29766         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29767         ret_ref = (uintptr_t)ret_var.inner;
29768         if (ret_var.is_owned) {
29769                 ret_ref |= 1;
29770         }
29771         return ret_ref;
29772 }
29773
29774 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_free"))) TS_UnsignedChannelAnnouncement_free(uint32_t this_obj) {
29775         LDKUnsignedChannelAnnouncement this_obj_conv;
29776         this_obj_conv.inner = (void*)(this_obj & (~1));
29777         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29779         UnsignedChannelAnnouncement_free(this_obj_conv);
29780 }
29781
29782 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_features"))) TS_UnsignedChannelAnnouncement_get_features(uint32_t this_ptr) {
29783         LDKUnsignedChannelAnnouncement this_ptr_conv;
29784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29785         this_ptr_conv.is_owned = false;
29786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29787         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
29788         uint32_t ret_ref = 0;
29789         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29790         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29791         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29792         ret_ref = (uintptr_t)ret_var.inner;
29793         if (ret_var.is_owned) {
29794                 ret_ref |= 1;
29795         }
29796         return ret_ref;
29797 }
29798
29799 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_features"))) TS_UnsignedChannelAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
29800         LDKUnsignedChannelAnnouncement this_ptr_conv;
29801         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29802         this_ptr_conv.is_owned = false;
29803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29804         LDKChannelFeatures val_conv;
29805         val_conv.inner = (void*)(val & (~1));
29806         val_conv.is_owned = (val & 1) || (val == 0);
29807         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29808         val_conv = ChannelFeatures_clone(&val_conv);
29809         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
29810 }
29811
29812 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_chain_hash"))) TS_UnsignedChannelAnnouncement_get_chain_hash(uint32_t this_ptr) {
29813         LDKUnsignedChannelAnnouncement this_ptr_conv;
29814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29815         this_ptr_conv.is_owned = false;
29816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29817         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29818         memcpy(ret_arr->elems, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv), 32);
29819         return ret_arr;
29820 }
29821
29822 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_chain_hash"))) TS_UnsignedChannelAnnouncement_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
29823         LDKUnsignedChannelAnnouncement this_ptr_conv;
29824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29825         this_ptr_conv.is_owned = false;
29826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29827         LDKThirtyTwoBytes val_ref;
29828         CHECK(val->arr_len == 32);
29829         memcpy(val_ref.data, val->elems, 32); FREE(val);
29830         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
29831 }
29832
29833 int64_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_short_channel_id"))) TS_UnsignedChannelAnnouncement_get_short_channel_id(uint32_t this_ptr) {
29834         LDKUnsignedChannelAnnouncement this_ptr_conv;
29835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29836         this_ptr_conv.is_owned = false;
29837         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29838         int64_t ret_conv = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
29839         return ret_conv;
29840 }
29841
29842 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_short_channel_id"))) TS_UnsignedChannelAnnouncement_set_short_channel_id(uint32_t this_ptr, int64_t val) {
29843         LDKUnsignedChannelAnnouncement this_ptr_conv;
29844         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29845         this_ptr_conv.is_owned = false;
29846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29847         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
29848 }
29849
29850 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_node_id_1"))) TS_UnsignedChannelAnnouncement_get_node_id_1(uint32_t this_ptr) {
29851         LDKUnsignedChannelAnnouncement this_ptr_conv;
29852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29853         this_ptr_conv.is_owned = false;
29854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29855         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29856         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form, 33);
29857         return ret_arr;
29858 }
29859
29860 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_node_id_1"))) TS_UnsignedChannelAnnouncement_set_node_id_1(uint32_t this_ptr, int8_tArray val) {
29861         LDKUnsignedChannelAnnouncement this_ptr_conv;
29862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29863         this_ptr_conv.is_owned = false;
29864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29865         LDKPublicKey val_ref;
29866         CHECK(val->arr_len == 33);
29867         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29868         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
29869 }
29870
29871 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_node_id_2"))) TS_UnsignedChannelAnnouncement_get_node_id_2(uint32_t this_ptr) {
29872         LDKUnsignedChannelAnnouncement this_ptr_conv;
29873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29874         this_ptr_conv.is_owned = false;
29875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29876         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29877         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form, 33);
29878         return ret_arr;
29879 }
29880
29881 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_node_id_2"))) TS_UnsignedChannelAnnouncement_set_node_id_2(uint32_t this_ptr, int8_tArray val) {
29882         LDKUnsignedChannelAnnouncement this_ptr_conv;
29883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29884         this_ptr_conv.is_owned = false;
29885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29886         LDKPublicKey val_ref;
29887         CHECK(val->arr_len == 33);
29888         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29889         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
29890 }
29891
29892 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_bitcoin_key_1"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_1(uint32_t this_ptr) {
29893         LDKUnsignedChannelAnnouncement this_ptr_conv;
29894         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29895         this_ptr_conv.is_owned = false;
29896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29897         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29898         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form, 33);
29899         return ret_arr;
29900 }
29901
29902 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_bitcoin_key_1"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_1(uint32_t this_ptr, int8_tArray val) {
29903         LDKUnsignedChannelAnnouncement this_ptr_conv;
29904         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29905         this_ptr_conv.is_owned = false;
29906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29907         LDKPublicKey val_ref;
29908         CHECK(val->arr_len == 33);
29909         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29910         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
29911 }
29912
29913 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_bitcoin_key_2"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_2(uint32_t this_ptr) {
29914         LDKUnsignedChannelAnnouncement 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(33, __LINE__);
29919         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form, 33);
29920         return ret_arr;
29921 }
29922
29923 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_bitcoin_key_2"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_2(uint32_t this_ptr, int8_tArray val) {
29924         LDKUnsignedChannelAnnouncement 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         LDKPublicKey val_ref;
29929         CHECK(val->arr_len == 33);
29930         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29931         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
29932 }
29933
29934 static inline uintptr_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
29935         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
29936 uint32_t ret_ref = 0;
29937 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29938 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29939 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29940 ret_ref = (uintptr_t)ret_var.inner;
29941 if (ret_var.is_owned) {
29942         ret_ref |= 1;
29943 }
29944         return ret_ref;
29945 }
29946 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_clone_ptr"))) TS_UnsignedChannelAnnouncement_clone_ptr(uint32_t arg) {
29947         LDKUnsignedChannelAnnouncement arg_conv;
29948         arg_conv.inner = (void*)(arg & (~1));
29949         arg_conv.is_owned = false;
29950         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29951         uint32_t ret_conv = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
29952         return ret_conv;
29953 }
29954
29955 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_clone"))) TS_UnsignedChannelAnnouncement_clone(uint32_t orig) {
29956         LDKUnsignedChannelAnnouncement orig_conv;
29957         orig_conv.inner = (void*)(orig & (~1));
29958         orig_conv.is_owned = false;
29959         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29960         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
29961         uint32_t ret_ref = 0;
29962         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29963         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29964         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29965         ret_ref = (uintptr_t)ret_var.inner;
29966         if (ret_var.is_owned) {
29967                 ret_ref |= 1;
29968         }
29969         return ret_ref;
29970 }
29971
29972 void  __attribute__((export_name("TS_ChannelAnnouncement_free"))) TS_ChannelAnnouncement_free(uint32_t this_obj) {
29973         LDKChannelAnnouncement this_obj_conv;
29974         this_obj_conv.inner = (void*)(this_obj & (~1));
29975         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29977         ChannelAnnouncement_free(this_obj_conv);
29978 }
29979
29980 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_node_signature_1"))) TS_ChannelAnnouncement_get_node_signature_1(uint32_t this_ptr) {
29981         LDKChannelAnnouncement this_ptr_conv;
29982         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29983         this_ptr_conv.is_owned = false;
29984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29985         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29986         memcpy(ret_arr->elems, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form, 64);
29987         return ret_arr;
29988 }
29989
29990 void  __attribute__((export_name("TS_ChannelAnnouncement_set_node_signature_1"))) TS_ChannelAnnouncement_set_node_signature_1(uint32_t this_ptr, int8_tArray val) {
29991         LDKChannelAnnouncement this_ptr_conv;
29992         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29993         this_ptr_conv.is_owned = false;
29994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29995         LDKSignature val_ref;
29996         CHECK(val->arr_len == 64);
29997         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29998         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
29999 }
30000
30001 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_node_signature_2"))) TS_ChannelAnnouncement_get_node_signature_2(uint32_t this_ptr) {
30002         LDKChannelAnnouncement this_ptr_conv;
30003         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30004         this_ptr_conv.is_owned = false;
30005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30006         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
30007         memcpy(ret_arr->elems, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form, 64);
30008         return ret_arr;
30009 }
30010
30011 void  __attribute__((export_name("TS_ChannelAnnouncement_set_node_signature_2"))) TS_ChannelAnnouncement_set_node_signature_2(uint32_t this_ptr, int8_tArray val) {
30012         LDKChannelAnnouncement this_ptr_conv;
30013         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30014         this_ptr_conv.is_owned = false;
30015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30016         LDKSignature val_ref;
30017         CHECK(val->arr_len == 64);
30018         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
30019         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
30020 }
30021
30022 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_bitcoin_signature_1"))) TS_ChannelAnnouncement_get_bitcoin_signature_1(uint32_t this_ptr) {
30023         LDKChannelAnnouncement this_ptr_conv;
30024         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30025         this_ptr_conv.is_owned = false;
30026         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30027         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
30028         memcpy(ret_arr->elems, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form, 64);
30029         return ret_arr;
30030 }
30031
30032 void  __attribute__((export_name("TS_ChannelAnnouncement_set_bitcoin_signature_1"))) TS_ChannelAnnouncement_set_bitcoin_signature_1(uint32_t this_ptr, int8_tArray val) {
30033         LDKChannelAnnouncement this_ptr_conv;
30034         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30035         this_ptr_conv.is_owned = false;
30036         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30037         LDKSignature val_ref;
30038         CHECK(val->arr_len == 64);
30039         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
30040         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
30041 }
30042
30043 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_bitcoin_signature_2"))) TS_ChannelAnnouncement_get_bitcoin_signature_2(uint32_t this_ptr) {
30044         LDKChannelAnnouncement this_ptr_conv;
30045         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30046         this_ptr_conv.is_owned = false;
30047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30048         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
30049         memcpy(ret_arr->elems, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form, 64);
30050         return ret_arr;
30051 }
30052
30053 void  __attribute__((export_name("TS_ChannelAnnouncement_set_bitcoin_signature_2"))) TS_ChannelAnnouncement_set_bitcoin_signature_2(uint32_t this_ptr, int8_tArray val) {
30054         LDKChannelAnnouncement this_ptr_conv;
30055         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30056         this_ptr_conv.is_owned = false;
30057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30058         LDKSignature val_ref;
30059         CHECK(val->arr_len == 64);
30060         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
30061         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
30062 }
30063
30064 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_get_contents"))) TS_ChannelAnnouncement_get_contents(uint32_t this_ptr) {
30065         LDKChannelAnnouncement this_ptr_conv;
30066         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30067         this_ptr_conv.is_owned = false;
30068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30069         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
30070         uint32_t ret_ref = 0;
30071         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30072         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30073         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30074         ret_ref = (uintptr_t)ret_var.inner;
30075         if (ret_var.is_owned) {
30076                 ret_ref |= 1;
30077         }
30078         return ret_ref;
30079 }
30080
30081 void  __attribute__((export_name("TS_ChannelAnnouncement_set_contents"))) TS_ChannelAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
30082         LDKChannelAnnouncement this_ptr_conv;
30083         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30084         this_ptr_conv.is_owned = false;
30085         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30086         LDKUnsignedChannelAnnouncement val_conv;
30087         val_conv.inner = (void*)(val & (~1));
30088         val_conv.is_owned = (val & 1) || (val == 0);
30089         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30090         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
30091         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
30092 }
30093
30094 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) {
30095         LDKSignature node_signature_1_arg_ref;
30096         CHECK(node_signature_1_arg->arr_len == 64);
30097         memcpy(node_signature_1_arg_ref.compact_form, node_signature_1_arg->elems, 64); FREE(node_signature_1_arg);
30098         LDKSignature node_signature_2_arg_ref;
30099         CHECK(node_signature_2_arg->arr_len == 64);
30100         memcpy(node_signature_2_arg_ref.compact_form, node_signature_2_arg->elems, 64); FREE(node_signature_2_arg);
30101         LDKSignature bitcoin_signature_1_arg_ref;
30102         CHECK(bitcoin_signature_1_arg->arr_len == 64);
30103         memcpy(bitcoin_signature_1_arg_ref.compact_form, bitcoin_signature_1_arg->elems, 64); FREE(bitcoin_signature_1_arg);
30104         LDKSignature bitcoin_signature_2_arg_ref;
30105         CHECK(bitcoin_signature_2_arg->arr_len == 64);
30106         memcpy(bitcoin_signature_2_arg_ref.compact_form, bitcoin_signature_2_arg->elems, 64); FREE(bitcoin_signature_2_arg);
30107         LDKUnsignedChannelAnnouncement contents_arg_conv;
30108         contents_arg_conv.inner = (void*)(contents_arg & (~1));
30109         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
30110         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
30111         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
30112         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);
30113         uint32_t ret_ref = 0;
30114         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30115         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30116         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30117         ret_ref = (uintptr_t)ret_var.inner;
30118         if (ret_var.is_owned) {
30119                 ret_ref |= 1;
30120         }
30121         return ret_ref;
30122 }
30123
30124 static inline uintptr_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
30125         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
30126 uint32_t ret_ref = 0;
30127 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30128 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30129 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30130 ret_ref = (uintptr_t)ret_var.inner;
30131 if (ret_var.is_owned) {
30132         ret_ref |= 1;
30133 }
30134         return ret_ref;
30135 }
30136 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_clone_ptr"))) TS_ChannelAnnouncement_clone_ptr(uint32_t arg) {
30137         LDKChannelAnnouncement arg_conv;
30138         arg_conv.inner = (void*)(arg & (~1));
30139         arg_conv.is_owned = false;
30140         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30141         uint32_t ret_conv = ChannelAnnouncement_clone_ptr(&arg_conv);
30142         return ret_conv;
30143 }
30144
30145 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_clone"))) TS_ChannelAnnouncement_clone(uint32_t orig) {
30146         LDKChannelAnnouncement orig_conv;
30147         orig_conv.inner = (void*)(orig & (~1));
30148         orig_conv.is_owned = false;
30149         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30150         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
30151         uint32_t ret_ref = 0;
30152         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30153         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30154         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30155         ret_ref = (uintptr_t)ret_var.inner;
30156         if (ret_var.is_owned) {
30157                 ret_ref |= 1;
30158         }
30159         return ret_ref;
30160 }
30161
30162 void  __attribute__((export_name("TS_UnsignedChannelUpdate_free"))) TS_UnsignedChannelUpdate_free(uint32_t this_obj) {
30163         LDKUnsignedChannelUpdate this_obj_conv;
30164         this_obj_conv.inner = (void*)(this_obj & (~1));
30165         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30167         UnsignedChannelUpdate_free(this_obj_conv);
30168 }
30169
30170 int8_tArray  __attribute__((export_name("TS_UnsignedChannelUpdate_get_chain_hash"))) TS_UnsignedChannelUpdate_get_chain_hash(uint32_t this_ptr) {
30171         LDKUnsignedChannelUpdate this_ptr_conv;
30172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30173         this_ptr_conv.is_owned = false;
30174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30175         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30176         memcpy(ret_arr->elems, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv), 32);
30177         return ret_arr;
30178 }
30179
30180 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_chain_hash"))) TS_UnsignedChannelUpdate_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
30181         LDKUnsignedChannelUpdate 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         LDKThirtyTwoBytes val_ref;
30186         CHECK(val->arr_len == 32);
30187         memcpy(val_ref.data, val->elems, 32); FREE(val);
30188         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
30189 }
30190
30191 int64_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_short_channel_id"))) TS_UnsignedChannelUpdate_get_short_channel_id(uint32_t this_ptr) {
30192         LDKUnsignedChannelUpdate this_ptr_conv;
30193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30194         this_ptr_conv.is_owned = false;
30195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30196         int64_t ret_conv = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
30197         return ret_conv;
30198 }
30199
30200 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_short_channel_id"))) TS_UnsignedChannelUpdate_set_short_channel_id(uint32_t this_ptr, int64_t val) {
30201         LDKUnsignedChannelUpdate this_ptr_conv;
30202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30203         this_ptr_conv.is_owned = false;
30204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30205         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
30206 }
30207
30208 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_timestamp"))) TS_UnsignedChannelUpdate_get_timestamp(uint32_t this_ptr) {
30209         LDKUnsignedChannelUpdate this_ptr_conv;
30210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30211         this_ptr_conv.is_owned = false;
30212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30213         int32_t ret_conv = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
30214         return ret_conv;
30215 }
30216
30217 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_timestamp"))) TS_UnsignedChannelUpdate_set_timestamp(uint32_t this_ptr, int32_t val) {
30218         LDKUnsignedChannelUpdate this_ptr_conv;
30219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30220         this_ptr_conv.is_owned = false;
30221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30222         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
30223 }
30224
30225 int8_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_flags"))) TS_UnsignedChannelUpdate_get_flags(uint32_t this_ptr) {
30226         LDKUnsignedChannelUpdate this_ptr_conv;
30227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30228         this_ptr_conv.is_owned = false;
30229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30230         int8_t ret_conv = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
30231         return ret_conv;
30232 }
30233
30234 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_flags"))) TS_UnsignedChannelUpdate_set_flags(uint32_t this_ptr, int8_t val) {
30235         LDKUnsignedChannelUpdate this_ptr_conv;
30236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30237         this_ptr_conv.is_owned = false;
30238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30239         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
30240 }
30241
30242 int16_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_cltv_expiry_delta"))) TS_UnsignedChannelUpdate_get_cltv_expiry_delta(uint32_t this_ptr) {
30243         LDKUnsignedChannelUpdate this_ptr_conv;
30244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30245         this_ptr_conv.is_owned = false;
30246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30247         int16_t ret_conv = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
30248         return ret_conv;
30249 }
30250
30251 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_cltv_expiry_delta"))) TS_UnsignedChannelUpdate_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
30252         LDKUnsignedChannelUpdate this_ptr_conv;
30253         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30254         this_ptr_conv.is_owned = false;
30255         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30256         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
30257 }
30258
30259 int64_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_htlc_minimum_msat"))) TS_UnsignedChannelUpdate_get_htlc_minimum_msat(uint32_t this_ptr) {
30260         LDKUnsignedChannelUpdate this_ptr_conv;
30261         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30262         this_ptr_conv.is_owned = false;
30263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30264         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
30265         return ret_conv;
30266 }
30267
30268 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_htlc_minimum_msat"))) TS_UnsignedChannelUpdate_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
30269         LDKUnsignedChannelUpdate this_ptr_conv;
30270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30271         this_ptr_conv.is_owned = false;
30272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30273         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
30274 }
30275
30276 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_fee_base_msat"))) TS_UnsignedChannelUpdate_get_fee_base_msat(uint32_t this_ptr) {
30277         LDKUnsignedChannelUpdate this_ptr_conv;
30278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30279         this_ptr_conv.is_owned = false;
30280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30281         int32_t ret_conv = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
30282         return ret_conv;
30283 }
30284
30285 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_fee_base_msat"))) TS_UnsignedChannelUpdate_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
30286         LDKUnsignedChannelUpdate this_ptr_conv;
30287         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30288         this_ptr_conv.is_owned = false;
30289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30290         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
30291 }
30292
30293 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_fee_proportional_millionths"))) TS_UnsignedChannelUpdate_get_fee_proportional_millionths(uint32_t this_ptr) {
30294         LDKUnsignedChannelUpdate this_ptr_conv;
30295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30296         this_ptr_conv.is_owned = false;
30297         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30298         int32_t ret_conv = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
30299         return ret_conv;
30300 }
30301
30302 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_fee_proportional_millionths"))) TS_UnsignedChannelUpdate_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
30303         LDKUnsignedChannelUpdate this_ptr_conv;
30304         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30305         this_ptr_conv.is_owned = false;
30306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30307         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
30308 }
30309
30310 static inline uintptr_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
30311         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
30312 uint32_t ret_ref = 0;
30313 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30314 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30315 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30316 ret_ref = (uintptr_t)ret_var.inner;
30317 if (ret_var.is_owned) {
30318         ret_ref |= 1;
30319 }
30320         return ret_ref;
30321 }
30322 uint32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_clone_ptr"))) TS_UnsignedChannelUpdate_clone_ptr(uint32_t arg) {
30323         LDKUnsignedChannelUpdate arg_conv;
30324         arg_conv.inner = (void*)(arg & (~1));
30325         arg_conv.is_owned = false;
30326         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30327         uint32_t ret_conv = UnsignedChannelUpdate_clone_ptr(&arg_conv);
30328         return ret_conv;
30329 }
30330
30331 uint32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_clone"))) TS_UnsignedChannelUpdate_clone(uint32_t orig) {
30332         LDKUnsignedChannelUpdate orig_conv;
30333         orig_conv.inner = (void*)(orig & (~1));
30334         orig_conv.is_owned = false;
30335         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30336         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
30337         uint32_t ret_ref = 0;
30338         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30339         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30340         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30341         ret_ref = (uintptr_t)ret_var.inner;
30342         if (ret_var.is_owned) {
30343                 ret_ref |= 1;
30344         }
30345         return ret_ref;
30346 }
30347
30348 void  __attribute__((export_name("TS_ChannelUpdate_free"))) TS_ChannelUpdate_free(uint32_t this_obj) {
30349         LDKChannelUpdate 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         ChannelUpdate_free(this_obj_conv);
30354 }
30355
30356 int8_tArray  __attribute__((export_name("TS_ChannelUpdate_get_signature"))) TS_ChannelUpdate_get_signature(uint32_t this_ptr) {
30357         LDKChannelUpdate 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         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
30362         memcpy(ret_arr->elems, ChannelUpdate_get_signature(&this_ptr_conv).compact_form, 64);
30363         return ret_arr;
30364 }
30365
30366 void  __attribute__((export_name("TS_ChannelUpdate_set_signature"))) TS_ChannelUpdate_set_signature(uint32_t this_ptr, int8_tArray val) {
30367         LDKChannelUpdate this_ptr_conv;
30368         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30369         this_ptr_conv.is_owned = false;
30370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30371         LDKSignature val_ref;
30372         CHECK(val->arr_len == 64);
30373         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
30374         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
30375 }
30376
30377 uint32_t  __attribute__((export_name("TS_ChannelUpdate_get_contents"))) TS_ChannelUpdate_get_contents(uint32_t this_ptr) {
30378         LDKChannelUpdate this_ptr_conv;
30379         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30380         this_ptr_conv.is_owned = false;
30381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30382         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
30383         uint32_t ret_ref = 0;
30384         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30385         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30386         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30387         ret_ref = (uintptr_t)ret_var.inner;
30388         if (ret_var.is_owned) {
30389                 ret_ref |= 1;
30390         }
30391         return ret_ref;
30392 }
30393
30394 void  __attribute__((export_name("TS_ChannelUpdate_set_contents"))) TS_ChannelUpdate_set_contents(uint32_t this_ptr, uint32_t val) {
30395         LDKChannelUpdate this_ptr_conv;
30396         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30397         this_ptr_conv.is_owned = false;
30398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30399         LDKUnsignedChannelUpdate val_conv;
30400         val_conv.inner = (void*)(val & (~1));
30401         val_conv.is_owned = (val & 1) || (val == 0);
30402         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30403         val_conv = UnsignedChannelUpdate_clone(&val_conv);
30404         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
30405 }
30406
30407 uint32_t  __attribute__((export_name("TS_ChannelUpdate_new"))) TS_ChannelUpdate_new(int8_tArray signature_arg, uint32_t contents_arg) {
30408         LDKSignature signature_arg_ref;
30409         CHECK(signature_arg->arr_len == 64);
30410         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
30411         LDKUnsignedChannelUpdate contents_arg_conv;
30412         contents_arg_conv.inner = (void*)(contents_arg & (~1));
30413         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
30414         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
30415         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
30416         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
30417         uint32_t ret_ref = 0;
30418         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30419         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30420         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30421         ret_ref = (uintptr_t)ret_var.inner;
30422         if (ret_var.is_owned) {
30423                 ret_ref |= 1;
30424         }
30425         return ret_ref;
30426 }
30427
30428 static inline uintptr_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
30429         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
30430 uint32_t ret_ref = 0;
30431 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30432 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30433 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30434 ret_ref = (uintptr_t)ret_var.inner;
30435 if (ret_var.is_owned) {
30436         ret_ref |= 1;
30437 }
30438         return ret_ref;
30439 }
30440 uint32_t  __attribute__((export_name("TS_ChannelUpdate_clone_ptr"))) TS_ChannelUpdate_clone_ptr(uint32_t arg) {
30441         LDKChannelUpdate arg_conv;
30442         arg_conv.inner = (void*)(arg & (~1));
30443         arg_conv.is_owned = false;
30444         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30445         uint32_t ret_conv = ChannelUpdate_clone_ptr(&arg_conv);
30446         return ret_conv;
30447 }
30448
30449 uint32_t  __attribute__((export_name("TS_ChannelUpdate_clone"))) TS_ChannelUpdate_clone(uint32_t orig) {
30450         LDKChannelUpdate orig_conv;
30451         orig_conv.inner = (void*)(orig & (~1));
30452         orig_conv.is_owned = false;
30453         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30454         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
30455         uint32_t ret_ref = 0;
30456         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30457         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30458         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30459         ret_ref = (uintptr_t)ret_var.inner;
30460         if (ret_var.is_owned) {
30461                 ret_ref |= 1;
30462         }
30463         return ret_ref;
30464 }
30465
30466 void  __attribute__((export_name("TS_QueryChannelRange_free"))) TS_QueryChannelRange_free(uint32_t this_obj) {
30467         LDKQueryChannelRange this_obj_conv;
30468         this_obj_conv.inner = (void*)(this_obj & (~1));
30469         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30471         QueryChannelRange_free(this_obj_conv);
30472 }
30473
30474 int8_tArray  __attribute__((export_name("TS_QueryChannelRange_get_chain_hash"))) TS_QueryChannelRange_get_chain_hash(uint32_t this_ptr) {
30475         LDKQueryChannelRange this_ptr_conv;
30476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30477         this_ptr_conv.is_owned = false;
30478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30479         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30480         memcpy(ret_arr->elems, *QueryChannelRange_get_chain_hash(&this_ptr_conv), 32);
30481         return ret_arr;
30482 }
30483
30484 void  __attribute__((export_name("TS_QueryChannelRange_set_chain_hash"))) TS_QueryChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
30485         LDKQueryChannelRange this_ptr_conv;
30486         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30487         this_ptr_conv.is_owned = false;
30488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30489         LDKThirtyTwoBytes val_ref;
30490         CHECK(val->arr_len == 32);
30491         memcpy(val_ref.data, val->elems, 32); FREE(val);
30492         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
30493 }
30494
30495 int32_t  __attribute__((export_name("TS_QueryChannelRange_get_first_blocknum"))) TS_QueryChannelRange_get_first_blocknum(uint32_t this_ptr) {
30496         LDKQueryChannelRange this_ptr_conv;
30497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30498         this_ptr_conv.is_owned = false;
30499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30500         int32_t ret_conv = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
30501         return ret_conv;
30502 }
30503
30504 void  __attribute__((export_name("TS_QueryChannelRange_set_first_blocknum"))) TS_QueryChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
30505         LDKQueryChannelRange this_ptr_conv;
30506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30507         this_ptr_conv.is_owned = false;
30508         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30509         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
30510 }
30511
30512 int32_t  __attribute__((export_name("TS_QueryChannelRange_get_number_of_blocks"))) TS_QueryChannelRange_get_number_of_blocks(uint32_t this_ptr) {
30513         LDKQueryChannelRange this_ptr_conv;
30514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30515         this_ptr_conv.is_owned = false;
30516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30517         int32_t ret_conv = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
30518         return ret_conv;
30519 }
30520
30521 void  __attribute__((export_name("TS_QueryChannelRange_set_number_of_blocks"))) TS_QueryChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
30522         LDKQueryChannelRange this_ptr_conv;
30523         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30524         this_ptr_conv.is_owned = false;
30525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30526         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
30527 }
30528
30529 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) {
30530         LDKThirtyTwoBytes chain_hash_arg_ref;
30531         CHECK(chain_hash_arg->arr_len == 32);
30532         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
30533         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
30534         uint32_t ret_ref = 0;
30535         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30536         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30537         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30538         ret_ref = (uintptr_t)ret_var.inner;
30539         if (ret_var.is_owned) {
30540                 ret_ref |= 1;
30541         }
30542         return ret_ref;
30543 }
30544
30545 static inline uintptr_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
30546         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
30547 uint32_t ret_ref = 0;
30548 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30549 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30550 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30551 ret_ref = (uintptr_t)ret_var.inner;
30552 if (ret_var.is_owned) {
30553         ret_ref |= 1;
30554 }
30555         return ret_ref;
30556 }
30557 uint32_t  __attribute__((export_name("TS_QueryChannelRange_clone_ptr"))) TS_QueryChannelRange_clone_ptr(uint32_t arg) {
30558         LDKQueryChannelRange arg_conv;
30559         arg_conv.inner = (void*)(arg & (~1));
30560         arg_conv.is_owned = false;
30561         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30562         uint32_t ret_conv = QueryChannelRange_clone_ptr(&arg_conv);
30563         return ret_conv;
30564 }
30565
30566 uint32_t  __attribute__((export_name("TS_QueryChannelRange_clone"))) TS_QueryChannelRange_clone(uint32_t orig) {
30567         LDKQueryChannelRange orig_conv;
30568         orig_conv.inner = (void*)(orig & (~1));
30569         orig_conv.is_owned = false;
30570         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30571         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
30572         uint32_t ret_ref = 0;
30573         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30574         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30575         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30576         ret_ref = (uintptr_t)ret_var.inner;
30577         if (ret_var.is_owned) {
30578                 ret_ref |= 1;
30579         }
30580         return ret_ref;
30581 }
30582
30583 void  __attribute__((export_name("TS_ReplyChannelRange_free"))) TS_ReplyChannelRange_free(uint32_t this_obj) {
30584         LDKReplyChannelRange this_obj_conv;
30585         this_obj_conv.inner = (void*)(this_obj & (~1));
30586         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30588         ReplyChannelRange_free(this_obj_conv);
30589 }
30590
30591 int8_tArray  __attribute__((export_name("TS_ReplyChannelRange_get_chain_hash"))) TS_ReplyChannelRange_get_chain_hash(uint32_t this_ptr) {
30592         LDKReplyChannelRange this_ptr_conv;
30593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30594         this_ptr_conv.is_owned = false;
30595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30596         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30597         memcpy(ret_arr->elems, *ReplyChannelRange_get_chain_hash(&this_ptr_conv), 32);
30598         return ret_arr;
30599 }
30600
30601 void  __attribute__((export_name("TS_ReplyChannelRange_set_chain_hash"))) TS_ReplyChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
30602         LDKReplyChannelRange this_ptr_conv;
30603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30604         this_ptr_conv.is_owned = false;
30605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30606         LDKThirtyTwoBytes val_ref;
30607         CHECK(val->arr_len == 32);
30608         memcpy(val_ref.data, val->elems, 32); FREE(val);
30609         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
30610 }
30611
30612 int32_t  __attribute__((export_name("TS_ReplyChannelRange_get_first_blocknum"))) TS_ReplyChannelRange_get_first_blocknum(uint32_t this_ptr) {
30613         LDKReplyChannelRange this_ptr_conv;
30614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30615         this_ptr_conv.is_owned = false;
30616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30617         int32_t ret_conv = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
30618         return ret_conv;
30619 }
30620
30621 void  __attribute__((export_name("TS_ReplyChannelRange_set_first_blocknum"))) TS_ReplyChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
30622         LDKReplyChannelRange this_ptr_conv;
30623         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30624         this_ptr_conv.is_owned = false;
30625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30626         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
30627 }
30628
30629 int32_t  __attribute__((export_name("TS_ReplyChannelRange_get_number_of_blocks"))) TS_ReplyChannelRange_get_number_of_blocks(uint32_t this_ptr) {
30630         LDKReplyChannelRange this_ptr_conv;
30631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30632         this_ptr_conv.is_owned = false;
30633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30634         int32_t ret_conv = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
30635         return ret_conv;
30636 }
30637
30638 void  __attribute__((export_name("TS_ReplyChannelRange_set_number_of_blocks"))) TS_ReplyChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
30639         LDKReplyChannelRange this_ptr_conv;
30640         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30641         this_ptr_conv.is_owned = false;
30642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30643         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
30644 }
30645
30646 jboolean  __attribute__((export_name("TS_ReplyChannelRange_get_sync_complete"))) TS_ReplyChannelRange_get_sync_complete(uint32_t this_ptr) {
30647         LDKReplyChannelRange this_ptr_conv;
30648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30649         this_ptr_conv.is_owned = false;
30650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30651         jboolean ret_conv = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
30652         return ret_conv;
30653 }
30654
30655 void  __attribute__((export_name("TS_ReplyChannelRange_set_sync_complete"))) TS_ReplyChannelRange_set_sync_complete(uint32_t this_ptr, jboolean val) {
30656         LDKReplyChannelRange this_ptr_conv;
30657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30658         this_ptr_conv.is_owned = false;
30659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30660         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
30661 }
30662
30663 void  __attribute__((export_name("TS_ReplyChannelRange_set_short_channel_ids"))) TS_ReplyChannelRange_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
30664         LDKReplyChannelRange this_ptr_conv;
30665         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30666         this_ptr_conv.is_owned = false;
30667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30668         LDKCVec_u64Z val_constr;
30669         val_constr.datalen = val->arr_len;
30670         if (val_constr.datalen > 0)
30671                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
30672         else
30673                 val_constr.data = NULL;
30674         int64_t* val_vals = val->elems /* XXX val leaks */;
30675         for (size_t i = 0; i < val_constr.datalen; i++) {
30676                 int64_t val_conv_8 = val_vals[i];
30677                 val_constr.data[i] = val_conv_8;
30678         }
30679         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
30680 }
30681
30682 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) {
30683         LDKThirtyTwoBytes chain_hash_arg_ref;
30684         CHECK(chain_hash_arg->arr_len == 32);
30685         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
30686         LDKCVec_u64Z short_channel_ids_arg_constr;
30687         short_channel_ids_arg_constr.datalen = short_channel_ids_arg->arr_len;
30688         if (short_channel_ids_arg_constr.datalen > 0)
30689                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
30690         else
30691                 short_channel_ids_arg_constr.data = NULL;
30692         int64_t* short_channel_ids_arg_vals = short_channel_ids_arg->elems /* XXX short_channel_ids_arg leaks */;
30693         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
30694                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
30695                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
30696         }
30697         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
30698         uint32_t ret_ref = 0;
30699         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30700         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30701         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30702         ret_ref = (uintptr_t)ret_var.inner;
30703         if (ret_var.is_owned) {
30704                 ret_ref |= 1;
30705         }
30706         return ret_ref;
30707 }
30708
30709 static inline uintptr_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
30710         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
30711 uint32_t ret_ref = 0;
30712 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30713 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30714 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30715 ret_ref = (uintptr_t)ret_var.inner;
30716 if (ret_var.is_owned) {
30717         ret_ref |= 1;
30718 }
30719         return ret_ref;
30720 }
30721 uint32_t  __attribute__((export_name("TS_ReplyChannelRange_clone_ptr"))) TS_ReplyChannelRange_clone_ptr(uint32_t arg) {
30722         LDKReplyChannelRange arg_conv;
30723         arg_conv.inner = (void*)(arg & (~1));
30724         arg_conv.is_owned = false;
30725         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30726         uint32_t ret_conv = ReplyChannelRange_clone_ptr(&arg_conv);
30727         return ret_conv;
30728 }
30729
30730 uint32_t  __attribute__((export_name("TS_ReplyChannelRange_clone"))) TS_ReplyChannelRange_clone(uint32_t orig) {
30731         LDKReplyChannelRange orig_conv;
30732         orig_conv.inner = (void*)(orig & (~1));
30733         orig_conv.is_owned = false;
30734         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30735         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
30736         uint32_t ret_ref = 0;
30737         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30738         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30739         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30740         ret_ref = (uintptr_t)ret_var.inner;
30741         if (ret_var.is_owned) {
30742                 ret_ref |= 1;
30743         }
30744         return ret_ref;
30745 }
30746
30747 void  __attribute__((export_name("TS_QueryShortChannelIds_free"))) TS_QueryShortChannelIds_free(uint32_t this_obj) {
30748         LDKQueryShortChannelIds this_obj_conv;
30749         this_obj_conv.inner = (void*)(this_obj & (~1));
30750         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30752         QueryShortChannelIds_free(this_obj_conv);
30753 }
30754
30755 int8_tArray  __attribute__((export_name("TS_QueryShortChannelIds_get_chain_hash"))) TS_QueryShortChannelIds_get_chain_hash(uint32_t this_ptr) {
30756         LDKQueryShortChannelIds this_ptr_conv;
30757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30758         this_ptr_conv.is_owned = false;
30759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30760         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30761         memcpy(ret_arr->elems, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv), 32);
30762         return ret_arr;
30763 }
30764
30765 void  __attribute__((export_name("TS_QueryShortChannelIds_set_chain_hash"))) TS_QueryShortChannelIds_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
30766         LDKQueryShortChannelIds this_ptr_conv;
30767         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30768         this_ptr_conv.is_owned = false;
30769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30770         LDKThirtyTwoBytes val_ref;
30771         CHECK(val->arr_len == 32);
30772         memcpy(val_ref.data, val->elems, 32); FREE(val);
30773         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
30774 }
30775
30776 void  __attribute__((export_name("TS_QueryShortChannelIds_set_short_channel_ids"))) TS_QueryShortChannelIds_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
30777         LDKQueryShortChannelIds this_ptr_conv;
30778         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30779         this_ptr_conv.is_owned = false;
30780         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30781         LDKCVec_u64Z val_constr;
30782         val_constr.datalen = val->arr_len;
30783         if (val_constr.datalen > 0)
30784                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
30785         else
30786                 val_constr.data = NULL;
30787         int64_t* val_vals = val->elems /* XXX val leaks */;
30788         for (size_t i = 0; i < val_constr.datalen; i++) {
30789                 int64_t val_conv_8 = val_vals[i];
30790                 val_constr.data[i] = val_conv_8;
30791         }
30792         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
30793 }
30794
30795 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_new"))) TS_QueryShortChannelIds_new(int8_tArray chain_hash_arg, int64_tArray short_channel_ids_arg) {
30796         LDKThirtyTwoBytes chain_hash_arg_ref;
30797         CHECK(chain_hash_arg->arr_len == 32);
30798         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
30799         LDKCVec_u64Z short_channel_ids_arg_constr;
30800         short_channel_ids_arg_constr.datalen = short_channel_ids_arg->arr_len;
30801         if (short_channel_ids_arg_constr.datalen > 0)
30802                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
30803         else
30804                 short_channel_ids_arg_constr.data = NULL;
30805         int64_t* short_channel_ids_arg_vals = short_channel_ids_arg->elems /* XXX short_channel_ids_arg leaks */;
30806         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
30807                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
30808                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
30809         }
30810         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
30811         uint32_t ret_ref = 0;
30812         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30813         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30814         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30815         ret_ref = (uintptr_t)ret_var.inner;
30816         if (ret_var.is_owned) {
30817                 ret_ref |= 1;
30818         }
30819         return ret_ref;
30820 }
30821
30822 static inline uintptr_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
30823         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
30824 uint32_t ret_ref = 0;
30825 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30826 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30827 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30828 ret_ref = (uintptr_t)ret_var.inner;
30829 if (ret_var.is_owned) {
30830         ret_ref |= 1;
30831 }
30832         return ret_ref;
30833 }
30834 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_clone_ptr"))) TS_QueryShortChannelIds_clone_ptr(uint32_t arg) {
30835         LDKQueryShortChannelIds arg_conv;
30836         arg_conv.inner = (void*)(arg & (~1));
30837         arg_conv.is_owned = false;
30838         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30839         uint32_t ret_conv = QueryShortChannelIds_clone_ptr(&arg_conv);
30840         return ret_conv;
30841 }
30842
30843 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_clone"))) TS_QueryShortChannelIds_clone(uint32_t orig) {
30844         LDKQueryShortChannelIds orig_conv;
30845         orig_conv.inner = (void*)(orig & (~1));
30846         orig_conv.is_owned = false;
30847         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30848         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
30849         uint32_t ret_ref = 0;
30850         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30851         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30852         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30853         ret_ref = (uintptr_t)ret_var.inner;
30854         if (ret_var.is_owned) {
30855                 ret_ref |= 1;
30856         }
30857         return ret_ref;
30858 }
30859
30860 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_free"))) TS_ReplyShortChannelIdsEnd_free(uint32_t this_obj) {
30861         LDKReplyShortChannelIdsEnd this_obj_conv;
30862         this_obj_conv.inner = (void*)(this_obj & (~1));
30863         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30865         ReplyShortChannelIdsEnd_free(this_obj_conv);
30866 }
30867
30868 int8_tArray  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_get_chain_hash"))) TS_ReplyShortChannelIdsEnd_get_chain_hash(uint32_t this_ptr) {
30869         LDKReplyShortChannelIdsEnd this_ptr_conv;
30870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30871         this_ptr_conv.is_owned = false;
30872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30873         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30874         memcpy(ret_arr->elems, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv), 32);
30875         return ret_arr;
30876 }
30877
30878 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_set_chain_hash"))) TS_ReplyShortChannelIdsEnd_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
30879         LDKReplyShortChannelIdsEnd this_ptr_conv;
30880         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30881         this_ptr_conv.is_owned = false;
30882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30883         LDKThirtyTwoBytes val_ref;
30884         CHECK(val->arr_len == 32);
30885         memcpy(val_ref.data, val->elems, 32); FREE(val);
30886         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
30887 }
30888
30889 jboolean  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_get_full_information"))) TS_ReplyShortChannelIdsEnd_get_full_information(uint32_t this_ptr) {
30890         LDKReplyShortChannelIdsEnd this_ptr_conv;
30891         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30892         this_ptr_conv.is_owned = false;
30893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30894         jboolean ret_conv = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
30895         return ret_conv;
30896 }
30897
30898 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_set_full_information"))) TS_ReplyShortChannelIdsEnd_set_full_information(uint32_t this_ptr, jboolean val) {
30899         LDKReplyShortChannelIdsEnd this_ptr_conv;
30900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30901         this_ptr_conv.is_owned = false;
30902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30903         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
30904 }
30905
30906 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_new"))) TS_ReplyShortChannelIdsEnd_new(int8_tArray chain_hash_arg, jboolean full_information_arg) {
30907         LDKThirtyTwoBytes chain_hash_arg_ref;
30908         CHECK(chain_hash_arg->arr_len == 32);
30909         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
30910         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
30911         uint32_t ret_ref = 0;
30912         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30913         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30914         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30915         ret_ref = (uintptr_t)ret_var.inner;
30916         if (ret_var.is_owned) {
30917                 ret_ref |= 1;
30918         }
30919         return ret_ref;
30920 }
30921
30922 static inline uintptr_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
30923         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
30924 uint32_t ret_ref = 0;
30925 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30926 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30927 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30928 ret_ref = (uintptr_t)ret_var.inner;
30929 if (ret_var.is_owned) {
30930         ret_ref |= 1;
30931 }
30932         return ret_ref;
30933 }
30934 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_clone_ptr"))) TS_ReplyShortChannelIdsEnd_clone_ptr(uint32_t arg) {
30935         LDKReplyShortChannelIdsEnd arg_conv;
30936         arg_conv.inner = (void*)(arg & (~1));
30937         arg_conv.is_owned = false;
30938         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30939         uint32_t ret_conv = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
30940         return ret_conv;
30941 }
30942
30943 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_clone"))) TS_ReplyShortChannelIdsEnd_clone(uint32_t orig) {
30944         LDKReplyShortChannelIdsEnd orig_conv;
30945         orig_conv.inner = (void*)(orig & (~1));
30946         orig_conv.is_owned = false;
30947         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30948         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
30949         uint32_t ret_ref = 0;
30950         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30951         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30952         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30953         ret_ref = (uintptr_t)ret_var.inner;
30954         if (ret_var.is_owned) {
30955                 ret_ref |= 1;
30956         }
30957         return ret_ref;
30958 }
30959
30960 void  __attribute__((export_name("TS_GossipTimestampFilter_free"))) TS_GossipTimestampFilter_free(uint32_t this_obj) {
30961         LDKGossipTimestampFilter this_obj_conv;
30962         this_obj_conv.inner = (void*)(this_obj & (~1));
30963         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30965         GossipTimestampFilter_free(this_obj_conv);
30966 }
30967
30968 int8_tArray  __attribute__((export_name("TS_GossipTimestampFilter_get_chain_hash"))) TS_GossipTimestampFilter_get_chain_hash(uint32_t this_ptr) {
30969         LDKGossipTimestampFilter this_ptr_conv;
30970         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30971         this_ptr_conv.is_owned = false;
30972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30973         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30974         memcpy(ret_arr->elems, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv), 32);
30975         return ret_arr;
30976 }
30977
30978 void  __attribute__((export_name("TS_GossipTimestampFilter_set_chain_hash"))) TS_GossipTimestampFilter_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
30979         LDKGossipTimestampFilter this_ptr_conv;
30980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30981         this_ptr_conv.is_owned = false;
30982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30983         LDKThirtyTwoBytes val_ref;
30984         CHECK(val->arr_len == 32);
30985         memcpy(val_ref.data, val->elems, 32); FREE(val);
30986         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
30987 }
30988
30989 int32_t  __attribute__((export_name("TS_GossipTimestampFilter_get_first_timestamp"))) TS_GossipTimestampFilter_get_first_timestamp(uint32_t this_ptr) {
30990         LDKGossipTimestampFilter this_ptr_conv;
30991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30992         this_ptr_conv.is_owned = false;
30993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30994         int32_t ret_conv = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
30995         return ret_conv;
30996 }
30997
30998 void  __attribute__((export_name("TS_GossipTimestampFilter_set_first_timestamp"))) TS_GossipTimestampFilter_set_first_timestamp(uint32_t this_ptr, int32_t val) {
30999         LDKGossipTimestampFilter this_ptr_conv;
31000         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31001         this_ptr_conv.is_owned = false;
31002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31003         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
31004 }
31005
31006 int32_t  __attribute__((export_name("TS_GossipTimestampFilter_get_timestamp_range"))) TS_GossipTimestampFilter_get_timestamp_range(uint32_t this_ptr) {
31007         LDKGossipTimestampFilter this_ptr_conv;
31008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31009         this_ptr_conv.is_owned = false;
31010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31011         int32_t ret_conv = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
31012         return ret_conv;
31013 }
31014
31015 void  __attribute__((export_name("TS_GossipTimestampFilter_set_timestamp_range"))) TS_GossipTimestampFilter_set_timestamp_range(uint32_t this_ptr, int32_t val) {
31016         LDKGossipTimestampFilter this_ptr_conv;
31017         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31018         this_ptr_conv.is_owned = false;
31019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31020         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
31021 }
31022
31023 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) {
31024         LDKThirtyTwoBytes chain_hash_arg_ref;
31025         CHECK(chain_hash_arg->arr_len == 32);
31026         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
31027         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
31028         uint32_t ret_ref = 0;
31029         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31030         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31031         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31032         ret_ref = (uintptr_t)ret_var.inner;
31033         if (ret_var.is_owned) {
31034                 ret_ref |= 1;
31035         }
31036         return ret_ref;
31037 }
31038
31039 static inline uintptr_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
31040         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
31041 uint32_t ret_ref = 0;
31042 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31043 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31044 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31045 ret_ref = (uintptr_t)ret_var.inner;
31046 if (ret_var.is_owned) {
31047         ret_ref |= 1;
31048 }
31049         return ret_ref;
31050 }
31051 uint32_t  __attribute__((export_name("TS_GossipTimestampFilter_clone_ptr"))) TS_GossipTimestampFilter_clone_ptr(uint32_t arg) {
31052         LDKGossipTimestampFilter arg_conv;
31053         arg_conv.inner = (void*)(arg & (~1));
31054         arg_conv.is_owned = false;
31055         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31056         uint32_t ret_conv = GossipTimestampFilter_clone_ptr(&arg_conv);
31057         return ret_conv;
31058 }
31059
31060 uint32_t  __attribute__((export_name("TS_GossipTimestampFilter_clone"))) TS_GossipTimestampFilter_clone(uint32_t orig) {
31061         LDKGossipTimestampFilter orig_conv;
31062         orig_conv.inner = (void*)(orig & (~1));
31063         orig_conv.is_owned = false;
31064         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31065         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
31066         uint32_t ret_ref = 0;
31067         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31068         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31069         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31070         ret_ref = (uintptr_t)ret_var.inner;
31071         if (ret_var.is_owned) {
31072                 ret_ref |= 1;
31073         }
31074         return ret_ref;
31075 }
31076
31077 void  __attribute__((export_name("TS_ErrorAction_free"))) TS_ErrorAction_free(uint32_t this_ptr) {
31078         if ((this_ptr & 1) != 0) return;
31079         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
31080         CHECK_ACCESS(this_ptr_ptr);
31081         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
31082         FREE((void*)this_ptr);
31083         ErrorAction_free(this_ptr_conv);
31084 }
31085
31086 static inline uintptr_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
31087         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
31088         *ret_copy = ErrorAction_clone(arg);
31089 uint32_t ret_ref = (uintptr_t)ret_copy;
31090         return ret_ref;
31091 }
31092 uint32_t  __attribute__((export_name("TS_ErrorAction_clone_ptr"))) TS_ErrorAction_clone_ptr(uint32_t arg) {
31093         LDKErrorAction* arg_conv = (LDKErrorAction*)arg;
31094         uint32_t ret_conv = ErrorAction_clone_ptr(arg_conv);
31095         return ret_conv;
31096 }
31097
31098 uint32_t  __attribute__((export_name("TS_ErrorAction_clone"))) TS_ErrorAction_clone(uint32_t orig) {
31099         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
31100         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
31101         *ret_copy = ErrorAction_clone(orig_conv);
31102         uint32_t ret_ref = (uintptr_t)ret_copy;
31103         return ret_ref;
31104 }
31105
31106 uint32_t  __attribute__((export_name("TS_ErrorAction_disconnect_peer"))) TS_ErrorAction_disconnect_peer(uint32_t msg) {
31107         LDKErrorMessage msg_conv;
31108         msg_conv.inner = (void*)(msg & (~1));
31109         msg_conv.is_owned = (msg & 1) || (msg == 0);
31110         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
31111         msg_conv = ErrorMessage_clone(&msg_conv);
31112         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
31113         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
31114         uint32_t ret_ref = (uintptr_t)ret_copy;
31115         return ret_ref;
31116 }
31117
31118 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_error"))) TS_ErrorAction_ignore_error() {
31119         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
31120         *ret_copy = ErrorAction_ignore_error();
31121         uint32_t ret_ref = (uintptr_t)ret_copy;
31122         return ret_ref;
31123 }
31124
31125 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_and_log"))) TS_ErrorAction_ignore_and_log(uint32_t a) {
31126         LDKLevel a_conv = LDKLevel_from_js(a);
31127         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
31128         *ret_copy = ErrorAction_ignore_and_log(a_conv);
31129         uint32_t ret_ref = (uintptr_t)ret_copy;
31130         return ret_ref;
31131 }
31132
31133 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_duplicate_gossip"))) TS_ErrorAction_ignore_duplicate_gossip() {
31134         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
31135         *ret_copy = ErrorAction_ignore_duplicate_gossip();
31136         uint32_t ret_ref = (uintptr_t)ret_copy;
31137         return ret_ref;
31138 }
31139
31140 uint32_t  __attribute__((export_name("TS_ErrorAction_send_error_message"))) TS_ErrorAction_send_error_message(uint32_t msg) {
31141         LDKErrorMessage msg_conv;
31142         msg_conv.inner = (void*)(msg & (~1));
31143         msg_conv.is_owned = (msg & 1) || (msg == 0);
31144         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
31145         msg_conv = ErrorMessage_clone(&msg_conv);
31146         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
31147         *ret_copy = ErrorAction_send_error_message(msg_conv);
31148         uint32_t ret_ref = (uintptr_t)ret_copy;
31149         return ret_ref;
31150 }
31151
31152 uint32_t  __attribute__((export_name("TS_ErrorAction_send_warning_message"))) TS_ErrorAction_send_warning_message(uint32_t msg, uint32_t log_level) {
31153         LDKWarningMessage msg_conv;
31154         msg_conv.inner = (void*)(msg & (~1));
31155         msg_conv.is_owned = (msg & 1) || (msg == 0);
31156         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
31157         msg_conv = WarningMessage_clone(&msg_conv);
31158         LDKLevel log_level_conv = LDKLevel_from_js(log_level);
31159         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
31160         *ret_copy = ErrorAction_send_warning_message(msg_conv, log_level_conv);
31161         uint32_t ret_ref = (uintptr_t)ret_copy;
31162         return ret_ref;
31163 }
31164
31165 void  __attribute__((export_name("TS_LightningError_free"))) TS_LightningError_free(uint32_t this_obj) {
31166         LDKLightningError this_obj_conv;
31167         this_obj_conv.inner = (void*)(this_obj & (~1));
31168         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31170         LightningError_free(this_obj_conv);
31171 }
31172
31173 jstring  __attribute__((export_name("TS_LightningError_get_err"))) TS_LightningError_get_err(uint32_t this_ptr) {
31174         LDKLightningError 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         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
31179         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
31180         Str_free(ret_str);
31181         return ret_conv;
31182 }
31183
31184 void  __attribute__((export_name("TS_LightningError_set_err"))) TS_LightningError_set_err(uint32_t this_ptr, jstring val) {
31185         LDKLightningError this_ptr_conv;
31186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31187         this_ptr_conv.is_owned = false;
31188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31189         LDKStr val_conv = str_ref_to_owned_c(val);
31190         LightningError_set_err(&this_ptr_conv, val_conv);
31191 }
31192
31193 uint32_t  __attribute__((export_name("TS_LightningError_get_action"))) TS_LightningError_get_action(uint32_t this_ptr) {
31194         LDKLightningError this_ptr_conv;
31195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31196         this_ptr_conv.is_owned = false;
31197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31198         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
31199         *ret_copy = LightningError_get_action(&this_ptr_conv);
31200         uint32_t ret_ref = (uintptr_t)ret_copy;
31201         return ret_ref;
31202 }
31203
31204 void  __attribute__((export_name("TS_LightningError_set_action"))) TS_LightningError_set_action(uint32_t this_ptr, uint32_t val) {
31205         LDKLightningError this_ptr_conv;
31206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31207         this_ptr_conv.is_owned = false;
31208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31209         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
31210         CHECK_ACCESS(val_ptr);
31211         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
31212         val_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)val) & ~1));
31213         LightningError_set_action(&this_ptr_conv, val_conv);
31214 }
31215
31216 uint32_t  __attribute__((export_name("TS_LightningError_new"))) TS_LightningError_new(jstring err_arg, uint32_t action_arg) {
31217         LDKStr err_arg_conv = str_ref_to_owned_c(err_arg);
31218         void* action_arg_ptr = (void*)(((uintptr_t)action_arg) & ~1);
31219         CHECK_ACCESS(action_arg_ptr);
31220         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
31221         action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action_arg) & ~1));
31222         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
31223         uint32_t ret_ref = 0;
31224         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31225         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31226         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31227         ret_ref = (uintptr_t)ret_var.inner;
31228         if (ret_var.is_owned) {
31229                 ret_ref |= 1;
31230         }
31231         return ret_ref;
31232 }
31233
31234 static inline uintptr_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
31235         LDKLightningError ret_var = LightningError_clone(arg);
31236 uint32_t ret_ref = 0;
31237 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31238 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31239 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31240 ret_ref = (uintptr_t)ret_var.inner;
31241 if (ret_var.is_owned) {
31242         ret_ref |= 1;
31243 }
31244         return ret_ref;
31245 }
31246 uint32_t  __attribute__((export_name("TS_LightningError_clone_ptr"))) TS_LightningError_clone_ptr(uint32_t arg) {
31247         LDKLightningError arg_conv;
31248         arg_conv.inner = (void*)(arg & (~1));
31249         arg_conv.is_owned = false;
31250         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31251         uint32_t ret_conv = LightningError_clone_ptr(&arg_conv);
31252         return ret_conv;
31253 }
31254
31255 uint32_t  __attribute__((export_name("TS_LightningError_clone"))) TS_LightningError_clone(uint32_t orig) {
31256         LDKLightningError orig_conv;
31257         orig_conv.inner = (void*)(orig & (~1));
31258         orig_conv.is_owned = false;
31259         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31260         LDKLightningError ret_var = LightningError_clone(&orig_conv);
31261         uint32_t ret_ref = 0;
31262         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31263         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31264         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31265         ret_ref = (uintptr_t)ret_var.inner;
31266         if (ret_var.is_owned) {
31267                 ret_ref |= 1;
31268         }
31269         return ret_ref;
31270 }
31271
31272 void  __attribute__((export_name("TS_CommitmentUpdate_free"))) TS_CommitmentUpdate_free(uint32_t this_obj) {
31273         LDKCommitmentUpdate this_obj_conv;
31274         this_obj_conv.inner = (void*)(this_obj & (~1));
31275         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31276         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31277         CommitmentUpdate_free(this_obj_conv);
31278 }
31279
31280 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_add_htlcs"))) TS_CommitmentUpdate_get_update_add_htlcs(uint32_t this_ptr) {
31281         LDKCommitmentUpdate this_ptr_conv;
31282         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31283         this_ptr_conv.is_owned = false;
31284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31285         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
31286         uint32_tArray ret_arr = NULL;
31287         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
31288         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
31289         for (size_t p = 0; p < ret_var.datalen; p++) {
31290                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
31291                 uint32_t ret_conv_15_ref = 0;
31292                 CHECK((((uintptr_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31293                 CHECK((((uintptr_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31294                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
31295                 ret_conv_15_ref = (uintptr_t)ret_conv_15_var.inner;
31296                 if (ret_conv_15_var.is_owned) {
31297                         ret_conv_15_ref |= 1;
31298                 }
31299                 ret_arr_ptr[p] = ret_conv_15_ref;
31300         }
31301         
31302         FREE(ret_var.data);
31303         return ret_arr;
31304 }
31305
31306 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_add_htlcs"))) TS_CommitmentUpdate_set_update_add_htlcs(uint32_t this_ptr, uint32_tArray val) {
31307         LDKCommitmentUpdate this_ptr_conv;
31308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31309         this_ptr_conv.is_owned = false;
31310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31311         LDKCVec_UpdateAddHTLCZ val_constr;
31312         val_constr.datalen = val->arr_len;
31313         if (val_constr.datalen > 0)
31314                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
31315         else
31316                 val_constr.data = NULL;
31317         uint32_t* val_vals = val->elems /* XXX val leaks */;
31318         for (size_t p = 0; p < val_constr.datalen; p++) {
31319                 uint32_t val_conv_15 = val_vals[p];
31320                 LDKUpdateAddHTLC val_conv_15_conv;
31321                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
31322                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
31323                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
31324                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
31325                 val_constr.data[p] = val_conv_15_conv;
31326         }
31327         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
31328 }
31329
31330 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fulfill_htlcs"))) TS_CommitmentUpdate_get_update_fulfill_htlcs(uint32_t this_ptr) {
31331         LDKCommitmentUpdate this_ptr_conv;
31332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31333         this_ptr_conv.is_owned = false;
31334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31335         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
31336         uint32_tArray ret_arr = NULL;
31337         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
31338         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
31339         for (size_t t = 0; t < ret_var.datalen; t++) {
31340                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
31341                 uint32_t ret_conv_19_ref = 0;
31342                 CHECK((((uintptr_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31343                 CHECK((((uintptr_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31344                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
31345                 ret_conv_19_ref = (uintptr_t)ret_conv_19_var.inner;
31346                 if (ret_conv_19_var.is_owned) {
31347                         ret_conv_19_ref |= 1;
31348                 }
31349                 ret_arr_ptr[t] = ret_conv_19_ref;
31350         }
31351         
31352         FREE(ret_var.data);
31353         return ret_arr;
31354 }
31355
31356 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fulfill_htlcs"))) TS_CommitmentUpdate_set_update_fulfill_htlcs(uint32_t this_ptr, uint32_tArray val) {
31357         LDKCommitmentUpdate this_ptr_conv;
31358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31359         this_ptr_conv.is_owned = false;
31360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31361         LDKCVec_UpdateFulfillHTLCZ val_constr;
31362         val_constr.datalen = val->arr_len;
31363         if (val_constr.datalen > 0)
31364                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
31365         else
31366                 val_constr.data = NULL;
31367         uint32_t* val_vals = val->elems /* XXX val leaks */;
31368         for (size_t t = 0; t < val_constr.datalen; t++) {
31369                 uint32_t val_conv_19 = val_vals[t];
31370                 LDKUpdateFulfillHTLC val_conv_19_conv;
31371                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
31372                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
31373                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
31374                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
31375                 val_constr.data[t] = val_conv_19_conv;
31376         }
31377         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
31378 }
31379
31380 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fail_htlcs"))) TS_CommitmentUpdate_get_update_fail_htlcs(uint32_t this_ptr) {
31381         LDKCommitmentUpdate this_ptr_conv;
31382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31383         this_ptr_conv.is_owned = false;
31384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31385         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
31386         uint32_tArray ret_arr = NULL;
31387         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
31388         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
31389         for (size_t q = 0; q < ret_var.datalen; q++) {
31390                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
31391                 uint32_t ret_conv_16_ref = 0;
31392                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31393                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31394                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
31395                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
31396                 if (ret_conv_16_var.is_owned) {
31397                         ret_conv_16_ref |= 1;
31398                 }
31399                 ret_arr_ptr[q] = ret_conv_16_ref;
31400         }
31401         
31402         FREE(ret_var.data);
31403         return ret_arr;
31404 }
31405
31406 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fail_htlcs"))) TS_CommitmentUpdate_set_update_fail_htlcs(uint32_t this_ptr, uint32_tArray val) {
31407         LDKCommitmentUpdate this_ptr_conv;
31408         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31409         this_ptr_conv.is_owned = false;
31410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31411         LDKCVec_UpdateFailHTLCZ val_constr;
31412         val_constr.datalen = val->arr_len;
31413         if (val_constr.datalen > 0)
31414                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
31415         else
31416                 val_constr.data = NULL;
31417         uint32_t* val_vals = val->elems /* XXX val leaks */;
31418         for (size_t q = 0; q < val_constr.datalen; q++) {
31419                 uint32_t val_conv_16 = val_vals[q];
31420                 LDKUpdateFailHTLC val_conv_16_conv;
31421                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
31422                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
31423                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
31424                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
31425                 val_constr.data[q] = val_conv_16_conv;
31426         }
31427         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
31428 }
31429
31430 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fail_malformed_htlcs"))) TS_CommitmentUpdate_get_update_fail_malformed_htlcs(uint32_t this_ptr) {
31431         LDKCommitmentUpdate this_ptr_conv;
31432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31433         this_ptr_conv.is_owned = false;
31434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31435         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
31436         uint32_tArray ret_arr = NULL;
31437         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
31438         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
31439         for (size_t z = 0; z < ret_var.datalen; z++) {
31440                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
31441                 uint32_t ret_conv_25_ref = 0;
31442                 CHECK((((uintptr_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31443                 CHECK((((uintptr_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31444                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
31445                 ret_conv_25_ref = (uintptr_t)ret_conv_25_var.inner;
31446                 if (ret_conv_25_var.is_owned) {
31447                         ret_conv_25_ref |= 1;
31448                 }
31449                 ret_arr_ptr[z] = ret_conv_25_ref;
31450         }
31451         
31452         FREE(ret_var.data);
31453         return ret_arr;
31454 }
31455
31456 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) {
31457         LDKCommitmentUpdate this_ptr_conv;
31458         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31459         this_ptr_conv.is_owned = false;
31460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31461         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
31462         val_constr.datalen = val->arr_len;
31463         if (val_constr.datalen > 0)
31464                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
31465         else
31466                 val_constr.data = NULL;
31467         uint32_t* val_vals = val->elems /* XXX val leaks */;
31468         for (size_t z = 0; z < val_constr.datalen; z++) {
31469                 uint32_t val_conv_25 = val_vals[z];
31470                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
31471                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
31472                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
31473                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
31474                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
31475                 val_constr.data[z] = val_conv_25_conv;
31476         }
31477         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
31478 }
31479
31480 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_get_update_fee"))) TS_CommitmentUpdate_get_update_fee(uint32_t this_ptr) {
31481         LDKCommitmentUpdate this_ptr_conv;
31482         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31483         this_ptr_conv.is_owned = false;
31484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31485         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
31486         uint32_t ret_ref = 0;
31487         if ((uintptr_t)ret_var.inner > 4096) {
31488                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31489                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31490         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31491                 ret_ref = (uintptr_t)ret_var.inner;
31492                 if (ret_var.is_owned) {
31493                         ret_ref |= 1;
31494                 }
31495         }
31496         return ret_ref;
31497 }
31498
31499 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fee"))) TS_CommitmentUpdate_set_update_fee(uint32_t this_ptr, uint32_t val) {
31500         LDKCommitmentUpdate this_ptr_conv;
31501         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31502         this_ptr_conv.is_owned = false;
31503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31504         LDKUpdateFee val_conv;
31505         val_conv.inner = (void*)(val & (~1));
31506         val_conv.is_owned = (val & 1) || (val == 0);
31507         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31508         val_conv = UpdateFee_clone(&val_conv);
31509         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
31510 }
31511
31512 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_get_commitment_signed"))) TS_CommitmentUpdate_get_commitment_signed(uint32_t this_ptr) {
31513         LDKCommitmentUpdate 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         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
31518         uint32_t ret_ref = 0;
31519         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31520         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31521         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31522         ret_ref = (uintptr_t)ret_var.inner;
31523         if (ret_var.is_owned) {
31524                 ret_ref |= 1;
31525         }
31526         return ret_ref;
31527 }
31528
31529 void  __attribute__((export_name("TS_CommitmentUpdate_set_commitment_signed"))) TS_CommitmentUpdate_set_commitment_signed(uint32_t this_ptr, uint32_t val) {
31530         LDKCommitmentUpdate 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         LDKCommitmentSigned val_conv;
31535         val_conv.inner = (void*)(val & (~1));
31536         val_conv.is_owned = (val & 1) || (val == 0);
31537         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31538         val_conv = CommitmentSigned_clone(&val_conv);
31539         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
31540 }
31541
31542 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) {
31543         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
31544         update_add_htlcs_arg_constr.datalen = update_add_htlcs_arg->arr_len;
31545         if (update_add_htlcs_arg_constr.datalen > 0)
31546                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
31547         else
31548                 update_add_htlcs_arg_constr.data = NULL;
31549         uint32_t* update_add_htlcs_arg_vals = update_add_htlcs_arg->elems /* XXX update_add_htlcs_arg leaks */;
31550         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
31551                 uint32_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
31552                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
31553                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
31554                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
31555                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
31556                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
31557                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
31558         }
31559         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
31560         update_fulfill_htlcs_arg_constr.datalen = update_fulfill_htlcs_arg->arr_len;
31561         if (update_fulfill_htlcs_arg_constr.datalen > 0)
31562                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
31563         else
31564                 update_fulfill_htlcs_arg_constr.data = NULL;
31565         uint32_t* update_fulfill_htlcs_arg_vals = update_fulfill_htlcs_arg->elems /* XXX update_fulfill_htlcs_arg leaks */;
31566         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
31567                 uint32_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
31568                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
31569                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
31570                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
31571                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
31572                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
31573                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
31574         }
31575         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
31576         update_fail_htlcs_arg_constr.datalen = update_fail_htlcs_arg->arr_len;
31577         if (update_fail_htlcs_arg_constr.datalen > 0)
31578                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
31579         else
31580                 update_fail_htlcs_arg_constr.data = NULL;
31581         uint32_t* update_fail_htlcs_arg_vals = update_fail_htlcs_arg->elems /* XXX update_fail_htlcs_arg leaks */;
31582         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
31583                 uint32_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
31584                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
31585                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
31586                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
31587                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
31588                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
31589                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
31590         }
31591         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
31592         update_fail_malformed_htlcs_arg_constr.datalen = update_fail_malformed_htlcs_arg->arr_len;
31593         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
31594                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
31595         else
31596                 update_fail_malformed_htlcs_arg_constr.data = NULL;
31597         uint32_t* update_fail_malformed_htlcs_arg_vals = update_fail_malformed_htlcs_arg->elems /* XXX update_fail_malformed_htlcs_arg leaks */;
31598         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
31599                 uint32_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
31600                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
31601                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
31602                 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);
31603                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
31604                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
31605                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
31606         }
31607         LDKUpdateFee update_fee_arg_conv;
31608         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
31609         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
31610         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
31611         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
31612         LDKCommitmentSigned commitment_signed_arg_conv;
31613         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
31614         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
31615         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
31616         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
31617         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);
31618         uint32_t ret_ref = 0;
31619         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31620         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31621         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31622         ret_ref = (uintptr_t)ret_var.inner;
31623         if (ret_var.is_owned) {
31624                 ret_ref |= 1;
31625         }
31626         return ret_ref;
31627 }
31628
31629 static inline uintptr_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
31630         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
31631 uint32_t ret_ref = 0;
31632 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31633 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31634 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31635 ret_ref = (uintptr_t)ret_var.inner;
31636 if (ret_var.is_owned) {
31637         ret_ref |= 1;
31638 }
31639         return ret_ref;
31640 }
31641 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_clone_ptr"))) TS_CommitmentUpdate_clone_ptr(uint32_t arg) {
31642         LDKCommitmentUpdate arg_conv;
31643         arg_conv.inner = (void*)(arg & (~1));
31644         arg_conv.is_owned = false;
31645         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31646         uint32_t ret_conv = CommitmentUpdate_clone_ptr(&arg_conv);
31647         return ret_conv;
31648 }
31649
31650 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_clone"))) TS_CommitmentUpdate_clone(uint32_t orig) {
31651         LDKCommitmentUpdate orig_conv;
31652         orig_conv.inner = (void*)(orig & (~1));
31653         orig_conv.is_owned = false;
31654         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31655         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
31656         uint32_t ret_ref = 0;
31657         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31658         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31659         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31660         ret_ref = (uintptr_t)ret_var.inner;
31661         if (ret_var.is_owned) {
31662                 ret_ref |= 1;
31663         }
31664         return ret_ref;
31665 }
31666
31667 void  __attribute__((export_name("TS_ChannelMessageHandler_free"))) TS_ChannelMessageHandler_free(uint32_t this_ptr) {
31668         if ((this_ptr & 1) != 0) return;
31669         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
31670         CHECK_ACCESS(this_ptr_ptr);
31671         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
31672         FREE((void*)this_ptr);
31673         ChannelMessageHandler_free(this_ptr_conv);
31674 }
31675
31676 void  __attribute__((export_name("TS_RoutingMessageHandler_free"))) TS_RoutingMessageHandler_free(uint32_t this_ptr) {
31677         if ((this_ptr & 1) != 0) return;
31678         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
31679         CHECK_ACCESS(this_ptr_ptr);
31680         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
31681         FREE((void*)this_ptr);
31682         RoutingMessageHandler_free(this_ptr_conv);
31683 }
31684
31685 int8_tArray  __attribute__((export_name("TS_AcceptChannel_write"))) TS_AcceptChannel_write(uint32_t obj) {
31686         LDKAcceptChannel obj_conv;
31687         obj_conv.inner = (void*)(obj & (~1));
31688         obj_conv.is_owned = false;
31689         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31690         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
31691         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31692         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31693         CVec_u8Z_free(ret_var);
31694         return ret_arr;
31695 }
31696
31697 uint32_t  __attribute__((export_name("TS_AcceptChannel_read"))) TS_AcceptChannel_read(int8_tArray ser) {
31698         LDKu8slice ser_ref;
31699         ser_ref.datalen = ser->arr_len;
31700         ser_ref.data = ser->elems /* XXX ser leaks */;
31701         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
31702         *ret_conv = AcceptChannel_read(ser_ref);
31703         return (uint32_t)ret_conv;
31704 }
31705
31706 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_write"))) TS_AnnouncementSignatures_write(uint32_t obj) {
31707         LDKAnnouncementSignatures obj_conv;
31708         obj_conv.inner = (void*)(obj & (~1));
31709         obj_conv.is_owned = false;
31710         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31711         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
31712         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31713         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31714         CVec_u8Z_free(ret_var);
31715         return ret_arr;
31716 }
31717
31718 uint32_t  __attribute__((export_name("TS_AnnouncementSignatures_read"))) TS_AnnouncementSignatures_read(int8_tArray ser) {
31719         LDKu8slice ser_ref;
31720         ser_ref.datalen = ser->arr_len;
31721         ser_ref.data = ser->elems /* XXX ser leaks */;
31722         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
31723         *ret_conv = AnnouncementSignatures_read(ser_ref);
31724         return (uint32_t)ret_conv;
31725 }
31726
31727 int8_tArray  __attribute__((export_name("TS_ChannelReestablish_write"))) TS_ChannelReestablish_write(uint32_t obj) {
31728         LDKChannelReestablish obj_conv;
31729         obj_conv.inner = (void*)(obj & (~1));
31730         obj_conv.is_owned = false;
31731         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31732         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
31733         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31734         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31735         CVec_u8Z_free(ret_var);
31736         return ret_arr;
31737 }
31738
31739 uint32_t  __attribute__((export_name("TS_ChannelReestablish_read"))) TS_ChannelReestablish_read(int8_tArray ser) {
31740         LDKu8slice ser_ref;
31741         ser_ref.datalen = ser->arr_len;
31742         ser_ref.data = ser->elems /* XXX ser leaks */;
31743         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
31744         *ret_conv = ChannelReestablish_read(ser_ref);
31745         return (uint32_t)ret_conv;
31746 }
31747
31748 int8_tArray  __attribute__((export_name("TS_ClosingSigned_write"))) TS_ClosingSigned_write(uint32_t obj) {
31749         LDKClosingSigned obj_conv;
31750         obj_conv.inner = (void*)(obj & (~1));
31751         obj_conv.is_owned = false;
31752         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31753         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
31754         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31755         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31756         CVec_u8Z_free(ret_var);
31757         return ret_arr;
31758 }
31759
31760 uint32_t  __attribute__((export_name("TS_ClosingSigned_read"))) TS_ClosingSigned_read(int8_tArray ser) {
31761         LDKu8slice ser_ref;
31762         ser_ref.datalen = ser->arr_len;
31763         ser_ref.data = ser->elems /* XXX ser leaks */;
31764         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
31765         *ret_conv = ClosingSigned_read(ser_ref);
31766         return (uint32_t)ret_conv;
31767 }
31768
31769 int8_tArray  __attribute__((export_name("TS_ClosingSignedFeeRange_write"))) TS_ClosingSignedFeeRange_write(uint32_t obj) {
31770         LDKClosingSignedFeeRange obj_conv;
31771         obj_conv.inner = (void*)(obj & (~1));
31772         obj_conv.is_owned = false;
31773         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31774         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
31775         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31776         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31777         CVec_u8Z_free(ret_var);
31778         return ret_arr;
31779 }
31780
31781 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_read"))) TS_ClosingSignedFeeRange_read(int8_tArray ser) {
31782         LDKu8slice ser_ref;
31783         ser_ref.datalen = ser->arr_len;
31784         ser_ref.data = ser->elems /* XXX ser leaks */;
31785         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
31786         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
31787         return (uint32_t)ret_conv;
31788 }
31789
31790 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_write"))) TS_CommitmentSigned_write(uint32_t obj) {
31791         LDKCommitmentSigned obj_conv;
31792         obj_conv.inner = (void*)(obj & (~1));
31793         obj_conv.is_owned = false;
31794         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31795         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
31796         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31797         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31798         CVec_u8Z_free(ret_var);
31799         return ret_arr;
31800 }
31801
31802 uint32_t  __attribute__((export_name("TS_CommitmentSigned_read"))) TS_CommitmentSigned_read(int8_tArray ser) {
31803         LDKu8slice ser_ref;
31804         ser_ref.datalen = ser->arr_len;
31805         ser_ref.data = ser->elems /* XXX ser leaks */;
31806         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
31807         *ret_conv = CommitmentSigned_read(ser_ref);
31808         return (uint32_t)ret_conv;
31809 }
31810
31811 int8_tArray  __attribute__((export_name("TS_FundingCreated_write"))) TS_FundingCreated_write(uint32_t obj) {
31812         LDKFundingCreated obj_conv;
31813         obj_conv.inner = (void*)(obj & (~1));
31814         obj_conv.is_owned = false;
31815         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31816         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
31817         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31818         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31819         CVec_u8Z_free(ret_var);
31820         return ret_arr;
31821 }
31822
31823 uint32_t  __attribute__((export_name("TS_FundingCreated_read"))) TS_FundingCreated_read(int8_tArray ser) {
31824         LDKu8slice ser_ref;
31825         ser_ref.datalen = ser->arr_len;
31826         ser_ref.data = ser->elems /* XXX ser leaks */;
31827         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
31828         *ret_conv = FundingCreated_read(ser_ref);
31829         return (uint32_t)ret_conv;
31830 }
31831
31832 int8_tArray  __attribute__((export_name("TS_FundingSigned_write"))) TS_FundingSigned_write(uint32_t obj) {
31833         LDKFundingSigned obj_conv;
31834         obj_conv.inner = (void*)(obj & (~1));
31835         obj_conv.is_owned = false;
31836         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31837         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
31838         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31839         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31840         CVec_u8Z_free(ret_var);
31841         return ret_arr;
31842 }
31843
31844 uint32_t  __attribute__((export_name("TS_FundingSigned_read"))) TS_FundingSigned_read(int8_tArray ser) {
31845         LDKu8slice ser_ref;
31846         ser_ref.datalen = ser->arr_len;
31847         ser_ref.data = ser->elems /* XXX ser leaks */;
31848         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
31849         *ret_conv = FundingSigned_read(ser_ref);
31850         return (uint32_t)ret_conv;
31851 }
31852
31853 int8_tArray  __attribute__((export_name("TS_FundingLocked_write"))) TS_FundingLocked_write(uint32_t obj) {
31854         LDKFundingLocked obj_conv;
31855         obj_conv.inner = (void*)(obj & (~1));
31856         obj_conv.is_owned = false;
31857         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31858         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
31859         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31860         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31861         CVec_u8Z_free(ret_var);
31862         return ret_arr;
31863 }
31864
31865 uint32_t  __attribute__((export_name("TS_FundingLocked_read"))) TS_FundingLocked_read(int8_tArray ser) {
31866         LDKu8slice ser_ref;
31867         ser_ref.datalen = ser->arr_len;
31868         ser_ref.data = ser->elems /* XXX ser leaks */;
31869         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
31870         *ret_conv = FundingLocked_read(ser_ref);
31871         return (uint32_t)ret_conv;
31872 }
31873
31874 int8_tArray  __attribute__((export_name("TS_Init_write"))) TS_Init_write(uint32_t obj) {
31875         LDKInit obj_conv;
31876         obj_conv.inner = (void*)(obj & (~1));
31877         obj_conv.is_owned = false;
31878         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31879         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
31880         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31881         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31882         CVec_u8Z_free(ret_var);
31883         return ret_arr;
31884 }
31885
31886 uint32_t  __attribute__((export_name("TS_Init_read"))) TS_Init_read(int8_tArray ser) {
31887         LDKu8slice ser_ref;
31888         ser_ref.datalen = ser->arr_len;
31889         ser_ref.data = ser->elems /* XXX ser leaks */;
31890         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
31891         *ret_conv = Init_read(ser_ref);
31892         return (uint32_t)ret_conv;
31893 }
31894
31895 int8_tArray  __attribute__((export_name("TS_OpenChannel_write"))) TS_OpenChannel_write(uint32_t obj) {
31896         LDKOpenChannel obj_conv;
31897         obj_conv.inner = (void*)(obj & (~1));
31898         obj_conv.is_owned = false;
31899         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31900         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
31901         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31902         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31903         CVec_u8Z_free(ret_var);
31904         return ret_arr;
31905 }
31906
31907 uint32_t  __attribute__((export_name("TS_OpenChannel_read"))) TS_OpenChannel_read(int8_tArray ser) {
31908         LDKu8slice ser_ref;
31909         ser_ref.datalen = ser->arr_len;
31910         ser_ref.data = ser->elems /* XXX ser leaks */;
31911         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
31912         *ret_conv = OpenChannel_read(ser_ref);
31913         return (uint32_t)ret_conv;
31914 }
31915
31916 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_write"))) TS_RevokeAndACK_write(uint32_t obj) {
31917         LDKRevokeAndACK obj_conv;
31918         obj_conv.inner = (void*)(obj & (~1));
31919         obj_conv.is_owned = false;
31920         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31921         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
31922         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31923         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31924         CVec_u8Z_free(ret_var);
31925         return ret_arr;
31926 }
31927
31928 uint32_t  __attribute__((export_name("TS_RevokeAndACK_read"))) TS_RevokeAndACK_read(int8_tArray ser) {
31929         LDKu8slice ser_ref;
31930         ser_ref.datalen = ser->arr_len;
31931         ser_ref.data = ser->elems /* XXX ser leaks */;
31932         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
31933         *ret_conv = RevokeAndACK_read(ser_ref);
31934         return (uint32_t)ret_conv;
31935 }
31936
31937 int8_tArray  __attribute__((export_name("TS_Shutdown_write"))) TS_Shutdown_write(uint32_t obj) {
31938         LDKShutdown obj_conv;
31939         obj_conv.inner = (void*)(obj & (~1));
31940         obj_conv.is_owned = false;
31941         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31942         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
31943         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31944         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31945         CVec_u8Z_free(ret_var);
31946         return ret_arr;
31947 }
31948
31949 uint32_t  __attribute__((export_name("TS_Shutdown_read"))) TS_Shutdown_read(int8_tArray ser) {
31950         LDKu8slice ser_ref;
31951         ser_ref.datalen = ser->arr_len;
31952         ser_ref.data = ser->elems /* XXX ser leaks */;
31953         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
31954         *ret_conv = Shutdown_read(ser_ref);
31955         return (uint32_t)ret_conv;
31956 }
31957
31958 int8_tArray  __attribute__((export_name("TS_UpdateFailHTLC_write"))) TS_UpdateFailHTLC_write(uint32_t obj) {
31959         LDKUpdateFailHTLC obj_conv;
31960         obj_conv.inner = (void*)(obj & (~1));
31961         obj_conv.is_owned = false;
31962         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31963         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
31964         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31965         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31966         CVec_u8Z_free(ret_var);
31967         return ret_arr;
31968 }
31969
31970 uint32_t  __attribute__((export_name("TS_UpdateFailHTLC_read"))) TS_UpdateFailHTLC_read(int8_tArray ser) {
31971         LDKu8slice ser_ref;
31972         ser_ref.datalen = ser->arr_len;
31973         ser_ref.data = ser->elems /* XXX ser leaks */;
31974         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
31975         *ret_conv = UpdateFailHTLC_read(ser_ref);
31976         return (uint32_t)ret_conv;
31977 }
31978
31979 int8_tArray  __attribute__((export_name("TS_UpdateFailMalformedHTLC_write"))) TS_UpdateFailMalformedHTLC_write(uint32_t obj) {
31980         LDKUpdateFailMalformedHTLC obj_conv;
31981         obj_conv.inner = (void*)(obj & (~1));
31982         obj_conv.is_owned = false;
31983         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31984         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
31985         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31986         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31987         CVec_u8Z_free(ret_var);
31988         return ret_arr;
31989 }
31990
31991 uint32_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_read"))) TS_UpdateFailMalformedHTLC_read(int8_tArray ser) {
31992         LDKu8slice ser_ref;
31993         ser_ref.datalen = ser->arr_len;
31994         ser_ref.data = ser->elems /* XXX ser leaks */;
31995         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
31996         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
31997         return (uint32_t)ret_conv;
31998 }
31999
32000 int8_tArray  __attribute__((export_name("TS_UpdateFee_write"))) TS_UpdateFee_write(uint32_t obj) {
32001         LDKUpdateFee obj_conv;
32002         obj_conv.inner = (void*)(obj & (~1));
32003         obj_conv.is_owned = false;
32004         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32005         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
32006         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32007         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32008         CVec_u8Z_free(ret_var);
32009         return ret_arr;
32010 }
32011
32012 uint32_t  __attribute__((export_name("TS_UpdateFee_read"))) TS_UpdateFee_read(int8_tArray ser) {
32013         LDKu8slice ser_ref;
32014         ser_ref.datalen = ser->arr_len;
32015         ser_ref.data = ser->elems /* XXX ser leaks */;
32016         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
32017         *ret_conv = UpdateFee_read(ser_ref);
32018         return (uint32_t)ret_conv;
32019 }
32020
32021 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_write"))) TS_UpdateFulfillHTLC_write(uint32_t obj) {
32022         LDKUpdateFulfillHTLC obj_conv;
32023         obj_conv.inner = (void*)(obj & (~1));
32024         obj_conv.is_owned = false;
32025         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32026         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
32027         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32028         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32029         CVec_u8Z_free(ret_var);
32030         return ret_arr;
32031 }
32032
32033 uint32_t  __attribute__((export_name("TS_UpdateFulfillHTLC_read"))) TS_UpdateFulfillHTLC_read(int8_tArray ser) {
32034         LDKu8slice ser_ref;
32035         ser_ref.datalen = ser->arr_len;
32036         ser_ref.data = ser->elems /* XXX ser leaks */;
32037         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
32038         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
32039         return (uint32_t)ret_conv;
32040 }
32041
32042 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_write"))) TS_UpdateAddHTLC_write(uint32_t obj) {
32043         LDKUpdateAddHTLC obj_conv;
32044         obj_conv.inner = (void*)(obj & (~1));
32045         obj_conv.is_owned = false;
32046         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32047         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
32048         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32049         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32050         CVec_u8Z_free(ret_var);
32051         return ret_arr;
32052 }
32053
32054 uint32_t  __attribute__((export_name("TS_UpdateAddHTLC_read"))) TS_UpdateAddHTLC_read(int8_tArray ser) {
32055         LDKu8slice ser_ref;
32056         ser_ref.datalen = ser->arr_len;
32057         ser_ref.data = ser->elems /* XXX ser leaks */;
32058         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
32059         *ret_conv = UpdateAddHTLC_read(ser_ref);
32060         return (uint32_t)ret_conv;
32061 }
32062
32063 int8_tArray  __attribute__((export_name("TS_Ping_write"))) TS_Ping_write(uint32_t obj) {
32064         LDKPing obj_conv;
32065         obj_conv.inner = (void*)(obj & (~1));
32066         obj_conv.is_owned = false;
32067         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32068         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
32069         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32070         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32071         CVec_u8Z_free(ret_var);
32072         return ret_arr;
32073 }
32074
32075 uint32_t  __attribute__((export_name("TS_Ping_read"))) TS_Ping_read(int8_tArray ser) {
32076         LDKu8slice ser_ref;
32077         ser_ref.datalen = ser->arr_len;
32078         ser_ref.data = ser->elems /* XXX ser leaks */;
32079         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
32080         *ret_conv = Ping_read(ser_ref);
32081         return (uint32_t)ret_conv;
32082 }
32083
32084 int8_tArray  __attribute__((export_name("TS_Pong_write"))) TS_Pong_write(uint32_t obj) {
32085         LDKPong obj_conv;
32086         obj_conv.inner = (void*)(obj & (~1));
32087         obj_conv.is_owned = false;
32088         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32089         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
32090         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32091         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32092         CVec_u8Z_free(ret_var);
32093         return ret_arr;
32094 }
32095
32096 uint32_t  __attribute__((export_name("TS_Pong_read"))) TS_Pong_read(int8_tArray ser) {
32097         LDKu8slice ser_ref;
32098         ser_ref.datalen = ser->arr_len;
32099         ser_ref.data = ser->elems /* XXX ser leaks */;
32100         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
32101         *ret_conv = Pong_read(ser_ref);
32102         return (uint32_t)ret_conv;
32103 }
32104
32105 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_write"))) TS_UnsignedChannelAnnouncement_write(uint32_t obj) {
32106         LDKUnsignedChannelAnnouncement obj_conv;
32107         obj_conv.inner = (void*)(obj & (~1));
32108         obj_conv.is_owned = false;
32109         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32110         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
32111         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32112         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32113         CVec_u8Z_free(ret_var);
32114         return ret_arr;
32115 }
32116
32117 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_read"))) TS_UnsignedChannelAnnouncement_read(int8_tArray ser) {
32118         LDKu8slice ser_ref;
32119         ser_ref.datalen = ser->arr_len;
32120         ser_ref.data = ser->elems /* XXX ser leaks */;
32121         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
32122         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
32123         return (uint32_t)ret_conv;
32124 }
32125
32126 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_write"))) TS_ChannelAnnouncement_write(uint32_t obj) {
32127         LDKChannelAnnouncement obj_conv;
32128         obj_conv.inner = (void*)(obj & (~1));
32129         obj_conv.is_owned = false;
32130         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32131         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
32132         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32133         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32134         CVec_u8Z_free(ret_var);
32135         return ret_arr;
32136 }
32137
32138 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_read"))) TS_ChannelAnnouncement_read(int8_tArray ser) {
32139         LDKu8slice ser_ref;
32140         ser_ref.datalen = ser->arr_len;
32141         ser_ref.data = ser->elems /* XXX ser leaks */;
32142         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
32143         *ret_conv = ChannelAnnouncement_read(ser_ref);
32144         return (uint32_t)ret_conv;
32145 }
32146
32147 int8_tArray  __attribute__((export_name("TS_UnsignedChannelUpdate_write"))) TS_UnsignedChannelUpdate_write(uint32_t obj) {
32148         LDKUnsignedChannelUpdate obj_conv;
32149         obj_conv.inner = (void*)(obj & (~1));
32150         obj_conv.is_owned = false;
32151         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32152         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
32153         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32154         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32155         CVec_u8Z_free(ret_var);
32156         return ret_arr;
32157 }
32158
32159 uint32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_read"))) TS_UnsignedChannelUpdate_read(int8_tArray ser) {
32160         LDKu8slice ser_ref;
32161         ser_ref.datalen = ser->arr_len;
32162         ser_ref.data = ser->elems /* XXX ser leaks */;
32163         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
32164         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
32165         return (uint32_t)ret_conv;
32166 }
32167
32168 int8_tArray  __attribute__((export_name("TS_ChannelUpdate_write"))) TS_ChannelUpdate_write(uint32_t obj) {
32169         LDKChannelUpdate obj_conv;
32170         obj_conv.inner = (void*)(obj & (~1));
32171         obj_conv.is_owned = false;
32172         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32173         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
32174         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32175         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32176         CVec_u8Z_free(ret_var);
32177         return ret_arr;
32178 }
32179
32180 uint32_t  __attribute__((export_name("TS_ChannelUpdate_read"))) TS_ChannelUpdate_read(int8_tArray ser) {
32181         LDKu8slice ser_ref;
32182         ser_ref.datalen = ser->arr_len;
32183         ser_ref.data = ser->elems /* XXX ser leaks */;
32184         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
32185         *ret_conv = ChannelUpdate_read(ser_ref);
32186         return (uint32_t)ret_conv;
32187 }
32188
32189 int8_tArray  __attribute__((export_name("TS_ErrorMessage_write"))) TS_ErrorMessage_write(uint32_t obj) {
32190         LDKErrorMessage obj_conv;
32191         obj_conv.inner = (void*)(obj & (~1));
32192         obj_conv.is_owned = false;
32193         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32194         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
32195         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32196         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32197         CVec_u8Z_free(ret_var);
32198         return ret_arr;
32199 }
32200
32201 uint32_t  __attribute__((export_name("TS_ErrorMessage_read"))) TS_ErrorMessage_read(int8_tArray ser) {
32202         LDKu8slice ser_ref;
32203         ser_ref.datalen = ser->arr_len;
32204         ser_ref.data = ser->elems /* XXX ser leaks */;
32205         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
32206         *ret_conv = ErrorMessage_read(ser_ref);
32207         return (uint32_t)ret_conv;
32208 }
32209
32210 int8_tArray  __attribute__((export_name("TS_WarningMessage_write"))) TS_WarningMessage_write(uint32_t obj) {
32211         LDKWarningMessage obj_conv;
32212         obj_conv.inner = (void*)(obj & (~1));
32213         obj_conv.is_owned = false;
32214         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32215         LDKCVec_u8Z ret_var = WarningMessage_write(&obj_conv);
32216         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32217         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32218         CVec_u8Z_free(ret_var);
32219         return ret_arr;
32220 }
32221
32222 uint32_t  __attribute__((export_name("TS_WarningMessage_read"))) TS_WarningMessage_read(int8_tArray ser) {
32223         LDKu8slice ser_ref;
32224         ser_ref.datalen = ser->arr_len;
32225         ser_ref.data = ser->elems /* XXX ser leaks */;
32226         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
32227         *ret_conv = WarningMessage_read(ser_ref);
32228         return (uint32_t)ret_conv;
32229 }
32230
32231 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_write"))) TS_UnsignedNodeAnnouncement_write(uint32_t obj) {
32232         LDKUnsignedNodeAnnouncement obj_conv;
32233         obj_conv.inner = (void*)(obj & (~1));
32234         obj_conv.is_owned = false;
32235         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32236         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
32237         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32238         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32239         CVec_u8Z_free(ret_var);
32240         return ret_arr;
32241 }
32242
32243 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_read"))) TS_UnsignedNodeAnnouncement_read(int8_tArray ser) {
32244         LDKu8slice ser_ref;
32245         ser_ref.datalen = ser->arr_len;
32246         ser_ref.data = ser->elems /* XXX ser leaks */;
32247         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
32248         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
32249         return (uint32_t)ret_conv;
32250 }
32251
32252 int8_tArray  __attribute__((export_name("TS_NodeAnnouncement_write"))) TS_NodeAnnouncement_write(uint32_t obj) {
32253         LDKNodeAnnouncement obj_conv;
32254         obj_conv.inner = (void*)(obj & (~1));
32255         obj_conv.is_owned = false;
32256         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32257         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
32258         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32259         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32260         CVec_u8Z_free(ret_var);
32261         return ret_arr;
32262 }
32263
32264 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_read"))) TS_NodeAnnouncement_read(int8_tArray ser) {
32265         LDKu8slice ser_ref;
32266         ser_ref.datalen = ser->arr_len;
32267         ser_ref.data = ser->elems /* XXX ser leaks */;
32268         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
32269         *ret_conv = NodeAnnouncement_read(ser_ref);
32270         return (uint32_t)ret_conv;
32271 }
32272
32273 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_read"))) TS_QueryShortChannelIds_read(int8_tArray ser) {
32274         LDKu8slice ser_ref;
32275         ser_ref.datalen = ser->arr_len;
32276         ser_ref.data = ser->elems /* XXX ser leaks */;
32277         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
32278         *ret_conv = QueryShortChannelIds_read(ser_ref);
32279         return (uint32_t)ret_conv;
32280 }
32281
32282 int8_tArray  __attribute__((export_name("TS_QueryShortChannelIds_write"))) TS_QueryShortChannelIds_write(uint32_t obj) {
32283         LDKQueryShortChannelIds obj_conv;
32284         obj_conv.inner = (void*)(obj & (~1));
32285         obj_conv.is_owned = false;
32286         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32287         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
32288         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32289         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32290         CVec_u8Z_free(ret_var);
32291         return ret_arr;
32292 }
32293
32294 int8_tArray  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_write"))) TS_ReplyShortChannelIdsEnd_write(uint32_t obj) {
32295         LDKReplyShortChannelIdsEnd obj_conv;
32296         obj_conv.inner = (void*)(obj & (~1));
32297         obj_conv.is_owned = false;
32298         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32299         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
32300         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32301         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32302         CVec_u8Z_free(ret_var);
32303         return ret_arr;
32304 }
32305
32306 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_read"))) TS_ReplyShortChannelIdsEnd_read(int8_tArray ser) {
32307         LDKu8slice ser_ref;
32308         ser_ref.datalen = ser->arr_len;
32309         ser_ref.data = ser->elems /* XXX ser leaks */;
32310         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
32311         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
32312         return (uint32_t)ret_conv;
32313 }
32314
32315 int32_t  __attribute__((export_name("TS_QueryChannelRange_end_blocknum"))) TS_QueryChannelRange_end_blocknum(uint32_t this_arg) {
32316         LDKQueryChannelRange this_arg_conv;
32317         this_arg_conv.inner = (void*)(this_arg & (~1));
32318         this_arg_conv.is_owned = false;
32319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32320         int32_t ret_conv = QueryChannelRange_end_blocknum(&this_arg_conv);
32321         return ret_conv;
32322 }
32323
32324 int8_tArray  __attribute__((export_name("TS_QueryChannelRange_write"))) TS_QueryChannelRange_write(uint32_t obj) {
32325         LDKQueryChannelRange obj_conv;
32326         obj_conv.inner = (void*)(obj & (~1));
32327         obj_conv.is_owned = false;
32328         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32329         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
32330         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32331         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32332         CVec_u8Z_free(ret_var);
32333         return ret_arr;
32334 }
32335
32336 uint32_t  __attribute__((export_name("TS_QueryChannelRange_read"))) TS_QueryChannelRange_read(int8_tArray ser) {
32337         LDKu8slice ser_ref;
32338         ser_ref.datalen = ser->arr_len;
32339         ser_ref.data = ser->elems /* XXX ser leaks */;
32340         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
32341         *ret_conv = QueryChannelRange_read(ser_ref);
32342         return (uint32_t)ret_conv;
32343 }
32344
32345 uint32_t  __attribute__((export_name("TS_ReplyChannelRange_read"))) TS_ReplyChannelRange_read(int8_tArray ser) {
32346         LDKu8slice ser_ref;
32347         ser_ref.datalen = ser->arr_len;
32348         ser_ref.data = ser->elems /* XXX ser leaks */;
32349         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
32350         *ret_conv = ReplyChannelRange_read(ser_ref);
32351         return (uint32_t)ret_conv;
32352 }
32353
32354 int8_tArray  __attribute__((export_name("TS_ReplyChannelRange_write"))) TS_ReplyChannelRange_write(uint32_t obj) {
32355         LDKReplyChannelRange obj_conv;
32356         obj_conv.inner = (void*)(obj & (~1));
32357         obj_conv.is_owned = false;
32358         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32359         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
32360         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32361         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32362         CVec_u8Z_free(ret_var);
32363         return ret_arr;
32364 }
32365
32366 int8_tArray  __attribute__((export_name("TS_GossipTimestampFilter_write"))) TS_GossipTimestampFilter_write(uint32_t obj) {
32367         LDKGossipTimestampFilter obj_conv;
32368         obj_conv.inner = (void*)(obj & (~1));
32369         obj_conv.is_owned = false;
32370         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32371         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
32372         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32373         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32374         CVec_u8Z_free(ret_var);
32375         return ret_arr;
32376 }
32377
32378 uint32_t  __attribute__((export_name("TS_GossipTimestampFilter_read"))) TS_GossipTimestampFilter_read(int8_tArray ser) {
32379         LDKu8slice ser_ref;
32380         ser_ref.datalen = ser->arr_len;
32381         ser_ref.data = ser->elems /* XXX ser leaks */;
32382         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
32383         *ret_conv = GossipTimestampFilter_read(ser_ref);
32384         return (uint32_t)ret_conv;
32385 }
32386
32387 void  __attribute__((export_name("TS_CustomMessageHandler_free"))) TS_CustomMessageHandler_free(uint32_t this_ptr) {
32388         if ((this_ptr & 1) != 0) return;
32389         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
32390         CHECK_ACCESS(this_ptr_ptr);
32391         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
32392         FREE((void*)this_ptr);
32393         CustomMessageHandler_free(this_ptr_conv);
32394 }
32395
32396 void  __attribute__((export_name("TS_IgnoringMessageHandler_free"))) TS_IgnoringMessageHandler_free(uint32_t this_obj) {
32397         LDKIgnoringMessageHandler this_obj_conv;
32398         this_obj_conv.inner = (void*)(this_obj & (~1));
32399         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32401         IgnoringMessageHandler_free(this_obj_conv);
32402 }
32403
32404 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_new"))) TS_IgnoringMessageHandler_new() {
32405         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
32406         uint32_t ret_ref = 0;
32407         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32408         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32409         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32410         ret_ref = (uintptr_t)ret_var.inner;
32411         if (ret_var.is_owned) {
32412                 ret_ref |= 1;
32413         }
32414         return ret_ref;
32415 }
32416
32417 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_MessageSendEventsProvider"))) TS_IgnoringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
32418         LDKIgnoringMessageHandler this_arg_conv;
32419         this_arg_conv.inner = (void*)(this_arg & (~1));
32420         this_arg_conv.is_owned = false;
32421         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32422         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
32423         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
32424         return (uint32_t)ret_ret;
32425 }
32426
32427 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_RoutingMessageHandler"))) TS_IgnoringMessageHandler_as_RoutingMessageHandler(uint32_t this_arg) {
32428         LDKIgnoringMessageHandler this_arg_conv;
32429         this_arg_conv.inner = (void*)(this_arg & (~1));
32430         this_arg_conv.is_owned = false;
32431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32432         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
32433         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
32434         return (uint32_t)ret_ret;
32435 }
32436
32437 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_CustomMessageReader"))) TS_IgnoringMessageHandler_as_CustomMessageReader(uint32_t this_arg) {
32438         LDKIgnoringMessageHandler this_arg_conv;
32439         this_arg_conv.inner = (void*)(this_arg & (~1));
32440         this_arg_conv.is_owned = false;
32441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32442         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
32443         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
32444         return (uint32_t)ret_ret;
32445 }
32446
32447 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_CustomMessageHandler"))) TS_IgnoringMessageHandler_as_CustomMessageHandler(uint32_t this_arg) {
32448         LDKIgnoringMessageHandler this_arg_conv;
32449         this_arg_conv.inner = (void*)(this_arg & (~1));
32450         this_arg_conv.is_owned = false;
32451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32452         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
32453         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
32454         return (uint32_t)ret_ret;
32455 }
32456
32457 void  __attribute__((export_name("TS_ErroringMessageHandler_free"))) TS_ErroringMessageHandler_free(uint32_t this_obj) {
32458         LDKErroringMessageHandler this_obj_conv;
32459         this_obj_conv.inner = (void*)(this_obj & (~1));
32460         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32462         ErroringMessageHandler_free(this_obj_conv);
32463 }
32464
32465 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_new"))) TS_ErroringMessageHandler_new() {
32466         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
32467         uint32_t ret_ref = 0;
32468         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32469         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32470         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32471         ret_ref = (uintptr_t)ret_var.inner;
32472         if (ret_var.is_owned) {
32473                 ret_ref |= 1;
32474         }
32475         return ret_ref;
32476 }
32477
32478 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_as_MessageSendEventsProvider"))) TS_ErroringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
32479         LDKErroringMessageHandler this_arg_conv;
32480         this_arg_conv.inner = (void*)(this_arg & (~1));
32481         this_arg_conv.is_owned = false;
32482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32483         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
32484         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
32485         return (uint32_t)ret_ret;
32486 }
32487
32488 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_as_ChannelMessageHandler"))) TS_ErroringMessageHandler_as_ChannelMessageHandler(uint32_t this_arg) {
32489         LDKErroringMessageHandler this_arg_conv;
32490         this_arg_conv.inner = (void*)(this_arg & (~1));
32491         this_arg_conv.is_owned = false;
32492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32493         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
32494         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
32495         return (uint32_t)ret_ret;
32496 }
32497
32498 void  __attribute__((export_name("TS_MessageHandler_free"))) TS_MessageHandler_free(uint32_t this_obj) {
32499         LDKMessageHandler this_obj_conv;
32500         this_obj_conv.inner = (void*)(this_obj & (~1));
32501         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32503         MessageHandler_free(this_obj_conv);
32504 }
32505
32506 uint32_t  __attribute__((export_name("TS_MessageHandler_get_chan_handler"))) TS_MessageHandler_get_chan_handler(uint32_t this_ptr) {
32507         LDKMessageHandler this_ptr_conv;
32508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32509         this_ptr_conv.is_owned = false;
32510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32511         // WARNING: This object doesn't live past this scope, needs clone!
32512         uint32_t ret_ret = ((uintptr_t)MessageHandler_get_chan_handler(&this_ptr_conv)) | 1;
32513         return ret_ret;
32514 }
32515
32516 void  __attribute__((export_name("TS_MessageHandler_set_chan_handler"))) TS_MessageHandler_set_chan_handler(uint32_t this_ptr, uint32_t val) {
32517         LDKMessageHandler this_ptr_conv;
32518         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32519         this_ptr_conv.is_owned = false;
32520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32521         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
32522         CHECK_ACCESS(val_ptr);
32523         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
32524         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
32525                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32526                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
32527         }
32528         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
32529 }
32530
32531 uint32_t  __attribute__((export_name("TS_MessageHandler_get_route_handler"))) TS_MessageHandler_get_route_handler(uint32_t this_ptr) {
32532         LDKMessageHandler this_ptr_conv;
32533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32534         this_ptr_conv.is_owned = false;
32535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32536         // WARNING: This object doesn't live past this scope, needs clone!
32537         uint32_t ret_ret = ((uintptr_t)MessageHandler_get_route_handler(&this_ptr_conv)) | 1;
32538         return ret_ret;
32539 }
32540
32541 void  __attribute__((export_name("TS_MessageHandler_set_route_handler"))) TS_MessageHandler_set_route_handler(uint32_t this_ptr, uint32_t val) {
32542         LDKMessageHandler this_ptr_conv;
32543         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32544         this_ptr_conv.is_owned = false;
32545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32546         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
32547         CHECK_ACCESS(val_ptr);
32548         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
32549         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
32550                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32551                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
32552         }
32553         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
32554 }
32555
32556 uint32_t  __attribute__((export_name("TS_MessageHandler_new"))) TS_MessageHandler_new(uint32_t chan_handler_arg, uint32_t route_handler_arg) {
32557         void* chan_handler_arg_ptr = (void*)(((uintptr_t)chan_handler_arg) & ~1);
32558         CHECK_ACCESS(chan_handler_arg_ptr);
32559         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
32560         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
32561                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32562                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
32563         }
32564         void* route_handler_arg_ptr = (void*)(((uintptr_t)route_handler_arg) & ~1);
32565         CHECK_ACCESS(route_handler_arg_ptr);
32566         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
32567         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
32568                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32569                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
32570         }
32571         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
32572         uint32_t ret_ref = 0;
32573         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32574         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32575         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32576         ret_ref = (uintptr_t)ret_var.inner;
32577         if (ret_var.is_owned) {
32578                 ret_ref |= 1;
32579         }
32580         return ret_ref;
32581 }
32582
32583 static inline uintptr_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
32584         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
32585         *ret_ret = SocketDescriptor_clone(arg);
32586         return (uint32_t)ret_ret;
32587 }
32588 uint32_t  __attribute__((export_name("TS_SocketDescriptor_clone_ptr"))) TS_SocketDescriptor_clone_ptr(uint32_t arg) {
32589         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
32590         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
32591         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
32592         uint32_t ret_conv = SocketDescriptor_clone_ptr(arg_conv);
32593         return ret_conv;
32594 }
32595
32596 uint32_t  __attribute__((export_name("TS_SocketDescriptor_clone"))) TS_SocketDescriptor_clone(uint32_t orig) {
32597         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
32598         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
32599         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
32600         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
32601         *ret_ret = SocketDescriptor_clone(orig_conv);
32602         return (uint32_t)ret_ret;
32603 }
32604
32605 void  __attribute__((export_name("TS_SocketDescriptor_free"))) TS_SocketDescriptor_free(uint32_t this_ptr) {
32606         if ((this_ptr & 1) != 0) return;
32607         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
32608         CHECK_ACCESS(this_ptr_ptr);
32609         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
32610         FREE((void*)this_ptr);
32611         SocketDescriptor_free(this_ptr_conv);
32612 }
32613
32614 void  __attribute__((export_name("TS_PeerHandleError_free"))) TS_PeerHandleError_free(uint32_t this_obj) {
32615         LDKPeerHandleError this_obj_conv;
32616         this_obj_conv.inner = (void*)(this_obj & (~1));
32617         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32619         PeerHandleError_free(this_obj_conv);
32620 }
32621
32622 jboolean  __attribute__((export_name("TS_PeerHandleError_get_no_connection_possible"))) TS_PeerHandleError_get_no_connection_possible(uint32_t this_ptr) {
32623         LDKPeerHandleError this_ptr_conv;
32624         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32625         this_ptr_conv.is_owned = false;
32626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32627         jboolean ret_conv = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
32628         return ret_conv;
32629 }
32630
32631 void  __attribute__((export_name("TS_PeerHandleError_set_no_connection_possible"))) TS_PeerHandleError_set_no_connection_possible(uint32_t this_ptr, jboolean val) {
32632         LDKPeerHandleError this_ptr_conv;
32633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32634         this_ptr_conv.is_owned = false;
32635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32636         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
32637 }
32638
32639 uint32_t  __attribute__((export_name("TS_PeerHandleError_new"))) TS_PeerHandleError_new(jboolean no_connection_possible_arg) {
32640         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
32641         uint32_t ret_ref = 0;
32642         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32643         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32644         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32645         ret_ref = (uintptr_t)ret_var.inner;
32646         if (ret_var.is_owned) {
32647                 ret_ref |= 1;
32648         }
32649         return ret_ref;
32650 }
32651
32652 static inline uintptr_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
32653         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
32654 uint32_t ret_ref = 0;
32655 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32656 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32657 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32658 ret_ref = (uintptr_t)ret_var.inner;
32659 if (ret_var.is_owned) {
32660         ret_ref |= 1;
32661 }
32662         return ret_ref;
32663 }
32664 uint32_t  __attribute__((export_name("TS_PeerHandleError_clone_ptr"))) TS_PeerHandleError_clone_ptr(uint32_t arg) {
32665         LDKPeerHandleError arg_conv;
32666         arg_conv.inner = (void*)(arg & (~1));
32667         arg_conv.is_owned = false;
32668         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32669         uint32_t ret_conv = PeerHandleError_clone_ptr(&arg_conv);
32670         return ret_conv;
32671 }
32672
32673 uint32_t  __attribute__((export_name("TS_PeerHandleError_clone"))) TS_PeerHandleError_clone(uint32_t orig) {
32674         LDKPeerHandleError orig_conv;
32675         orig_conv.inner = (void*)(orig & (~1));
32676         orig_conv.is_owned = false;
32677         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32678         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
32679         uint32_t ret_ref = 0;
32680         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32681         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32682         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32683         ret_ref = (uintptr_t)ret_var.inner;
32684         if (ret_var.is_owned) {
32685                 ret_ref |= 1;
32686         }
32687         return ret_ref;
32688 }
32689
32690 void  __attribute__((export_name("TS_PeerManager_free"))) TS_PeerManager_free(uint32_t this_obj) {
32691         LDKPeerManager this_obj_conv;
32692         this_obj_conv.inner = (void*)(this_obj & (~1));
32693         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32695         PeerManager_free(this_obj_conv);
32696 }
32697
32698 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) {
32699         LDKMessageHandler message_handler_conv;
32700         message_handler_conv.inner = (void*)(message_handler & (~1));
32701         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
32702         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
32703         // WARNING: we need a move here but no clone is available for LDKMessageHandler
32704         LDKSecretKey our_node_secret_ref;
32705         CHECK(our_node_secret->arr_len == 32);
32706         memcpy(our_node_secret_ref.bytes, our_node_secret->elems, 32); FREE(our_node_secret);
32707         unsigned char ephemeral_random_data_arr[32];
32708         CHECK(ephemeral_random_data->arr_len == 32);
32709         memcpy(ephemeral_random_data_arr, ephemeral_random_data->elems, 32); FREE(ephemeral_random_data);
32710         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
32711         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
32712         CHECK_ACCESS(logger_ptr);
32713         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
32714         if (logger_conv.free == LDKLogger_JCalls_free) {
32715                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32716                 LDKLogger_JCalls_cloned(&logger_conv);
32717         }
32718         void* custom_message_handler_ptr = (void*)(((uintptr_t)custom_message_handler) & ~1);
32719         CHECK_ACCESS(custom_message_handler_ptr);
32720         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
32721         if (custom_message_handler_conv.free == LDKCustomMessageHandler_JCalls_free) {
32722                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32723                 LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_conv);
32724         }
32725         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
32726         uint32_t ret_ref = 0;
32727         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32728         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32729         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32730         ret_ref = (uintptr_t)ret_var.inner;
32731         if (ret_var.is_owned) {
32732                 ret_ref |= 1;
32733         }
32734         return ret_ref;
32735 }
32736
32737 ptrArray  __attribute__((export_name("TS_PeerManager_get_peer_node_ids"))) TS_PeerManager_get_peer_node_ids(uint32_t this_arg) {
32738         LDKPeerManager this_arg_conv;
32739         this_arg_conv.inner = (void*)(this_arg & (~1));
32740         this_arg_conv.is_owned = false;
32741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32742         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
32743         ptrArray ret_arr = NULL;
32744         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
32745         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
32746         for (size_t m = 0; m < ret_var.datalen; m++) {
32747                 int8_tArray ret_conv_12_arr = init_int8_tArray(33, __LINE__);
32748                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compressed_form, 33);
32749                 ret_arr_ptr[m] = ret_conv_12_arr;
32750         }
32751         
32752         FREE(ret_var.data);
32753         return ret_arr;
32754 }
32755
32756 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) {
32757         LDKPeerManager this_arg_conv;
32758         this_arg_conv.inner = (void*)(this_arg & (~1));
32759         this_arg_conv.is_owned = false;
32760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32761         LDKPublicKey their_node_id_ref;
32762         CHECK(their_node_id->arr_len == 33);
32763         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
32764         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
32765         CHECK_ACCESS(descriptor_ptr);
32766         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
32767         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
32768                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32769                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
32770         }
32771         void* remote_network_address_ptr = (void*)(((uintptr_t)remote_network_address) & ~1);
32772         CHECK_ACCESS(remote_network_address_ptr);
32773         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
32774         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
32775         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv, remote_network_address_conv);
32776         return (uint32_t)ret_conv;
32777 }
32778
32779 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) {
32780         LDKPeerManager this_arg_conv;
32781         this_arg_conv.inner = (void*)(this_arg & (~1));
32782         this_arg_conv.is_owned = false;
32783         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32784         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
32785         CHECK_ACCESS(descriptor_ptr);
32786         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
32787         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
32788                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32789                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
32790         }
32791         void* remote_network_address_ptr = (void*)(((uintptr_t)remote_network_address) & ~1);
32792         CHECK_ACCESS(remote_network_address_ptr);
32793         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
32794         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
32795         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv, remote_network_address_conv);
32796         return (uint32_t)ret_conv;
32797 }
32798
32799 uint32_t  __attribute__((export_name("TS_PeerManager_write_buffer_space_avail"))) TS_PeerManager_write_buffer_space_avail(uint32_t this_arg, uint32_t descriptor) {
32800         LDKPeerManager this_arg_conv;
32801         this_arg_conv.inner = (void*)(this_arg & (~1));
32802         this_arg_conv.is_owned = false;
32803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32804         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
32805         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
32806         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
32807         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
32808         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
32809         return (uint32_t)ret_conv;
32810 }
32811
32812 uint32_t  __attribute__((export_name("TS_PeerManager_read_event"))) TS_PeerManager_read_event(uint32_t this_arg, uint32_t peer_descriptor, int8_tArray data) {
32813         LDKPeerManager this_arg_conv;
32814         this_arg_conv.inner = (void*)(this_arg & (~1));
32815         this_arg_conv.is_owned = false;
32816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32817         void* peer_descriptor_ptr = (void*)(((uintptr_t)peer_descriptor) & ~1);
32818         if (!(peer_descriptor & 1)) { CHECK_ACCESS(peer_descriptor_ptr); }
32819         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
32820         LDKu8slice data_ref;
32821         data_ref.datalen = data->arr_len;
32822         data_ref.data = data->elems /* XXX data leaks */;
32823         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
32824         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
32825         return (uint32_t)ret_conv;
32826 }
32827
32828 void  __attribute__((export_name("TS_PeerManager_process_events"))) TS_PeerManager_process_events(uint32_t this_arg) {
32829         LDKPeerManager this_arg_conv;
32830         this_arg_conv.inner = (void*)(this_arg & (~1));
32831         this_arg_conv.is_owned = false;
32832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32833         PeerManager_process_events(&this_arg_conv);
32834 }
32835
32836 void  __attribute__((export_name("TS_PeerManager_socket_disconnected"))) TS_PeerManager_socket_disconnected(uint32_t this_arg, uint32_t descriptor) {
32837         LDKPeerManager this_arg_conv;
32838         this_arg_conv.inner = (void*)(this_arg & (~1));
32839         this_arg_conv.is_owned = false;
32840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32841         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
32842         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
32843         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
32844         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
32845 }
32846
32847 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) {
32848         LDKPeerManager this_arg_conv;
32849         this_arg_conv.inner = (void*)(this_arg & (~1));
32850         this_arg_conv.is_owned = false;
32851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32852         LDKPublicKey node_id_ref;
32853         CHECK(node_id->arr_len == 33);
32854         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
32855         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
32856 }
32857
32858 void  __attribute__((export_name("TS_PeerManager_disconnect_all_peers"))) TS_PeerManager_disconnect_all_peers(uint32_t this_arg) {
32859         LDKPeerManager this_arg_conv;
32860         this_arg_conv.inner = (void*)(this_arg & (~1));
32861         this_arg_conv.is_owned = false;
32862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32863         PeerManager_disconnect_all_peers(&this_arg_conv);
32864 }
32865
32866 void  __attribute__((export_name("TS_PeerManager_timer_tick_occurred"))) TS_PeerManager_timer_tick_occurred(uint32_t this_arg) {
32867         LDKPeerManager this_arg_conv;
32868         this_arg_conv.inner = (void*)(this_arg & (~1));
32869         this_arg_conv.is_owned = false;
32870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32871         PeerManager_timer_tick_occurred(&this_arg_conv);
32872 }
32873
32874 int64_t  __attribute__((export_name("TS_htlc_success_tx_weight"))) TS_htlc_success_tx_weight(jboolean opt_anchors) {
32875         int64_t ret_conv = htlc_success_tx_weight(opt_anchors);
32876         return ret_conv;
32877 }
32878
32879 int64_t  __attribute__((export_name("TS_htlc_timeout_tx_weight"))) TS_htlc_timeout_tx_weight(jboolean opt_anchors) {
32880         int64_t ret_conv = htlc_timeout_tx_weight(opt_anchors);
32881         return ret_conv;
32882 }
32883
32884 int8_tArray  __attribute__((export_name("TS_build_commitment_secret"))) TS_build_commitment_secret(int8_tArray commitment_seed, int64_t idx) {
32885         unsigned char commitment_seed_arr[32];
32886         CHECK(commitment_seed->arr_len == 32);
32887         memcpy(commitment_seed_arr, commitment_seed->elems, 32); FREE(commitment_seed);
32888         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
32889         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
32890         memcpy(ret_arr->elems, build_commitment_secret(commitment_seed_ref, idx).data, 32);
32891         return ret_arr;
32892 }
32893
32894 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) {
32895         LDKCVec_u8Z to_holder_script_ref;
32896         to_holder_script_ref.datalen = to_holder_script->arr_len;
32897         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
32898         memcpy(to_holder_script_ref.data, to_holder_script->elems, to_holder_script_ref.datalen); FREE(to_holder_script);
32899         LDKCVec_u8Z to_counterparty_script_ref;
32900         to_counterparty_script_ref.datalen = to_counterparty_script->arr_len;
32901         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
32902         memcpy(to_counterparty_script_ref.data, to_counterparty_script->elems, to_counterparty_script_ref.datalen); FREE(to_counterparty_script);
32903         LDKOutPoint funding_outpoint_conv;
32904         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
32905         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
32906         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
32907         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
32908         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);
32909         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32910         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32911         Transaction_free(ret_var);
32912         return ret_arr;
32913 }
32914
32915 void  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_free"))) TS_CounterpartyCommitmentSecrets_free(uint32_t this_obj) {
32916         LDKCounterpartyCommitmentSecrets this_obj_conv;
32917         this_obj_conv.inner = (void*)(this_obj & (~1));
32918         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32920         CounterpartyCommitmentSecrets_free(this_obj_conv);
32921 }
32922
32923 static inline uintptr_t CounterpartyCommitmentSecrets_clone_ptr(LDKCounterpartyCommitmentSecrets *NONNULL_PTR arg) {
32924         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(arg);
32925 uint32_t ret_ref = 0;
32926 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32927 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32928 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32929 ret_ref = (uintptr_t)ret_var.inner;
32930 if (ret_var.is_owned) {
32931         ret_ref |= 1;
32932 }
32933         return ret_ref;
32934 }
32935 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_clone_ptr"))) TS_CounterpartyCommitmentSecrets_clone_ptr(uint32_t arg) {
32936         LDKCounterpartyCommitmentSecrets arg_conv;
32937         arg_conv.inner = (void*)(arg & (~1));
32938         arg_conv.is_owned = false;
32939         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32940         uint32_t ret_conv = CounterpartyCommitmentSecrets_clone_ptr(&arg_conv);
32941         return ret_conv;
32942 }
32943
32944 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_clone"))) TS_CounterpartyCommitmentSecrets_clone(uint32_t orig) {
32945         LDKCounterpartyCommitmentSecrets orig_conv;
32946         orig_conv.inner = (void*)(orig & (~1));
32947         orig_conv.is_owned = false;
32948         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32949         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(&orig_conv);
32950         uint32_t ret_ref = 0;
32951         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32952         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32953         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32954         ret_ref = (uintptr_t)ret_var.inner;
32955         if (ret_var.is_owned) {
32956                 ret_ref |= 1;
32957         }
32958         return ret_ref;
32959 }
32960
32961 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_new"))) TS_CounterpartyCommitmentSecrets_new() {
32962         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_new();
32963         uint32_t ret_ref = 0;
32964         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32965         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32966         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32967         ret_ref = (uintptr_t)ret_var.inner;
32968         if (ret_var.is_owned) {
32969                 ret_ref |= 1;
32970         }
32971         return ret_ref;
32972 }
32973
32974 int64_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_get_min_seen_secret"))) TS_CounterpartyCommitmentSecrets_get_min_seen_secret(uint32_t this_arg) {
32975         LDKCounterpartyCommitmentSecrets this_arg_conv;
32976         this_arg_conv.inner = (void*)(this_arg & (~1));
32977         this_arg_conv.is_owned = false;
32978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32979         int64_t ret_conv = CounterpartyCommitmentSecrets_get_min_seen_secret(&this_arg_conv);
32980         return ret_conv;
32981 }
32982
32983 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_provide_secret"))) TS_CounterpartyCommitmentSecrets_provide_secret(uint32_t this_arg, int64_t idx, int8_tArray secret) {
32984         LDKCounterpartyCommitmentSecrets this_arg_conv;
32985         this_arg_conv.inner = (void*)(this_arg & (~1));
32986         this_arg_conv.is_owned = false;
32987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32988         LDKThirtyTwoBytes secret_ref;
32989         CHECK(secret->arr_len == 32);
32990         memcpy(secret_ref.data, secret->elems, 32); FREE(secret);
32991         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
32992         *ret_conv = CounterpartyCommitmentSecrets_provide_secret(&this_arg_conv, idx, secret_ref);
32993         return (uint32_t)ret_conv;
32994 }
32995
32996 int8_tArray  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_get_secret"))) TS_CounterpartyCommitmentSecrets_get_secret(uint32_t this_arg, int64_t idx) {
32997         LDKCounterpartyCommitmentSecrets this_arg_conv;
32998         this_arg_conv.inner = (void*)(this_arg & (~1));
32999         this_arg_conv.is_owned = false;
33000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33001         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
33002         memcpy(ret_arr->elems, CounterpartyCommitmentSecrets_get_secret(&this_arg_conv, idx).data, 32);
33003         return ret_arr;
33004 }
33005
33006 int8_tArray  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_write"))) TS_CounterpartyCommitmentSecrets_write(uint32_t obj) {
33007         LDKCounterpartyCommitmentSecrets obj_conv;
33008         obj_conv.inner = (void*)(obj & (~1));
33009         obj_conv.is_owned = false;
33010         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33011         LDKCVec_u8Z ret_var = CounterpartyCommitmentSecrets_write(&obj_conv);
33012         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33013         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33014         CVec_u8Z_free(ret_var);
33015         return ret_arr;
33016 }
33017
33018 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_read"))) TS_CounterpartyCommitmentSecrets_read(int8_tArray ser) {
33019         LDKu8slice ser_ref;
33020         ser_ref.datalen = ser->arr_len;
33021         ser_ref.data = ser->elems /* XXX ser leaks */;
33022         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
33023         *ret_conv = CounterpartyCommitmentSecrets_read(ser_ref);
33024         return (uint32_t)ret_conv;
33025 }
33026
33027 uint32_t  __attribute__((export_name("TS_derive_private_key"))) TS_derive_private_key(int8_tArray per_commitment_point, int8_tArray base_secret) {
33028         LDKPublicKey per_commitment_point_ref;
33029         CHECK(per_commitment_point->arr_len == 33);
33030         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
33031         unsigned char base_secret_arr[32];
33032         CHECK(base_secret->arr_len == 32);
33033         memcpy(base_secret_arr, base_secret->elems, 32); FREE(base_secret);
33034         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
33035         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
33036         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
33037         return (uint32_t)ret_conv;
33038 }
33039
33040 uint32_t  __attribute__((export_name("TS_derive_public_key"))) TS_derive_public_key(int8_tArray per_commitment_point, int8_tArray base_point) {
33041         LDKPublicKey per_commitment_point_ref;
33042         CHECK(per_commitment_point->arr_len == 33);
33043         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
33044         LDKPublicKey base_point_ref;
33045         CHECK(base_point->arr_len == 33);
33046         memcpy(base_point_ref.compressed_form, base_point->elems, 33); FREE(base_point);
33047         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
33048         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
33049         return (uint32_t)ret_conv;
33050 }
33051
33052 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) {
33053         unsigned char per_commitment_secret_arr[32];
33054         CHECK(per_commitment_secret->arr_len == 32);
33055         memcpy(per_commitment_secret_arr, per_commitment_secret->elems, 32); FREE(per_commitment_secret);
33056         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
33057         unsigned char countersignatory_revocation_base_secret_arr[32];
33058         CHECK(countersignatory_revocation_base_secret->arr_len == 32);
33059         memcpy(countersignatory_revocation_base_secret_arr, countersignatory_revocation_base_secret->elems, 32); FREE(countersignatory_revocation_base_secret);
33060         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
33061         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
33062         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
33063         return (uint32_t)ret_conv;
33064 }
33065
33066 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) {
33067         LDKPublicKey per_commitment_point_ref;
33068         CHECK(per_commitment_point->arr_len == 33);
33069         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
33070         LDKPublicKey countersignatory_revocation_base_point_ref;
33071         CHECK(countersignatory_revocation_base_point->arr_len == 33);
33072         memcpy(countersignatory_revocation_base_point_ref.compressed_form, countersignatory_revocation_base_point->elems, 33); FREE(countersignatory_revocation_base_point);
33073         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
33074         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
33075         return (uint32_t)ret_conv;
33076 }
33077
33078 void  __attribute__((export_name("TS_TxCreationKeys_free"))) TS_TxCreationKeys_free(uint32_t this_obj) {
33079         LDKTxCreationKeys this_obj_conv;
33080         this_obj_conv.inner = (void*)(this_obj & (~1));
33081         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33083         TxCreationKeys_free(this_obj_conv);
33084 }
33085
33086 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_per_commitment_point"))) TS_TxCreationKeys_get_per_commitment_point(uint32_t this_ptr) {
33087         LDKTxCreationKeys this_ptr_conv;
33088         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33089         this_ptr_conv.is_owned = false;
33090         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33091         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
33092         memcpy(ret_arr->elems, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
33093         return ret_arr;
33094 }
33095
33096 void  __attribute__((export_name("TS_TxCreationKeys_set_per_commitment_point"))) TS_TxCreationKeys_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
33097         LDKTxCreationKeys this_ptr_conv;
33098         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33099         this_ptr_conv.is_owned = false;
33100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33101         LDKPublicKey val_ref;
33102         CHECK(val->arr_len == 33);
33103         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
33104         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
33105 }
33106
33107 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_revocation_key"))) TS_TxCreationKeys_get_revocation_key(uint32_t this_ptr) {
33108         LDKTxCreationKeys this_ptr_conv;
33109         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33110         this_ptr_conv.is_owned = false;
33111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33112         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
33113         memcpy(ret_arr->elems, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form, 33);
33114         return ret_arr;
33115 }
33116
33117 void  __attribute__((export_name("TS_TxCreationKeys_set_revocation_key"))) TS_TxCreationKeys_set_revocation_key(uint32_t this_ptr, int8_tArray val) {
33118         LDKTxCreationKeys this_ptr_conv;
33119         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33120         this_ptr_conv.is_owned = false;
33121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33122         LDKPublicKey val_ref;
33123         CHECK(val->arr_len == 33);
33124         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
33125         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
33126 }
33127
33128 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_broadcaster_htlc_key"))) TS_TxCreationKeys_get_broadcaster_htlc_key(uint32_t this_ptr) {
33129         LDKTxCreationKeys this_ptr_conv;
33130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33131         this_ptr_conv.is_owned = false;
33132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33133         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
33134         memcpy(ret_arr->elems, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form, 33);
33135         return ret_arr;
33136 }
33137
33138 void  __attribute__((export_name("TS_TxCreationKeys_set_broadcaster_htlc_key"))) TS_TxCreationKeys_set_broadcaster_htlc_key(uint32_t this_ptr, int8_tArray val) {
33139         LDKTxCreationKeys this_ptr_conv;
33140         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33141         this_ptr_conv.is_owned = false;
33142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33143         LDKPublicKey val_ref;
33144         CHECK(val->arr_len == 33);
33145         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
33146         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
33147 }
33148
33149 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_countersignatory_htlc_key"))) TS_TxCreationKeys_get_countersignatory_htlc_key(uint32_t this_ptr) {
33150         LDKTxCreationKeys this_ptr_conv;
33151         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33152         this_ptr_conv.is_owned = false;
33153         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33154         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
33155         memcpy(ret_arr->elems, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form, 33);
33156         return ret_arr;
33157 }
33158
33159 void  __attribute__((export_name("TS_TxCreationKeys_set_countersignatory_htlc_key"))) TS_TxCreationKeys_set_countersignatory_htlc_key(uint32_t this_ptr, int8_tArray val) {
33160         LDKTxCreationKeys this_ptr_conv;
33161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33162         this_ptr_conv.is_owned = false;
33163         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33164         LDKPublicKey val_ref;
33165         CHECK(val->arr_len == 33);
33166         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
33167         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
33168 }
33169
33170 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_broadcaster_delayed_payment_key"))) TS_TxCreationKeys_get_broadcaster_delayed_payment_key(uint32_t this_ptr) {
33171         LDKTxCreationKeys this_ptr_conv;
33172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33173         this_ptr_conv.is_owned = false;
33174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33175         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
33176         memcpy(ret_arr->elems, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form, 33);
33177         return ret_arr;
33178 }
33179
33180 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) {
33181         LDKTxCreationKeys this_ptr_conv;
33182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33183         this_ptr_conv.is_owned = false;
33184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33185         LDKPublicKey val_ref;
33186         CHECK(val->arr_len == 33);
33187         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
33188         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
33189 }
33190
33191 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) {
33192         LDKPublicKey per_commitment_point_arg_ref;
33193         CHECK(per_commitment_point_arg->arr_len == 33);
33194         memcpy(per_commitment_point_arg_ref.compressed_form, per_commitment_point_arg->elems, 33); FREE(per_commitment_point_arg);
33195         LDKPublicKey revocation_key_arg_ref;
33196         CHECK(revocation_key_arg->arr_len == 33);
33197         memcpy(revocation_key_arg_ref.compressed_form, revocation_key_arg->elems, 33); FREE(revocation_key_arg);
33198         LDKPublicKey broadcaster_htlc_key_arg_ref;
33199         CHECK(broadcaster_htlc_key_arg->arr_len == 33);
33200         memcpy(broadcaster_htlc_key_arg_ref.compressed_form, broadcaster_htlc_key_arg->elems, 33); FREE(broadcaster_htlc_key_arg);
33201         LDKPublicKey countersignatory_htlc_key_arg_ref;
33202         CHECK(countersignatory_htlc_key_arg->arr_len == 33);
33203         memcpy(countersignatory_htlc_key_arg_ref.compressed_form, countersignatory_htlc_key_arg->elems, 33); FREE(countersignatory_htlc_key_arg);
33204         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
33205         CHECK(broadcaster_delayed_payment_key_arg->arr_len == 33);
33206         memcpy(broadcaster_delayed_payment_key_arg_ref.compressed_form, broadcaster_delayed_payment_key_arg->elems, 33); FREE(broadcaster_delayed_payment_key_arg);
33207         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);
33208         uint32_t ret_ref = 0;
33209         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33210         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33211         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33212         ret_ref = (uintptr_t)ret_var.inner;
33213         if (ret_var.is_owned) {
33214                 ret_ref |= 1;
33215         }
33216         return ret_ref;
33217 }
33218
33219 static inline uintptr_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
33220         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
33221 uint32_t ret_ref = 0;
33222 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33223 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33224 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33225 ret_ref = (uintptr_t)ret_var.inner;
33226 if (ret_var.is_owned) {
33227         ret_ref |= 1;
33228 }
33229         return ret_ref;
33230 }
33231 uint32_t  __attribute__((export_name("TS_TxCreationKeys_clone_ptr"))) TS_TxCreationKeys_clone_ptr(uint32_t arg) {
33232         LDKTxCreationKeys arg_conv;
33233         arg_conv.inner = (void*)(arg & (~1));
33234         arg_conv.is_owned = false;
33235         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33236         uint32_t ret_conv = TxCreationKeys_clone_ptr(&arg_conv);
33237         return ret_conv;
33238 }
33239
33240 uint32_t  __attribute__((export_name("TS_TxCreationKeys_clone"))) TS_TxCreationKeys_clone(uint32_t orig) {
33241         LDKTxCreationKeys orig_conv;
33242         orig_conv.inner = (void*)(orig & (~1));
33243         orig_conv.is_owned = false;
33244         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33245         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
33246         uint32_t ret_ref = 0;
33247         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33248         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33249         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33250         ret_ref = (uintptr_t)ret_var.inner;
33251         if (ret_var.is_owned) {
33252                 ret_ref |= 1;
33253         }
33254         return ret_ref;
33255 }
33256
33257 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_write"))) TS_TxCreationKeys_write(uint32_t obj) {
33258         LDKTxCreationKeys obj_conv;
33259         obj_conv.inner = (void*)(obj & (~1));
33260         obj_conv.is_owned = false;
33261         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33262         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
33263         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33264         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33265         CVec_u8Z_free(ret_var);
33266         return ret_arr;
33267 }
33268
33269 uint32_t  __attribute__((export_name("TS_TxCreationKeys_read"))) TS_TxCreationKeys_read(int8_tArray ser) {
33270         LDKu8slice ser_ref;
33271         ser_ref.datalen = ser->arr_len;
33272         ser_ref.data = ser->elems /* XXX ser leaks */;
33273         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
33274         *ret_conv = TxCreationKeys_read(ser_ref);
33275         return (uint32_t)ret_conv;
33276 }
33277
33278 void  __attribute__((export_name("TS_ChannelPublicKeys_free"))) TS_ChannelPublicKeys_free(uint32_t this_obj) {
33279         LDKChannelPublicKeys this_obj_conv;
33280         this_obj_conv.inner = (void*)(this_obj & (~1));
33281         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33283         ChannelPublicKeys_free(this_obj_conv);
33284 }
33285
33286 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_funding_pubkey"))) TS_ChannelPublicKeys_get_funding_pubkey(uint32_t this_ptr) {
33287         LDKChannelPublicKeys this_ptr_conv;
33288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33289         this_ptr_conv.is_owned = false;
33290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33291         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
33292         memcpy(ret_arr->elems, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
33293         return ret_arr;
33294 }
33295
33296 void  __attribute__((export_name("TS_ChannelPublicKeys_set_funding_pubkey"))) TS_ChannelPublicKeys_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
33297         LDKChannelPublicKeys this_ptr_conv;
33298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33299         this_ptr_conv.is_owned = false;
33300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33301         LDKPublicKey val_ref;
33302         CHECK(val->arr_len == 33);
33303         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
33304         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
33305 }
33306
33307 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_revocation_basepoint"))) TS_ChannelPublicKeys_get_revocation_basepoint(uint32_t this_ptr) {
33308         LDKChannelPublicKeys this_ptr_conv;
33309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33310         this_ptr_conv.is_owned = false;
33311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33312         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
33313         memcpy(ret_arr->elems, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
33314         return ret_arr;
33315 }
33316
33317 void  __attribute__((export_name("TS_ChannelPublicKeys_set_revocation_basepoint"))) TS_ChannelPublicKeys_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
33318         LDKChannelPublicKeys this_ptr_conv;
33319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33320         this_ptr_conv.is_owned = false;
33321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33322         LDKPublicKey val_ref;
33323         CHECK(val->arr_len == 33);
33324         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
33325         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
33326 }
33327
33328 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_payment_point"))) TS_ChannelPublicKeys_get_payment_point(uint32_t this_ptr) {
33329         LDKChannelPublicKeys this_ptr_conv;
33330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33331         this_ptr_conv.is_owned = false;
33332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33333         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
33334         memcpy(ret_arr->elems, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form, 33);
33335         return ret_arr;
33336 }
33337
33338 void  __attribute__((export_name("TS_ChannelPublicKeys_set_payment_point"))) TS_ChannelPublicKeys_set_payment_point(uint32_t this_ptr, int8_tArray val) {
33339         LDKChannelPublicKeys this_ptr_conv;
33340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33341         this_ptr_conv.is_owned = false;
33342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33343         LDKPublicKey val_ref;
33344         CHECK(val->arr_len == 33);
33345         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
33346         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
33347 }
33348
33349 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_delayed_payment_basepoint"))) TS_ChannelPublicKeys_get_delayed_payment_basepoint(uint32_t this_ptr) {
33350         LDKChannelPublicKeys this_ptr_conv;
33351         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33352         this_ptr_conv.is_owned = false;
33353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33354         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
33355         memcpy(ret_arr->elems, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
33356         return ret_arr;
33357 }
33358
33359 void  __attribute__((export_name("TS_ChannelPublicKeys_set_delayed_payment_basepoint"))) TS_ChannelPublicKeys_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
33360         LDKChannelPublicKeys this_ptr_conv;
33361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33362         this_ptr_conv.is_owned = false;
33363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33364         LDKPublicKey val_ref;
33365         CHECK(val->arr_len == 33);
33366         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
33367         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
33368 }
33369
33370 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_htlc_basepoint"))) TS_ChannelPublicKeys_get_htlc_basepoint(uint32_t this_ptr) {
33371         LDKChannelPublicKeys this_ptr_conv;
33372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33373         this_ptr_conv.is_owned = false;
33374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33375         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
33376         memcpy(ret_arr->elems, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
33377         return ret_arr;
33378 }
33379
33380 void  __attribute__((export_name("TS_ChannelPublicKeys_set_htlc_basepoint"))) TS_ChannelPublicKeys_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
33381         LDKChannelPublicKeys this_ptr_conv;
33382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33383         this_ptr_conv.is_owned = false;
33384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33385         LDKPublicKey val_ref;
33386         CHECK(val->arr_len == 33);
33387         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
33388         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
33389 }
33390
33391 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) {
33392         LDKPublicKey funding_pubkey_arg_ref;
33393         CHECK(funding_pubkey_arg->arr_len == 33);
33394         memcpy(funding_pubkey_arg_ref.compressed_form, funding_pubkey_arg->elems, 33); FREE(funding_pubkey_arg);
33395         LDKPublicKey revocation_basepoint_arg_ref;
33396         CHECK(revocation_basepoint_arg->arr_len == 33);
33397         memcpy(revocation_basepoint_arg_ref.compressed_form, revocation_basepoint_arg->elems, 33); FREE(revocation_basepoint_arg);
33398         LDKPublicKey payment_point_arg_ref;
33399         CHECK(payment_point_arg->arr_len == 33);
33400         memcpy(payment_point_arg_ref.compressed_form, payment_point_arg->elems, 33); FREE(payment_point_arg);
33401         LDKPublicKey delayed_payment_basepoint_arg_ref;
33402         CHECK(delayed_payment_basepoint_arg->arr_len == 33);
33403         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, delayed_payment_basepoint_arg->elems, 33); FREE(delayed_payment_basepoint_arg);
33404         LDKPublicKey htlc_basepoint_arg_ref;
33405         CHECK(htlc_basepoint_arg->arr_len == 33);
33406         memcpy(htlc_basepoint_arg_ref.compressed_form, htlc_basepoint_arg->elems, 33); FREE(htlc_basepoint_arg);
33407         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);
33408         uint32_t ret_ref = 0;
33409         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33410         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33411         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33412         ret_ref = (uintptr_t)ret_var.inner;
33413         if (ret_var.is_owned) {
33414                 ret_ref |= 1;
33415         }
33416         return ret_ref;
33417 }
33418
33419 static inline uintptr_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
33420         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
33421 uint32_t ret_ref = 0;
33422 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33423 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33424 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33425 ret_ref = (uintptr_t)ret_var.inner;
33426 if (ret_var.is_owned) {
33427         ret_ref |= 1;
33428 }
33429         return ret_ref;
33430 }
33431 uint32_t  __attribute__((export_name("TS_ChannelPublicKeys_clone_ptr"))) TS_ChannelPublicKeys_clone_ptr(uint32_t arg) {
33432         LDKChannelPublicKeys arg_conv;
33433         arg_conv.inner = (void*)(arg & (~1));
33434         arg_conv.is_owned = false;
33435         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33436         uint32_t ret_conv = ChannelPublicKeys_clone_ptr(&arg_conv);
33437         return ret_conv;
33438 }
33439
33440 uint32_t  __attribute__((export_name("TS_ChannelPublicKeys_clone"))) TS_ChannelPublicKeys_clone(uint32_t orig) {
33441         LDKChannelPublicKeys orig_conv;
33442         orig_conv.inner = (void*)(orig & (~1));
33443         orig_conv.is_owned = false;
33444         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33445         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
33446         uint32_t ret_ref = 0;
33447         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33448         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33449         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33450         ret_ref = (uintptr_t)ret_var.inner;
33451         if (ret_var.is_owned) {
33452                 ret_ref |= 1;
33453         }
33454         return ret_ref;
33455 }
33456
33457 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_write"))) TS_ChannelPublicKeys_write(uint32_t obj) {
33458         LDKChannelPublicKeys obj_conv;
33459         obj_conv.inner = (void*)(obj & (~1));
33460         obj_conv.is_owned = false;
33461         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33462         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
33463         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33464         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33465         CVec_u8Z_free(ret_var);
33466         return ret_arr;
33467 }
33468
33469 uint32_t  __attribute__((export_name("TS_ChannelPublicKeys_read"))) TS_ChannelPublicKeys_read(int8_tArray ser) {
33470         LDKu8slice ser_ref;
33471         ser_ref.datalen = ser->arr_len;
33472         ser_ref.data = ser->elems /* XXX ser leaks */;
33473         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
33474         *ret_conv = ChannelPublicKeys_read(ser_ref);
33475         return (uint32_t)ret_conv;
33476 }
33477
33478 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) {
33479         LDKPublicKey per_commitment_point_ref;
33480         CHECK(per_commitment_point->arr_len == 33);
33481         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
33482         LDKPublicKey broadcaster_delayed_payment_base_ref;
33483         CHECK(broadcaster_delayed_payment_base->arr_len == 33);
33484         memcpy(broadcaster_delayed_payment_base_ref.compressed_form, broadcaster_delayed_payment_base->elems, 33); FREE(broadcaster_delayed_payment_base);
33485         LDKPublicKey broadcaster_htlc_base_ref;
33486         CHECK(broadcaster_htlc_base->arr_len == 33);
33487         memcpy(broadcaster_htlc_base_ref.compressed_form, broadcaster_htlc_base->elems, 33); FREE(broadcaster_htlc_base);
33488         LDKPublicKey countersignatory_revocation_base_ref;
33489         CHECK(countersignatory_revocation_base->arr_len == 33);
33490         memcpy(countersignatory_revocation_base_ref.compressed_form, countersignatory_revocation_base->elems, 33); FREE(countersignatory_revocation_base);
33491         LDKPublicKey countersignatory_htlc_base_ref;
33492         CHECK(countersignatory_htlc_base->arr_len == 33);
33493         memcpy(countersignatory_htlc_base_ref.compressed_form, countersignatory_htlc_base->elems, 33); FREE(countersignatory_htlc_base);
33494         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
33495         *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);
33496         return (uint32_t)ret_conv;
33497 }
33498
33499 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) {
33500         LDKPublicKey per_commitment_point_ref;
33501         CHECK(per_commitment_point->arr_len == 33);
33502         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
33503         LDKChannelPublicKeys broadcaster_keys_conv;
33504         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
33505         broadcaster_keys_conv.is_owned = false;
33506         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
33507         LDKChannelPublicKeys countersignatory_keys_conv;
33508         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
33509         countersignatory_keys_conv.is_owned = false;
33510         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
33511         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
33512         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
33513         return (uint32_t)ret_conv;
33514 }
33515
33516 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) {
33517         LDKPublicKey revocation_key_ref;
33518         CHECK(revocation_key->arr_len == 33);
33519         memcpy(revocation_key_ref.compressed_form, revocation_key->elems, 33); FREE(revocation_key);
33520         LDKPublicKey broadcaster_delayed_payment_key_ref;
33521         CHECK(broadcaster_delayed_payment_key->arr_len == 33);
33522         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, broadcaster_delayed_payment_key->elems, 33); FREE(broadcaster_delayed_payment_key);
33523         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
33524         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33525         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33526         CVec_u8Z_free(ret_var);
33527         return ret_arr;
33528 }
33529
33530 void  __attribute__((export_name("TS_HTLCOutputInCommitment_free"))) TS_HTLCOutputInCommitment_free(uint32_t this_obj) {
33531         LDKHTLCOutputInCommitment this_obj_conv;
33532         this_obj_conv.inner = (void*)(this_obj & (~1));
33533         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33535         HTLCOutputInCommitment_free(this_obj_conv);
33536 }
33537
33538 jboolean  __attribute__((export_name("TS_HTLCOutputInCommitment_get_offered"))) TS_HTLCOutputInCommitment_get_offered(uint32_t this_ptr) {
33539         LDKHTLCOutputInCommitment this_ptr_conv;
33540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33541         this_ptr_conv.is_owned = false;
33542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33543         jboolean ret_conv = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
33544         return ret_conv;
33545 }
33546
33547 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_offered"))) TS_HTLCOutputInCommitment_set_offered(uint32_t this_ptr, jboolean val) {
33548         LDKHTLCOutputInCommitment this_ptr_conv;
33549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33550         this_ptr_conv.is_owned = false;
33551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33552         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
33553 }
33554
33555 int64_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_amount_msat"))) TS_HTLCOutputInCommitment_get_amount_msat(uint32_t this_ptr) {
33556         LDKHTLCOutputInCommitment this_ptr_conv;
33557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33558         this_ptr_conv.is_owned = false;
33559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33560         int64_t ret_conv = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
33561         return ret_conv;
33562 }
33563
33564 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_amount_msat"))) TS_HTLCOutputInCommitment_set_amount_msat(uint32_t this_ptr, int64_t val) {
33565         LDKHTLCOutputInCommitment this_ptr_conv;
33566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33567         this_ptr_conv.is_owned = false;
33568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33569         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
33570 }
33571
33572 int32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_cltv_expiry"))) TS_HTLCOutputInCommitment_get_cltv_expiry(uint32_t this_ptr) {
33573         LDKHTLCOutputInCommitment this_ptr_conv;
33574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33575         this_ptr_conv.is_owned = false;
33576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33577         int32_t ret_conv = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
33578         return ret_conv;
33579 }
33580
33581 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_cltv_expiry"))) TS_HTLCOutputInCommitment_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
33582         LDKHTLCOutputInCommitment this_ptr_conv;
33583         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33584         this_ptr_conv.is_owned = false;
33585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33586         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
33587 }
33588
33589 int8_tArray  __attribute__((export_name("TS_HTLCOutputInCommitment_get_payment_hash"))) TS_HTLCOutputInCommitment_get_payment_hash(uint32_t this_ptr) {
33590         LDKHTLCOutputInCommitment this_ptr_conv;
33591         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33592         this_ptr_conv.is_owned = false;
33593         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33594         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
33595         memcpy(ret_arr->elems, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv), 32);
33596         return ret_arr;
33597 }
33598
33599 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_payment_hash"))) TS_HTLCOutputInCommitment_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
33600         LDKHTLCOutputInCommitment this_ptr_conv;
33601         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33602         this_ptr_conv.is_owned = false;
33603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33604         LDKThirtyTwoBytes val_ref;
33605         CHECK(val->arr_len == 32);
33606         memcpy(val_ref.data, val->elems, 32); FREE(val);
33607         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
33608 }
33609
33610 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_transaction_output_index"))) TS_HTLCOutputInCommitment_get_transaction_output_index(uint32_t this_ptr) {
33611         LDKHTLCOutputInCommitment this_ptr_conv;
33612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33613         this_ptr_conv.is_owned = false;
33614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33615         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
33616         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
33617         uint32_t ret_ref = (uintptr_t)ret_copy;
33618         return ret_ref;
33619 }
33620
33621 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_transaction_output_index"))) TS_HTLCOutputInCommitment_set_transaction_output_index(uint32_t this_ptr, uint32_t val) {
33622         LDKHTLCOutputInCommitment this_ptr_conv;
33623         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33624         this_ptr_conv.is_owned = false;
33625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33626         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
33627         CHECK_ACCESS(val_ptr);
33628         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
33629         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
33630         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
33631 }
33632
33633 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) {
33634         LDKThirtyTwoBytes payment_hash_arg_ref;
33635         CHECK(payment_hash_arg->arr_len == 32);
33636         memcpy(payment_hash_arg_ref.data, payment_hash_arg->elems, 32); FREE(payment_hash_arg);
33637         void* transaction_output_index_arg_ptr = (void*)(((uintptr_t)transaction_output_index_arg) & ~1);
33638         CHECK_ACCESS(transaction_output_index_arg_ptr);
33639         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
33640         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)transaction_output_index_arg) & ~1));
33641         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
33642         uint32_t ret_ref = 0;
33643         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33644         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33645         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33646         ret_ref = (uintptr_t)ret_var.inner;
33647         if (ret_var.is_owned) {
33648                 ret_ref |= 1;
33649         }
33650         return ret_ref;
33651 }
33652
33653 static inline uintptr_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
33654         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
33655 uint32_t ret_ref = 0;
33656 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33657 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33658 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33659 ret_ref = (uintptr_t)ret_var.inner;
33660 if (ret_var.is_owned) {
33661         ret_ref |= 1;
33662 }
33663         return ret_ref;
33664 }
33665 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_clone_ptr"))) TS_HTLCOutputInCommitment_clone_ptr(uint32_t arg) {
33666         LDKHTLCOutputInCommitment arg_conv;
33667         arg_conv.inner = (void*)(arg & (~1));
33668         arg_conv.is_owned = false;
33669         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33670         uint32_t ret_conv = HTLCOutputInCommitment_clone_ptr(&arg_conv);
33671         return ret_conv;
33672 }
33673
33674 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_clone"))) TS_HTLCOutputInCommitment_clone(uint32_t orig) {
33675         LDKHTLCOutputInCommitment orig_conv;
33676         orig_conv.inner = (void*)(orig & (~1));
33677         orig_conv.is_owned = false;
33678         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33679         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
33680         uint32_t ret_ref = 0;
33681         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33682         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33683         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33684         ret_ref = (uintptr_t)ret_var.inner;
33685         if (ret_var.is_owned) {
33686                 ret_ref |= 1;
33687         }
33688         return ret_ref;
33689 }
33690
33691 int8_tArray  __attribute__((export_name("TS_HTLCOutputInCommitment_write"))) TS_HTLCOutputInCommitment_write(uint32_t obj) {
33692         LDKHTLCOutputInCommitment obj_conv;
33693         obj_conv.inner = (void*)(obj & (~1));
33694         obj_conv.is_owned = false;
33695         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33696         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
33697         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33698         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33699         CVec_u8Z_free(ret_var);
33700         return ret_arr;
33701 }
33702
33703 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_read"))) TS_HTLCOutputInCommitment_read(int8_tArray ser) {
33704         LDKu8slice ser_ref;
33705         ser_ref.datalen = ser->arr_len;
33706         ser_ref.data = ser->elems /* XXX ser leaks */;
33707         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
33708         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
33709         return (uint32_t)ret_conv;
33710 }
33711
33712 int8_tArray  __attribute__((export_name("TS_get_htlc_redeemscript"))) TS_get_htlc_redeemscript(uint32_t htlc, jboolean opt_anchors, uint32_t keys) {
33713         LDKHTLCOutputInCommitment htlc_conv;
33714         htlc_conv.inner = (void*)(htlc & (~1));
33715         htlc_conv.is_owned = false;
33716         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
33717         LDKTxCreationKeys keys_conv;
33718         keys_conv.inner = (void*)(keys & (~1));
33719         keys_conv.is_owned = false;
33720         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
33721         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, opt_anchors, &keys_conv);
33722         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33723         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33724         CVec_u8Z_free(ret_var);
33725         return ret_arr;
33726 }
33727
33728 int8_tArray  __attribute__((export_name("TS_make_funding_redeemscript"))) TS_make_funding_redeemscript(int8_tArray broadcaster, int8_tArray countersignatory) {
33729         LDKPublicKey broadcaster_ref;
33730         CHECK(broadcaster->arr_len == 33);
33731         memcpy(broadcaster_ref.compressed_form, broadcaster->elems, 33); FREE(broadcaster);
33732         LDKPublicKey countersignatory_ref;
33733         CHECK(countersignatory->arr_len == 33);
33734         memcpy(countersignatory_ref.compressed_form, countersignatory->elems, 33); FREE(countersignatory);
33735         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
33736         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33737         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33738         CVec_u8Z_free(ret_var);
33739         return ret_arr;
33740 }
33741
33742 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) {
33743         unsigned char commitment_txid_arr[32];
33744         CHECK(commitment_txid->arr_len == 32);
33745         memcpy(commitment_txid_arr, commitment_txid->elems, 32); FREE(commitment_txid);
33746         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
33747         LDKHTLCOutputInCommitment htlc_conv;
33748         htlc_conv.inner = (void*)(htlc & (~1));
33749         htlc_conv.is_owned = false;
33750         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
33751         LDKPublicKey broadcaster_delayed_payment_key_ref;
33752         CHECK(broadcaster_delayed_payment_key->arr_len == 33);
33753         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, broadcaster_delayed_payment_key->elems, 33); FREE(broadcaster_delayed_payment_key);
33754         LDKPublicKey revocation_key_ref;
33755         CHECK(revocation_key->arr_len == 33);
33756         memcpy(revocation_key_ref.compressed_form, revocation_key->elems, 33); FREE(revocation_key);
33757         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);
33758         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33759         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33760         Transaction_free(ret_var);
33761         return ret_arr;
33762 }
33763
33764 int8_tArray  __attribute__((export_name("TS_get_anchor_redeemscript"))) TS_get_anchor_redeemscript(int8_tArray funding_pubkey) {
33765         LDKPublicKey funding_pubkey_ref;
33766         CHECK(funding_pubkey->arr_len == 33);
33767         memcpy(funding_pubkey_ref.compressed_form, funding_pubkey->elems, 33); FREE(funding_pubkey);
33768         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
33769         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33770         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33771         CVec_u8Z_free(ret_var);
33772         return ret_arr;
33773 }
33774
33775 void  __attribute__((export_name("TS_ChannelTransactionParameters_free"))) TS_ChannelTransactionParameters_free(uint32_t this_obj) {
33776         LDKChannelTransactionParameters this_obj_conv;
33777         this_obj_conv.inner = (void*)(this_obj & (~1));
33778         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33780         ChannelTransactionParameters_free(this_obj_conv);
33781 }
33782
33783 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_holder_pubkeys"))) TS_ChannelTransactionParameters_get_holder_pubkeys(uint32_t this_ptr) {
33784         LDKChannelTransactionParameters this_ptr_conv;
33785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33786         this_ptr_conv.is_owned = false;
33787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33788         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
33789         uint32_t ret_ref = 0;
33790         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33791         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33792         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33793         ret_ref = (uintptr_t)ret_var.inner;
33794         if (ret_var.is_owned) {
33795                 ret_ref |= 1;
33796         }
33797         return ret_ref;
33798 }
33799
33800 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_holder_pubkeys"))) TS_ChannelTransactionParameters_set_holder_pubkeys(uint32_t this_ptr, uint32_t val) {
33801         LDKChannelTransactionParameters this_ptr_conv;
33802         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33803         this_ptr_conv.is_owned = false;
33804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33805         LDKChannelPublicKeys val_conv;
33806         val_conv.inner = (void*)(val & (~1));
33807         val_conv.is_owned = (val & 1) || (val == 0);
33808         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33809         val_conv = ChannelPublicKeys_clone(&val_conv);
33810         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
33811 }
33812
33813 int16_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_holder_selected_contest_delay"))) TS_ChannelTransactionParameters_get_holder_selected_contest_delay(uint32_t this_ptr) {
33814         LDKChannelTransactionParameters this_ptr_conv;
33815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33816         this_ptr_conv.is_owned = false;
33817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33818         int16_t ret_conv = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
33819         return ret_conv;
33820 }
33821
33822 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) {
33823         LDKChannelTransactionParameters this_ptr_conv;
33824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33825         this_ptr_conv.is_owned = false;
33826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33827         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
33828 }
33829
33830 jboolean  __attribute__((export_name("TS_ChannelTransactionParameters_get_is_outbound_from_holder"))) TS_ChannelTransactionParameters_get_is_outbound_from_holder(uint32_t this_ptr) {
33831         LDKChannelTransactionParameters this_ptr_conv;
33832         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33833         this_ptr_conv.is_owned = false;
33834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33835         jboolean ret_conv = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
33836         return ret_conv;
33837 }
33838
33839 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_is_outbound_from_holder"))) TS_ChannelTransactionParameters_set_is_outbound_from_holder(uint32_t this_ptr, jboolean val) {
33840         LDKChannelTransactionParameters this_ptr_conv;
33841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33842         this_ptr_conv.is_owned = false;
33843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33844         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
33845 }
33846
33847 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_counterparty_parameters"))) TS_ChannelTransactionParameters_get_counterparty_parameters(uint32_t this_ptr) {
33848         LDKChannelTransactionParameters this_ptr_conv;
33849         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33850         this_ptr_conv.is_owned = false;
33851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33852         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
33853         uint32_t ret_ref = 0;
33854         if ((uintptr_t)ret_var.inner > 4096) {
33855                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33856                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33857         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33858                 ret_ref = (uintptr_t)ret_var.inner;
33859                 if (ret_var.is_owned) {
33860                         ret_ref |= 1;
33861                 }
33862         }
33863         return ret_ref;
33864 }
33865
33866 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_counterparty_parameters"))) TS_ChannelTransactionParameters_set_counterparty_parameters(uint32_t this_ptr, uint32_t val) {
33867         LDKChannelTransactionParameters this_ptr_conv;
33868         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33869         this_ptr_conv.is_owned = false;
33870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33871         LDKCounterpartyChannelTransactionParameters val_conv;
33872         val_conv.inner = (void*)(val & (~1));
33873         val_conv.is_owned = (val & 1) || (val == 0);
33874         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33875         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
33876         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
33877 }
33878
33879 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_funding_outpoint"))) TS_ChannelTransactionParameters_get_funding_outpoint(uint32_t this_ptr) {
33880         LDKChannelTransactionParameters this_ptr_conv;
33881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33882         this_ptr_conv.is_owned = false;
33883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33884         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
33885         uint32_t ret_ref = 0;
33886         if ((uintptr_t)ret_var.inner > 4096) {
33887                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33888                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33889         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33890                 ret_ref = (uintptr_t)ret_var.inner;
33891                 if (ret_var.is_owned) {
33892                         ret_ref |= 1;
33893                 }
33894         }
33895         return ret_ref;
33896 }
33897
33898 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_funding_outpoint"))) TS_ChannelTransactionParameters_set_funding_outpoint(uint32_t this_ptr, uint32_t val) {
33899         LDKChannelTransactionParameters this_ptr_conv;
33900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33901         this_ptr_conv.is_owned = false;
33902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33903         LDKOutPoint val_conv;
33904         val_conv.inner = (void*)(val & (~1));
33905         val_conv.is_owned = (val & 1) || (val == 0);
33906         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33907         val_conv = OutPoint_clone(&val_conv);
33908         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
33909 }
33910
33911 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_opt_anchors"))) TS_ChannelTransactionParameters_get_opt_anchors(uint32_t this_ptr) {
33912         LDKChannelTransactionParameters this_ptr_conv;
33913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33914         this_ptr_conv.is_owned = false;
33915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33916         uint32_t ret_conv = LDKCOption_NoneZ_to_js(ChannelTransactionParameters_get_opt_anchors(&this_ptr_conv));
33917         return ret_conv;
33918 }
33919
33920 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_opt_anchors"))) TS_ChannelTransactionParameters_set_opt_anchors(uint32_t this_ptr, uint32_t val) {
33921         LDKChannelTransactionParameters this_ptr_conv;
33922         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33923         this_ptr_conv.is_owned = false;
33924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33925         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_js(val);
33926         ChannelTransactionParameters_set_opt_anchors(&this_ptr_conv, val_conv);
33927 }
33928
33929 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) {
33930         LDKChannelPublicKeys holder_pubkeys_arg_conv;
33931         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
33932         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
33933         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
33934         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
33935         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
33936         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
33937         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
33938         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
33939         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
33940         LDKOutPoint funding_outpoint_arg_conv;
33941         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
33942         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
33943         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
33944         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
33945         LDKCOption_NoneZ opt_anchors_arg_conv = LDKCOption_NoneZ_from_js(opt_anchors_arg);
33946         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);
33947         uint32_t ret_ref = 0;
33948         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33949         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33950         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33951         ret_ref = (uintptr_t)ret_var.inner;
33952         if (ret_var.is_owned) {
33953                 ret_ref |= 1;
33954         }
33955         return ret_ref;
33956 }
33957
33958 static inline uintptr_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
33959         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
33960 uint32_t ret_ref = 0;
33961 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33962 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33963 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33964 ret_ref = (uintptr_t)ret_var.inner;
33965 if (ret_var.is_owned) {
33966         ret_ref |= 1;
33967 }
33968         return ret_ref;
33969 }
33970 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_clone_ptr"))) TS_ChannelTransactionParameters_clone_ptr(uint32_t arg) {
33971         LDKChannelTransactionParameters arg_conv;
33972         arg_conv.inner = (void*)(arg & (~1));
33973         arg_conv.is_owned = false;
33974         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33975         uint32_t ret_conv = ChannelTransactionParameters_clone_ptr(&arg_conv);
33976         return ret_conv;
33977 }
33978
33979 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_clone"))) TS_ChannelTransactionParameters_clone(uint32_t orig) {
33980         LDKChannelTransactionParameters orig_conv;
33981         orig_conv.inner = (void*)(orig & (~1));
33982         orig_conv.is_owned = false;
33983         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33984         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
33985         uint32_t ret_ref = 0;
33986         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33987         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33988         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33989         ret_ref = (uintptr_t)ret_var.inner;
33990         if (ret_var.is_owned) {
33991                 ret_ref |= 1;
33992         }
33993         return ret_ref;
33994 }
33995
33996 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_free"))) TS_CounterpartyChannelTransactionParameters_free(uint32_t this_obj) {
33997         LDKCounterpartyChannelTransactionParameters this_obj_conv;
33998         this_obj_conv.inner = (void*)(this_obj & (~1));
33999         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34001         CounterpartyChannelTransactionParameters_free(this_obj_conv);
34002 }
34003
34004 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_get_pubkeys"))) TS_CounterpartyChannelTransactionParameters_get_pubkeys(uint32_t this_ptr) {
34005         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
34006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34007         this_ptr_conv.is_owned = false;
34008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34009         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
34010         uint32_t ret_ref = 0;
34011         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34012         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34013         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34014         ret_ref = (uintptr_t)ret_var.inner;
34015         if (ret_var.is_owned) {
34016                 ret_ref |= 1;
34017         }
34018         return ret_ref;
34019 }
34020
34021 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_set_pubkeys"))) TS_CounterpartyChannelTransactionParameters_set_pubkeys(uint32_t this_ptr, uint32_t val) {
34022         LDKCounterpartyChannelTransactionParameters 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         LDKChannelPublicKeys val_conv;
34027         val_conv.inner = (void*)(val & (~1));
34028         val_conv.is_owned = (val & 1) || (val == 0);
34029         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34030         val_conv = ChannelPublicKeys_clone(&val_conv);
34031         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
34032 }
34033
34034 int16_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay"))) TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay(uint32_t this_ptr) {
34035         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
34036         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34037         this_ptr_conv.is_owned = false;
34038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34039         int16_t ret_conv = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
34040         return ret_conv;
34041 }
34042
34043 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay"))) TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay(uint32_t this_ptr, int16_t val) {
34044         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
34045         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34046         this_ptr_conv.is_owned = false;
34047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34048         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
34049 }
34050
34051 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_new"))) TS_CounterpartyChannelTransactionParameters_new(uint32_t pubkeys_arg, int16_t selected_contest_delay_arg) {
34052         LDKChannelPublicKeys pubkeys_arg_conv;
34053         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
34054         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
34055         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
34056         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
34057         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
34058         uint32_t ret_ref = 0;
34059         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34060         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34061         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34062         ret_ref = (uintptr_t)ret_var.inner;
34063         if (ret_var.is_owned) {
34064                 ret_ref |= 1;
34065         }
34066         return ret_ref;
34067 }
34068
34069 static inline uintptr_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
34070         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
34071 uint32_t ret_ref = 0;
34072 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34073 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34074 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34075 ret_ref = (uintptr_t)ret_var.inner;
34076 if (ret_var.is_owned) {
34077         ret_ref |= 1;
34078 }
34079         return ret_ref;
34080 }
34081 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_clone_ptr"))) TS_CounterpartyChannelTransactionParameters_clone_ptr(uint32_t arg) {
34082         LDKCounterpartyChannelTransactionParameters arg_conv;
34083         arg_conv.inner = (void*)(arg & (~1));
34084         arg_conv.is_owned = false;
34085         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34086         uint32_t ret_conv = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
34087         return ret_conv;
34088 }
34089
34090 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_clone"))) TS_CounterpartyChannelTransactionParameters_clone(uint32_t orig) {
34091         LDKCounterpartyChannelTransactionParameters orig_conv;
34092         orig_conv.inner = (void*)(orig & (~1));
34093         orig_conv.is_owned = false;
34094         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34095         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
34096         uint32_t ret_ref = 0;
34097         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34098         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34099         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34100         ret_ref = (uintptr_t)ret_var.inner;
34101         if (ret_var.is_owned) {
34102                 ret_ref |= 1;
34103         }
34104         return ret_ref;
34105 }
34106
34107 jboolean  __attribute__((export_name("TS_ChannelTransactionParameters_is_populated"))) TS_ChannelTransactionParameters_is_populated(uint32_t this_arg) {
34108         LDKChannelTransactionParameters this_arg_conv;
34109         this_arg_conv.inner = (void*)(this_arg & (~1));
34110         this_arg_conv.is_owned = false;
34111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34112         jboolean ret_conv = ChannelTransactionParameters_is_populated(&this_arg_conv);
34113         return ret_conv;
34114 }
34115
34116 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_as_holder_broadcastable"))) TS_ChannelTransactionParameters_as_holder_broadcastable(uint32_t this_arg) {
34117         LDKChannelTransactionParameters this_arg_conv;
34118         this_arg_conv.inner = (void*)(this_arg & (~1));
34119         this_arg_conv.is_owned = false;
34120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34121         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
34122         uint32_t ret_ref = 0;
34123         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34124         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34125         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34126         ret_ref = (uintptr_t)ret_var.inner;
34127         if (ret_var.is_owned) {
34128                 ret_ref |= 1;
34129         }
34130         return ret_ref;
34131 }
34132
34133 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_as_counterparty_broadcastable"))) TS_ChannelTransactionParameters_as_counterparty_broadcastable(uint32_t this_arg) {
34134         LDKChannelTransactionParameters this_arg_conv;
34135         this_arg_conv.inner = (void*)(this_arg & (~1));
34136         this_arg_conv.is_owned = false;
34137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34138         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
34139         uint32_t ret_ref = 0;
34140         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34141         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34142         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34143         ret_ref = (uintptr_t)ret_var.inner;
34144         if (ret_var.is_owned) {
34145                 ret_ref |= 1;
34146         }
34147         return ret_ref;
34148 }
34149
34150 int8_tArray  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_write"))) TS_CounterpartyChannelTransactionParameters_write(uint32_t obj) {
34151         LDKCounterpartyChannelTransactionParameters obj_conv;
34152         obj_conv.inner = (void*)(obj & (~1));
34153         obj_conv.is_owned = false;
34154         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34155         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
34156         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34157         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34158         CVec_u8Z_free(ret_var);
34159         return ret_arr;
34160 }
34161
34162 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_read"))) TS_CounterpartyChannelTransactionParameters_read(int8_tArray ser) {
34163         LDKu8slice ser_ref;
34164         ser_ref.datalen = ser->arr_len;
34165         ser_ref.data = ser->elems /* XXX ser leaks */;
34166         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
34167         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
34168         return (uint32_t)ret_conv;
34169 }
34170
34171 int8_tArray  __attribute__((export_name("TS_ChannelTransactionParameters_write"))) TS_ChannelTransactionParameters_write(uint32_t obj) {
34172         LDKChannelTransactionParameters obj_conv;
34173         obj_conv.inner = (void*)(obj & (~1));
34174         obj_conv.is_owned = false;
34175         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34176         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
34177         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34178         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34179         CVec_u8Z_free(ret_var);
34180         return ret_arr;
34181 }
34182
34183 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_read"))) TS_ChannelTransactionParameters_read(int8_tArray ser) {
34184         LDKu8slice ser_ref;
34185         ser_ref.datalen = ser->arr_len;
34186         ser_ref.data = ser->elems /* XXX ser leaks */;
34187         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
34188         *ret_conv = ChannelTransactionParameters_read(ser_ref);
34189         return (uint32_t)ret_conv;
34190 }
34191
34192 void  __attribute__((export_name("TS_DirectedChannelTransactionParameters_free"))) TS_DirectedChannelTransactionParameters_free(uint32_t this_obj) {
34193         LDKDirectedChannelTransactionParameters this_obj_conv;
34194         this_obj_conv.inner = (void*)(this_obj & (~1));
34195         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34197         DirectedChannelTransactionParameters_free(this_obj_conv);
34198 }
34199
34200 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_broadcaster_pubkeys"))) TS_DirectedChannelTransactionParameters_broadcaster_pubkeys(uint32_t this_arg) {
34201         LDKDirectedChannelTransactionParameters this_arg_conv;
34202         this_arg_conv.inner = (void*)(this_arg & (~1));
34203         this_arg_conv.is_owned = false;
34204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34205         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
34206         uint32_t ret_ref = 0;
34207         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34208         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34209         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34210         ret_ref = (uintptr_t)ret_var.inner;
34211         if (ret_var.is_owned) {
34212                 ret_ref |= 1;
34213         }
34214         return ret_ref;
34215 }
34216
34217 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_countersignatory_pubkeys"))) TS_DirectedChannelTransactionParameters_countersignatory_pubkeys(uint32_t this_arg) {
34218         LDKDirectedChannelTransactionParameters this_arg_conv;
34219         this_arg_conv.inner = (void*)(this_arg & (~1));
34220         this_arg_conv.is_owned = false;
34221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34222         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
34223         uint32_t ret_ref = 0;
34224         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34225         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34226         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34227         ret_ref = (uintptr_t)ret_var.inner;
34228         if (ret_var.is_owned) {
34229                 ret_ref |= 1;
34230         }
34231         return ret_ref;
34232 }
34233
34234 int16_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_contest_delay"))) TS_DirectedChannelTransactionParameters_contest_delay(uint32_t this_arg) {
34235         LDKDirectedChannelTransactionParameters this_arg_conv;
34236         this_arg_conv.inner = (void*)(this_arg & (~1));
34237         this_arg_conv.is_owned = false;
34238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34239         int16_t ret_conv = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
34240         return ret_conv;
34241 }
34242
34243 jboolean  __attribute__((export_name("TS_DirectedChannelTransactionParameters_is_outbound"))) TS_DirectedChannelTransactionParameters_is_outbound(uint32_t this_arg) {
34244         LDKDirectedChannelTransactionParameters this_arg_conv;
34245         this_arg_conv.inner = (void*)(this_arg & (~1));
34246         this_arg_conv.is_owned = false;
34247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34248         jboolean ret_conv = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
34249         return ret_conv;
34250 }
34251
34252 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_funding_outpoint"))) TS_DirectedChannelTransactionParameters_funding_outpoint(uint32_t this_arg) {
34253         LDKDirectedChannelTransactionParameters this_arg_conv;
34254         this_arg_conv.inner = (void*)(this_arg & (~1));
34255         this_arg_conv.is_owned = false;
34256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34257         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
34258         uint32_t ret_ref = 0;
34259         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34260         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34261         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34262         ret_ref = (uintptr_t)ret_var.inner;
34263         if (ret_var.is_owned) {
34264                 ret_ref |= 1;
34265         }
34266         return ret_ref;
34267 }
34268
34269 jboolean  __attribute__((export_name("TS_DirectedChannelTransactionParameters_opt_anchors"))) TS_DirectedChannelTransactionParameters_opt_anchors(uint32_t this_arg) {
34270         LDKDirectedChannelTransactionParameters this_arg_conv;
34271         this_arg_conv.inner = (void*)(this_arg & (~1));
34272         this_arg_conv.is_owned = false;
34273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34274         jboolean ret_conv = DirectedChannelTransactionParameters_opt_anchors(&this_arg_conv);
34275         return ret_conv;
34276 }
34277
34278 void  __attribute__((export_name("TS_HolderCommitmentTransaction_free"))) TS_HolderCommitmentTransaction_free(uint32_t this_obj) {
34279         LDKHolderCommitmentTransaction this_obj_conv;
34280         this_obj_conv.inner = (void*)(this_obj & (~1));
34281         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34283         HolderCommitmentTransaction_free(this_obj_conv);
34284 }
34285
34286 int8_tArray  __attribute__((export_name("TS_HolderCommitmentTransaction_get_counterparty_sig"))) TS_HolderCommitmentTransaction_get_counterparty_sig(uint32_t this_ptr) {
34287         LDKHolderCommitmentTransaction this_ptr_conv;
34288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34289         this_ptr_conv.is_owned = false;
34290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34291         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
34292         memcpy(ret_arr->elems, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form, 64);
34293         return ret_arr;
34294 }
34295
34296 void  __attribute__((export_name("TS_HolderCommitmentTransaction_set_counterparty_sig"))) TS_HolderCommitmentTransaction_set_counterparty_sig(uint32_t this_ptr, int8_tArray val) {
34297         LDKHolderCommitmentTransaction this_ptr_conv;
34298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34299         this_ptr_conv.is_owned = false;
34300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34301         LDKSignature val_ref;
34302         CHECK(val->arr_len == 64);
34303         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
34304         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
34305 }
34306
34307 void  __attribute__((export_name("TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs"))) TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs(uint32_t this_ptr, ptrArray val) {
34308         LDKHolderCommitmentTransaction this_ptr_conv;
34309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34310         this_ptr_conv.is_owned = false;
34311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34312         LDKCVec_SignatureZ val_constr;
34313         val_constr.datalen = val->arr_len;
34314         if (val_constr.datalen > 0)
34315                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
34316         else
34317                 val_constr.data = NULL;
34318         int8_tArray* val_vals = (void*) val->elems /* XXX val leaks */;
34319         for (size_t m = 0; m < val_constr.datalen; m++) {
34320                 int8_tArray val_conv_12 = val_vals[m];
34321                 LDKSignature val_conv_12_ref;
34322                 CHECK(val_conv_12->arr_len == 64);
34323                 memcpy(val_conv_12_ref.compact_form, val_conv_12->elems, 64); FREE(val_conv_12);
34324                 val_constr.data[m] = val_conv_12_ref;
34325         }
34326         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
34327 }
34328
34329 static inline uintptr_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
34330         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
34331 uint32_t ret_ref = 0;
34332 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34333 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34334 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34335 ret_ref = (uintptr_t)ret_var.inner;
34336 if (ret_var.is_owned) {
34337         ret_ref |= 1;
34338 }
34339         return ret_ref;
34340 }
34341 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_clone_ptr"))) TS_HolderCommitmentTransaction_clone_ptr(uint32_t arg) {
34342         LDKHolderCommitmentTransaction arg_conv;
34343         arg_conv.inner = (void*)(arg & (~1));
34344         arg_conv.is_owned = false;
34345         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34346         uint32_t ret_conv = HolderCommitmentTransaction_clone_ptr(&arg_conv);
34347         return ret_conv;
34348 }
34349
34350 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_clone"))) TS_HolderCommitmentTransaction_clone(uint32_t orig) {
34351         LDKHolderCommitmentTransaction orig_conv;
34352         orig_conv.inner = (void*)(orig & (~1));
34353         orig_conv.is_owned = false;
34354         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34355         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
34356         uint32_t ret_ref = 0;
34357         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34358         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34359         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34360         ret_ref = (uintptr_t)ret_var.inner;
34361         if (ret_var.is_owned) {
34362                 ret_ref |= 1;
34363         }
34364         return ret_ref;
34365 }
34366
34367 int8_tArray  __attribute__((export_name("TS_HolderCommitmentTransaction_write"))) TS_HolderCommitmentTransaction_write(uint32_t obj) {
34368         LDKHolderCommitmentTransaction obj_conv;
34369         obj_conv.inner = (void*)(obj & (~1));
34370         obj_conv.is_owned = false;
34371         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34372         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
34373         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34374         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34375         CVec_u8Z_free(ret_var);
34376         return ret_arr;
34377 }
34378
34379 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_read"))) TS_HolderCommitmentTransaction_read(int8_tArray ser) {
34380         LDKu8slice ser_ref;
34381         ser_ref.datalen = ser->arr_len;
34382         ser_ref.data = ser->elems /* XXX ser leaks */;
34383         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
34384         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
34385         return (uint32_t)ret_conv;
34386 }
34387
34388 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) {
34389         LDKCommitmentTransaction commitment_tx_conv;
34390         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
34391         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
34392         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
34393         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
34394         LDKSignature counterparty_sig_ref;
34395         CHECK(counterparty_sig->arr_len == 64);
34396         memcpy(counterparty_sig_ref.compact_form, counterparty_sig->elems, 64); FREE(counterparty_sig);
34397         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
34398         counterparty_htlc_sigs_constr.datalen = counterparty_htlc_sigs->arr_len;
34399         if (counterparty_htlc_sigs_constr.datalen > 0)
34400                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
34401         else
34402                 counterparty_htlc_sigs_constr.data = NULL;
34403         int8_tArray* counterparty_htlc_sigs_vals = (void*) counterparty_htlc_sigs->elems /* XXX counterparty_htlc_sigs leaks */;
34404         for (size_t m = 0; m < counterparty_htlc_sigs_constr.datalen; m++) {
34405                 int8_tArray counterparty_htlc_sigs_conv_12 = counterparty_htlc_sigs_vals[m];
34406                 LDKSignature counterparty_htlc_sigs_conv_12_ref;
34407                 CHECK(counterparty_htlc_sigs_conv_12->arr_len == 64);
34408                 memcpy(counterparty_htlc_sigs_conv_12_ref.compact_form, counterparty_htlc_sigs_conv_12->elems, 64); FREE(counterparty_htlc_sigs_conv_12);
34409                 counterparty_htlc_sigs_constr.data[m] = counterparty_htlc_sigs_conv_12_ref;
34410         }
34411         LDKPublicKey holder_funding_key_ref;
34412         CHECK(holder_funding_key->arr_len == 33);
34413         memcpy(holder_funding_key_ref.compressed_form, holder_funding_key->elems, 33); FREE(holder_funding_key);
34414         LDKPublicKey counterparty_funding_key_ref;
34415         CHECK(counterparty_funding_key->arr_len == 33);
34416         memcpy(counterparty_funding_key_ref.compressed_form, counterparty_funding_key->elems, 33); FREE(counterparty_funding_key);
34417         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
34418         uint32_t ret_ref = 0;
34419         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34420         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34421         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34422         ret_ref = (uintptr_t)ret_var.inner;
34423         if (ret_var.is_owned) {
34424                 ret_ref |= 1;
34425         }
34426         return ret_ref;
34427 }
34428
34429 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_free"))) TS_BuiltCommitmentTransaction_free(uint32_t this_obj) {
34430         LDKBuiltCommitmentTransaction this_obj_conv;
34431         this_obj_conv.inner = (void*)(this_obj & (~1));
34432         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34434         BuiltCommitmentTransaction_free(this_obj_conv);
34435 }
34436
34437 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_get_transaction"))) TS_BuiltCommitmentTransaction_get_transaction(uint32_t this_ptr) {
34438         LDKBuiltCommitmentTransaction this_ptr_conv;
34439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34440         this_ptr_conv.is_owned = false;
34441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34442         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
34443         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34444         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34445         Transaction_free(ret_var);
34446         return ret_arr;
34447 }
34448
34449 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_set_transaction"))) TS_BuiltCommitmentTransaction_set_transaction(uint32_t this_ptr, int8_tArray val) {
34450         LDKBuiltCommitmentTransaction this_ptr_conv;
34451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34452         this_ptr_conv.is_owned = false;
34453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34454         LDKTransaction val_ref;
34455         val_ref.datalen = val->arr_len;
34456         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
34457         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
34458         val_ref.data_is_owned = true;
34459         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
34460 }
34461
34462 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_get_txid"))) TS_BuiltCommitmentTransaction_get_txid(uint32_t this_ptr) {
34463         LDKBuiltCommitmentTransaction this_ptr_conv;
34464         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34465         this_ptr_conv.is_owned = false;
34466         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34467         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
34468         memcpy(ret_arr->elems, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv), 32);
34469         return ret_arr;
34470 }
34471
34472 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_set_txid"))) TS_BuiltCommitmentTransaction_set_txid(uint32_t this_ptr, int8_tArray val) {
34473         LDKBuiltCommitmentTransaction 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         LDKThirtyTwoBytes val_ref;
34478         CHECK(val->arr_len == 32);
34479         memcpy(val_ref.data, val->elems, 32); FREE(val);
34480         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
34481 }
34482
34483 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_new"))) TS_BuiltCommitmentTransaction_new(int8_tArray transaction_arg, int8_tArray txid_arg) {
34484         LDKTransaction transaction_arg_ref;
34485         transaction_arg_ref.datalen = transaction_arg->arr_len;
34486         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
34487         memcpy(transaction_arg_ref.data, transaction_arg->elems, transaction_arg_ref.datalen); FREE(transaction_arg);
34488         transaction_arg_ref.data_is_owned = true;
34489         LDKThirtyTwoBytes txid_arg_ref;
34490         CHECK(txid_arg->arr_len == 32);
34491         memcpy(txid_arg_ref.data, txid_arg->elems, 32); FREE(txid_arg);
34492         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
34493         uint32_t ret_ref = 0;
34494         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34495         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34496         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34497         ret_ref = (uintptr_t)ret_var.inner;
34498         if (ret_var.is_owned) {
34499                 ret_ref |= 1;
34500         }
34501         return ret_ref;
34502 }
34503
34504 static inline uintptr_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
34505         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
34506 uint32_t ret_ref = 0;
34507 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34508 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34509 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34510 ret_ref = (uintptr_t)ret_var.inner;
34511 if (ret_var.is_owned) {
34512         ret_ref |= 1;
34513 }
34514         return ret_ref;
34515 }
34516 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_clone_ptr"))) TS_BuiltCommitmentTransaction_clone_ptr(uint32_t arg) {
34517         LDKBuiltCommitmentTransaction arg_conv;
34518         arg_conv.inner = (void*)(arg & (~1));
34519         arg_conv.is_owned = false;
34520         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34521         uint32_t ret_conv = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
34522         return ret_conv;
34523 }
34524
34525 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_clone"))) TS_BuiltCommitmentTransaction_clone(uint32_t orig) {
34526         LDKBuiltCommitmentTransaction orig_conv;
34527         orig_conv.inner = (void*)(orig & (~1));
34528         orig_conv.is_owned = false;
34529         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34530         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
34531         uint32_t ret_ref = 0;
34532         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34533         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34534         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34535         ret_ref = (uintptr_t)ret_var.inner;
34536         if (ret_var.is_owned) {
34537                 ret_ref |= 1;
34538         }
34539         return ret_ref;
34540 }
34541
34542 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_write"))) TS_BuiltCommitmentTransaction_write(uint32_t obj) {
34543         LDKBuiltCommitmentTransaction obj_conv;
34544         obj_conv.inner = (void*)(obj & (~1));
34545         obj_conv.is_owned = false;
34546         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34547         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
34548         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34549         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34550         CVec_u8Z_free(ret_var);
34551         return ret_arr;
34552 }
34553
34554 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_read"))) TS_BuiltCommitmentTransaction_read(int8_tArray ser) {
34555         LDKu8slice ser_ref;
34556         ser_ref.datalen = ser->arr_len;
34557         ser_ref.data = ser->elems /* XXX ser leaks */;
34558         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
34559         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
34560         return (uint32_t)ret_conv;
34561 }
34562
34563 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) {
34564         LDKBuiltCommitmentTransaction this_arg_conv;
34565         this_arg_conv.inner = (void*)(this_arg & (~1));
34566         this_arg_conv.is_owned = false;
34567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34568         LDKu8slice funding_redeemscript_ref;
34569         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
34570         funding_redeemscript_ref.data = funding_redeemscript->elems /* XXX funding_redeemscript leaks */;
34571         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
34572         memcpy(ret_arr->elems, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
34573         return ret_arr;
34574 }
34575
34576 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) {
34577         LDKBuiltCommitmentTransaction this_arg_conv;
34578         this_arg_conv.inner = (void*)(this_arg & (~1));
34579         this_arg_conv.is_owned = false;
34580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34581         unsigned char funding_key_arr[32];
34582         CHECK(funding_key->arr_len == 32);
34583         memcpy(funding_key_arr, funding_key->elems, 32); FREE(funding_key);
34584         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
34585         LDKu8slice funding_redeemscript_ref;
34586         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
34587         funding_redeemscript_ref.data = funding_redeemscript->elems /* XXX funding_redeemscript leaks */;
34588         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
34589         memcpy(ret_arr->elems, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
34590         return ret_arr;
34591 }
34592
34593 void  __attribute__((export_name("TS_ClosingTransaction_free"))) TS_ClosingTransaction_free(uint32_t this_obj) {
34594         LDKClosingTransaction this_obj_conv;
34595         this_obj_conv.inner = (void*)(this_obj & (~1));
34596         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34598         ClosingTransaction_free(this_obj_conv);
34599 }
34600
34601 static inline uintptr_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
34602         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
34603 uint32_t ret_ref = 0;
34604 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34605 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34606 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34607 ret_ref = (uintptr_t)ret_var.inner;
34608 if (ret_var.is_owned) {
34609         ret_ref |= 1;
34610 }
34611         return ret_ref;
34612 }
34613 uint32_t  __attribute__((export_name("TS_ClosingTransaction_clone_ptr"))) TS_ClosingTransaction_clone_ptr(uint32_t arg) {
34614         LDKClosingTransaction arg_conv;
34615         arg_conv.inner = (void*)(arg & (~1));
34616         arg_conv.is_owned = false;
34617         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34618         uint32_t ret_conv = ClosingTransaction_clone_ptr(&arg_conv);
34619         return ret_conv;
34620 }
34621
34622 uint32_t  __attribute__((export_name("TS_ClosingTransaction_clone"))) TS_ClosingTransaction_clone(uint32_t orig) {
34623         LDKClosingTransaction orig_conv;
34624         orig_conv.inner = (void*)(orig & (~1));
34625         orig_conv.is_owned = false;
34626         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34627         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
34628         uint32_t ret_ref = 0;
34629         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34630         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34631         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34632         ret_ref = (uintptr_t)ret_var.inner;
34633         if (ret_var.is_owned) {
34634                 ret_ref |= 1;
34635         }
34636         return ret_ref;
34637 }
34638
34639 int64_t  __attribute__((export_name("TS_ClosingTransaction_hash"))) TS_ClosingTransaction_hash(uint32_t o) {
34640         LDKClosingTransaction o_conv;
34641         o_conv.inner = (void*)(o & (~1));
34642         o_conv.is_owned = false;
34643         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
34644         int64_t ret_conv = ClosingTransaction_hash(&o_conv);
34645         return ret_conv;
34646 }
34647
34648 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) {
34649         LDKCVec_u8Z to_holder_script_ref;
34650         to_holder_script_ref.datalen = to_holder_script->arr_len;
34651         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
34652         memcpy(to_holder_script_ref.data, to_holder_script->elems, to_holder_script_ref.datalen); FREE(to_holder_script);
34653         LDKCVec_u8Z to_counterparty_script_ref;
34654         to_counterparty_script_ref.datalen = to_counterparty_script->arr_len;
34655         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
34656         memcpy(to_counterparty_script_ref.data, to_counterparty_script->elems, to_counterparty_script_ref.datalen); FREE(to_counterparty_script);
34657         LDKOutPoint funding_outpoint_conv;
34658         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
34659         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
34660         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
34661         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
34662         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
34663         uint32_t ret_ref = 0;
34664         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34665         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34666         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34667         ret_ref = (uintptr_t)ret_var.inner;
34668         if (ret_var.is_owned) {
34669                 ret_ref |= 1;
34670         }
34671         return ret_ref;
34672 }
34673
34674 uint32_t  __attribute__((export_name("TS_ClosingTransaction_trust"))) TS_ClosingTransaction_trust(uint32_t this_arg) {
34675         LDKClosingTransaction this_arg_conv;
34676         this_arg_conv.inner = (void*)(this_arg & (~1));
34677         this_arg_conv.is_owned = false;
34678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34679         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
34680         uint32_t ret_ref = 0;
34681         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34682         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34683         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34684         ret_ref = (uintptr_t)ret_var.inner;
34685         if (ret_var.is_owned) {
34686                 ret_ref |= 1;
34687         }
34688         return ret_ref;
34689 }
34690
34691 uint32_t  __attribute__((export_name("TS_ClosingTransaction_verify"))) TS_ClosingTransaction_verify(uint32_t this_arg, uint32_t funding_outpoint) {
34692         LDKClosingTransaction this_arg_conv;
34693         this_arg_conv.inner = (void*)(this_arg & (~1));
34694         this_arg_conv.is_owned = false;
34695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34696         LDKOutPoint funding_outpoint_conv;
34697         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
34698         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
34699         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
34700         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
34701         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
34702         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
34703         return (uint32_t)ret_conv;
34704 }
34705
34706 int64_t  __attribute__((export_name("TS_ClosingTransaction_to_holder_value_sat"))) TS_ClosingTransaction_to_holder_value_sat(uint32_t this_arg) {
34707         LDKClosingTransaction this_arg_conv;
34708         this_arg_conv.inner = (void*)(this_arg & (~1));
34709         this_arg_conv.is_owned = false;
34710         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34711         int64_t ret_conv = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
34712         return ret_conv;
34713 }
34714
34715 int64_t  __attribute__((export_name("TS_ClosingTransaction_to_counterparty_value_sat"))) TS_ClosingTransaction_to_counterparty_value_sat(uint32_t this_arg) {
34716         LDKClosingTransaction this_arg_conv;
34717         this_arg_conv.inner = (void*)(this_arg & (~1));
34718         this_arg_conv.is_owned = false;
34719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34720         int64_t ret_conv = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
34721         return ret_conv;
34722 }
34723
34724 int8_tArray  __attribute__((export_name("TS_ClosingTransaction_to_holder_script"))) TS_ClosingTransaction_to_holder_script(uint32_t this_arg) {
34725         LDKClosingTransaction this_arg_conv;
34726         this_arg_conv.inner = (void*)(this_arg & (~1));
34727         this_arg_conv.is_owned = false;
34728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34729         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
34730         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34731         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34732         return ret_arr;
34733 }
34734
34735 int8_tArray  __attribute__((export_name("TS_ClosingTransaction_to_counterparty_script"))) TS_ClosingTransaction_to_counterparty_script(uint32_t this_arg) {
34736         LDKClosingTransaction this_arg_conv;
34737         this_arg_conv.inner = (void*)(this_arg & (~1));
34738         this_arg_conv.is_owned = false;
34739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34740         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
34741         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34742         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34743         return ret_arr;
34744 }
34745
34746 void  __attribute__((export_name("TS_TrustedClosingTransaction_free"))) TS_TrustedClosingTransaction_free(uint32_t this_obj) {
34747         LDKTrustedClosingTransaction this_obj_conv;
34748         this_obj_conv.inner = (void*)(this_obj & (~1));
34749         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34751         TrustedClosingTransaction_free(this_obj_conv);
34752 }
34753
34754 int8_tArray  __attribute__((export_name("TS_TrustedClosingTransaction_built_transaction"))) TS_TrustedClosingTransaction_built_transaction(uint32_t this_arg) {
34755         LDKTrustedClosingTransaction this_arg_conv;
34756         this_arg_conv.inner = (void*)(this_arg & (~1));
34757         this_arg_conv.is_owned = false;
34758         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34759         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
34760         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34761         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34762         Transaction_free(ret_var);
34763         return ret_arr;
34764 }
34765
34766 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) {
34767         LDKTrustedClosingTransaction this_arg_conv;
34768         this_arg_conv.inner = (void*)(this_arg & (~1));
34769         this_arg_conv.is_owned = false;
34770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34771         LDKu8slice funding_redeemscript_ref;
34772         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
34773         funding_redeemscript_ref.data = funding_redeemscript->elems /* XXX funding_redeemscript leaks */;
34774         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
34775         memcpy(ret_arr->elems, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
34776         return ret_arr;
34777 }
34778
34779 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) {
34780         LDKTrustedClosingTransaction this_arg_conv;
34781         this_arg_conv.inner = (void*)(this_arg & (~1));
34782         this_arg_conv.is_owned = false;
34783         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34784         unsigned char funding_key_arr[32];
34785         CHECK(funding_key->arr_len == 32);
34786         memcpy(funding_key_arr, funding_key->elems, 32); FREE(funding_key);
34787         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
34788         LDKu8slice funding_redeemscript_ref;
34789         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
34790         funding_redeemscript_ref.data = funding_redeemscript->elems /* XXX funding_redeemscript leaks */;
34791         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
34792         memcpy(ret_arr->elems, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
34793         return ret_arr;
34794 }
34795
34796 void  __attribute__((export_name("TS_CommitmentTransaction_free"))) TS_CommitmentTransaction_free(uint32_t this_obj) {
34797         LDKCommitmentTransaction this_obj_conv;
34798         this_obj_conv.inner = (void*)(this_obj & (~1));
34799         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34801         CommitmentTransaction_free(this_obj_conv);
34802 }
34803
34804 static inline uintptr_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
34805         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
34806 uint32_t ret_ref = 0;
34807 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34808 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34809 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34810 ret_ref = (uintptr_t)ret_var.inner;
34811 if (ret_var.is_owned) {
34812         ret_ref |= 1;
34813 }
34814         return ret_ref;
34815 }
34816 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_clone_ptr"))) TS_CommitmentTransaction_clone_ptr(uint32_t arg) {
34817         LDKCommitmentTransaction arg_conv;
34818         arg_conv.inner = (void*)(arg & (~1));
34819         arg_conv.is_owned = false;
34820         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34821         uint32_t ret_conv = CommitmentTransaction_clone_ptr(&arg_conv);
34822         return ret_conv;
34823 }
34824
34825 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_clone"))) TS_CommitmentTransaction_clone(uint32_t orig) {
34826         LDKCommitmentTransaction orig_conv;
34827         orig_conv.inner = (void*)(orig & (~1));
34828         orig_conv.is_owned = false;
34829         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34830         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
34831         uint32_t ret_ref = 0;
34832         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34833         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34834         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34835         ret_ref = (uintptr_t)ret_var.inner;
34836         if (ret_var.is_owned) {
34837                 ret_ref |= 1;
34838         }
34839         return ret_ref;
34840 }
34841
34842 int8_tArray  __attribute__((export_name("TS_CommitmentTransaction_write"))) TS_CommitmentTransaction_write(uint32_t obj) {
34843         LDKCommitmentTransaction obj_conv;
34844         obj_conv.inner = (void*)(obj & (~1));
34845         obj_conv.is_owned = false;
34846         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34847         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
34848         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34849         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34850         CVec_u8Z_free(ret_var);
34851         return ret_arr;
34852 }
34853
34854 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_read"))) TS_CommitmentTransaction_read(int8_tArray ser) {
34855         LDKu8slice ser_ref;
34856         ser_ref.datalen = ser->arr_len;
34857         ser_ref.data = ser->elems /* XXX ser leaks */;
34858         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
34859         *ret_conv = CommitmentTransaction_read(ser_ref);
34860         return (uint32_t)ret_conv;
34861 }
34862
34863 int64_t  __attribute__((export_name("TS_CommitmentTransaction_commitment_number"))) TS_CommitmentTransaction_commitment_number(uint32_t this_arg) {
34864         LDKCommitmentTransaction this_arg_conv;
34865         this_arg_conv.inner = (void*)(this_arg & (~1));
34866         this_arg_conv.is_owned = false;
34867         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34868         int64_t ret_conv = CommitmentTransaction_commitment_number(&this_arg_conv);
34869         return ret_conv;
34870 }
34871
34872 int64_t  __attribute__((export_name("TS_CommitmentTransaction_to_broadcaster_value_sat"))) TS_CommitmentTransaction_to_broadcaster_value_sat(uint32_t this_arg) {
34873         LDKCommitmentTransaction this_arg_conv;
34874         this_arg_conv.inner = (void*)(this_arg & (~1));
34875         this_arg_conv.is_owned = false;
34876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34877         int64_t ret_conv = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
34878         return ret_conv;
34879 }
34880
34881 int64_t  __attribute__((export_name("TS_CommitmentTransaction_to_countersignatory_value_sat"))) TS_CommitmentTransaction_to_countersignatory_value_sat(uint32_t this_arg) {
34882         LDKCommitmentTransaction this_arg_conv;
34883         this_arg_conv.inner = (void*)(this_arg & (~1));
34884         this_arg_conv.is_owned = false;
34885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34886         int64_t ret_conv = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
34887         return ret_conv;
34888 }
34889
34890 int32_t  __attribute__((export_name("TS_CommitmentTransaction_feerate_per_kw"))) TS_CommitmentTransaction_feerate_per_kw(uint32_t this_arg) {
34891         LDKCommitmentTransaction this_arg_conv;
34892         this_arg_conv.inner = (void*)(this_arg & (~1));
34893         this_arg_conv.is_owned = false;
34894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34895         int32_t ret_conv = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
34896         return ret_conv;
34897 }
34898
34899 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_trust"))) TS_CommitmentTransaction_trust(uint32_t this_arg) {
34900         LDKCommitmentTransaction this_arg_conv;
34901         this_arg_conv.inner = (void*)(this_arg & (~1));
34902         this_arg_conv.is_owned = false;
34903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34904         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
34905         uint32_t ret_ref = 0;
34906         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34907         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34908         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34909         ret_ref = (uintptr_t)ret_var.inner;
34910         if (ret_var.is_owned) {
34911                 ret_ref |= 1;
34912         }
34913         return ret_ref;
34914 }
34915
34916 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) {
34917         LDKCommitmentTransaction this_arg_conv;
34918         this_arg_conv.inner = (void*)(this_arg & (~1));
34919         this_arg_conv.is_owned = false;
34920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34921         LDKDirectedChannelTransactionParameters channel_parameters_conv;
34922         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
34923         channel_parameters_conv.is_owned = false;
34924         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
34925         LDKChannelPublicKeys broadcaster_keys_conv;
34926         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
34927         broadcaster_keys_conv.is_owned = false;
34928         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
34929         LDKChannelPublicKeys countersignatory_keys_conv;
34930         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
34931         countersignatory_keys_conv.is_owned = false;
34932         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
34933         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
34934         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
34935         return (uint32_t)ret_conv;
34936 }
34937
34938 void  __attribute__((export_name("TS_TrustedCommitmentTransaction_free"))) TS_TrustedCommitmentTransaction_free(uint32_t this_obj) {
34939         LDKTrustedCommitmentTransaction this_obj_conv;
34940         this_obj_conv.inner = (void*)(this_obj & (~1));
34941         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34943         TrustedCommitmentTransaction_free(this_obj_conv);
34944 }
34945
34946 int8_tArray  __attribute__((export_name("TS_TrustedCommitmentTransaction_txid"))) TS_TrustedCommitmentTransaction_txid(uint32_t this_arg) {
34947         LDKTrustedCommitmentTransaction this_arg_conv;
34948         this_arg_conv.inner = (void*)(this_arg & (~1));
34949         this_arg_conv.is_owned = false;
34950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34951         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
34952         memcpy(ret_arr->elems, TrustedCommitmentTransaction_txid(&this_arg_conv).data, 32);
34953         return ret_arr;
34954 }
34955
34956 uint32_t  __attribute__((export_name("TS_TrustedCommitmentTransaction_built_transaction"))) TS_TrustedCommitmentTransaction_built_transaction(uint32_t this_arg) {
34957         LDKTrustedCommitmentTransaction this_arg_conv;
34958         this_arg_conv.inner = (void*)(this_arg & (~1));
34959         this_arg_conv.is_owned = false;
34960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34961         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
34962         uint32_t ret_ref = 0;
34963         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34964         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34965         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34966         ret_ref = (uintptr_t)ret_var.inner;
34967         if (ret_var.is_owned) {
34968                 ret_ref |= 1;
34969         }
34970         return ret_ref;
34971 }
34972
34973 uint32_t  __attribute__((export_name("TS_TrustedCommitmentTransaction_keys"))) TS_TrustedCommitmentTransaction_keys(uint32_t this_arg) {
34974         LDKTrustedCommitmentTransaction this_arg_conv;
34975         this_arg_conv.inner = (void*)(this_arg & (~1));
34976         this_arg_conv.is_owned = false;
34977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34978         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_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_TrustedCommitmentTransaction_opt_anchors"))) TS_TrustedCommitmentTransaction_opt_anchors(uint32_t this_arg) {
34991         LDKTrustedCommitmentTransaction 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 = TrustedCommitmentTransaction_opt_anchors(&this_arg_conv);
34996         return ret_conv;
34997 }
34998
34999 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) {
35000         LDKTrustedCommitmentTransaction 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         unsigned char htlc_base_key_arr[32];
35005         CHECK(htlc_base_key->arr_len == 32);
35006         memcpy(htlc_base_key_arr, htlc_base_key->elems, 32); FREE(htlc_base_key);
35007         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
35008         LDKDirectedChannelTransactionParameters channel_parameters_conv;
35009         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
35010         channel_parameters_conv.is_owned = false;
35011         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
35012         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
35013         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
35014         return (uint32_t)ret_conv;
35015 }
35016
35017 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) {
35018         LDKPublicKey broadcaster_payment_basepoint_ref;
35019         CHECK(broadcaster_payment_basepoint->arr_len == 33);
35020         memcpy(broadcaster_payment_basepoint_ref.compressed_form, broadcaster_payment_basepoint->elems, 33); FREE(broadcaster_payment_basepoint);
35021         LDKPublicKey countersignatory_payment_basepoint_ref;
35022         CHECK(countersignatory_payment_basepoint->arr_len == 33);
35023         memcpy(countersignatory_payment_basepoint_ref.compressed_form, countersignatory_payment_basepoint->elems, 33); FREE(countersignatory_payment_basepoint);
35024         int64_t ret_conv = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
35025         return ret_conv;
35026 }
35027
35028 jboolean  __attribute__((export_name("TS_InitFeatures_eq"))) TS_InitFeatures_eq(uint32_t a, uint32_t b) {
35029         LDKInitFeatures a_conv;
35030         a_conv.inner = (void*)(a & (~1));
35031         a_conv.is_owned = false;
35032         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35033         LDKInitFeatures b_conv;
35034         b_conv.inner = (void*)(b & (~1));
35035         b_conv.is_owned = false;
35036         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35037         jboolean ret_conv = InitFeatures_eq(&a_conv, &b_conv);
35038         return ret_conv;
35039 }
35040
35041 jboolean  __attribute__((export_name("TS_NodeFeatures_eq"))) TS_NodeFeatures_eq(uint32_t a, uint32_t b) {
35042         LDKNodeFeatures a_conv;
35043         a_conv.inner = (void*)(a & (~1));
35044         a_conv.is_owned = false;
35045         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35046         LDKNodeFeatures b_conv;
35047         b_conv.inner = (void*)(b & (~1));
35048         b_conv.is_owned = false;
35049         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35050         jboolean ret_conv = NodeFeatures_eq(&a_conv, &b_conv);
35051         return ret_conv;
35052 }
35053
35054 jboolean  __attribute__((export_name("TS_ChannelFeatures_eq"))) TS_ChannelFeatures_eq(uint32_t a, uint32_t b) {
35055         LDKChannelFeatures a_conv;
35056         a_conv.inner = (void*)(a & (~1));
35057         a_conv.is_owned = false;
35058         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35059         LDKChannelFeatures b_conv;
35060         b_conv.inner = (void*)(b & (~1));
35061         b_conv.is_owned = false;
35062         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35063         jboolean ret_conv = ChannelFeatures_eq(&a_conv, &b_conv);
35064         return ret_conv;
35065 }
35066
35067 jboolean  __attribute__((export_name("TS_InvoiceFeatures_eq"))) TS_InvoiceFeatures_eq(uint32_t a, uint32_t b) {
35068         LDKInvoiceFeatures a_conv;
35069         a_conv.inner = (void*)(a & (~1));
35070         a_conv.is_owned = false;
35071         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35072         LDKInvoiceFeatures b_conv;
35073         b_conv.inner = (void*)(b & (~1));
35074         b_conv.is_owned = false;
35075         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35076         jboolean ret_conv = InvoiceFeatures_eq(&a_conv, &b_conv);
35077         return ret_conv;
35078 }
35079
35080 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_eq"))) TS_ChannelTypeFeatures_eq(uint32_t a, uint32_t b) {
35081         LDKChannelTypeFeatures a_conv;
35082         a_conv.inner = (void*)(a & (~1));
35083         a_conv.is_owned = false;
35084         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35085         LDKChannelTypeFeatures b_conv;
35086         b_conv.inner = (void*)(b & (~1));
35087         b_conv.is_owned = false;
35088         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35089         jboolean ret_conv = ChannelTypeFeatures_eq(&a_conv, &b_conv);
35090         return ret_conv;
35091 }
35092
35093 static inline uintptr_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
35094         LDKInitFeatures ret_var = InitFeatures_clone(arg);
35095 uint32_t ret_ref = 0;
35096 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35097 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35098 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35099 ret_ref = (uintptr_t)ret_var.inner;
35100 if (ret_var.is_owned) {
35101         ret_ref |= 1;
35102 }
35103         return ret_ref;
35104 }
35105 uint32_t  __attribute__((export_name("TS_InitFeatures_clone_ptr"))) TS_InitFeatures_clone_ptr(uint32_t arg) {
35106         LDKInitFeatures arg_conv;
35107         arg_conv.inner = (void*)(arg & (~1));
35108         arg_conv.is_owned = false;
35109         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35110         uint32_t ret_conv = InitFeatures_clone_ptr(&arg_conv);
35111         return ret_conv;
35112 }
35113
35114 uint32_t  __attribute__((export_name("TS_InitFeatures_clone"))) TS_InitFeatures_clone(uint32_t orig) {
35115         LDKInitFeatures orig_conv;
35116         orig_conv.inner = (void*)(orig & (~1));
35117         orig_conv.is_owned = false;
35118         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35119         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
35120         uint32_t ret_ref = 0;
35121         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35122         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35123         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35124         ret_ref = (uintptr_t)ret_var.inner;
35125         if (ret_var.is_owned) {
35126                 ret_ref |= 1;
35127         }
35128         return ret_ref;
35129 }
35130
35131 static inline uintptr_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
35132         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
35133 uint32_t ret_ref = 0;
35134 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35135 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35136 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35137 ret_ref = (uintptr_t)ret_var.inner;
35138 if (ret_var.is_owned) {
35139         ret_ref |= 1;
35140 }
35141         return ret_ref;
35142 }
35143 uint32_t  __attribute__((export_name("TS_NodeFeatures_clone_ptr"))) TS_NodeFeatures_clone_ptr(uint32_t arg) {
35144         LDKNodeFeatures arg_conv;
35145         arg_conv.inner = (void*)(arg & (~1));
35146         arg_conv.is_owned = false;
35147         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35148         uint32_t ret_conv = NodeFeatures_clone_ptr(&arg_conv);
35149         return ret_conv;
35150 }
35151
35152 uint32_t  __attribute__((export_name("TS_NodeFeatures_clone"))) TS_NodeFeatures_clone(uint32_t orig) {
35153         LDKNodeFeatures orig_conv;
35154         orig_conv.inner = (void*)(orig & (~1));
35155         orig_conv.is_owned = false;
35156         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35157         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
35158         uint32_t ret_ref = 0;
35159         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35160         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35161         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35162         ret_ref = (uintptr_t)ret_var.inner;
35163         if (ret_var.is_owned) {
35164                 ret_ref |= 1;
35165         }
35166         return ret_ref;
35167 }
35168
35169 static inline uintptr_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
35170         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
35171 uint32_t ret_ref = 0;
35172 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35173 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35174 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35175 ret_ref = (uintptr_t)ret_var.inner;
35176 if (ret_var.is_owned) {
35177         ret_ref |= 1;
35178 }
35179         return ret_ref;
35180 }
35181 uint32_t  __attribute__((export_name("TS_ChannelFeatures_clone_ptr"))) TS_ChannelFeatures_clone_ptr(uint32_t arg) {
35182         LDKChannelFeatures arg_conv;
35183         arg_conv.inner = (void*)(arg & (~1));
35184         arg_conv.is_owned = false;
35185         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35186         uint32_t ret_conv = ChannelFeatures_clone_ptr(&arg_conv);
35187         return ret_conv;
35188 }
35189
35190 uint32_t  __attribute__((export_name("TS_ChannelFeatures_clone"))) TS_ChannelFeatures_clone(uint32_t orig) {
35191         LDKChannelFeatures orig_conv;
35192         orig_conv.inner = (void*)(orig & (~1));
35193         orig_conv.is_owned = false;
35194         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35195         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
35196         uint32_t ret_ref = 0;
35197         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35198         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35199         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35200         ret_ref = (uintptr_t)ret_var.inner;
35201         if (ret_var.is_owned) {
35202                 ret_ref |= 1;
35203         }
35204         return ret_ref;
35205 }
35206
35207 static inline uintptr_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
35208         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
35209 uint32_t ret_ref = 0;
35210 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35211 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35212 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35213 ret_ref = (uintptr_t)ret_var.inner;
35214 if (ret_var.is_owned) {
35215         ret_ref |= 1;
35216 }
35217         return ret_ref;
35218 }
35219 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_clone_ptr"))) TS_InvoiceFeatures_clone_ptr(uint32_t arg) {
35220         LDKInvoiceFeatures arg_conv;
35221         arg_conv.inner = (void*)(arg & (~1));
35222         arg_conv.is_owned = false;
35223         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35224         uint32_t ret_conv = InvoiceFeatures_clone_ptr(&arg_conv);
35225         return ret_conv;
35226 }
35227
35228 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_clone"))) TS_InvoiceFeatures_clone(uint32_t orig) {
35229         LDKInvoiceFeatures orig_conv;
35230         orig_conv.inner = (void*)(orig & (~1));
35231         orig_conv.is_owned = false;
35232         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35233         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
35234         uint32_t ret_ref = 0;
35235         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35236         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35237         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35238         ret_ref = (uintptr_t)ret_var.inner;
35239         if (ret_var.is_owned) {
35240                 ret_ref |= 1;
35241         }
35242         return ret_ref;
35243 }
35244
35245 static inline uintptr_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
35246         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
35247 uint32_t ret_ref = 0;
35248 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35249 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35250 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35251 ret_ref = (uintptr_t)ret_var.inner;
35252 if (ret_var.is_owned) {
35253         ret_ref |= 1;
35254 }
35255         return ret_ref;
35256 }
35257 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_clone_ptr"))) TS_ChannelTypeFeatures_clone_ptr(uint32_t arg) {
35258         LDKChannelTypeFeatures arg_conv;
35259         arg_conv.inner = (void*)(arg & (~1));
35260         arg_conv.is_owned = false;
35261         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35262         uint32_t ret_conv = ChannelTypeFeatures_clone_ptr(&arg_conv);
35263         return ret_conv;
35264 }
35265
35266 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_clone"))) TS_ChannelTypeFeatures_clone(uint32_t orig) {
35267         LDKChannelTypeFeatures orig_conv;
35268         orig_conv.inner = (void*)(orig & (~1));
35269         orig_conv.is_owned = false;
35270         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35271         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_conv);
35272         uint32_t ret_ref = 0;
35273         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35274         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35275         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35276         ret_ref = (uintptr_t)ret_var.inner;
35277         if (ret_var.is_owned) {
35278                 ret_ref |= 1;
35279         }
35280         return ret_ref;
35281 }
35282
35283 void  __attribute__((export_name("TS_InitFeatures_free"))) TS_InitFeatures_free(uint32_t this_obj) {
35284         LDKInitFeatures this_obj_conv;
35285         this_obj_conv.inner = (void*)(this_obj & (~1));
35286         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35288         InitFeatures_free(this_obj_conv);
35289 }
35290
35291 void  __attribute__((export_name("TS_NodeFeatures_free"))) TS_NodeFeatures_free(uint32_t this_obj) {
35292         LDKNodeFeatures this_obj_conv;
35293         this_obj_conv.inner = (void*)(this_obj & (~1));
35294         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35296         NodeFeatures_free(this_obj_conv);
35297 }
35298
35299 void  __attribute__((export_name("TS_ChannelFeatures_free"))) TS_ChannelFeatures_free(uint32_t this_obj) {
35300         LDKChannelFeatures this_obj_conv;
35301         this_obj_conv.inner = (void*)(this_obj & (~1));
35302         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35303         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35304         ChannelFeatures_free(this_obj_conv);
35305 }
35306
35307 void  __attribute__((export_name("TS_InvoiceFeatures_free"))) TS_InvoiceFeatures_free(uint32_t this_obj) {
35308         LDKInvoiceFeatures this_obj_conv;
35309         this_obj_conv.inner = (void*)(this_obj & (~1));
35310         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35312         InvoiceFeatures_free(this_obj_conv);
35313 }
35314
35315 void  __attribute__((export_name("TS_ChannelTypeFeatures_free"))) TS_ChannelTypeFeatures_free(uint32_t this_obj) {
35316         LDKChannelTypeFeatures this_obj_conv;
35317         this_obj_conv.inner = (void*)(this_obj & (~1));
35318         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35320         ChannelTypeFeatures_free(this_obj_conv);
35321 }
35322
35323 uint32_t  __attribute__((export_name("TS_InitFeatures_empty"))) TS_InitFeatures_empty() {
35324         LDKInitFeatures ret_var = InitFeatures_empty();
35325         uint32_t ret_ref = 0;
35326         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35327         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35328         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35329         ret_ref = (uintptr_t)ret_var.inner;
35330         if (ret_var.is_owned) {
35331                 ret_ref |= 1;
35332         }
35333         return ret_ref;
35334 }
35335
35336 uint32_t  __attribute__((export_name("TS_InitFeatures_known"))) TS_InitFeatures_known() {
35337         LDKInitFeatures ret_var = InitFeatures_known();
35338         uint32_t ret_ref = 0;
35339         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35340         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35341         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35342         ret_ref = (uintptr_t)ret_var.inner;
35343         if (ret_var.is_owned) {
35344                 ret_ref |= 1;
35345         }
35346         return ret_ref;
35347 }
35348
35349 jboolean  __attribute__((export_name("TS_InitFeatures_requires_unknown_bits"))) TS_InitFeatures_requires_unknown_bits(uint32_t this_arg) {
35350         LDKInitFeatures this_arg_conv;
35351         this_arg_conv.inner = (void*)(this_arg & (~1));
35352         this_arg_conv.is_owned = false;
35353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35354         jboolean ret_conv = InitFeatures_requires_unknown_bits(&this_arg_conv);
35355         return ret_conv;
35356 }
35357
35358 uint32_t  __attribute__((export_name("TS_NodeFeatures_empty"))) TS_NodeFeatures_empty() {
35359         LDKNodeFeatures ret_var = NodeFeatures_empty();
35360         uint32_t ret_ref = 0;
35361         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35362         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35363         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35364         ret_ref = (uintptr_t)ret_var.inner;
35365         if (ret_var.is_owned) {
35366                 ret_ref |= 1;
35367         }
35368         return ret_ref;
35369 }
35370
35371 uint32_t  __attribute__((export_name("TS_NodeFeatures_known"))) TS_NodeFeatures_known() {
35372         LDKNodeFeatures ret_var = NodeFeatures_known();
35373         uint32_t ret_ref = 0;
35374         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35375         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35376         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35377         ret_ref = (uintptr_t)ret_var.inner;
35378         if (ret_var.is_owned) {
35379                 ret_ref |= 1;
35380         }
35381         return ret_ref;
35382 }
35383
35384 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_unknown_bits"))) TS_NodeFeatures_requires_unknown_bits(uint32_t this_arg) {
35385         LDKNodeFeatures this_arg_conv;
35386         this_arg_conv.inner = (void*)(this_arg & (~1));
35387         this_arg_conv.is_owned = false;
35388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35389         jboolean ret_conv = NodeFeatures_requires_unknown_bits(&this_arg_conv);
35390         return ret_conv;
35391 }
35392
35393 uint32_t  __attribute__((export_name("TS_ChannelFeatures_empty"))) TS_ChannelFeatures_empty() {
35394         LDKChannelFeatures ret_var = ChannelFeatures_empty();
35395         uint32_t ret_ref = 0;
35396         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35397         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35398         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35399         ret_ref = (uintptr_t)ret_var.inner;
35400         if (ret_var.is_owned) {
35401                 ret_ref |= 1;
35402         }
35403         return ret_ref;
35404 }
35405
35406 uint32_t  __attribute__((export_name("TS_ChannelFeatures_known"))) TS_ChannelFeatures_known() {
35407         LDKChannelFeatures ret_var = ChannelFeatures_known();
35408         uint32_t ret_ref = 0;
35409         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35410         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35411         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35412         ret_ref = (uintptr_t)ret_var.inner;
35413         if (ret_var.is_owned) {
35414                 ret_ref |= 1;
35415         }
35416         return ret_ref;
35417 }
35418
35419 jboolean  __attribute__((export_name("TS_ChannelFeatures_requires_unknown_bits"))) TS_ChannelFeatures_requires_unknown_bits(uint32_t this_arg) {
35420         LDKChannelFeatures this_arg_conv;
35421         this_arg_conv.inner = (void*)(this_arg & (~1));
35422         this_arg_conv.is_owned = false;
35423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35424         jboolean ret_conv = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
35425         return ret_conv;
35426 }
35427
35428 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_empty"))) TS_InvoiceFeatures_empty() {
35429         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
35430         uint32_t ret_ref = 0;
35431         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35432         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35433         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35434         ret_ref = (uintptr_t)ret_var.inner;
35435         if (ret_var.is_owned) {
35436                 ret_ref |= 1;
35437         }
35438         return ret_ref;
35439 }
35440
35441 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_known"))) TS_InvoiceFeatures_known() {
35442         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
35443         uint32_t ret_ref = 0;
35444         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35445         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35446         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35447         ret_ref = (uintptr_t)ret_var.inner;
35448         if (ret_var.is_owned) {
35449                 ret_ref |= 1;
35450         }
35451         return ret_ref;
35452 }
35453
35454 jboolean  __attribute__((export_name("TS_InvoiceFeatures_requires_unknown_bits"))) TS_InvoiceFeatures_requires_unknown_bits(uint32_t this_arg) {
35455         LDKInvoiceFeatures this_arg_conv;
35456         this_arg_conv.inner = (void*)(this_arg & (~1));
35457         this_arg_conv.is_owned = false;
35458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35459         jboolean ret_conv = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
35460         return ret_conv;
35461 }
35462
35463 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_empty"))) TS_ChannelTypeFeatures_empty() {
35464         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
35465         uint32_t ret_ref = 0;
35466         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35467         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35468         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35469         ret_ref = (uintptr_t)ret_var.inner;
35470         if (ret_var.is_owned) {
35471                 ret_ref |= 1;
35472         }
35473         return ret_ref;
35474 }
35475
35476 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_known"))) TS_ChannelTypeFeatures_known() {
35477         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_known();
35478         uint32_t ret_ref = 0;
35479         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35480         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35481         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35482         ret_ref = (uintptr_t)ret_var.inner;
35483         if (ret_var.is_owned) {
35484                 ret_ref |= 1;
35485         }
35486         return ret_ref;
35487 }
35488
35489 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_requires_unknown_bits"))) TS_ChannelTypeFeatures_requires_unknown_bits(uint32_t this_arg) {
35490         LDKChannelTypeFeatures this_arg_conv;
35491         this_arg_conv.inner = (void*)(this_arg & (~1));
35492         this_arg_conv.is_owned = false;
35493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35494         jboolean ret_conv = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
35495         return ret_conv;
35496 }
35497
35498 int8_tArray  __attribute__((export_name("TS_InitFeatures_write"))) TS_InitFeatures_write(uint32_t obj) {
35499         LDKInitFeatures obj_conv;
35500         obj_conv.inner = (void*)(obj & (~1));
35501         obj_conv.is_owned = false;
35502         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35503         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
35504         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35505         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35506         CVec_u8Z_free(ret_var);
35507         return ret_arr;
35508 }
35509
35510 uint32_t  __attribute__((export_name("TS_InitFeatures_read"))) TS_InitFeatures_read(int8_tArray ser) {
35511         LDKu8slice ser_ref;
35512         ser_ref.datalen = ser->arr_len;
35513         ser_ref.data = ser->elems /* XXX ser leaks */;
35514         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
35515         *ret_conv = InitFeatures_read(ser_ref);
35516         return (uint32_t)ret_conv;
35517 }
35518
35519 int8_tArray  __attribute__((export_name("TS_ChannelFeatures_write"))) TS_ChannelFeatures_write(uint32_t obj) {
35520         LDKChannelFeatures obj_conv;
35521         obj_conv.inner = (void*)(obj & (~1));
35522         obj_conv.is_owned = false;
35523         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35524         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
35525         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35526         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35527         CVec_u8Z_free(ret_var);
35528         return ret_arr;
35529 }
35530
35531 uint32_t  __attribute__((export_name("TS_ChannelFeatures_read"))) TS_ChannelFeatures_read(int8_tArray ser) {
35532         LDKu8slice ser_ref;
35533         ser_ref.datalen = ser->arr_len;
35534         ser_ref.data = ser->elems /* XXX ser leaks */;
35535         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
35536         *ret_conv = ChannelFeatures_read(ser_ref);
35537         return (uint32_t)ret_conv;
35538 }
35539
35540 int8_tArray  __attribute__((export_name("TS_NodeFeatures_write"))) TS_NodeFeatures_write(uint32_t obj) {
35541         LDKNodeFeatures obj_conv;
35542         obj_conv.inner = (void*)(obj & (~1));
35543         obj_conv.is_owned = false;
35544         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35545         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
35546         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35547         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35548         CVec_u8Z_free(ret_var);
35549         return ret_arr;
35550 }
35551
35552 uint32_t  __attribute__((export_name("TS_NodeFeatures_read"))) TS_NodeFeatures_read(int8_tArray ser) {
35553         LDKu8slice ser_ref;
35554         ser_ref.datalen = ser->arr_len;
35555         ser_ref.data = ser->elems /* XXX ser leaks */;
35556         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
35557         *ret_conv = NodeFeatures_read(ser_ref);
35558         return (uint32_t)ret_conv;
35559 }
35560
35561 int8_tArray  __attribute__((export_name("TS_InvoiceFeatures_write"))) TS_InvoiceFeatures_write(uint32_t obj) {
35562         LDKInvoiceFeatures obj_conv;
35563         obj_conv.inner = (void*)(obj & (~1));
35564         obj_conv.is_owned = false;
35565         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35566         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
35567         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35568         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35569         CVec_u8Z_free(ret_var);
35570         return ret_arr;
35571 }
35572
35573 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_read"))) TS_InvoiceFeatures_read(int8_tArray ser) {
35574         LDKu8slice ser_ref;
35575         ser_ref.datalen = ser->arr_len;
35576         ser_ref.data = ser->elems /* XXX ser leaks */;
35577         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
35578         *ret_conv = InvoiceFeatures_read(ser_ref);
35579         return (uint32_t)ret_conv;
35580 }
35581
35582 int8_tArray  __attribute__((export_name("TS_ChannelTypeFeatures_write"))) TS_ChannelTypeFeatures_write(uint32_t obj) {
35583         LDKChannelTypeFeatures obj_conv;
35584         obj_conv.inner = (void*)(obj & (~1));
35585         obj_conv.is_owned = false;
35586         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35587         LDKCVec_u8Z ret_var = ChannelTypeFeatures_write(&obj_conv);
35588         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35589         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35590         CVec_u8Z_free(ret_var);
35591         return ret_arr;
35592 }
35593
35594 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_read"))) TS_ChannelTypeFeatures_read(int8_tArray ser) {
35595         LDKu8slice ser_ref;
35596         ser_ref.datalen = ser->arr_len;
35597         ser_ref.data = ser->elems /* XXX ser leaks */;
35598         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
35599         *ret_conv = ChannelTypeFeatures_read(ser_ref);
35600         return (uint32_t)ret_conv;
35601 }
35602
35603 void  __attribute__((export_name("TS_ShutdownScript_free"))) TS_ShutdownScript_free(uint32_t this_obj) {
35604         LDKShutdownScript this_obj_conv;
35605         this_obj_conv.inner = (void*)(this_obj & (~1));
35606         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35607         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35608         ShutdownScript_free(this_obj_conv);
35609 }
35610
35611 static inline uintptr_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
35612         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
35613 uint32_t ret_ref = 0;
35614 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35615 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35616 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35617 ret_ref = (uintptr_t)ret_var.inner;
35618 if (ret_var.is_owned) {
35619         ret_ref |= 1;
35620 }
35621         return ret_ref;
35622 }
35623 uint32_t  __attribute__((export_name("TS_ShutdownScript_clone_ptr"))) TS_ShutdownScript_clone_ptr(uint32_t arg) {
35624         LDKShutdownScript arg_conv;
35625         arg_conv.inner = (void*)(arg & (~1));
35626         arg_conv.is_owned = false;
35627         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35628         uint32_t ret_conv = ShutdownScript_clone_ptr(&arg_conv);
35629         return ret_conv;
35630 }
35631
35632 uint32_t  __attribute__((export_name("TS_ShutdownScript_clone"))) TS_ShutdownScript_clone(uint32_t orig) {
35633         LDKShutdownScript orig_conv;
35634         orig_conv.inner = (void*)(orig & (~1));
35635         orig_conv.is_owned = false;
35636         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35637         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
35638         uint32_t ret_ref = 0;
35639         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35640         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35641         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35642         ret_ref = (uintptr_t)ret_var.inner;
35643         if (ret_var.is_owned) {
35644                 ret_ref |= 1;
35645         }
35646         return ret_ref;
35647 }
35648
35649 void  __attribute__((export_name("TS_InvalidShutdownScript_free"))) TS_InvalidShutdownScript_free(uint32_t this_obj) {
35650         LDKInvalidShutdownScript this_obj_conv;
35651         this_obj_conv.inner = (void*)(this_obj & (~1));
35652         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35654         InvalidShutdownScript_free(this_obj_conv);
35655 }
35656
35657 int8_tArray  __attribute__((export_name("TS_InvalidShutdownScript_get_script"))) TS_InvalidShutdownScript_get_script(uint32_t this_ptr) {
35658         LDKInvalidShutdownScript this_ptr_conv;
35659         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35660         this_ptr_conv.is_owned = false;
35661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35662         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
35663         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35664         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35665         return ret_arr;
35666 }
35667
35668 void  __attribute__((export_name("TS_InvalidShutdownScript_set_script"))) TS_InvalidShutdownScript_set_script(uint32_t this_ptr, int8_tArray val) {
35669         LDKInvalidShutdownScript this_ptr_conv;
35670         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35671         this_ptr_conv.is_owned = false;
35672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35673         LDKCVec_u8Z val_ref;
35674         val_ref.datalen = val->arr_len;
35675         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
35676         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
35677         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
35678 }
35679
35680 uint32_t  __attribute__((export_name("TS_InvalidShutdownScript_new"))) TS_InvalidShutdownScript_new(int8_tArray script_arg) {
35681         LDKCVec_u8Z script_arg_ref;
35682         script_arg_ref.datalen = script_arg->arr_len;
35683         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
35684         memcpy(script_arg_ref.data, script_arg->elems, script_arg_ref.datalen); FREE(script_arg);
35685         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
35686         uint32_t ret_ref = 0;
35687         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35688         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35689         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35690         ret_ref = (uintptr_t)ret_var.inner;
35691         if (ret_var.is_owned) {
35692                 ret_ref |= 1;
35693         }
35694         return ret_ref;
35695 }
35696
35697 static inline uintptr_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
35698         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
35699 uint32_t ret_ref = 0;
35700 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35701 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35702 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35703 ret_ref = (uintptr_t)ret_var.inner;
35704 if (ret_var.is_owned) {
35705         ret_ref |= 1;
35706 }
35707         return ret_ref;
35708 }
35709 uint32_t  __attribute__((export_name("TS_InvalidShutdownScript_clone_ptr"))) TS_InvalidShutdownScript_clone_ptr(uint32_t arg) {
35710         LDKInvalidShutdownScript arg_conv;
35711         arg_conv.inner = (void*)(arg & (~1));
35712         arg_conv.is_owned = false;
35713         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35714         uint32_t ret_conv = InvalidShutdownScript_clone_ptr(&arg_conv);
35715         return ret_conv;
35716 }
35717
35718 uint32_t  __attribute__((export_name("TS_InvalidShutdownScript_clone"))) TS_InvalidShutdownScript_clone(uint32_t orig) {
35719         LDKInvalidShutdownScript orig_conv;
35720         orig_conv.inner = (void*)(orig & (~1));
35721         orig_conv.is_owned = false;
35722         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35723         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
35724         uint32_t ret_ref = 0;
35725         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35726         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35727         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35728         ret_ref = (uintptr_t)ret_var.inner;
35729         if (ret_var.is_owned) {
35730                 ret_ref |= 1;
35731         }
35732         return ret_ref;
35733 }
35734
35735 int8_tArray  __attribute__((export_name("TS_ShutdownScript_write"))) TS_ShutdownScript_write(uint32_t obj) {
35736         LDKShutdownScript obj_conv;
35737         obj_conv.inner = (void*)(obj & (~1));
35738         obj_conv.is_owned = false;
35739         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35740         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
35741         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35742         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35743         CVec_u8Z_free(ret_var);
35744         return ret_arr;
35745 }
35746
35747 uint32_t  __attribute__((export_name("TS_ShutdownScript_read"))) TS_ShutdownScript_read(int8_tArray ser) {
35748         LDKu8slice ser_ref;
35749         ser_ref.datalen = ser->arr_len;
35750         ser_ref.data = ser->elems /* XXX ser leaks */;
35751         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
35752         *ret_conv = ShutdownScript_read(ser_ref);
35753         return (uint32_t)ret_conv;
35754 }
35755
35756 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_p2wpkh"))) TS_ShutdownScript_new_p2wpkh(int8_tArray pubkey_hash) {
35757         unsigned char pubkey_hash_arr[20];
35758         CHECK(pubkey_hash->arr_len == 20);
35759         memcpy(pubkey_hash_arr, pubkey_hash->elems, 20); FREE(pubkey_hash);
35760         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
35761         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
35762         uint32_t ret_ref = 0;
35763         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35764         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35765         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35766         ret_ref = (uintptr_t)ret_var.inner;
35767         if (ret_var.is_owned) {
35768                 ret_ref |= 1;
35769         }
35770         return ret_ref;
35771 }
35772
35773 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_p2wsh"))) TS_ShutdownScript_new_p2wsh(int8_tArray script_hash) {
35774         unsigned char script_hash_arr[32];
35775         CHECK(script_hash->arr_len == 32);
35776         memcpy(script_hash_arr, script_hash->elems, 32); FREE(script_hash);
35777         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
35778         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
35779         uint32_t ret_ref = 0;
35780         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35781         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35782         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35783         ret_ref = (uintptr_t)ret_var.inner;
35784         if (ret_var.is_owned) {
35785                 ret_ref |= 1;
35786         }
35787         return ret_ref;
35788 }
35789
35790 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_witness_program"))) TS_ShutdownScript_new_witness_program(int8_t version, int8_tArray program) {
35791         LDKu8slice program_ref;
35792         program_ref.datalen = program->arr_len;
35793         program_ref.data = program->elems /* XXX program leaks */;
35794         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
35795         *ret_conv = ShutdownScript_new_witness_program(version, program_ref);
35796         return (uint32_t)ret_conv;
35797 }
35798
35799 int8_tArray  __attribute__((export_name("TS_ShutdownScript_into_inner"))) TS_ShutdownScript_into_inner(uint32_t this_arg) {
35800         LDKShutdownScript this_arg_conv;
35801         this_arg_conv.inner = (void*)(this_arg & (~1));
35802         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
35803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35804         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
35805         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
35806         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35807         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35808         CVec_u8Z_free(ret_var);
35809         return ret_arr;
35810 }
35811
35812 int8_tArray  __attribute__((export_name("TS_ShutdownScript_as_legacy_pubkey"))) TS_ShutdownScript_as_legacy_pubkey(uint32_t this_arg) {
35813         LDKShutdownScript this_arg_conv;
35814         this_arg_conv.inner = (void*)(this_arg & (~1));
35815         this_arg_conv.is_owned = false;
35816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35817         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35818         memcpy(ret_arr->elems, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form, 33);
35819         return ret_arr;
35820 }
35821
35822 jboolean  __attribute__((export_name("TS_ShutdownScript_is_compatible"))) TS_ShutdownScript_is_compatible(uint32_t this_arg, uint32_t features) {
35823         LDKShutdownScript this_arg_conv;
35824         this_arg_conv.inner = (void*)(this_arg & (~1));
35825         this_arg_conv.is_owned = false;
35826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35827         LDKInitFeatures features_conv;
35828         features_conv.inner = (void*)(features & (~1));
35829         features_conv.is_owned = false;
35830         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
35831         jboolean ret_conv = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
35832         return ret_conv;
35833 }
35834
35835 void  __attribute__((export_name("TS_CustomMessageReader_free"))) TS_CustomMessageReader_free(uint32_t this_ptr) {
35836         if ((this_ptr & 1) != 0) return;
35837         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
35838         CHECK_ACCESS(this_ptr_ptr);
35839         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
35840         FREE((void*)this_ptr);
35841         CustomMessageReader_free(this_ptr_conv);
35842 }
35843
35844 static inline uintptr_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
35845         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
35846         *ret_ret = Type_clone(arg);
35847         return (uint32_t)ret_ret;
35848 }
35849 uint32_t  __attribute__((export_name("TS_Type_clone_ptr"))) TS_Type_clone_ptr(uint32_t arg) {
35850         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
35851         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
35852         LDKType* arg_conv = (LDKType*)arg_ptr;
35853         uint32_t ret_conv = Type_clone_ptr(arg_conv);
35854         return ret_conv;
35855 }
35856
35857 uint32_t  __attribute__((export_name("TS_Type_clone"))) TS_Type_clone(uint32_t orig) {
35858         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
35859         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
35860         LDKType* orig_conv = (LDKType*)orig_ptr;
35861         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
35862         *ret_ret = Type_clone(orig_conv);
35863         return (uint32_t)ret_ret;
35864 }
35865
35866 void  __attribute__((export_name("TS_Type_free"))) TS_Type_free(uint32_t this_ptr) {
35867         if ((this_ptr & 1) != 0) return;
35868         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
35869         CHECK_ACCESS(this_ptr_ptr);
35870         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
35871         FREE((void*)this_ptr);
35872         Type_free(this_ptr_conv);
35873 }
35874
35875 void  __attribute__((export_name("TS_NodeId_free"))) TS_NodeId_free(uint32_t this_obj) {
35876         LDKNodeId this_obj_conv;
35877         this_obj_conv.inner = (void*)(this_obj & (~1));
35878         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35880         NodeId_free(this_obj_conv);
35881 }
35882
35883 static inline uintptr_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
35884         LDKNodeId ret_var = NodeId_clone(arg);
35885 uint32_t ret_ref = 0;
35886 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35887 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35888 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35889 ret_ref = (uintptr_t)ret_var.inner;
35890 if (ret_var.is_owned) {
35891         ret_ref |= 1;
35892 }
35893         return ret_ref;
35894 }
35895 uint32_t  __attribute__((export_name("TS_NodeId_clone_ptr"))) TS_NodeId_clone_ptr(uint32_t arg) {
35896         LDKNodeId arg_conv;
35897         arg_conv.inner = (void*)(arg & (~1));
35898         arg_conv.is_owned = false;
35899         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35900         uint32_t ret_conv = NodeId_clone_ptr(&arg_conv);
35901         return ret_conv;
35902 }
35903
35904 uint32_t  __attribute__((export_name("TS_NodeId_clone"))) TS_NodeId_clone(uint32_t orig) {
35905         LDKNodeId orig_conv;
35906         orig_conv.inner = (void*)(orig & (~1));
35907         orig_conv.is_owned = false;
35908         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35909         LDKNodeId ret_var = NodeId_clone(&orig_conv);
35910         uint32_t ret_ref = 0;
35911         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35912         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35913         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35914         ret_ref = (uintptr_t)ret_var.inner;
35915         if (ret_var.is_owned) {
35916                 ret_ref |= 1;
35917         }
35918         return ret_ref;
35919 }
35920
35921 uint32_t  __attribute__((export_name("TS_NodeId_from_pubkey"))) TS_NodeId_from_pubkey(int8_tArray pubkey) {
35922         LDKPublicKey pubkey_ref;
35923         CHECK(pubkey->arr_len == 33);
35924         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
35925         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
35926         uint32_t ret_ref = 0;
35927         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35928         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35929         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35930         ret_ref = (uintptr_t)ret_var.inner;
35931         if (ret_var.is_owned) {
35932                 ret_ref |= 1;
35933         }
35934         return ret_ref;
35935 }
35936
35937 int8_tArray  __attribute__((export_name("TS_NodeId_as_slice"))) TS_NodeId_as_slice(uint32_t this_arg) {
35938         LDKNodeId this_arg_conv;
35939         this_arg_conv.inner = (void*)(this_arg & (~1));
35940         this_arg_conv.is_owned = false;
35941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35942         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
35943         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35944         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35945         return ret_arr;
35946 }
35947
35948 int64_t  __attribute__((export_name("TS_NodeId_hash"))) TS_NodeId_hash(uint32_t o) {
35949         LDKNodeId o_conv;
35950         o_conv.inner = (void*)(o & (~1));
35951         o_conv.is_owned = false;
35952         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
35953         int64_t ret_conv = NodeId_hash(&o_conv);
35954         return ret_conv;
35955 }
35956
35957 int8_tArray  __attribute__((export_name("TS_NodeId_write"))) TS_NodeId_write(uint32_t obj) {
35958         LDKNodeId obj_conv;
35959         obj_conv.inner = (void*)(obj & (~1));
35960         obj_conv.is_owned = false;
35961         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35962         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
35963         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35964         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35965         CVec_u8Z_free(ret_var);
35966         return ret_arr;
35967 }
35968
35969 uint32_t  __attribute__((export_name("TS_NodeId_read"))) TS_NodeId_read(int8_tArray ser) {
35970         LDKu8slice ser_ref;
35971         ser_ref.datalen = ser->arr_len;
35972         ser_ref.data = ser->elems /* XXX ser leaks */;
35973         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
35974         *ret_conv = NodeId_read(ser_ref);
35975         return (uint32_t)ret_conv;
35976 }
35977
35978 void  __attribute__((export_name("TS_NetworkGraph_free"))) TS_NetworkGraph_free(uint32_t this_obj) {
35979         LDKNetworkGraph this_obj_conv;
35980         this_obj_conv.inner = (void*)(this_obj & (~1));
35981         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35983         NetworkGraph_free(this_obj_conv);
35984 }
35985
35986 static inline uintptr_t NetworkGraph_clone_ptr(LDKNetworkGraph *NONNULL_PTR arg) {
35987         LDKNetworkGraph ret_var = NetworkGraph_clone(arg);
35988 uint32_t ret_ref = 0;
35989 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35990 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35991 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35992 ret_ref = (uintptr_t)ret_var.inner;
35993 if (ret_var.is_owned) {
35994         ret_ref |= 1;
35995 }
35996         return ret_ref;
35997 }
35998 uint32_t  __attribute__((export_name("TS_NetworkGraph_clone_ptr"))) TS_NetworkGraph_clone_ptr(uint32_t arg) {
35999         LDKNetworkGraph arg_conv;
36000         arg_conv.inner = (void*)(arg & (~1));
36001         arg_conv.is_owned = false;
36002         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36003         uint32_t ret_conv = NetworkGraph_clone_ptr(&arg_conv);
36004         return ret_conv;
36005 }
36006
36007 uint32_t  __attribute__((export_name("TS_NetworkGraph_clone"))) TS_NetworkGraph_clone(uint32_t orig) {
36008         LDKNetworkGraph orig_conv;
36009         orig_conv.inner = (void*)(orig & (~1));
36010         orig_conv.is_owned = false;
36011         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36012         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
36013         uint32_t ret_ref = 0;
36014         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36015         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36016         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36017         ret_ref = (uintptr_t)ret_var.inner;
36018         if (ret_var.is_owned) {
36019                 ret_ref |= 1;
36020         }
36021         return ret_ref;
36022 }
36023
36024 void  __attribute__((export_name("TS_ReadOnlyNetworkGraph_free"))) TS_ReadOnlyNetworkGraph_free(uint32_t this_obj) {
36025         LDKReadOnlyNetworkGraph this_obj_conv;
36026         this_obj_conv.inner = (void*)(this_obj & (~1));
36027         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36029         ReadOnlyNetworkGraph_free(this_obj_conv);
36030 }
36031
36032 void  __attribute__((export_name("TS_NetworkUpdate_free"))) TS_NetworkUpdate_free(uint32_t this_ptr) {
36033         if ((this_ptr & 1) != 0) return;
36034         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
36035         CHECK_ACCESS(this_ptr_ptr);
36036         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
36037         FREE((void*)this_ptr);
36038         NetworkUpdate_free(this_ptr_conv);
36039 }
36040
36041 static inline uintptr_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
36042         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
36043         *ret_copy = NetworkUpdate_clone(arg);
36044 uint32_t ret_ref = (uintptr_t)ret_copy;
36045         return ret_ref;
36046 }
36047 uint32_t  __attribute__((export_name("TS_NetworkUpdate_clone_ptr"))) TS_NetworkUpdate_clone_ptr(uint32_t arg) {
36048         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)arg;
36049         uint32_t ret_conv = NetworkUpdate_clone_ptr(arg_conv);
36050         return ret_conv;
36051 }
36052
36053 uint32_t  __attribute__((export_name("TS_NetworkUpdate_clone"))) TS_NetworkUpdate_clone(uint32_t orig) {
36054         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig;
36055         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
36056         *ret_copy = NetworkUpdate_clone(orig_conv);
36057         uint32_t ret_ref = (uintptr_t)ret_copy;
36058         return ret_ref;
36059 }
36060
36061 uint32_t  __attribute__((export_name("TS_NetworkUpdate_channel_update_message"))) TS_NetworkUpdate_channel_update_message(uint32_t msg) {
36062         LDKChannelUpdate msg_conv;
36063         msg_conv.inner = (void*)(msg & (~1));
36064         msg_conv.is_owned = (msg & 1) || (msg == 0);
36065         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36066         msg_conv = ChannelUpdate_clone(&msg_conv);
36067         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
36068         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
36069         uint32_t ret_ref = (uintptr_t)ret_copy;
36070         return ret_ref;
36071 }
36072
36073 uint32_t  __attribute__((export_name("TS_NetworkUpdate_channel_closed"))) TS_NetworkUpdate_channel_closed(int64_t short_channel_id, jboolean is_permanent) {
36074         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
36075         *ret_copy = NetworkUpdate_channel_closed(short_channel_id, is_permanent);
36076         uint32_t ret_ref = (uintptr_t)ret_copy;
36077         return ret_ref;
36078 }
36079
36080 uint32_t  __attribute__((export_name("TS_NetworkUpdate_node_failure"))) TS_NetworkUpdate_node_failure(int8_tArray node_id, jboolean is_permanent) {
36081         LDKPublicKey node_id_ref;
36082         CHECK(node_id->arr_len == 33);
36083         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
36084         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
36085         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
36086         uint32_t ret_ref = (uintptr_t)ret_copy;
36087         return ret_ref;
36088 }
36089
36090 int8_tArray  __attribute__((export_name("TS_NetworkUpdate_write"))) TS_NetworkUpdate_write(uint32_t obj) {
36091         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj;
36092         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
36093         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36094         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36095         CVec_u8Z_free(ret_var);
36096         return ret_arr;
36097 }
36098
36099 uint32_t  __attribute__((export_name("TS_NetworkUpdate_read"))) TS_NetworkUpdate_read(int8_tArray ser) {
36100         LDKu8slice ser_ref;
36101         ser_ref.datalen = ser->arr_len;
36102         ser_ref.data = ser->elems /* XXX ser leaks */;
36103         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
36104         *ret_conv = NetworkUpdate_read(ser_ref);
36105         return (uint32_t)ret_conv;
36106 }
36107
36108 uint32_t  __attribute__((export_name("TS_NetGraphMsgHandler_as_EventHandler"))) TS_NetGraphMsgHandler_as_EventHandler(uint32_t this_arg) {
36109         LDKNetGraphMsgHandler this_arg_conv;
36110         this_arg_conv.inner = (void*)(this_arg & (~1));
36111         this_arg_conv.is_owned = false;
36112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36113         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
36114         *ret_ret = NetGraphMsgHandler_as_EventHandler(&this_arg_conv);
36115         return (uint32_t)ret_ret;
36116 }
36117
36118 void  __attribute__((export_name("TS_NetGraphMsgHandler_free"))) TS_NetGraphMsgHandler_free(uint32_t this_obj) {
36119         LDKNetGraphMsgHandler this_obj_conv;
36120         this_obj_conv.inner = (void*)(this_obj & (~1));
36121         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36123         NetGraphMsgHandler_free(this_obj_conv);
36124 }
36125
36126 uint32_t  __attribute__((export_name("TS_NetGraphMsgHandler_new"))) TS_NetGraphMsgHandler_new(uint32_t network_graph, uint32_t chain_access, uint32_t logger) {
36127         LDKNetworkGraph network_graph_conv;
36128         network_graph_conv.inner = (void*)(network_graph & (~1));
36129         network_graph_conv.is_owned = false;
36130         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
36131         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
36132         CHECK_ACCESS(chain_access_ptr);
36133         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
36134         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
36135         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
36136                 // Manually implement clone for Java trait instances
36137                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
36138                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36139                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
36140                 }
36141         }
36142         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
36143         CHECK_ACCESS(logger_ptr);
36144         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
36145         if (logger_conv.free == LDKLogger_JCalls_free) {
36146                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36147                 LDKLogger_JCalls_cloned(&logger_conv);
36148         }
36149         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(&network_graph_conv, chain_access_conv, logger_conv);
36150         uint32_t ret_ref = 0;
36151         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36152         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36153         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36154         ret_ref = (uintptr_t)ret_var.inner;
36155         if (ret_var.is_owned) {
36156                 ret_ref |= 1;
36157         }
36158         return ret_ref;
36159 }
36160
36161 void  __attribute__((export_name("TS_NetGraphMsgHandler_add_chain_access"))) TS_NetGraphMsgHandler_add_chain_access(uint32_t this_arg, uint32_t chain_access) {
36162         LDKNetGraphMsgHandler this_arg_conv;
36163         this_arg_conv.inner = (void*)(this_arg & (~1));
36164         this_arg_conv.is_owned = false;
36165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36166         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
36167         CHECK_ACCESS(chain_access_ptr);
36168         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
36169         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
36170         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
36171                 // Manually implement clone for Java trait instances
36172                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
36173                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36174                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
36175                 }
36176         }
36177         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv);
36178 }
36179
36180 uint32_t  __attribute__((export_name("TS_NetGraphMsgHandler_as_RoutingMessageHandler"))) TS_NetGraphMsgHandler_as_RoutingMessageHandler(uint32_t this_arg) {
36181         LDKNetGraphMsgHandler this_arg_conv;
36182         this_arg_conv.inner = (void*)(this_arg & (~1));
36183         this_arg_conv.is_owned = false;
36184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36185         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
36186         *ret_ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
36187         return (uint32_t)ret_ret;
36188 }
36189
36190 uint32_t  __attribute__((export_name("TS_NetGraphMsgHandler_as_MessageSendEventsProvider"))) TS_NetGraphMsgHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
36191         LDKNetGraphMsgHandler this_arg_conv;
36192         this_arg_conv.inner = (void*)(this_arg & (~1));
36193         this_arg_conv.is_owned = false;
36194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36195         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
36196         *ret_ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
36197         return (uint32_t)ret_ret;
36198 }
36199
36200 void  __attribute__((export_name("TS_ChannelUpdateInfo_free"))) TS_ChannelUpdateInfo_free(uint32_t this_obj) {
36201         LDKChannelUpdateInfo this_obj_conv;
36202         this_obj_conv.inner = (void*)(this_obj & (~1));
36203         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36205         ChannelUpdateInfo_free(this_obj_conv);
36206 }
36207
36208 int32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_last_update"))) TS_ChannelUpdateInfo_get_last_update(uint32_t this_ptr) {
36209         LDKChannelUpdateInfo this_ptr_conv;
36210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36211         this_ptr_conv.is_owned = false;
36212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36213         int32_t ret_conv = ChannelUpdateInfo_get_last_update(&this_ptr_conv);
36214         return ret_conv;
36215 }
36216
36217 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_last_update"))) TS_ChannelUpdateInfo_set_last_update(uint32_t this_ptr, int32_t val) {
36218         LDKChannelUpdateInfo this_ptr_conv;
36219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36220         this_ptr_conv.is_owned = false;
36221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36222         ChannelUpdateInfo_set_last_update(&this_ptr_conv, val);
36223 }
36224
36225 jboolean  __attribute__((export_name("TS_ChannelUpdateInfo_get_enabled"))) TS_ChannelUpdateInfo_get_enabled(uint32_t this_ptr) {
36226         LDKChannelUpdateInfo this_ptr_conv;
36227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36228         this_ptr_conv.is_owned = false;
36229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36230         jboolean ret_conv = ChannelUpdateInfo_get_enabled(&this_ptr_conv);
36231         return ret_conv;
36232 }
36233
36234 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_enabled"))) TS_ChannelUpdateInfo_set_enabled(uint32_t this_ptr, jboolean val) {
36235         LDKChannelUpdateInfo this_ptr_conv;
36236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36237         this_ptr_conv.is_owned = false;
36238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36239         ChannelUpdateInfo_set_enabled(&this_ptr_conv, val);
36240 }
36241
36242 int16_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_cltv_expiry_delta"))) TS_ChannelUpdateInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
36243         LDKChannelUpdateInfo this_ptr_conv;
36244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36245         this_ptr_conv.is_owned = false;
36246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36247         int16_t ret_conv = ChannelUpdateInfo_get_cltv_expiry_delta(&this_ptr_conv);
36248         return ret_conv;
36249 }
36250
36251 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_cltv_expiry_delta"))) TS_ChannelUpdateInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
36252         LDKChannelUpdateInfo this_ptr_conv;
36253         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36254         this_ptr_conv.is_owned = false;
36255         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36256         ChannelUpdateInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
36257 }
36258
36259 int64_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_htlc_minimum_msat"))) TS_ChannelUpdateInfo_get_htlc_minimum_msat(uint32_t this_ptr) {
36260         LDKChannelUpdateInfo this_ptr_conv;
36261         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36262         this_ptr_conv.is_owned = false;
36263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36264         int64_t ret_conv = ChannelUpdateInfo_get_htlc_minimum_msat(&this_ptr_conv);
36265         return ret_conv;
36266 }
36267
36268 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_htlc_minimum_msat"))) TS_ChannelUpdateInfo_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
36269         LDKChannelUpdateInfo this_ptr_conv;
36270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36271         this_ptr_conv.is_owned = false;
36272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36273         ChannelUpdateInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
36274 }
36275
36276 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_htlc_maximum_msat"))) TS_ChannelUpdateInfo_get_htlc_maximum_msat(uint32_t this_ptr) {
36277         LDKChannelUpdateInfo this_ptr_conv;
36278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36279         this_ptr_conv.is_owned = false;
36280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36281         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
36282         *ret_copy = ChannelUpdateInfo_get_htlc_maximum_msat(&this_ptr_conv);
36283         uint32_t ret_ref = (uintptr_t)ret_copy;
36284         return ret_ref;
36285 }
36286
36287 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_htlc_maximum_msat"))) TS_ChannelUpdateInfo_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
36288         LDKChannelUpdateInfo this_ptr_conv;
36289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36290         this_ptr_conv.is_owned = false;
36291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36292         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
36293         CHECK_ACCESS(val_ptr);
36294         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
36295         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
36296         ChannelUpdateInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
36297 }
36298
36299 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_fees"))) TS_ChannelUpdateInfo_get_fees(uint32_t this_ptr) {
36300         LDKChannelUpdateInfo this_ptr_conv;
36301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36302         this_ptr_conv.is_owned = false;
36303         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36304         LDKRoutingFees ret_var = ChannelUpdateInfo_get_fees(&this_ptr_conv);
36305         uint32_t ret_ref = 0;
36306         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36307         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36308         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36309         ret_ref = (uintptr_t)ret_var.inner;
36310         if (ret_var.is_owned) {
36311                 ret_ref |= 1;
36312         }
36313         return ret_ref;
36314 }
36315
36316 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_fees"))) TS_ChannelUpdateInfo_set_fees(uint32_t this_ptr, uint32_t val) {
36317         LDKChannelUpdateInfo this_ptr_conv;
36318         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36319         this_ptr_conv.is_owned = false;
36320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36321         LDKRoutingFees val_conv;
36322         val_conv.inner = (void*)(val & (~1));
36323         val_conv.is_owned = (val & 1) || (val == 0);
36324         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36325         val_conv = RoutingFees_clone(&val_conv);
36326         ChannelUpdateInfo_set_fees(&this_ptr_conv, val_conv);
36327 }
36328
36329 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_last_update_message"))) TS_ChannelUpdateInfo_get_last_update_message(uint32_t this_ptr) {
36330         LDKChannelUpdateInfo this_ptr_conv;
36331         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36332         this_ptr_conv.is_owned = false;
36333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36334         LDKChannelUpdate ret_var = ChannelUpdateInfo_get_last_update_message(&this_ptr_conv);
36335         uint32_t ret_ref = 0;
36336         if ((uintptr_t)ret_var.inner > 4096) {
36337                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36338                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36339         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36340                 ret_ref = (uintptr_t)ret_var.inner;
36341                 if (ret_var.is_owned) {
36342                         ret_ref |= 1;
36343                 }
36344         }
36345         return ret_ref;
36346 }
36347
36348 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_last_update_message"))) TS_ChannelUpdateInfo_set_last_update_message(uint32_t this_ptr, uint32_t val) {
36349         LDKChannelUpdateInfo this_ptr_conv;
36350         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36351         this_ptr_conv.is_owned = false;
36352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36353         LDKChannelUpdate val_conv;
36354         val_conv.inner = (void*)(val & (~1));
36355         val_conv.is_owned = (val & 1) || (val == 0);
36356         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36357         val_conv = ChannelUpdate_clone(&val_conv);
36358         ChannelUpdateInfo_set_last_update_message(&this_ptr_conv, val_conv);
36359 }
36360
36361 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) {
36362         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
36363         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
36364         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
36365         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
36366         LDKRoutingFees fees_arg_conv;
36367         fees_arg_conv.inner = (void*)(fees_arg & (~1));
36368         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
36369         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
36370         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
36371         LDKChannelUpdate last_update_message_arg_conv;
36372         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
36373         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
36374         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
36375         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
36376         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);
36377         uint32_t ret_ref = 0;
36378         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36379         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36380         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36381         ret_ref = (uintptr_t)ret_var.inner;
36382         if (ret_var.is_owned) {
36383                 ret_ref |= 1;
36384         }
36385         return ret_ref;
36386 }
36387
36388 static inline uintptr_t ChannelUpdateInfo_clone_ptr(LDKChannelUpdateInfo *NONNULL_PTR arg) {
36389         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(arg);
36390 uint32_t ret_ref = 0;
36391 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36392 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36393 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36394 ret_ref = (uintptr_t)ret_var.inner;
36395 if (ret_var.is_owned) {
36396         ret_ref |= 1;
36397 }
36398         return ret_ref;
36399 }
36400 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_clone_ptr"))) TS_ChannelUpdateInfo_clone_ptr(uint32_t arg) {
36401         LDKChannelUpdateInfo arg_conv;
36402         arg_conv.inner = (void*)(arg & (~1));
36403         arg_conv.is_owned = false;
36404         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36405         uint32_t ret_conv = ChannelUpdateInfo_clone_ptr(&arg_conv);
36406         return ret_conv;
36407 }
36408
36409 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_clone"))) TS_ChannelUpdateInfo_clone(uint32_t orig) {
36410         LDKChannelUpdateInfo orig_conv;
36411         orig_conv.inner = (void*)(orig & (~1));
36412         orig_conv.is_owned = false;
36413         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36414         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(&orig_conv);
36415         uint32_t ret_ref = 0;
36416         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36417         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36418         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36419         ret_ref = (uintptr_t)ret_var.inner;
36420         if (ret_var.is_owned) {
36421                 ret_ref |= 1;
36422         }
36423         return ret_ref;
36424 }
36425
36426 int8_tArray  __attribute__((export_name("TS_ChannelUpdateInfo_write"))) TS_ChannelUpdateInfo_write(uint32_t obj) {
36427         LDKChannelUpdateInfo obj_conv;
36428         obj_conv.inner = (void*)(obj & (~1));
36429         obj_conv.is_owned = false;
36430         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36431         LDKCVec_u8Z ret_var = ChannelUpdateInfo_write(&obj_conv);
36432         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36433         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36434         CVec_u8Z_free(ret_var);
36435         return ret_arr;
36436 }
36437
36438 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_read"))) TS_ChannelUpdateInfo_read(int8_tArray ser) {
36439         LDKu8slice ser_ref;
36440         ser_ref.datalen = ser->arr_len;
36441         ser_ref.data = ser->elems /* XXX ser leaks */;
36442         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
36443         *ret_conv = ChannelUpdateInfo_read(ser_ref);
36444         return (uint32_t)ret_conv;
36445 }
36446
36447 void  __attribute__((export_name("TS_ChannelInfo_free"))) TS_ChannelInfo_free(uint32_t this_obj) {
36448         LDKChannelInfo this_obj_conv;
36449         this_obj_conv.inner = (void*)(this_obj & (~1));
36450         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36452         ChannelInfo_free(this_obj_conv);
36453 }
36454
36455 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_features"))) TS_ChannelInfo_get_features(uint32_t this_ptr) {
36456         LDKChannelInfo this_ptr_conv;
36457         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36458         this_ptr_conv.is_owned = false;
36459         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36460         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
36461         uint32_t ret_ref = 0;
36462         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36463         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36464         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36465         ret_ref = (uintptr_t)ret_var.inner;
36466         if (ret_var.is_owned) {
36467                 ret_ref |= 1;
36468         }
36469         return ret_ref;
36470 }
36471
36472 void  __attribute__((export_name("TS_ChannelInfo_set_features"))) TS_ChannelInfo_set_features(uint32_t this_ptr, uint32_t val) {
36473         LDKChannelInfo this_ptr_conv;
36474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36475         this_ptr_conv.is_owned = false;
36476         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36477         LDKChannelFeatures val_conv;
36478         val_conv.inner = (void*)(val & (~1));
36479         val_conv.is_owned = (val & 1) || (val == 0);
36480         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36481         val_conv = ChannelFeatures_clone(&val_conv);
36482         ChannelInfo_set_features(&this_ptr_conv, val_conv);
36483 }
36484
36485 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_node_one"))) TS_ChannelInfo_get_node_one(uint32_t this_ptr) {
36486         LDKChannelInfo this_ptr_conv;
36487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36488         this_ptr_conv.is_owned = false;
36489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36490         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
36491         uint32_t ret_ref = 0;
36492         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36493         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36494         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36495         ret_ref = (uintptr_t)ret_var.inner;
36496         if (ret_var.is_owned) {
36497                 ret_ref |= 1;
36498         }
36499         return ret_ref;
36500 }
36501
36502 void  __attribute__((export_name("TS_ChannelInfo_set_node_one"))) TS_ChannelInfo_set_node_one(uint32_t this_ptr, uint32_t val) {
36503         LDKChannelInfo this_ptr_conv;
36504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36505         this_ptr_conv.is_owned = false;
36506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36507         LDKNodeId val_conv;
36508         val_conv.inner = (void*)(val & (~1));
36509         val_conv.is_owned = (val & 1) || (val == 0);
36510         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36511         val_conv = NodeId_clone(&val_conv);
36512         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
36513 }
36514
36515 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_one_to_two"))) TS_ChannelInfo_get_one_to_two(uint32_t this_ptr) {
36516         LDKChannelInfo this_ptr_conv;
36517         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36518         this_ptr_conv.is_owned = false;
36519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36520         LDKChannelUpdateInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
36521         uint32_t ret_ref = 0;
36522         if ((uintptr_t)ret_var.inner > 4096) {
36523                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36524                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36525         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36526                 ret_ref = (uintptr_t)ret_var.inner;
36527                 if (ret_var.is_owned) {
36528                         ret_ref |= 1;
36529                 }
36530         }
36531         return ret_ref;
36532 }
36533
36534 void  __attribute__((export_name("TS_ChannelInfo_set_one_to_two"))) TS_ChannelInfo_set_one_to_two(uint32_t this_ptr, uint32_t val) {
36535         LDKChannelInfo this_ptr_conv;
36536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36537         this_ptr_conv.is_owned = false;
36538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36539         LDKChannelUpdateInfo val_conv;
36540         val_conv.inner = (void*)(val & (~1));
36541         val_conv.is_owned = (val & 1) || (val == 0);
36542         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36543         val_conv = ChannelUpdateInfo_clone(&val_conv);
36544         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
36545 }
36546
36547 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_node_two"))) TS_ChannelInfo_get_node_two(uint32_t this_ptr) {
36548         LDKChannelInfo this_ptr_conv;
36549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36550         this_ptr_conv.is_owned = false;
36551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36552         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
36553         uint32_t ret_ref = 0;
36554         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36555         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36556         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36557         ret_ref = (uintptr_t)ret_var.inner;
36558         if (ret_var.is_owned) {
36559                 ret_ref |= 1;
36560         }
36561         return ret_ref;
36562 }
36563
36564 void  __attribute__((export_name("TS_ChannelInfo_set_node_two"))) TS_ChannelInfo_set_node_two(uint32_t this_ptr, uint32_t val) {
36565         LDKChannelInfo this_ptr_conv;
36566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36567         this_ptr_conv.is_owned = false;
36568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36569         LDKNodeId val_conv;
36570         val_conv.inner = (void*)(val & (~1));
36571         val_conv.is_owned = (val & 1) || (val == 0);
36572         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36573         val_conv = NodeId_clone(&val_conv);
36574         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
36575 }
36576
36577 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_two_to_one"))) TS_ChannelInfo_get_two_to_one(uint32_t this_ptr) {
36578         LDKChannelInfo this_ptr_conv;
36579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36580         this_ptr_conv.is_owned = false;
36581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36582         LDKChannelUpdateInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
36583         uint32_t ret_ref = 0;
36584         if ((uintptr_t)ret_var.inner > 4096) {
36585                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36586                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36587         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36588                 ret_ref = (uintptr_t)ret_var.inner;
36589                 if (ret_var.is_owned) {
36590                         ret_ref |= 1;
36591                 }
36592         }
36593         return ret_ref;
36594 }
36595
36596 void  __attribute__((export_name("TS_ChannelInfo_set_two_to_one"))) TS_ChannelInfo_set_two_to_one(uint32_t this_ptr, uint32_t val) {
36597         LDKChannelInfo this_ptr_conv;
36598         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36599         this_ptr_conv.is_owned = false;
36600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36601         LDKChannelUpdateInfo val_conv;
36602         val_conv.inner = (void*)(val & (~1));
36603         val_conv.is_owned = (val & 1) || (val == 0);
36604         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36605         val_conv = ChannelUpdateInfo_clone(&val_conv);
36606         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
36607 }
36608
36609 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_capacity_sats"))) TS_ChannelInfo_get_capacity_sats(uint32_t this_ptr) {
36610         LDKChannelInfo this_ptr_conv;
36611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36612         this_ptr_conv.is_owned = false;
36613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36614         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
36615         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
36616         uint32_t ret_ref = (uintptr_t)ret_copy;
36617         return ret_ref;
36618 }
36619
36620 void  __attribute__((export_name("TS_ChannelInfo_set_capacity_sats"))) TS_ChannelInfo_set_capacity_sats(uint32_t this_ptr, uint32_t val) {
36621         LDKChannelInfo this_ptr_conv;
36622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36623         this_ptr_conv.is_owned = false;
36624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36625         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
36626         CHECK_ACCESS(val_ptr);
36627         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
36628         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
36629         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
36630 }
36631
36632 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_announcement_message"))) TS_ChannelInfo_get_announcement_message(uint32_t this_ptr) {
36633         LDKChannelInfo this_ptr_conv;
36634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36635         this_ptr_conv.is_owned = false;
36636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36637         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
36638         uint32_t ret_ref = 0;
36639         if ((uintptr_t)ret_var.inner > 4096) {
36640                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36641                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36642         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36643                 ret_ref = (uintptr_t)ret_var.inner;
36644                 if (ret_var.is_owned) {
36645                         ret_ref |= 1;
36646                 }
36647         }
36648         return ret_ref;
36649 }
36650
36651 void  __attribute__((export_name("TS_ChannelInfo_set_announcement_message"))) TS_ChannelInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
36652         LDKChannelInfo this_ptr_conv;
36653         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36654         this_ptr_conv.is_owned = false;
36655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36656         LDKChannelAnnouncement val_conv;
36657         val_conv.inner = (void*)(val & (~1));
36658         val_conv.is_owned = (val & 1) || (val == 0);
36659         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36660         val_conv = ChannelAnnouncement_clone(&val_conv);
36661         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
36662 }
36663
36664 static inline uintptr_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
36665         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
36666 uint32_t ret_ref = 0;
36667 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36668 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36669 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36670 ret_ref = (uintptr_t)ret_var.inner;
36671 if (ret_var.is_owned) {
36672         ret_ref |= 1;
36673 }
36674         return ret_ref;
36675 }
36676 uint32_t  __attribute__((export_name("TS_ChannelInfo_clone_ptr"))) TS_ChannelInfo_clone_ptr(uint32_t arg) {
36677         LDKChannelInfo arg_conv;
36678         arg_conv.inner = (void*)(arg & (~1));
36679         arg_conv.is_owned = false;
36680         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36681         uint32_t ret_conv = ChannelInfo_clone_ptr(&arg_conv);
36682         return ret_conv;
36683 }
36684
36685 uint32_t  __attribute__((export_name("TS_ChannelInfo_clone"))) TS_ChannelInfo_clone(uint32_t orig) {
36686         LDKChannelInfo orig_conv;
36687         orig_conv.inner = (void*)(orig & (~1));
36688         orig_conv.is_owned = false;
36689         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36690         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
36691         uint32_t ret_ref = 0;
36692         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36693         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36694         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36695         ret_ref = (uintptr_t)ret_var.inner;
36696         if (ret_var.is_owned) {
36697                 ret_ref |= 1;
36698         }
36699         return ret_ref;
36700 }
36701
36702 int8_tArray  __attribute__((export_name("TS_ChannelInfo_write"))) TS_ChannelInfo_write(uint32_t obj) {
36703         LDKChannelInfo obj_conv;
36704         obj_conv.inner = (void*)(obj & (~1));
36705         obj_conv.is_owned = false;
36706         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36707         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
36708         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36709         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36710         CVec_u8Z_free(ret_var);
36711         return ret_arr;
36712 }
36713
36714 uint32_t  __attribute__((export_name("TS_ChannelInfo_read"))) TS_ChannelInfo_read(int8_tArray ser) {
36715         LDKu8slice ser_ref;
36716         ser_ref.datalen = ser->arr_len;
36717         ser_ref.data = ser->elems /* XXX ser leaks */;
36718         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
36719         *ret_conv = ChannelInfo_read(ser_ref);
36720         return (uint32_t)ret_conv;
36721 }
36722
36723 void  __attribute__((export_name("TS_DirectedChannelInfo_free"))) TS_DirectedChannelInfo_free(uint32_t this_obj) {
36724         LDKDirectedChannelInfo this_obj_conv;
36725         this_obj_conv.inner = (void*)(this_obj & (~1));
36726         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36728         DirectedChannelInfo_free(this_obj_conv);
36729 }
36730
36731 static inline uintptr_t DirectedChannelInfo_clone_ptr(LDKDirectedChannelInfo *NONNULL_PTR arg) {
36732         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(arg);
36733 uint32_t ret_ref = 0;
36734 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36735 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36736 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36737 ret_ref = (uintptr_t)ret_var.inner;
36738 if (ret_var.is_owned) {
36739         ret_ref |= 1;
36740 }
36741         return ret_ref;
36742 }
36743 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_clone_ptr"))) TS_DirectedChannelInfo_clone_ptr(uint32_t arg) {
36744         LDKDirectedChannelInfo arg_conv;
36745         arg_conv.inner = (void*)(arg & (~1));
36746         arg_conv.is_owned = false;
36747         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36748         uint32_t ret_conv = DirectedChannelInfo_clone_ptr(&arg_conv);
36749         return ret_conv;
36750 }
36751
36752 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_clone"))) TS_DirectedChannelInfo_clone(uint32_t orig) {
36753         LDKDirectedChannelInfo orig_conv;
36754         orig_conv.inner = (void*)(orig & (~1));
36755         orig_conv.is_owned = false;
36756         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36757         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(&orig_conv);
36758         uint32_t ret_ref = 0;
36759         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36760         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36761         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36762         ret_ref = (uintptr_t)ret_var.inner;
36763         if (ret_var.is_owned) {
36764                 ret_ref |= 1;
36765         }
36766         return ret_ref;
36767 }
36768
36769 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_channel"))) TS_DirectedChannelInfo_channel(uint32_t this_arg) {
36770         LDKDirectedChannelInfo this_arg_conv;
36771         this_arg_conv.inner = (void*)(this_arg & (~1));
36772         this_arg_conv.is_owned = false;
36773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36774         LDKChannelInfo ret_var = DirectedChannelInfo_channel(&this_arg_conv);
36775         uint32_t ret_ref = 0;
36776         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36777         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36778         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36779         ret_ref = (uintptr_t)ret_var.inner;
36780         if (ret_var.is_owned) {
36781                 ret_ref |= 1;
36782         }
36783         return ret_ref;
36784 }
36785
36786 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_direction"))) TS_DirectedChannelInfo_direction(uint32_t this_arg) {
36787         LDKDirectedChannelInfo this_arg_conv;
36788         this_arg_conv.inner = (void*)(this_arg & (~1));
36789         this_arg_conv.is_owned = false;
36790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36791         LDKChannelUpdateInfo ret_var = DirectedChannelInfo_direction(&this_arg_conv);
36792         uint32_t ret_ref = 0;
36793         if ((uintptr_t)ret_var.inner > 4096) {
36794                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36795                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36796         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36797                 ret_ref = (uintptr_t)ret_var.inner;
36798                 if (ret_var.is_owned) {
36799                         ret_ref |= 1;
36800                 }
36801         }
36802         return ret_ref;
36803 }
36804
36805 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_effective_capacity"))) TS_DirectedChannelInfo_effective_capacity(uint32_t this_arg) {
36806         LDKDirectedChannelInfo this_arg_conv;
36807         this_arg_conv.inner = (void*)(this_arg & (~1));
36808         this_arg_conv.is_owned = false;
36809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36810         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36811         *ret_copy = DirectedChannelInfo_effective_capacity(&this_arg_conv);
36812         uint32_t ret_ref = (uintptr_t)ret_copy;
36813         return ret_ref;
36814 }
36815
36816 void  __attribute__((export_name("TS_EffectiveCapacity_free"))) TS_EffectiveCapacity_free(uint32_t this_ptr) {
36817         if ((this_ptr & 1) != 0) return;
36818         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
36819         CHECK_ACCESS(this_ptr_ptr);
36820         LDKEffectiveCapacity this_ptr_conv = *(LDKEffectiveCapacity*)(this_ptr_ptr);
36821         FREE((void*)this_ptr);
36822         EffectiveCapacity_free(this_ptr_conv);
36823 }
36824
36825 static inline uintptr_t EffectiveCapacity_clone_ptr(LDKEffectiveCapacity *NONNULL_PTR arg) {
36826         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36827         *ret_copy = EffectiveCapacity_clone(arg);
36828 uint32_t ret_ref = (uintptr_t)ret_copy;
36829         return ret_ref;
36830 }
36831 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_clone_ptr"))) TS_EffectiveCapacity_clone_ptr(uint32_t arg) {
36832         LDKEffectiveCapacity* arg_conv = (LDKEffectiveCapacity*)arg;
36833         uint32_t ret_conv = EffectiveCapacity_clone_ptr(arg_conv);
36834         return ret_conv;
36835 }
36836
36837 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_clone"))) TS_EffectiveCapacity_clone(uint32_t orig) {
36838         LDKEffectiveCapacity* orig_conv = (LDKEffectiveCapacity*)orig;
36839         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36840         *ret_copy = EffectiveCapacity_clone(orig_conv);
36841         uint32_t ret_ref = (uintptr_t)ret_copy;
36842         return ret_ref;
36843 }
36844
36845 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_exact_liquidity"))) TS_EffectiveCapacity_exact_liquidity(int64_t liquidity_msat) {
36846         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36847         *ret_copy = EffectiveCapacity_exact_liquidity(liquidity_msat);
36848         uint32_t ret_ref = (uintptr_t)ret_copy;
36849         return ret_ref;
36850 }
36851
36852 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_maximum_htlc"))) TS_EffectiveCapacity_maximum_htlc(int64_t amount_msat) {
36853         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36854         *ret_copy = EffectiveCapacity_maximum_htlc(amount_msat);
36855         uint32_t ret_ref = (uintptr_t)ret_copy;
36856         return ret_ref;
36857 }
36858
36859 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_total"))) TS_EffectiveCapacity_total(int64_t capacity_msat) {
36860         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36861         *ret_copy = EffectiveCapacity_total(capacity_msat);
36862         uint32_t ret_ref = (uintptr_t)ret_copy;
36863         return ret_ref;
36864 }
36865
36866 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_infinite"))) TS_EffectiveCapacity_infinite() {
36867         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36868         *ret_copy = EffectiveCapacity_infinite();
36869         uint32_t ret_ref = (uintptr_t)ret_copy;
36870         return ret_ref;
36871 }
36872
36873 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_unknown"))) TS_EffectiveCapacity_unknown() {
36874         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36875         *ret_copy = EffectiveCapacity_unknown();
36876         uint32_t ret_ref = (uintptr_t)ret_copy;
36877         return ret_ref;
36878 }
36879
36880 int64_t  __attribute__((export_name("TS_EffectiveCapacity_as_msat"))) TS_EffectiveCapacity_as_msat(uint32_t this_arg) {
36881         LDKEffectiveCapacity* this_arg_conv = (LDKEffectiveCapacity*)this_arg;
36882         int64_t ret_conv = EffectiveCapacity_as_msat(this_arg_conv);
36883         return ret_conv;
36884 }
36885
36886 void  __attribute__((export_name("TS_RoutingFees_free"))) TS_RoutingFees_free(uint32_t this_obj) {
36887         LDKRoutingFees this_obj_conv;
36888         this_obj_conv.inner = (void*)(this_obj & (~1));
36889         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36890         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36891         RoutingFees_free(this_obj_conv);
36892 }
36893
36894 int32_t  __attribute__((export_name("TS_RoutingFees_get_base_msat"))) TS_RoutingFees_get_base_msat(uint32_t this_ptr) {
36895         LDKRoutingFees this_ptr_conv;
36896         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36897         this_ptr_conv.is_owned = false;
36898         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36899         int32_t ret_conv = RoutingFees_get_base_msat(&this_ptr_conv);
36900         return ret_conv;
36901 }
36902
36903 void  __attribute__((export_name("TS_RoutingFees_set_base_msat"))) TS_RoutingFees_set_base_msat(uint32_t this_ptr, int32_t val) {
36904         LDKRoutingFees this_ptr_conv;
36905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36906         this_ptr_conv.is_owned = false;
36907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36908         RoutingFees_set_base_msat(&this_ptr_conv, val);
36909 }
36910
36911 int32_t  __attribute__((export_name("TS_RoutingFees_get_proportional_millionths"))) TS_RoutingFees_get_proportional_millionths(uint32_t this_ptr) {
36912         LDKRoutingFees this_ptr_conv;
36913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36914         this_ptr_conv.is_owned = false;
36915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36916         int32_t ret_conv = RoutingFees_get_proportional_millionths(&this_ptr_conv);
36917         return ret_conv;
36918 }
36919
36920 void  __attribute__((export_name("TS_RoutingFees_set_proportional_millionths"))) TS_RoutingFees_set_proportional_millionths(uint32_t this_ptr, int32_t val) {
36921         LDKRoutingFees this_ptr_conv;
36922         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36923         this_ptr_conv.is_owned = false;
36924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36925         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
36926 }
36927
36928 uint32_t  __attribute__((export_name("TS_RoutingFees_new"))) TS_RoutingFees_new(int32_t base_msat_arg, int32_t proportional_millionths_arg) {
36929         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
36930         uint32_t ret_ref = 0;
36931         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36932         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36933         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36934         ret_ref = (uintptr_t)ret_var.inner;
36935         if (ret_var.is_owned) {
36936                 ret_ref |= 1;
36937         }
36938         return ret_ref;
36939 }
36940
36941 jboolean  __attribute__((export_name("TS_RoutingFees_eq"))) TS_RoutingFees_eq(uint32_t a, uint32_t b) {
36942         LDKRoutingFees a_conv;
36943         a_conv.inner = (void*)(a & (~1));
36944         a_conv.is_owned = false;
36945         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36946         LDKRoutingFees b_conv;
36947         b_conv.inner = (void*)(b & (~1));
36948         b_conv.is_owned = false;
36949         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36950         jboolean ret_conv = RoutingFees_eq(&a_conv, &b_conv);
36951         return ret_conv;
36952 }
36953
36954 static inline uintptr_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
36955         LDKRoutingFees ret_var = RoutingFees_clone(arg);
36956 uint32_t ret_ref = 0;
36957 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36958 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36959 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36960 ret_ref = (uintptr_t)ret_var.inner;
36961 if (ret_var.is_owned) {
36962         ret_ref |= 1;
36963 }
36964         return ret_ref;
36965 }
36966 uint32_t  __attribute__((export_name("TS_RoutingFees_clone_ptr"))) TS_RoutingFees_clone_ptr(uint32_t arg) {
36967         LDKRoutingFees arg_conv;
36968         arg_conv.inner = (void*)(arg & (~1));
36969         arg_conv.is_owned = false;
36970         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36971         uint32_t ret_conv = RoutingFees_clone_ptr(&arg_conv);
36972         return ret_conv;
36973 }
36974
36975 uint32_t  __attribute__((export_name("TS_RoutingFees_clone"))) TS_RoutingFees_clone(uint32_t orig) {
36976         LDKRoutingFees orig_conv;
36977         orig_conv.inner = (void*)(orig & (~1));
36978         orig_conv.is_owned = false;
36979         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36980         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
36981         uint32_t ret_ref = 0;
36982         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36983         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36984         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36985         ret_ref = (uintptr_t)ret_var.inner;
36986         if (ret_var.is_owned) {
36987                 ret_ref |= 1;
36988         }
36989         return ret_ref;
36990 }
36991
36992 int64_t  __attribute__((export_name("TS_RoutingFees_hash"))) TS_RoutingFees_hash(uint32_t o) {
36993         LDKRoutingFees o_conv;
36994         o_conv.inner = (void*)(o & (~1));
36995         o_conv.is_owned = false;
36996         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
36997         int64_t ret_conv = RoutingFees_hash(&o_conv);
36998         return ret_conv;
36999 }
37000
37001 int8_tArray  __attribute__((export_name("TS_RoutingFees_write"))) TS_RoutingFees_write(uint32_t obj) {
37002         LDKRoutingFees obj_conv;
37003         obj_conv.inner = (void*)(obj & (~1));
37004         obj_conv.is_owned = false;
37005         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37006         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
37007         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37008         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37009         CVec_u8Z_free(ret_var);
37010         return ret_arr;
37011 }
37012
37013 uint32_t  __attribute__((export_name("TS_RoutingFees_read"))) TS_RoutingFees_read(int8_tArray ser) {
37014         LDKu8slice ser_ref;
37015         ser_ref.datalen = ser->arr_len;
37016         ser_ref.data = ser->elems /* XXX ser leaks */;
37017         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
37018         *ret_conv = RoutingFees_read(ser_ref);
37019         return (uint32_t)ret_conv;
37020 }
37021
37022 void  __attribute__((export_name("TS_NodeAnnouncementInfo_free"))) TS_NodeAnnouncementInfo_free(uint32_t this_obj) {
37023         LDKNodeAnnouncementInfo this_obj_conv;
37024         this_obj_conv.inner = (void*)(this_obj & (~1));
37025         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37026         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37027         NodeAnnouncementInfo_free(this_obj_conv);
37028 }
37029
37030 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_features"))) TS_NodeAnnouncementInfo_get_features(uint32_t this_ptr) {
37031         LDKNodeAnnouncementInfo this_ptr_conv;
37032         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37033         this_ptr_conv.is_owned = false;
37034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37035         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
37036         uint32_t ret_ref = 0;
37037         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37038         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37039         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37040         ret_ref = (uintptr_t)ret_var.inner;
37041         if (ret_var.is_owned) {
37042                 ret_ref |= 1;
37043         }
37044         return ret_ref;
37045 }
37046
37047 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_features"))) TS_NodeAnnouncementInfo_set_features(uint32_t this_ptr, uint32_t val) {
37048         LDKNodeAnnouncementInfo this_ptr_conv;
37049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37050         this_ptr_conv.is_owned = false;
37051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37052         LDKNodeFeatures val_conv;
37053         val_conv.inner = (void*)(val & (~1));
37054         val_conv.is_owned = (val & 1) || (val == 0);
37055         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37056         val_conv = NodeFeatures_clone(&val_conv);
37057         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
37058 }
37059
37060 int32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_last_update"))) TS_NodeAnnouncementInfo_get_last_update(uint32_t this_ptr) {
37061         LDKNodeAnnouncementInfo this_ptr_conv;
37062         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37063         this_ptr_conv.is_owned = false;
37064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37065         int32_t ret_conv = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
37066         return ret_conv;
37067 }
37068
37069 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_last_update"))) TS_NodeAnnouncementInfo_set_last_update(uint32_t this_ptr, int32_t val) {
37070         LDKNodeAnnouncementInfo this_ptr_conv;
37071         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37072         this_ptr_conv.is_owned = false;
37073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37074         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
37075 }
37076
37077 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_get_rgb"))) TS_NodeAnnouncementInfo_get_rgb(uint32_t this_ptr) {
37078         LDKNodeAnnouncementInfo this_ptr_conv;
37079         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37080         this_ptr_conv.is_owned = false;
37081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37082         int8_tArray ret_arr = init_int8_tArray(3, __LINE__);
37083         memcpy(ret_arr->elems, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv), 3);
37084         return ret_arr;
37085 }
37086
37087 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_rgb"))) TS_NodeAnnouncementInfo_set_rgb(uint32_t this_ptr, int8_tArray val) {
37088         LDKNodeAnnouncementInfo this_ptr_conv;
37089         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37090         this_ptr_conv.is_owned = false;
37091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37092         LDKThreeBytes val_ref;
37093         CHECK(val->arr_len == 3);
37094         memcpy(val_ref.data, val->elems, 3); FREE(val);
37095         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
37096 }
37097
37098 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_get_alias"))) TS_NodeAnnouncementInfo_get_alias(uint32_t this_ptr) {
37099         LDKNodeAnnouncementInfo this_ptr_conv;
37100         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37101         this_ptr_conv.is_owned = false;
37102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37103         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
37104         memcpy(ret_arr->elems, *NodeAnnouncementInfo_get_alias(&this_ptr_conv), 32);
37105         return ret_arr;
37106 }
37107
37108 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_alias"))) TS_NodeAnnouncementInfo_set_alias(uint32_t this_ptr, int8_tArray val) {
37109         LDKNodeAnnouncementInfo this_ptr_conv;
37110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37111         this_ptr_conv.is_owned = false;
37112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37113         LDKThirtyTwoBytes val_ref;
37114         CHECK(val->arr_len == 32);
37115         memcpy(val_ref.data, val->elems, 32); FREE(val);
37116         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
37117 }
37118
37119 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_addresses"))) TS_NodeAnnouncementInfo_set_addresses(uint32_t this_ptr, uint32_tArray val) {
37120         LDKNodeAnnouncementInfo this_ptr_conv;
37121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37122         this_ptr_conv.is_owned = false;
37123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37124         LDKCVec_NetAddressZ val_constr;
37125         val_constr.datalen = val->arr_len;
37126         if (val_constr.datalen > 0)
37127                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
37128         else
37129                 val_constr.data = NULL;
37130         uint32_t* val_vals = val->elems /* XXX val leaks */;
37131         for (size_t m = 0; m < val_constr.datalen; m++) {
37132                 uint32_t val_conv_12 = val_vals[m];
37133                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
37134                 CHECK_ACCESS(val_conv_12_ptr);
37135                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
37136                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
37137                 val_constr.data[m] = val_conv_12_conv;
37138         }
37139         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
37140 }
37141
37142 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_announcement_message"))) TS_NodeAnnouncementInfo_get_announcement_message(uint32_t this_ptr) {
37143         LDKNodeAnnouncementInfo this_ptr_conv;
37144         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37145         this_ptr_conv.is_owned = false;
37146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37147         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
37148         uint32_t ret_ref = 0;
37149         if ((uintptr_t)ret_var.inner > 4096) {
37150                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37151                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37152         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37153                 ret_ref = (uintptr_t)ret_var.inner;
37154                 if (ret_var.is_owned) {
37155                         ret_ref |= 1;
37156                 }
37157         }
37158         return ret_ref;
37159 }
37160
37161 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_announcement_message"))) TS_NodeAnnouncementInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
37162         LDKNodeAnnouncementInfo this_ptr_conv;
37163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37164         this_ptr_conv.is_owned = false;
37165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37166         LDKNodeAnnouncement val_conv;
37167         val_conv.inner = (void*)(val & (~1));
37168         val_conv.is_owned = (val & 1) || (val == 0);
37169         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37170         val_conv = NodeAnnouncement_clone(&val_conv);
37171         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
37172 }
37173
37174 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) {
37175         LDKNodeFeatures features_arg_conv;
37176         features_arg_conv.inner = (void*)(features_arg & (~1));
37177         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
37178         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
37179         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
37180         LDKThreeBytes rgb_arg_ref;
37181         CHECK(rgb_arg->arr_len == 3);
37182         memcpy(rgb_arg_ref.data, rgb_arg->elems, 3); FREE(rgb_arg);
37183         LDKThirtyTwoBytes alias_arg_ref;
37184         CHECK(alias_arg->arr_len == 32);
37185         memcpy(alias_arg_ref.data, alias_arg->elems, 32); FREE(alias_arg);
37186         LDKCVec_NetAddressZ addresses_arg_constr;
37187         addresses_arg_constr.datalen = addresses_arg->arr_len;
37188         if (addresses_arg_constr.datalen > 0)
37189                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
37190         else
37191                 addresses_arg_constr.data = NULL;
37192         uint32_t* addresses_arg_vals = addresses_arg->elems /* XXX addresses_arg leaks */;
37193         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
37194                 uint32_t addresses_arg_conv_12 = addresses_arg_vals[m];
37195                 void* addresses_arg_conv_12_ptr = (void*)(((uintptr_t)addresses_arg_conv_12) & ~1);
37196                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
37197                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
37198                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
37199         }
37200         LDKNodeAnnouncement announcement_message_arg_conv;
37201         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
37202         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
37203         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
37204         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
37205         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
37206         uint32_t ret_ref = 0;
37207         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37208         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37209         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37210         ret_ref = (uintptr_t)ret_var.inner;
37211         if (ret_var.is_owned) {
37212                 ret_ref |= 1;
37213         }
37214         return ret_ref;
37215 }
37216
37217 static inline uintptr_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
37218         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
37219 uint32_t ret_ref = 0;
37220 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37221 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37222 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37223 ret_ref = (uintptr_t)ret_var.inner;
37224 if (ret_var.is_owned) {
37225         ret_ref |= 1;
37226 }
37227         return ret_ref;
37228 }
37229 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_clone_ptr"))) TS_NodeAnnouncementInfo_clone_ptr(uint32_t arg) {
37230         LDKNodeAnnouncementInfo arg_conv;
37231         arg_conv.inner = (void*)(arg & (~1));
37232         arg_conv.is_owned = false;
37233         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37234         uint32_t ret_conv = NodeAnnouncementInfo_clone_ptr(&arg_conv);
37235         return ret_conv;
37236 }
37237
37238 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_clone"))) TS_NodeAnnouncementInfo_clone(uint32_t orig) {
37239         LDKNodeAnnouncementInfo orig_conv;
37240         orig_conv.inner = (void*)(orig & (~1));
37241         orig_conv.is_owned = false;
37242         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37243         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
37244         uint32_t ret_ref = 0;
37245         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37246         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37247         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37248         ret_ref = (uintptr_t)ret_var.inner;
37249         if (ret_var.is_owned) {
37250                 ret_ref |= 1;
37251         }
37252         return ret_ref;
37253 }
37254
37255 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_write"))) TS_NodeAnnouncementInfo_write(uint32_t obj) {
37256         LDKNodeAnnouncementInfo obj_conv;
37257         obj_conv.inner = (void*)(obj & (~1));
37258         obj_conv.is_owned = false;
37259         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37260         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
37261         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37262         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37263         CVec_u8Z_free(ret_var);
37264         return ret_arr;
37265 }
37266
37267 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_read"))) TS_NodeAnnouncementInfo_read(int8_tArray ser) {
37268         LDKu8slice ser_ref;
37269         ser_ref.datalen = ser->arr_len;
37270         ser_ref.data = ser->elems /* XXX ser leaks */;
37271         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
37272         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
37273         return (uint32_t)ret_conv;
37274 }
37275
37276 void  __attribute__((export_name("TS_NodeInfo_free"))) TS_NodeInfo_free(uint32_t this_obj) {
37277         LDKNodeInfo this_obj_conv;
37278         this_obj_conv.inner = (void*)(this_obj & (~1));
37279         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37281         NodeInfo_free(this_obj_conv);
37282 }
37283
37284 void  __attribute__((export_name("TS_NodeInfo_set_channels"))) TS_NodeInfo_set_channels(uint32_t this_ptr, int64_tArray val) {
37285         LDKNodeInfo this_ptr_conv;
37286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37287         this_ptr_conv.is_owned = false;
37288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37289         LDKCVec_u64Z val_constr;
37290         val_constr.datalen = val->arr_len;
37291         if (val_constr.datalen > 0)
37292                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
37293         else
37294                 val_constr.data = NULL;
37295         int64_t* val_vals = val->elems /* XXX val leaks */;
37296         for (size_t i = 0; i < val_constr.datalen; i++) {
37297                 int64_t val_conv_8 = val_vals[i];
37298                 val_constr.data[i] = val_conv_8;
37299         }
37300         NodeInfo_set_channels(&this_ptr_conv, val_constr);
37301 }
37302
37303 uint32_t  __attribute__((export_name("TS_NodeInfo_get_lowest_inbound_channel_fees"))) TS_NodeInfo_get_lowest_inbound_channel_fees(uint32_t this_ptr) {
37304         LDKNodeInfo this_ptr_conv;
37305         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37306         this_ptr_conv.is_owned = false;
37307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37308         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
37309         uint32_t ret_ref = 0;
37310         if ((uintptr_t)ret_var.inner > 4096) {
37311                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37312                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37313         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37314                 ret_ref = (uintptr_t)ret_var.inner;
37315                 if (ret_var.is_owned) {
37316                         ret_ref |= 1;
37317                 }
37318         }
37319         return ret_ref;
37320 }
37321
37322 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) {
37323         LDKNodeInfo this_ptr_conv;
37324         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37325         this_ptr_conv.is_owned = false;
37326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37327         LDKRoutingFees val_conv;
37328         val_conv.inner = (void*)(val & (~1));
37329         val_conv.is_owned = (val & 1) || (val == 0);
37330         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37331         val_conv = RoutingFees_clone(&val_conv);
37332         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
37333 }
37334
37335 uint32_t  __attribute__((export_name("TS_NodeInfo_get_announcement_info"))) TS_NodeInfo_get_announcement_info(uint32_t this_ptr) {
37336         LDKNodeInfo this_ptr_conv;
37337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37338         this_ptr_conv.is_owned = false;
37339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37340         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
37341         uint32_t ret_ref = 0;
37342         if ((uintptr_t)ret_var.inner > 4096) {
37343                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37344                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37345         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37346                 ret_ref = (uintptr_t)ret_var.inner;
37347                 if (ret_var.is_owned) {
37348                         ret_ref |= 1;
37349                 }
37350         }
37351         return ret_ref;
37352 }
37353
37354 void  __attribute__((export_name("TS_NodeInfo_set_announcement_info"))) TS_NodeInfo_set_announcement_info(uint32_t this_ptr, uint32_t val) {
37355         LDKNodeInfo this_ptr_conv;
37356         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37357         this_ptr_conv.is_owned = false;
37358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37359         LDKNodeAnnouncementInfo val_conv;
37360         val_conv.inner = (void*)(val & (~1));
37361         val_conv.is_owned = (val & 1) || (val == 0);
37362         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37363         val_conv = NodeAnnouncementInfo_clone(&val_conv);
37364         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
37365 }
37366
37367 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) {
37368         LDKCVec_u64Z channels_arg_constr;
37369         channels_arg_constr.datalen = channels_arg->arr_len;
37370         if (channels_arg_constr.datalen > 0)
37371                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
37372         else
37373                 channels_arg_constr.data = NULL;
37374         int64_t* channels_arg_vals = channels_arg->elems /* XXX channels_arg leaks */;
37375         for (size_t i = 0; i < channels_arg_constr.datalen; i++) {
37376                 int64_t channels_arg_conv_8 = channels_arg_vals[i];
37377                 channels_arg_constr.data[i] = channels_arg_conv_8;
37378         }
37379         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
37380         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
37381         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
37382         CHECK_INNER_FIELD_ACCESS_OR_NULL(lowest_inbound_channel_fees_arg_conv);
37383         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
37384         LDKNodeAnnouncementInfo announcement_info_arg_conv;
37385         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
37386         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
37387         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
37388         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
37389         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
37390         uint32_t ret_ref = 0;
37391         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37392         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37393         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37394         ret_ref = (uintptr_t)ret_var.inner;
37395         if (ret_var.is_owned) {
37396                 ret_ref |= 1;
37397         }
37398         return ret_ref;
37399 }
37400
37401 static inline uintptr_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
37402         LDKNodeInfo ret_var = NodeInfo_clone(arg);
37403 uint32_t ret_ref = 0;
37404 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37405 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37406 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37407 ret_ref = (uintptr_t)ret_var.inner;
37408 if (ret_var.is_owned) {
37409         ret_ref |= 1;
37410 }
37411         return ret_ref;
37412 }
37413 uint32_t  __attribute__((export_name("TS_NodeInfo_clone_ptr"))) TS_NodeInfo_clone_ptr(uint32_t arg) {
37414         LDKNodeInfo arg_conv;
37415         arg_conv.inner = (void*)(arg & (~1));
37416         arg_conv.is_owned = false;
37417         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37418         uint32_t ret_conv = NodeInfo_clone_ptr(&arg_conv);
37419         return ret_conv;
37420 }
37421
37422 uint32_t  __attribute__((export_name("TS_NodeInfo_clone"))) TS_NodeInfo_clone(uint32_t orig) {
37423         LDKNodeInfo orig_conv;
37424         orig_conv.inner = (void*)(orig & (~1));
37425         orig_conv.is_owned = false;
37426         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37427         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
37428         uint32_t ret_ref = 0;
37429         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37430         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37431         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37432         ret_ref = (uintptr_t)ret_var.inner;
37433         if (ret_var.is_owned) {
37434                 ret_ref |= 1;
37435         }
37436         return ret_ref;
37437 }
37438
37439 int8_tArray  __attribute__((export_name("TS_NodeInfo_write"))) TS_NodeInfo_write(uint32_t obj) {
37440         LDKNodeInfo obj_conv;
37441         obj_conv.inner = (void*)(obj & (~1));
37442         obj_conv.is_owned = false;
37443         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37444         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
37445         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37446         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37447         CVec_u8Z_free(ret_var);
37448         return ret_arr;
37449 }
37450
37451 uint32_t  __attribute__((export_name("TS_NodeInfo_read"))) TS_NodeInfo_read(int8_tArray ser) {
37452         LDKu8slice ser_ref;
37453         ser_ref.datalen = ser->arr_len;
37454         ser_ref.data = ser->elems /* XXX ser leaks */;
37455         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
37456         *ret_conv = NodeInfo_read(ser_ref);
37457         return (uint32_t)ret_conv;
37458 }
37459
37460 int8_tArray  __attribute__((export_name("TS_NetworkGraph_write"))) TS_NetworkGraph_write(uint32_t obj) {
37461         LDKNetworkGraph obj_conv;
37462         obj_conv.inner = (void*)(obj & (~1));
37463         obj_conv.is_owned = false;
37464         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37465         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
37466         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37467         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37468         CVec_u8Z_free(ret_var);
37469         return ret_arr;
37470 }
37471
37472 uint32_t  __attribute__((export_name("TS_NetworkGraph_read"))) TS_NetworkGraph_read(int8_tArray ser) {
37473         LDKu8slice ser_ref;
37474         ser_ref.datalen = ser->arr_len;
37475         ser_ref.data = ser->elems /* XXX ser leaks */;
37476         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
37477         *ret_conv = NetworkGraph_read(ser_ref);
37478         return (uint32_t)ret_conv;
37479 }
37480
37481 uint32_t  __attribute__((export_name("TS_NetworkGraph_new"))) TS_NetworkGraph_new(int8_tArray genesis_hash) {
37482         LDKThirtyTwoBytes genesis_hash_ref;
37483         CHECK(genesis_hash->arr_len == 32);
37484         memcpy(genesis_hash_ref.data, genesis_hash->elems, 32); FREE(genesis_hash);
37485         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
37486         uint32_t ret_ref = 0;
37487         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37488         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37489         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37490         ret_ref = (uintptr_t)ret_var.inner;
37491         if (ret_var.is_owned) {
37492                 ret_ref |= 1;
37493         }
37494         return ret_ref;
37495 }
37496
37497 uint32_t  __attribute__((export_name("TS_NetworkGraph_read_only"))) TS_NetworkGraph_read_only(uint32_t this_arg) {
37498         LDKNetworkGraph this_arg_conv;
37499         this_arg_conv.inner = (void*)(this_arg & (~1));
37500         this_arg_conv.is_owned = false;
37501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37502         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
37503         uint32_t ret_ref = 0;
37504         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37505         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37506         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37507         ret_ref = (uintptr_t)ret_var.inner;
37508         if (ret_var.is_owned) {
37509                 ret_ref |= 1;
37510         }
37511         return ret_ref;
37512 }
37513
37514 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_node_from_announcement"))) TS_NetworkGraph_update_node_from_announcement(uint32_t this_arg, uint32_t msg) {
37515         LDKNetworkGraph this_arg_conv;
37516         this_arg_conv.inner = (void*)(this_arg & (~1));
37517         this_arg_conv.is_owned = false;
37518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37519         LDKNodeAnnouncement msg_conv;
37520         msg_conv.inner = (void*)(msg & (~1));
37521         msg_conv.is_owned = false;
37522         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
37523         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
37524         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
37525         return (uint32_t)ret_conv;
37526 }
37527
37528 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) {
37529         LDKNetworkGraph this_arg_conv;
37530         this_arg_conv.inner = (void*)(this_arg & (~1));
37531         this_arg_conv.is_owned = false;
37532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37533         LDKUnsignedNodeAnnouncement msg_conv;
37534         msg_conv.inner = (void*)(msg & (~1));
37535         msg_conv.is_owned = false;
37536         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
37537         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
37538         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
37539         return (uint32_t)ret_conv;
37540 }
37541
37542 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) {
37543         LDKNetworkGraph this_arg_conv;
37544         this_arg_conv.inner = (void*)(this_arg & (~1));
37545         this_arg_conv.is_owned = false;
37546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37547         LDKChannelAnnouncement msg_conv;
37548         msg_conv.inner = (void*)(msg & (~1));
37549         msg_conv.is_owned = false;
37550         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
37551         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
37552         CHECK_ACCESS(chain_access_ptr);
37553         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
37554         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
37555         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
37556                 // Manually implement clone for Java trait instances
37557                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
37558                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37559                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
37560                 }
37561         }
37562         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
37563         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
37564         return (uint32_t)ret_conv;
37565 }
37566
37567 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) {
37568         LDKNetworkGraph this_arg_conv;
37569         this_arg_conv.inner = (void*)(this_arg & (~1));
37570         this_arg_conv.is_owned = false;
37571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37572         LDKUnsignedChannelAnnouncement msg_conv;
37573         msg_conv.inner = (void*)(msg & (~1));
37574         msg_conv.is_owned = false;
37575         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
37576         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
37577         CHECK_ACCESS(chain_access_ptr);
37578         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
37579         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
37580         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
37581                 // Manually implement clone for Java trait instances
37582                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
37583                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37584                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
37585                 }
37586         }
37587         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
37588         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
37589         return (uint32_t)ret_conv;
37590 }
37591
37592 void  __attribute__((export_name("TS_NetworkGraph_close_channel_from_update"))) TS_NetworkGraph_close_channel_from_update(uint32_t this_arg, int64_t short_channel_id, jboolean is_permanent) {
37593         LDKNetworkGraph this_arg_conv;
37594         this_arg_conv.inner = (void*)(this_arg & (~1));
37595         this_arg_conv.is_owned = false;
37596         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37597         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
37598 }
37599
37600 void  __attribute__((export_name("TS_NetworkGraph_fail_node"))) TS_NetworkGraph_fail_node(uint32_t this_arg, int8_tArray _node_id, jboolean is_permanent) {
37601         LDKNetworkGraph this_arg_conv;
37602         this_arg_conv.inner = (void*)(this_arg & (~1));
37603         this_arg_conv.is_owned = false;
37604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37605         LDKPublicKey _node_id_ref;
37606         CHECK(_node_id->arr_len == 33);
37607         memcpy(_node_id_ref.compressed_form, _node_id->elems, 33); FREE(_node_id);
37608         NetworkGraph_fail_node(&this_arg_conv, _node_id_ref, is_permanent);
37609 }
37610
37611 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) {
37612         LDKNetworkGraph this_arg_conv;
37613         this_arg_conv.inner = (void*)(this_arg & (~1));
37614         this_arg_conv.is_owned = false;
37615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37616         NetworkGraph_remove_stale_channels_with_time(&this_arg_conv, current_time_unix);
37617 }
37618
37619 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_channel"))) TS_NetworkGraph_update_channel(uint32_t this_arg, uint32_t msg) {
37620         LDKNetworkGraph this_arg_conv;
37621         this_arg_conv.inner = (void*)(this_arg & (~1));
37622         this_arg_conv.is_owned = false;
37623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37624         LDKChannelUpdate msg_conv;
37625         msg_conv.inner = (void*)(msg & (~1));
37626         msg_conv.is_owned = false;
37627         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
37628         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
37629         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
37630         return (uint32_t)ret_conv;
37631 }
37632
37633 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_channel_unsigned"))) TS_NetworkGraph_update_channel_unsigned(uint32_t this_arg, uint32_t msg) {
37634         LDKNetworkGraph this_arg_conv;
37635         this_arg_conv.inner = (void*)(this_arg & (~1));
37636         this_arg_conv.is_owned = false;
37637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37638         LDKUnsignedChannelUpdate msg_conv;
37639         msg_conv.inner = (void*)(msg & (~1));
37640         msg_conv.is_owned = false;
37641         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
37642         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
37643         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
37644         return (uint32_t)ret_conv;
37645 }
37646
37647 uint32_t  __attribute__((export_name("TS_ReadOnlyNetworkGraph_get_addresses"))) TS_ReadOnlyNetworkGraph_get_addresses(uint32_t this_arg, int8_tArray pubkey) {
37648         LDKReadOnlyNetworkGraph this_arg_conv;
37649         this_arg_conv.inner = (void*)(this_arg & (~1));
37650         this_arg_conv.is_owned = false;
37651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37652         LDKPublicKey pubkey_ref;
37653         CHECK(pubkey->arr_len == 33);
37654         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
37655         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
37656         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
37657         uint32_t ret_ref = (uintptr_t)ret_copy;
37658         return ret_ref;
37659 }
37660
37661 void  __attribute__((export_name("TS_RouteHop_free"))) TS_RouteHop_free(uint32_t this_obj) {
37662         LDKRouteHop this_obj_conv;
37663         this_obj_conv.inner = (void*)(this_obj & (~1));
37664         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37666         RouteHop_free(this_obj_conv);
37667 }
37668
37669 int8_tArray  __attribute__((export_name("TS_RouteHop_get_pubkey"))) TS_RouteHop_get_pubkey(uint32_t this_ptr) {
37670         LDKRouteHop this_ptr_conv;
37671         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37672         this_ptr_conv.is_owned = false;
37673         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37674         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
37675         memcpy(ret_arr->elems, RouteHop_get_pubkey(&this_ptr_conv).compressed_form, 33);
37676         return ret_arr;
37677 }
37678
37679 void  __attribute__((export_name("TS_RouteHop_set_pubkey"))) TS_RouteHop_set_pubkey(uint32_t this_ptr, int8_tArray val) {
37680         LDKRouteHop this_ptr_conv;
37681         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37682         this_ptr_conv.is_owned = false;
37683         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37684         LDKPublicKey val_ref;
37685         CHECK(val->arr_len == 33);
37686         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
37687         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
37688 }
37689
37690 uint32_t  __attribute__((export_name("TS_RouteHop_get_node_features"))) TS_RouteHop_get_node_features(uint32_t this_ptr) {
37691         LDKRouteHop this_ptr_conv;
37692         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37693         this_ptr_conv.is_owned = false;
37694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37695         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
37696         uint32_t ret_ref = 0;
37697         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37698         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37699         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37700         ret_ref = (uintptr_t)ret_var.inner;
37701         if (ret_var.is_owned) {
37702                 ret_ref |= 1;
37703         }
37704         return ret_ref;
37705 }
37706
37707 void  __attribute__((export_name("TS_RouteHop_set_node_features"))) TS_RouteHop_set_node_features(uint32_t this_ptr, uint32_t val) {
37708         LDKRouteHop this_ptr_conv;
37709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37710         this_ptr_conv.is_owned = false;
37711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37712         LDKNodeFeatures val_conv;
37713         val_conv.inner = (void*)(val & (~1));
37714         val_conv.is_owned = (val & 1) || (val == 0);
37715         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37716         val_conv = NodeFeatures_clone(&val_conv);
37717         RouteHop_set_node_features(&this_ptr_conv, val_conv);
37718 }
37719
37720 int64_t  __attribute__((export_name("TS_RouteHop_get_short_channel_id"))) TS_RouteHop_get_short_channel_id(uint32_t this_ptr) {
37721         LDKRouteHop this_ptr_conv;
37722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37723         this_ptr_conv.is_owned = false;
37724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37725         int64_t ret_conv = RouteHop_get_short_channel_id(&this_ptr_conv);
37726         return ret_conv;
37727 }
37728
37729 void  __attribute__((export_name("TS_RouteHop_set_short_channel_id"))) TS_RouteHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
37730         LDKRouteHop this_ptr_conv;
37731         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37732         this_ptr_conv.is_owned = false;
37733         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37734         RouteHop_set_short_channel_id(&this_ptr_conv, val);
37735 }
37736
37737 uint32_t  __attribute__((export_name("TS_RouteHop_get_channel_features"))) TS_RouteHop_get_channel_features(uint32_t this_ptr) {
37738         LDKRouteHop this_ptr_conv;
37739         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37740         this_ptr_conv.is_owned = false;
37741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37742         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
37743         uint32_t ret_ref = 0;
37744         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37745         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37746         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37747         ret_ref = (uintptr_t)ret_var.inner;
37748         if (ret_var.is_owned) {
37749                 ret_ref |= 1;
37750         }
37751         return ret_ref;
37752 }
37753
37754 void  __attribute__((export_name("TS_RouteHop_set_channel_features"))) TS_RouteHop_set_channel_features(uint32_t this_ptr, uint32_t val) {
37755         LDKRouteHop this_ptr_conv;
37756         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37757         this_ptr_conv.is_owned = false;
37758         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37759         LDKChannelFeatures val_conv;
37760         val_conv.inner = (void*)(val & (~1));
37761         val_conv.is_owned = (val & 1) || (val == 0);
37762         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37763         val_conv = ChannelFeatures_clone(&val_conv);
37764         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
37765 }
37766
37767 int64_t  __attribute__((export_name("TS_RouteHop_get_fee_msat"))) TS_RouteHop_get_fee_msat(uint32_t this_ptr) {
37768         LDKRouteHop this_ptr_conv;
37769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37770         this_ptr_conv.is_owned = false;
37771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37772         int64_t ret_conv = RouteHop_get_fee_msat(&this_ptr_conv);
37773         return ret_conv;
37774 }
37775
37776 void  __attribute__((export_name("TS_RouteHop_set_fee_msat"))) TS_RouteHop_set_fee_msat(uint32_t this_ptr, int64_t val) {
37777         LDKRouteHop this_ptr_conv;
37778         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37779         this_ptr_conv.is_owned = false;
37780         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37781         RouteHop_set_fee_msat(&this_ptr_conv, val);
37782 }
37783
37784 int32_t  __attribute__((export_name("TS_RouteHop_get_cltv_expiry_delta"))) TS_RouteHop_get_cltv_expiry_delta(uint32_t this_ptr) {
37785         LDKRouteHop this_ptr_conv;
37786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37787         this_ptr_conv.is_owned = false;
37788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37789         int32_t ret_conv = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
37790         return ret_conv;
37791 }
37792
37793 void  __attribute__((export_name("TS_RouteHop_set_cltv_expiry_delta"))) TS_RouteHop_set_cltv_expiry_delta(uint32_t this_ptr, int32_t val) {
37794         LDKRouteHop this_ptr_conv;
37795         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37796         this_ptr_conv.is_owned = false;
37797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37798         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
37799 }
37800
37801 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) {
37802         LDKPublicKey pubkey_arg_ref;
37803         CHECK(pubkey_arg->arr_len == 33);
37804         memcpy(pubkey_arg_ref.compressed_form, pubkey_arg->elems, 33); FREE(pubkey_arg);
37805         LDKNodeFeatures node_features_arg_conv;
37806         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
37807         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
37808         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
37809         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
37810         LDKChannelFeatures channel_features_arg_conv;
37811         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
37812         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
37813         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
37814         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
37815         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);
37816         uint32_t ret_ref = 0;
37817         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37818         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37819         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37820         ret_ref = (uintptr_t)ret_var.inner;
37821         if (ret_var.is_owned) {
37822                 ret_ref |= 1;
37823         }
37824         return ret_ref;
37825 }
37826
37827 static inline uintptr_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
37828         LDKRouteHop ret_var = RouteHop_clone(arg);
37829 uint32_t ret_ref = 0;
37830 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37831 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37832 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37833 ret_ref = (uintptr_t)ret_var.inner;
37834 if (ret_var.is_owned) {
37835         ret_ref |= 1;
37836 }
37837         return ret_ref;
37838 }
37839 uint32_t  __attribute__((export_name("TS_RouteHop_clone_ptr"))) TS_RouteHop_clone_ptr(uint32_t arg) {
37840         LDKRouteHop arg_conv;
37841         arg_conv.inner = (void*)(arg & (~1));
37842         arg_conv.is_owned = false;
37843         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37844         uint32_t ret_conv = RouteHop_clone_ptr(&arg_conv);
37845         return ret_conv;
37846 }
37847
37848 uint32_t  __attribute__((export_name("TS_RouteHop_clone"))) TS_RouteHop_clone(uint32_t orig) {
37849         LDKRouteHop orig_conv;
37850         orig_conv.inner = (void*)(orig & (~1));
37851         orig_conv.is_owned = false;
37852         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37853         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
37854         uint32_t ret_ref = 0;
37855         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37856         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37857         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37858         ret_ref = (uintptr_t)ret_var.inner;
37859         if (ret_var.is_owned) {
37860                 ret_ref |= 1;
37861         }
37862         return ret_ref;
37863 }
37864
37865 int64_t  __attribute__((export_name("TS_RouteHop_hash"))) TS_RouteHop_hash(uint32_t o) {
37866         LDKRouteHop o_conv;
37867         o_conv.inner = (void*)(o & (~1));
37868         o_conv.is_owned = false;
37869         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
37870         int64_t ret_conv = RouteHop_hash(&o_conv);
37871         return ret_conv;
37872 }
37873
37874 jboolean  __attribute__((export_name("TS_RouteHop_eq"))) TS_RouteHop_eq(uint32_t a, uint32_t b) {
37875         LDKRouteHop a_conv;
37876         a_conv.inner = (void*)(a & (~1));
37877         a_conv.is_owned = false;
37878         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37879         LDKRouteHop b_conv;
37880         b_conv.inner = (void*)(b & (~1));
37881         b_conv.is_owned = false;
37882         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37883         jboolean ret_conv = RouteHop_eq(&a_conv, &b_conv);
37884         return ret_conv;
37885 }
37886
37887 int8_tArray  __attribute__((export_name("TS_RouteHop_write"))) TS_RouteHop_write(uint32_t obj) {
37888         LDKRouteHop obj_conv;
37889         obj_conv.inner = (void*)(obj & (~1));
37890         obj_conv.is_owned = false;
37891         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37892         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
37893         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37894         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37895         CVec_u8Z_free(ret_var);
37896         return ret_arr;
37897 }
37898
37899 uint32_t  __attribute__((export_name("TS_RouteHop_read"))) TS_RouteHop_read(int8_tArray ser) {
37900         LDKu8slice ser_ref;
37901         ser_ref.datalen = ser->arr_len;
37902         ser_ref.data = ser->elems /* XXX ser leaks */;
37903         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
37904         *ret_conv = RouteHop_read(ser_ref);
37905         return (uint32_t)ret_conv;
37906 }
37907
37908 void  __attribute__((export_name("TS_Route_free"))) TS_Route_free(uint32_t this_obj) {
37909         LDKRoute this_obj_conv;
37910         this_obj_conv.inner = (void*)(this_obj & (~1));
37911         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37913         Route_free(this_obj_conv);
37914 }
37915
37916 ptrArray  __attribute__((export_name("TS_Route_get_paths"))) TS_Route_get_paths(uint32_t this_ptr) {
37917         LDKRoute this_ptr_conv;
37918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37919         this_ptr_conv.is_owned = false;
37920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37921         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
37922         ptrArray ret_arr = NULL;
37923         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
37924         uint32_tArray *ret_arr_ptr = (uint32_tArray*)(((uint8_t*)ret_arr) + 4);
37925         for (size_t m = 0; m < ret_var.datalen; m++) {
37926                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
37927                 uint32_tArray ret_conv_12_arr = NULL;
37928                 ret_conv_12_arr = init_uint32_tArray(ret_conv_12_var.datalen, __LINE__);
37929                 uint32_t *ret_conv_12_arr_ptr = (uint32_t*)(((uint8_t*)ret_conv_12_arr) + 4);
37930                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
37931                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
37932                         uint32_t ret_conv_12_conv_10_ref = 0;
37933                         CHECK((((uintptr_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37934                         CHECK((((uintptr_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37935                         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_conv_10_var);
37936                         ret_conv_12_conv_10_ref = (uintptr_t)ret_conv_12_conv_10_var.inner;
37937                         if (ret_conv_12_conv_10_var.is_owned) {
37938                                 ret_conv_12_conv_10_ref |= 1;
37939                         }
37940                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
37941                 }
37942                 
37943                 FREE(ret_conv_12_var.data);
37944                 ret_arr_ptr[m] = ret_conv_12_arr;
37945         }
37946         
37947         FREE(ret_var.data);
37948         return ret_arr;
37949 }
37950
37951 void  __attribute__((export_name("TS_Route_set_paths"))) TS_Route_set_paths(uint32_t this_ptr, ptrArray val) {
37952         LDKRoute this_ptr_conv;
37953         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37954         this_ptr_conv.is_owned = false;
37955         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37956         LDKCVec_CVec_RouteHopZZ val_constr;
37957         val_constr.datalen = val->arr_len;
37958         if (val_constr.datalen > 0)
37959                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
37960         else
37961                 val_constr.data = NULL;
37962         uint32_tArray* val_vals = (void*) val->elems /* XXX val leaks */;
37963         for (size_t m = 0; m < val_constr.datalen; m++) {
37964                 uint32_tArray val_conv_12 = val_vals[m];
37965                 LDKCVec_RouteHopZ val_conv_12_constr;
37966                 val_conv_12_constr.datalen = val_conv_12->arr_len;
37967                 if (val_conv_12_constr.datalen > 0)
37968                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
37969                 else
37970                         val_conv_12_constr.data = NULL;
37971                 uint32_t* val_conv_12_vals = val_conv_12->elems /* XXX val_conv_12 leaks */;
37972                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
37973                         uint32_t val_conv_12_conv_10 = val_conv_12_vals[k];
37974                         LDKRouteHop val_conv_12_conv_10_conv;
37975                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
37976                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
37977                         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv_10_conv);
37978                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
37979                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
37980                 }
37981                 val_constr.data[m] = val_conv_12_constr;
37982         }
37983         Route_set_paths(&this_ptr_conv, val_constr);
37984 }
37985
37986 uint32_t  __attribute__((export_name("TS_Route_get_payment_params"))) TS_Route_get_payment_params(uint32_t this_ptr) {
37987         LDKRoute this_ptr_conv;
37988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37989         this_ptr_conv.is_owned = false;
37990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37991         LDKPaymentParameters ret_var = Route_get_payment_params(&this_ptr_conv);
37992         uint32_t ret_ref = 0;
37993         if ((uintptr_t)ret_var.inner > 4096) {
37994                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37995                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37996         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37997                 ret_ref = (uintptr_t)ret_var.inner;
37998                 if (ret_var.is_owned) {
37999                         ret_ref |= 1;
38000                 }
38001         }
38002         return ret_ref;
38003 }
38004
38005 void  __attribute__((export_name("TS_Route_set_payment_params"))) TS_Route_set_payment_params(uint32_t this_ptr, uint32_t val) {
38006         LDKRoute this_ptr_conv;
38007         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38008         this_ptr_conv.is_owned = false;
38009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38010         LDKPaymentParameters val_conv;
38011         val_conv.inner = (void*)(val & (~1));
38012         val_conv.is_owned = (val & 1) || (val == 0);
38013         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38014         val_conv = PaymentParameters_clone(&val_conv);
38015         Route_set_payment_params(&this_ptr_conv, val_conv);
38016 }
38017
38018 uint32_t  __attribute__((export_name("TS_Route_new"))) TS_Route_new(ptrArray paths_arg, uint32_t payment_params_arg) {
38019         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
38020         paths_arg_constr.datalen = paths_arg->arr_len;
38021         if (paths_arg_constr.datalen > 0)
38022                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
38023         else
38024                 paths_arg_constr.data = NULL;
38025         uint32_tArray* paths_arg_vals = (void*) paths_arg->elems /* XXX paths_arg leaks */;
38026         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
38027                 uint32_tArray paths_arg_conv_12 = paths_arg_vals[m];
38028                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
38029                 paths_arg_conv_12_constr.datalen = paths_arg_conv_12->arr_len;
38030                 if (paths_arg_conv_12_constr.datalen > 0)
38031                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
38032                 else
38033                         paths_arg_conv_12_constr.data = NULL;
38034                 uint32_t* paths_arg_conv_12_vals = paths_arg_conv_12->elems /* XXX paths_arg_conv_12 leaks */;
38035                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
38036                         uint32_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
38037                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
38038                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
38039                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
38040                         CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_12_conv_10_conv);
38041                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
38042                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
38043                 }
38044                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
38045         }
38046         LDKPaymentParameters payment_params_arg_conv;
38047         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
38048         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
38049         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
38050         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
38051         LDKRoute ret_var = Route_new(paths_arg_constr, payment_params_arg_conv);
38052         uint32_t ret_ref = 0;
38053         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38054         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38055         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38056         ret_ref = (uintptr_t)ret_var.inner;
38057         if (ret_var.is_owned) {
38058                 ret_ref |= 1;
38059         }
38060         return ret_ref;
38061 }
38062
38063 static inline uintptr_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
38064         LDKRoute ret_var = Route_clone(arg);
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 uint32_t  __attribute__((export_name("TS_Route_clone_ptr"))) TS_Route_clone_ptr(uint32_t arg) {
38076         LDKRoute arg_conv;
38077         arg_conv.inner = (void*)(arg & (~1));
38078         arg_conv.is_owned = false;
38079         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38080         uint32_t ret_conv = Route_clone_ptr(&arg_conv);
38081         return ret_conv;
38082 }
38083
38084 uint32_t  __attribute__((export_name("TS_Route_clone"))) TS_Route_clone(uint32_t orig) {
38085         LDKRoute orig_conv;
38086         orig_conv.inner = (void*)(orig & (~1));
38087         orig_conv.is_owned = false;
38088         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38089         LDKRoute ret_var = Route_clone(&orig_conv);
38090         uint32_t ret_ref = 0;
38091         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38092         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38093         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38094         ret_ref = (uintptr_t)ret_var.inner;
38095         if (ret_var.is_owned) {
38096                 ret_ref |= 1;
38097         }
38098         return ret_ref;
38099 }
38100
38101 int64_t  __attribute__((export_name("TS_Route_hash"))) TS_Route_hash(uint32_t o) {
38102         LDKRoute o_conv;
38103         o_conv.inner = (void*)(o & (~1));
38104         o_conv.is_owned = false;
38105         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38106         int64_t ret_conv = Route_hash(&o_conv);
38107         return ret_conv;
38108 }
38109
38110 jboolean  __attribute__((export_name("TS_Route_eq"))) TS_Route_eq(uint32_t a, uint32_t b) {
38111         LDKRoute a_conv;
38112         a_conv.inner = (void*)(a & (~1));
38113         a_conv.is_owned = false;
38114         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38115         LDKRoute b_conv;
38116         b_conv.inner = (void*)(b & (~1));
38117         b_conv.is_owned = false;
38118         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38119         jboolean ret_conv = Route_eq(&a_conv, &b_conv);
38120         return ret_conv;
38121 }
38122
38123 int64_t  __attribute__((export_name("TS_Route_get_total_fees"))) TS_Route_get_total_fees(uint32_t this_arg) {
38124         LDKRoute this_arg_conv;
38125         this_arg_conv.inner = (void*)(this_arg & (~1));
38126         this_arg_conv.is_owned = false;
38127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38128         int64_t ret_conv = Route_get_total_fees(&this_arg_conv);
38129         return ret_conv;
38130 }
38131
38132 int64_t  __attribute__((export_name("TS_Route_get_total_amount"))) TS_Route_get_total_amount(uint32_t this_arg) {
38133         LDKRoute this_arg_conv;
38134         this_arg_conv.inner = (void*)(this_arg & (~1));
38135         this_arg_conv.is_owned = false;
38136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38137         int64_t ret_conv = Route_get_total_amount(&this_arg_conv);
38138         return ret_conv;
38139 }
38140
38141 int8_tArray  __attribute__((export_name("TS_Route_write"))) TS_Route_write(uint32_t obj) {
38142         LDKRoute obj_conv;
38143         obj_conv.inner = (void*)(obj & (~1));
38144         obj_conv.is_owned = false;
38145         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38146         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
38147         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38148         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38149         CVec_u8Z_free(ret_var);
38150         return ret_arr;
38151 }
38152
38153 uint32_t  __attribute__((export_name("TS_Route_read"))) TS_Route_read(int8_tArray ser) {
38154         LDKu8slice ser_ref;
38155         ser_ref.datalen = ser->arr_len;
38156         ser_ref.data = ser->elems /* XXX ser leaks */;
38157         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
38158         *ret_conv = Route_read(ser_ref);
38159         return (uint32_t)ret_conv;
38160 }
38161
38162 void  __attribute__((export_name("TS_RouteParameters_free"))) TS_RouteParameters_free(uint32_t this_obj) {
38163         LDKRouteParameters this_obj_conv;
38164         this_obj_conv.inner = (void*)(this_obj & (~1));
38165         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38167         RouteParameters_free(this_obj_conv);
38168 }
38169
38170 uint32_t  __attribute__((export_name("TS_RouteParameters_get_payment_params"))) TS_RouteParameters_get_payment_params(uint32_t this_ptr) {
38171         LDKRouteParameters this_ptr_conv;
38172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38173         this_ptr_conv.is_owned = false;
38174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38175         LDKPaymentParameters ret_var = RouteParameters_get_payment_params(&this_ptr_conv);
38176         uint32_t ret_ref = 0;
38177         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38178         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38179         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38180         ret_ref = (uintptr_t)ret_var.inner;
38181         if (ret_var.is_owned) {
38182                 ret_ref |= 1;
38183         }
38184         return ret_ref;
38185 }
38186
38187 void  __attribute__((export_name("TS_RouteParameters_set_payment_params"))) TS_RouteParameters_set_payment_params(uint32_t this_ptr, uint32_t val) {
38188         LDKRouteParameters this_ptr_conv;
38189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38190         this_ptr_conv.is_owned = false;
38191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38192         LDKPaymentParameters val_conv;
38193         val_conv.inner = (void*)(val & (~1));
38194         val_conv.is_owned = (val & 1) || (val == 0);
38195         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38196         val_conv = PaymentParameters_clone(&val_conv);
38197         RouteParameters_set_payment_params(&this_ptr_conv, val_conv);
38198 }
38199
38200 int64_t  __attribute__((export_name("TS_RouteParameters_get_final_value_msat"))) TS_RouteParameters_get_final_value_msat(uint32_t this_ptr) {
38201         LDKRouteParameters this_ptr_conv;
38202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38203         this_ptr_conv.is_owned = false;
38204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38205         int64_t ret_conv = RouteParameters_get_final_value_msat(&this_ptr_conv);
38206         return ret_conv;
38207 }
38208
38209 void  __attribute__((export_name("TS_RouteParameters_set_final_value_msat"))) TS_RouteParameters_set_final_value_msat(uint32_t this_ptr, int64_t val) {
38210         LDKRouteParameters this_ptr_conv;
38211         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38212         this_ptr_conv.is_owned = false;
38213         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38214         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
38215 }
38216
38217 int32_t  __attribute__((export_name("TS_RouteParameters_get_final_cltv_expiry_delta"))) TS_RouteParameters_get_final_cltv_expiry_delta(uint32_t this_ptr) {
38218         LDKRouteParameters this_ptr_conv;
38219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38220         this_ptr_conv.is_owned = false;
38221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38222         int32_t ret_conv = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
38223         return ret_conv;
38224 }
38225
38226 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) {
38227         LDKRouteParameters this_ptr_conv;
38228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38229         this_ptr_conv.is_owned = false;
38230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38231         RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
38232 }
38233
38234 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) {
38235         LDKPaymentParameters payment_params_arg_conv;
38236         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
38237         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
38238         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
38239         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
38240         LDKRouteParameters ret_var = RouteParameters_new(payment_params_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
38241         uint32_t ret_ref = 0;
38242         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38243         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38244         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38245         ret_ref = (uintptr_t)ret_var.inner;
38246         if (ret_var.is_owned) {
38247                 ret_ref |= 1;
38248         }
38249         return ret_ref;
38250 }
38251
38252 static inline uintptr_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
38253         LDKRouteParameters ret_var = RouteParameters_clone(arg);
38254 uint32_t ret_ref = 0;
38255 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38256 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38257 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38258 ret_ref = (uintptr_t)ret_var.inner;
38259 if (ret_var.is_owned) {
38260         ret_ref |= 1;
38261 }
38262         return ret_ref;
38263 }
38264 uint32_t  __attribute__((export_name("TS_RouteParameters_clone_ptr"))) TS_RouteParameters_clone_ptr(uint32_t arg) {
38265         LDKRouteParameters arg_conv;
38266         arg_conv.inner = (void*)(arg & (~1));
38267         arg_conv.is_owned = false;
38268         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38269         uint32_t ret_conv = RouteParameters_clone_ptr(&arg_conv);
38270         return ret_conv;
38271 }
38272
38273 uint32_t  __attribute__((export_name("TS_RouteParameters_clone"))) TS_RouteParameters_clone(uint32_t orig) {
38274         LDKRouteParameters orig_conv;
38275         orig_conv.inner = (void*)(orig & (~1));
38276         orig_conv.is_owned = false;
38277         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38278         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
38279         uint32_t ret_ref = 0;
38280         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38281         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38282         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38283         ret_ref = (uintptr_t)ret_var.inner;
38284         if (ret_var.is_owned) {
38285                 ret_ref |= 1;
38286         }
38287         return ret_ref;
38288 }
38289
38290 int8_tArray  __attribute__((export_name("TS_RouteParameters_write"))) TS_RouteParameters_write(uint32_t obj) {
38291         LDKRouteParameters obj_conv;
38292         obj_conv.inner = (void*)(obj & (~1));
38293         obj_conv.is_owned = false;
38294         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38295         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
38296         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38297         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38298         CVec_u8Z_free(ret_var);
38299         return ret_arr;
38300 }
38301
38302 uint32_t  __attribute__((export_name("TS_RouteParameters_read"))) TS_RouteParameters_read(int8_tArray ser) {
38303         LDKu8slice ser_ref;
38304         ser_ref.datalen = ser->arr_len;
38305         ser_ref.data = ser->elems /* XXX ser leaks */;
38306         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
38307         *ret_conv = RouteParameters_read(ser_ref);
38308         return (uint32_t)ret_conv;
38309 }
38310
38311 void  __attribute__((export_name("TS_PaymentParameters_free"))) TS_PaymentParameters_free(uint32_t this_obj) {
38312         LDKPaymentParameters this_obj_conv;
38313         this_obj_conv.inner = (void*)(this_obj & (~1));
38314         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38316         PaymentParameters_free(this_obj_conv);
38317 }
38318
38319 int8_tArray  __attribute__((export_name("TS_PaymentParameters_get_payee_pubkey"))) TS_PaymentParameters_get_payee_pubkey(uint32_t this_ptr) {
38320         LDKPaymentParameters this_ptr_conv;
38321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38322         this_ptr_conv.is_owned = false;
38323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38324         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
38325         memcpy(ret_arr->elems, PaymentParameters_get_payee_pubkey(&this_ptr_conv).compressed_form, 33);
38326         return ret_arr;
38327 }
38328
38329 void  __attribute__((export_name("TS_PaymentParameters_set_payee_pubkey"))) TS_PaymentParameters_set_payee_pubkey(uint32_t this_ptr, int8_tArray val) {
38330         LDKPaymentParameters this_ptr_conv;
38331         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38332         this_ptr_conv.is_owned = false;
38333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38334         LDKPublicKey val_ref;
38335         CHECK(val->arr_len == 33);
38336         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
38337         PaymentParameters_set_payee_pubkey(&this_ptr_conv, val_ref);
38338 }
38339
38340 uint32_t  __attribute__((export_name("TS_PaymentParameters_get_features"))) TS_PaymentParameters_get_features(uint32_t this_ptr) {
38341         LDKPaymentParameters this_ptr_conv;
38342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38343         this_ptr_conv.is_owned = false;
38344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38345         LDKInvoiceFeatures ret_var = PaymentParameters_get_features(&this_ptr_conv);
38346         uint32_t ret_ref = 0;
38347         if ((uintptr_t)ret_var.inner > 4096) {
38348                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38349                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38350         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38351                 ret_ref = (uintptr_t)ret_var.inner;
38352                 if (ret_var.is_owned) {
38353                         ret_ref |= 1;
38354                 }
38355         }
38356         return ret_ref;
38357 }
38358
38359 void  __attribute__((export_name("TS_PaymentParameters_set_features"))) TS_PaymentParameters_set_features(uint32_t this_ptr, uint32_t val) {
38360         LDKPaymentParameters this_ptr_conv;
38361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38362         this_ptr_conv.is_owned = false;
38363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38364         LDKInvoiceFeatures val_conv;
38365         val_conv.inner = (void*)(val & (~1));
38366         val_conv.is_owned = (val & 1) || (val == 0);
38367         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38368         val_conv = InvoiceFeatures_clone(&val_conv);
38369         PaymentParameters_set_features(&this_ptr_conv, val_conv);
38370 }
38371
38372 uint32_tArray  __attribute__((export_name("TS_PaymentParameters_get_route_hints"))) TS_PaymentParameters_get_route_hints(uint32_t this_ptr) {
38373         LDKPaymentParameters this_ptr_conv;
38374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38375         this_ptr_conv.is_owned = false;
38376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38377         LDKCVec_RouteHintZ ret_var = PaymentParameters_get_route_hints(&this_ptr_conv);
38378         uint32_tArray ret_arr = NULL;
38379         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
38380         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
38381         for (size_t l = 0; l < ret_var.datalen; l++) {
38382                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
38383                 uint32_t ret_conv_11_ref = 0;
38384                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38385                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38386                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
38387                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
38388                 if (ret_conv_11_var.is_owned) {
38389                         ret_conv_11_ref |= 1;
38390                 }
38391                 ret_arr_ptr[l] = ret_conv_11_ref;
38392         }
38393         
38394         FREE(ret_var.data);
38395         return ret_arr;
38396 }
38397
38398 void  __attribute__((export_name("TS_PaymentParameters_set_route_hints"))) TS_PaymentParameters_set_route_hints(uint32_t this_ptr, uint32_tArray val) {
38399         LDKPaymentParameters this_ptr_conv;
38400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38401         this_ptr_conv.is_owned = false;
38402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38403         LDKCVec_RouteHintZ val_constr;
38404         val_constr.datalen = val->arr_len;
38405         if (val_constr.datalen > 0)
38406                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
38407         else
38408                 val_constr.data = NULL;
38409         uint32_t* val_vals = val->elems /* XXX val leaks */;
38410         for (size_t l = 0; l < val_constr.datalen; l++) {
38411                 uint32_t val_conv_11 = val_vals[l];
38412                 LDKRouteHint val_conv_11_conv;
38413                 val_conv_11_conv.inner = (void*)(val_conv_11 & (~1));
38414                 val_conv_11_conv.is_owned = (val_conv_11 & 1) || (val_conv_11 == 0);
38415                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_11_conv);
38416                 val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
38417                 val_constr.data[l] = val_conv_11_conv;
38418         }
38419         PaymentParameters_set_route_hints(&this_ptr_conv, val_constr);
38420 }
38421
38422 uint32_t  __attribute__((export_name("TS_PaymentParameters_get_expiry_time"))) TS_PaymentParameters_get_expiry_time(uint32_t this_ptr) {
38423         LDKPaymentParameters this_ptr_conv;
38424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38425         this_ptr_conv.is_owned = false;
38426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38427         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
38428         *ret_copy = PaymentParameters_get_expiry_time(&this_ptr_conv);
38429         uint32_t ret_ref = (uintptr_t)ret_copy;
38430         return ret_ref;
38431 }
38432
38433 void  __attribute__((export_name("TS_PaymentParameters_set_expiry_time"))) TS_PaymentParameters_set_expiry_time(uint32_t this_ptr, uint32_t val) {
38434         LDKPaymentParameters this_ptr_conv;
38435         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38436         this_ptr_conv.is_owned = false;
38437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38438         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
38439         CHECK_ACCESS(val_ptr);
38440         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
38441         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
38442         PaymentParameters_set_expiry_time(&this_ptr_conv, val_conv);
38443 }
38444
38445 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) {
38446         LDKPaymentParameters this_ptr_conv;
38447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38448         this_ptr_conv.is_owned = false;
38449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38450         int32_t ret_conv = PaymentParameters_get_max_total_cltv_expiry_delta(&this_ptr_conv);
38451         return ret_conv;
38452 }
38453
38454 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) {
38455         LDKPaymentParameters this_ptr_conv;
38456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38457         this_ptr_conv.is_owned = false;
38458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38459         PaymentParameters_set_max_total_cltv_expiry_delta(&this_ptr_conv, val);
38460 }
38461
38462 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) {
38463         LDKPublicKey payee_pubkey_arg_ref;
38464         CHECK(payee_pubkey_arg->arr_len == 33);
38465         memcpy(payee_pubkey_arg_ref.compressed_form, payee_pubkey_arg->elems, 33); FREE(payee_pubkey_arg);
38466         LDKInvoiceFeatures features_arg_conv;
38467         features_arg_conv.inner = (void*)(features_arg & (~1));
38468         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
38469         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
38470         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
38471         LDKCVec_RouteHintZ route_hints_arg_constr;
38472         route_hints_arg_constr.datalen = route_hints_arg->arr_len;
38473         if (route_hints_arg_constr.datalen > 0)
38474                 route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
38475         else
38476                 route_hints_arg_constr.data = NULL;
38477         uint32_t* route_hints_arg_vals = route_hints_arg->elems /* XXX route_hints_arg leaks */;
38478         for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
38479                 uint32_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
38480                 LDKRouteHint route_hints_arg_conv_11_conv;
38481                 route_hints_arg_conv_11_conv.inner = (void*)(route_hints_arg_conv_11 & (~1));
38482                 route_hints_arg_conv_11_conv.is_owned = (route_hints_arg_conv_11 & 1) || (route_hints_arg_conv_11 == 0);
38483                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_arg_conv_11_conv);
38484                 route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
38485                 route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
38486         }
38487         void* expiry_time_arg_ptr = (void*)(((uintptr_t)expiry_time_arg) & ~1);
38488         CHECK_ACCESS(expiry_time_arg_ptr);
38489         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
38490         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)expiry_time_arg) & ~1));
38491         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);
38492         uint32_t ret_ref = 0;
38493         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38494         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38495         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38496         ret_ref = (uintptr_t)ret_var.inner;
38497         if (ret_var.is_owned) {
38498                 ret_ref |= 1;
38499         }
38500         return ret_ref;
38501 }
38502
38503 static inline uintptr_t PaymentParameters_clone_ptr(LDKPaymentParameters *NONNULL_PTR arg) {
38504         LDKPaymentParameters ret_var = PaymentParameters_clone(arg);
38505 uint32_t ret_ref = 0;
38506 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38507 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38508 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38509 ret_ref = (uintptr_t)ret_var.inner;
38510 if (ret_var.is_owned) {
38511         ret_ref |= 1;
38512 }
38513         return ret_ref;
38514 }
38515 uint32_t  __attribute__((export_name("TS_PaymentParameters_clone_ptr"))) TS_PaymentParameters_clone_ptr(uint32_t arg) {
38516         LDKPaymentParameters arg_conv;
38517         arg_conv.inner = (void*)(arg & (~1));
38518         arg_conv.is_owned = false;
38519         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38520         uint32_t ret_conv = PaymentParameters_clone_ptr(&arg_conv);
38521         return ret_conv;
38522 }
38523
38524 uint32_t  __attribute__((export_name("TS_PaymentParameters_clone"))) TS_PaymentParameters_clone(uint32_t orig) {
38525         LDKPaymentParameters orig_conv;
38526         orig_conv.inner = (void*)(orig & (~1));
38527         orig_conv.is_owned = false;
38528         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38529         LDKPaymentParameters ret_var = PaymentParameters_clone(&orig_conv);
38530         uint32_t ret_ref = 0;
38531         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38532         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38533         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38534         ret_ref = (uintptr_t)ret_var.inner;
38535         if (ret_var.is_owned) {
38536                 ret_ref |= 1;
38537         }
38538         return ret_ref;
38539 }
38540
38541 int64_t  __attribute__((export_name("TS_PaymentParameters_hash"))) TS_PaymentParameters_hash(uint32_t o) {
38542         LDKPaymentParameters o_conv;
38543         o_conv.inner = (void*)(o & (~1));
38544         o_conv.is_owned = false;
38545         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38546         int64_t ret_conv = PaymentParameters_hash(&o_conv);
38547         return ret_conv;
38548 }
38549
38550 jboolean  __attribute__((export_name("TS_PaymentParameters_eq"))) TS_PaymentParameters_eq(uint32_t a, uint32_t b) {
38551         LDKPaymentParameters a_conv;
38552         a_conv.inner = (void*)(a & (~1));
38553         a_conv.is_owned = false;
38554         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38555         LDKPaymentParameters b_conv;
38556         b_conv.inner = (void*)(b & (~1));
38557         b_conv.is_owned = false;
38558         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38559         jboolean ret_conv = PaymentParameters_eq(&a_conv, &b_conv);
38560         return ret_conv;
38561 }
38562
38563 int8_tArray  __attribute__((export_name("TS_PaymentParameters_write"))) TS_PaymentParameters_write(uint32_t obj) {
38564         LDKPaymentParameters obj_conv;
38565         obj_conv.inner = (void*)(obj & (~1));
38566         obj_conv.is_owned = false;
38567         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38568         LDKCVec_u8Z ret_var = PaymentParameters_write(&obj_conv);
38569         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38570         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38571         CVec_u8Z_free(ret_var);
38572         return ret_arr;
38573 }
38574
38575 uint32_t  __attribute__((export_name("TS_PaymentParameters_read"))) TS_PaymentParameters_read(int8_tArray ser) {
38576         LDKu8slice ser_ref;
38577         ser_ref.datalen = ser->arr_len;
38578         ser_ref.data = ser->elems /* XXX ser leaks */;
38579         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
38580         *ret_conv = PaymentParameters_read(ser_ref);
38581         return (uint32_t)ret_conv;
38582 }
38583
38584 uint32_t  __attribute__((export_name("TS_PaymentParameters_from_node_id"))) TS_PaymentParameters_from_node_id(int8_tArray payee_pubkey) {
38585         LDKPublicKey payee_pubkey_ref;
38586         CHECK(payee_pubkey->arr_len == 33);
38587         memcpy(payee_pubkey_ref.compressed_form, payee_pubkey->elems, 33); FREE(payee_pubkey);
38588         LDKPaymentParameters ret_var = PaymentParameters_from_node_id(payee_pubkey_ref);
38589         uint32_t ret_ref = 0;
38590         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38591         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38592         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38593         ret_ref = (uintptr_t)ret_var.inner;
38594         if (ret_var.is_owned) {
38595                 ret_ref |= 1;
38596         }
38597         return ret_ref;
38598 }
38599
38600 uint32_t  __attribute__((export_name("TS_PaymentParameters_for_keysend"))) TS_PaymentParameters_for_keysend(int8_tArray payee_pubkey) {
38601         LDKPublicKey payee_pubkey_ref;
38602         CHECK(payee_pubkey->arr_len == 33);
38603         memcpy(payee_pubkey_ref.compressed_form, payee_pubkey->elems, 33); FREE(payee_pubkey);
38604         LDKPaymentParameters ret_var = PaymentParameters_for_keysend(payee_pubkey_ref);
38605         uint32_t ret_ref = 0;
38606         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38607         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38608         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38609         ret_ref = (uintptr_t)ret_var.inner;
38610         if (ret_var.is_owned) {
38611                 ret_ref |= 1;
38612         }
38613         return ret_ref;
38614 }
38615
38616 void  __attribute__((export_name("TS_RouteHint_free"))) TS_RouteHint_free(uint32_t this_obj) {
38617         LDKRouteHint this_obj_conv;
38618         this_obj_conv.inner = (void*)(this_obj & (~1));
38619         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38621         RouteHint_free(this_obj_conv);
38622 }
38623
38624 uint32_tArray  __attribute__((export_name("TS_RouteHint_get_a"))) TS_RouteHint_get_a(uint32_t this_ptr) {
38625         LDKRouteHint this_ptr_conv;
38626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38627         this_ptr_conv.is_owned = false;
38628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38629         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
38630         uint32_tArray ret_arr = NULL;
38631         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
38632         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
38633         for (size_t o = 0; o < ret_var.datalen; o++) {
38634                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
38635                 uint32_t ret_conv_14_ref = 0;
38636                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38637                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38638                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
38639                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
38640                 if (ret_conv_14_var.is_owned) {
38641                         ret_conv_14_ref |= 1;
38642                 }
38643                 ret_arr_ptr[o] = ret_conv_14_ref;
38644         }
38645         
38646         FREE(ret_var.data);
38647         return ret_arr;
38648 }
38649
38650 void  __attribute__((export_name("TS_RouteHint_set_a"))) TS_RouteHint_set_a(uint32_t this_ptr, uint32_tArray val) {
38651         LDKRouteHint this_ptr_conv;
38652         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38653         this_ptr_conv.is_owned = false;
38654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38655         LDKCVec_RouteHintHopZ val_constr;
38656         val_constr.datalen = val->arr_len;
38657         if (val_constr.datalen > 0)
38658                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
38659         else
38660                 val_constr.data = NULL;
38661         uint32_t* val_vals = val->elems /* XXX val leaks */;
38662         for (size_t o = 0; o < val_constr.datalen; o++) {
38663                 uint32_t val_conv_14 = val_vals[o];
38664                 LDKRouteHintHop val_conv_14_conv;
38665                 val_conv_14_conv.inner = (void*)(val_conv_14 & (~1));
38666                 val_conv_14_conv.is_owned = (val_conv_14 & 1) || (val_conv_14 == 0);
38667                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
38668                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
38669                 val_constr.data[o] = val_conv_14_conv;
38670         }
38671         RouteHint_set_a(&this_ptr_conv, val_constr);
38672 }
38673
38674 uint32_t  __attribute__((export_name("TS_RouteHint_new"))) TS_RouteHint_new(uint32_tArray a_arg) {
38675         LDKCVec_RouteHintHopZ a_arg_constr;
38676         a_arg_constr.datalen = a_arg->arr_len;
38677         if (a_arg_constr.datalen > 0)
38678                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
38679         else
38680                 a_arg_constr.data = NULL;
38681         uint32_t* a_arg_vals = a_arg->elems /* XXX a_arg leaks */;
38682         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
38683                 uint32_t a_arg_conv_14 = a_arg_vals[o];
38684                 LDKRouteHintHop a_arg_conv_14_conv;
38685                 a_arg_conv_14_conv.inner = (void*)(a_arg_conv_14 & (~1));
38686                 a_arg_conv_14_conv.is_owned = (a_arg_conv_14 & 1) || (a_arg_conv_14 == 0);
38687                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
38688                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
38689                 a_arg_constr.data[o] = a_arg_conv_14_conv;
38690         }
38691         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
38692         uint32_t ret_ref = 0;
38693         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38694         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38695         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38696         ret_ref = (uintptr_t)ret_var.inner;
38697         if (ret_var.is_owned) {
38698                 ret_ref |= 1;
38699         }
38700         return ret_ref;
38701 }
38702
38703 static inline uintptr_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
38704         LDKRouteHint ret_var = RouteHint_clone(arg);
38705 uint32_t ret_ref = 0;
38706 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38707 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38708 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38709 ret_ref = (uintptr_t)ret_var.inner;
38710 if (ret_var.is_owned) {
38711         ret_ref |= 1;
38712 }
38713         return ret_ref;
38714 }
38715 uint32_t  __attribute__((export_name("TS_RouteHint_clone_ptr"))) TS_RouteHint_clone_ptr(uint32_t arg) {
38716         LDKRouteHint arg_conv;
38717         arg_conv.inner = (void*)(arg & (~1));
38718         arg_conv.is_owned = false;
38719         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38720         uint32_t ret_conv = RouteHint_clone_ptr(&arg_conv);
38721         return ret_conv;
38722 }
38723
38724 uint32_t  __attribute__((export_name("TS_RouteHint_clone"))) TS_RouteHint_clone(uint32_t orig) {
38725         LDKRouteHint orig_conv;
38726         orig_conv.inner = (void*)(orig & (~1));
38727         orig_conv.is_owned = false;
38728         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38729         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
38730         uint32_t ret_ref = 0;
38731         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38732         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38733         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38734         ret_ref = (uintptr_t)ret_var.inner;
38735         if (ret_var.is_owned) {
38736                 ret_ref |= 1;
38737         }
38738         return ret_ref;
38739 }
38740
38741 int64_t  __attribute__((export_name("TS_RouteHint_hash"))) TS_RouteHint_hash(uint32_t o) {
38742         LDKRouteHint o_conv;
38743         o_conv.inner = (void*)(o & (~1));
38744         o_conv.is_owned = false;
38745         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38746         int64_t ret_conv = RouteHint_hash(&o_conv);
38747         return ret_conv;
38748 }
38749
38750 jboolean  __attribute__((export_name("TS_RouteHint_eq"))) TS_RouteHint_eq(uint32_t a, uint32_t b) {
38751         LDKRouteHint a_conv;
38752         a_conv.inner = (void*)(a & (~1));
38753         a_conv.is_owned = false;
38754         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38755         LDKRouteHint b_conv;
38756         b_conv.inner = (void*)(b & (~1));
38757         b_conv.is_owned = false;
38758         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38759         jboolean ret_conv = RouteHint_eq(&a_conv, &b_conv);
38760         return ret_conv;
38761 }
38762
38763 int8_tArray  __attribute__((export_name("TS_RouteHint_write"))) TS_RouteHint_write(uint32_t obj) {
38764         LDKRouteHint obj_conv;
38765         obj_conv.inner = (void*)(obj & (~1));
38766         obj_conv.is_owned = false;
38767         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38768         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
38769         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38770         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38771         CVec_u8Z_free(ret_var);
38772         return ret_arr;
38773 }
38774
38775 uint32_t  __attribute__((export_name("TS_RouteHint_read"))) TS_RouteHint_read(int8_tArray ser) {
38776         LDKu8slice ser_ref;
38777         ser_ref.datalen = ser->arr_len;
38778         ser_ref.data = ser->elems /* XXX ser leaks */;
38779         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
38780         *ret_conv = RouteHint_read(ser_ref);
38781         return (uint32_t)ret_conv;
38782 }
38783
38784 void  __attribute__((export_name("TS_RouteHintHop_free"))) TS_RouteHintHop_free(uint32_t this_obj) {
38785         LDKRouteHintHop this_obj_conv;
38786         this_obj_conv.inner = (void*)(this_obj & (~1));
38787         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38789         RouteHintHop_free(this_obj_conv);
38790 }
38791
38792 int8_tArray  __attribute__((export_name("TS_RouteHintHop_get_src_node_id"))) TS_RouteHintHop_get_src_node_id(uint32_t this_ptr) {
38793         LDKRouteHintHop this_ptr_conv;
38794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38795         this_ptr_conv.is_owned = false;
38796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38797         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
38798         memcpy(ret_arr->elems, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form, 33);
38799         return ret_arr;
38800 }
38801
38802 void  __attribute__((export_name("TS_RouteHintHop_set_src_node_id"))) TS_RouteHintHop_set_src_node_id(uint32_t this_ptr, int8_tArray val) {
38803         LDKRouteHintHop this_ptr_conv;
38804         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38805         this_ptr_conv.is_owned = false;
38806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38807         LDKPublicKey val_ref;
38808         CHECK(val->arr_len == 33);
38809         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
38810         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
38811 }
38812
38813 int64_t  __attribute__((export_name("TS_RouteHintHop_get_short_channel_id"))) TS_RouteHintHop_get_short_channel_id(uint32_t this_ptr) {
38814         LDKRouteHintHop this_ptr_conv;
38815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38816         this_ptr_conv.is_owned = false;
38817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38818         int64_t ret_conv = RouteHintHop_get_short_channel_id(&this_ptr_conv);
38819         return ret_conv;
38820 }
38821
38822 void  __attribute__((export_name("TS_RouteHintHop_set_short_channel_id"))) TS_RouteHintHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
38823         LDKRouteHintHop this_ptr_conv;
38824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38825         this_ptr_conv.is_owned = false;
38826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38827         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
38828 }
38829
38830 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_fees"))) TS_RouteHintHop_get_fees(uint32_t this_ptr) {
38831         LDKRouteHintHop this_ptr_conv;
38832         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38833         this_ptr_conv.is_owned = false;
38834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38835         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
38836         uint32_t ret_ref = 0;
38837         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38838         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38839         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38840         ret_ref = (uintptr_t)ret_var.inner;
38841         if (ret_var.is_owned) {
38842                 ret_ref |= 1;
38843         }
38844         return ret_ref;
38845 }
38846
38847 void  __attribute__((export_name("TS_RouteHintHop_set_fees"))) TS_RouteHintHop_set_fees(uint32_t this_ptr, uint32_t val) {
38848         LDKRouteHintHop 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         LDKRoutingFees val_conv;
38853         val_conv.inner = (void*)(val & (~1));
38854         val_conv.is_owned = (val & 1) || (val == 0);
38855         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38856         val_conv = RoutingFees_clone(&val_conv);
38857         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
38858 }
38859
38860 int16_t  __attribute__((export_name("TS_RouteHintHop_get_cltv_expiry_delta"))) TS_RouteHintHop_get_cltv_expiry_delta(uint32_t this_ptr) {
38861         LDKRouteHintHop this_ptr_conv;
38862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38863         this_ptr_conv.is_owned = false;
38864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38865         int16_t ret_conv = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
38866         return ret_conv;
38867 }
38868
38869 void  __attribute__((export_name("TS_RouteHintHop_set_cltv_expiry_delta"))) TS_RouteHintHop_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
38870         LDKRouteHintHop this_ptr_conv;
38871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38872         this_ptr_conv.is_owned = false;
38873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38874         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
38875 }
38876
38877 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_htlc_minimum_msat"))) TS_RouteHintHop_get_htlc_minimum_msat(uint32_t this_ptr) {
38878         LDKRouteHintHop this_ptr_conv;
38879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38880         this_ptr_conv.is_owned = false;
38881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38882         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
38883         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
38884         uint32_t ret_ref = (uintptr_t)ret_copy;
38885         return ret_ref;
38886 }
38887
38888 void  __attribute__((export_name("TS_RouteHintHop_set_htlc_minimum_msat"))) TS_RouteHintHop_set_htlc_minimum_msat(uint32_t this_ptr, uint32_t val) {
38889         LDKRouteHintHop this_ptr_conv;
38890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38891         this_ptr_conv.is_owned = false;
38892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38893         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
38894         CHECK_ACCESS(val_ptr);
38895         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
38896         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
38897         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
38898 }
38899
38900 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_htlc_maximum_msat"))) TS_RouteHintHop_get_htlc_maximum_msat(uint32_t this_ptr) {
38901         LDKRouteHintHop this_ptr_conv;
38902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38903         this_ptr_conv.is_owned = false;
38904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38905         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
38906         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
38907         uint32_t ret_ref = (uintptr_t)ret_copy;
38908         return ret_ref;
38909 }
38910
38911 void  __attribute__((export_name("TS_RouteHintHop_set_htlc_maximum_msat"))) TS_RouteHintHop_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
38912         LDKRouteHintHop this_ptr_conv;
38913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38914         this_ptr_conv.is_owned = false;
38915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38916         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
38917         CHECK_ACCESS(val_ptr);
38918         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
38919         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
38920         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
38921 }
38922
38923 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) {
38924         LDKPublicKey src_node_id_arg_ref;
38925         CHECK(src_node_id_arg->arr_len == 33);
38926         memcpy(src_node_id_arg_ref.compressed_form, src_node_id_arg->elems, 33); FREE(src_node_id_arg);
38927         LDKRoutingFees fees_arg_conv;
38928         fees_arg_conv.inner = (void*)(fees_arg & (~1));
38929         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
38930         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
38931         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
38932         void* htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)htlc_minimum_msat_arg) & ~1);
38933         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
38934         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
38935         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_minimum_msat_arg) & ~1));
38936         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
38937         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
38938         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
38939         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
38940         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);
38941         uint32_t ret_ref = 0;
38942         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38943         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38944         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38945         ret_ref = (uintptr_t)ret_var.inner;
38946         if (ret_var.is_owned) {
38947                 ret_ref |= 1;
38948         }
38949         return ret_ref;
38950 }
38951
38952 static inline uintptr_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
38953         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
38954 uint32_t ret_ref = 0;
38955 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38956 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38957 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38958 ret_ref = (uintptr_t)ret_var.inner;
38959 if (ret_var.is_owned) {
38960         ret_ref |= 1;
38961 }
38962         return ret_ref;
38963 }
38964 uint32_t  __attribute__((export_name("TS_RouteHintHop_clone_ptr"))) TS_RouteHintHop_clone_ptr(uint32_t arg) {
38965         LDKRouteHintHop arg_conv;
38966         arg_conv.inner = (void*)(arg & (~1));
38967         arg_conv.is_owned = false;
38968         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38969         uint32_t ret_conv = RouteHintHop_clone_ptr(&arg_conv);
38970         return ret_conv;
38971 }
38972
38973 uint32_t  __attribute__((export_name("TS_RouteHintHop_clone"))) TS_RouteHintHop_clone(uint32_t orig) {
38974         LDKRouteHintHop orig_conv;
38975         orig_conv.inner = (void*)(orig & (~1));
38976         orig_conv.is_owned = false;
38977         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38978         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
38979         uint32_t ret_ref = 0;
38980         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38981         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38982         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38983         ret_ref = (uintptr_t)ret_var.inner;
38984         if (ret_var.is_owned) {
38985                 ret_ref |= 1;
38986         }
38987         return ret_ref;
38988 }
38989
38990 int64_t  __attribute__((export_name("TS_RouteHintHop_hash"))) TS_RouteHintHop_hash(uint32_t o) {
38991         LDKRouteHintHop o_conv;
38992         o_conv.inner = (void*)(o & (~1));
38993         o_conv.is_owned = false;
38994         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38995         int64_t ret_conv = RouteHintHop_hash(&o_conv);
38996         return ret_conv;
38997 }
38998
38999 jboolean  __attribute__((export_name("TS_RouteHintHop_eq"))) TS_RouteHintHop_eq(uint32_t a, uint32_t b) {
39000         LDKRouteHintHop a_conv;
39001         a_conv.inner = (void*)(a & (~1));
39002         a_conv.is_owned = false;
39003         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39004         LDKRouteHintHop b_conv;
39005         b_conv.inner = (void*)(b & (~1));
39006         b_conv.is_owned = false;
39007         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39008         jboolean ret_conv = RouteHintHop_eq(&a_conv, &b_conv);
39009         return ret_conv;
39010 }
39011
39012 int8_tArray  __attribute__((export_name("TS_RouteHintHop_write"))) TS_RouteHintHop_write(uint32_t obj) {
39013         LDKRouteHintHop obj_conv;
39014         obj_conv.inner = (void*)(obj & (~1));
39015         obj_conv.is_owned = false;
39016         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39017         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
39018         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39019         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39020         CVec_u8Z_free(ret_var);
39021         return ret_arr;
39022 }
39023
39024 uint32_t  __attribute__((export_name("TS_RouteHintHop_read"))) TS_RouteHintHop_read(int8_tArray ser) {
39025         LDKu8slice ser_ref;
39026         ser_ref.datalen = ser->arr_len;
39027         ser_ref.data = ser->elems /* XXX ser leaks */;
39028         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
39029         *ret_conv = RouteHintHop_read(ser_ref);
39030         return (uint32_t)ret_conv;
39031 }
39032
39033 uint32_t  __attribute__((export_name("TS_find_route"))) TS_find_route(int8_tArray our_node_pubkey, uint32_t route_params, uint32_t network, uint32_tArray first_hops, uint32_t logger, uint32_t scorer, int8_tArray random_seed_bytes) {
39034         LDKPublicKey our_node_pubkey_ref;
39035         CHECK(our_node_pubkey->arr_len == 33);
39036         memcpy(our_node_pubkey_ref.compressed_form, our_node_pubkey->elems, 33); FREE(our_node_pubkey);
39037         LDKRouteParameters route_params_conv;
39038         route_params_conv.inner = (void*)(route_params & (~1));
39039         route_params_conv.is_owned = false;
39040         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
39041         LDKNetworkGraph network_conv;
39042         network_conv.inner = (void*)(network & (~1));
39043         network_conv.is_owned = false;
39044         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_conv);
39045         LDKCVec_ChannelDetailsZ first_hops_constr;
39046         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
39047         if (first_hops != 0) {
39048                 first_hops_constr.datalen = first_hops->arr_len;
39049                 if (first_hops_constr.datalen > 0)
39050                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
39051                 else
39052                         first_hops_constr.data = NULL;
39053                 uint32_t* first_hops_vals = first_hops->elems /* XXX first_hops leaks */;
39054                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
39055                         uint32_t first_hops_conv_16 = first_hops_vals[q];
39056                         LDKChannelDetails first_hops_conv_16_conv;
39057                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
39058                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
39059                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
39060                         first_hops_constr.data[q] = first_hops_conv_16_conv;
39061                 }
39062                 first_hops_ptr = &first_hops_constr;
39063         }
39064         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
39065         CHECK_ACCESS(logger_ptr);
39066         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
39067         if (logger_conv.free == LDKLogger_JCalls_free) {
39068                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39069                 LDKLogger_JCalls_cloned(&logger_conv);
39070         }
39071         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
39072         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
39073         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
39074         unsigned char random_seed_bytes_arr[32];
39075         CHECK(random_seed_bytes->arr_len == 32);
39076         memcpy(random_seed_bytes_arr, random_seed_bytes->elems, 32); FREE(random_seed_bytes);
39077         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
39078         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
39079         *ret_conv = find_route(our_node_pubkey_ref, &route_params_conv, &network_conv, first_hops_ptr, logger_conv, scorer_conv, random_seed_bytes_ref);
39080         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
39081         return (uint32_t)ret_conv;
39082 }
39083
39084 void  __attribute__((export_name("TS_Score_free"))) TS_Score_free(uint32_t this_ptr) {
39085         if ((this_ptr & 1) != 0) return;
39086         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39087         CHECK_ACCESS(this_ptr_ptr);
39088         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
39089         FREE((void*)this_ptr);
39090         Score_free(this_ptr_conv);
39091 }
39092
39093 void  __attribute__((export_name("TS_LockableScore_free"))) TS_LockableScore_free(uint32_t this_ptr) {
39094         if ((this_ptr & 1) != 0) return;
39095         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39096         CHECK_ACCESS(this_ptr_ptr);
39097         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
39098         FREE((void*)this_ptr);
39099         LockableScore_free(this_ptr_conv);
39100 }
39101
39102 void  __attribute__((export_name("TS_MultiThreadedLockableScore_free"))) TS_MultiThreadedLockableScore_free(uint32_t this_obj) {
39103         LDKMultiThreadedLockableScore this_obj_conv;
39104         this_obj_conv.inner = (void*)(this_obj & (~1));
39105         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39107         MultiThreadedLockableScore_free(this_obj_conv);
39108 }
39109
39110 uint32_t  __attribute__((export_name("TS_MultiThreadedLockableScore_new"))) TS_MultiThreadedLockableScore_new(uint32_t score) {
39111         void* score_ptr = (void*)(((uintptr_t)score) & ~1);
39112         CHECK_ACCESS(score_ptr);
39113         LDKScore score_conv = *(LDKScore*)(score_ptr);
39114         if (score_conv.free == LDKScore_JCalls_free) {
39115                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39116                 LDKScore_JCalls_cloned(&score_conv);
39117         }
39118         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
39119         uint32_t ret_ref = 0;
39120         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39121         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39122         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39123         ret_ref = (uintptr_t)ret_var.inner;
39124         if (ret_var.is_owned) {
39125                 ret_ref |= 1;
39126         }
39127         return ret_ref;
39128 }
39129
39130 void  __attribute__((export_name("TS_FixedPenaltyScorer_free"))) TS_FixedPenaltyScorer_free(uint32_t this_obj) {
39131         LDKFixedPenaltyScorer this_obj_conv;
39132         this_obj_conv.inner = (void*)(this_obj & (~1));
39133         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39135         FixedPenaltyScorer_free(this_obj_conv);
39136 }
39137
39138 static inline uintptr_t FixedPenaltyScorer_clone_ptr(LDKFixedPenaltyScorer *NONNULL_PTR arg) {
39139         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(arg);
39140 uint32_t ret_ref = 0;
39141 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39142 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39143 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39144 ret_ref = (uintptr_t)ret_var.inner;
39145 if (ret_var.is_owned) {
39146         ret_ref |= 1;
39147 }
39148         return ret_ref;
39149 }
39150 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_clone_ptr"))) TS_FixedPenaltyScorer_clone_ptr(uint32_t arg) {
39151         LDKFixedPenaltyScorer arg_conv;
39152         arg_conv.inner = (void*)(arg & (~1));
39153         arg_conv.is_owned = false;
39154         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39155         uint32_t ret_conv = FixedPenaltyScorer_clone_ptr(&arg_conv);
39156         return ret_conv;
39157 }
39158
39159 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_clone"))) TS_FixedPenaltyScorer_clone(uint32_t orig) {
39160         LDKFixedPenaltyScorer orig_conv;
39161         orig_conv.inner = (void*)(orig & (~1));
39162         orig_conv.is_owned = false;
39163         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39164         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(&orig_conv);
39165         uint32_t ret_ref = 0;
39166         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39167         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39168         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39169         ret_ref = (uintptr_t)ret_var.inner;
39170         if (ret_var.is_owned) {
39171                 ret_ref |= 1;
39172         }
39173         return ret_ref;
39174 }
39175
39176 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_with_penalty"))) TS_FixedPenaltyScorer_with_penalty(int64_t penalty_msat) {
39177         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_with_penalty(penalty_msat);
39178         uint32_t ret_ref = 0;
39179         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39180         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39181         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39182         ret_ref = (uintptr_t)ret_var.inner;
39183         if (ret_var.is_owned) {
39184                 ret_ref |= 1;
39185         }
39186         return ret_ref;
39187 }
39188
39189 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_as_Score"))) TS_FixedPenaltyScorer_as_Score(uint32_t this_arg) {
39190         LDKFixedPenaltyScorer this_arg_conv;
39191         this_arg_conv.inner = (void*)(this_arg & (~1));
39192         this_arg_conv.is_owned = false;
39193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39194         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
39195         *ret_ret = FixedPenaltyScorer_as_Score(&this_arg_conv);
39196         return (uint32_t)ret_ret;
39197 }
39198
39199 int8_tArray  __attribute__((export_name("TS_FixedPenaltyScorer_write"))) TS_FixedPenaltyScorer_write(uint32_t obj) {
39200         LDKFixedPenaltyScorer obj_conv;
39201         obj_conv.inner = (void*)(obj & (~1));
39202         obj_conv.is_owned = false;
39203         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39204         LDKCVec_u8Z ret_var = FixedPenaltyScorer_write(&obj_conv);
39205         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39206         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39207         CVec_u8Z_free(ret_var);
39208         return ret_arr;
39209 }
39210
39211 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_read"))) TS_FixedPenaltyScorer_read(int8_tArray ser, int64_t arg) {
39212         LDKu8slice ser_ref;
39213         ser_ref.datalen = ser->arr_len;
39214         ser_ref.data = ser->elems /* XXX ser leaks */;
39215         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
39216         *ret_conv = FixedPenaltyScorer_read(ser_ref, arg);
39217         return (uint32_t)ret_conv;
39218 }
39219
39220 void  __attribute__((export_name("TS_Scorer_free"))) TS_Scorer_free(uint32_t this_obj) {
39221         LDKScorer this_obj_conv;
39222         this_obj_conv.inner = (void*)(this_obj & (~1));
39223         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39225         Scorer_free(this_obj_conv);
39226 }
39227
39228 void  __attribute__((export_name("TS_ScoringParameters_free"))) TS_ScoringParameters_free(uint32_t this_obj) {
39229         LDKScoringParameters this_obj_conv;
39230         this_obj_conv.inner = (void*)(this_obj & (~1));
39231         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39233         ScoringParameters_free(this_obj_conv);
39234 }
39235
39236 int64_t  __attribute__((export_name("TS_ScoringParameters_get_base_penalty_msat"))) TS_ScoringParameters_get_base_penalty_msat(uint32_t this_ptr) {
39237         LDKScoringParameters this_ptr_conv;
39238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39239         this_ptr_conv.is_owned = false;
39240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39241         int64_t ret_conv = ScoringParameters_get_base_penalty_msat(&this_ptr_conv);
39242         return ret_conv;
39243 }
39244
39245 void  __attribute__((export_name("TS_ScoringParameters_set_base_penalty_msat"))) TS_ScoringParameters_set_base_penalty_msat(uint32_t this_ptr, int64_t val) {
39246         LDKScoringParameters this_ptr_conv;
39247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39248         this_ptr_conv.is_owned = false;
39249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39250         ScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
39251 }
39252
39253 int64_t  __attribute__((export_name("TS_ScoringParameters_get_failure_penalty_msat"))) TS_ScoringParameters_get_failure_penalty_msat(uint32_t this_ptr) {
39254         LDKScoringParameters this_ptr_conv;
39255         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39256         this_ptr_conv.is_owned = false;
39257         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39258         int64_t ret_conv = ScoringParameters_get_failure_penalty_msat(&this_ptr_conv);
39259         return ret_conv;
39260 }
39261
39262 void  __attribute__((export_name("TS_ScoringParameters_set_failure_penalty_msat"))) TS_ScoringParameters_set_failure_penalty_msat(uint32_t this_ptr, int64_t val) {
39263         LDKScoringParameters this_ptr_conv;
39264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39265         this_ptr_conv.is_owned = false;
39266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39267         ScoringParameters_set_failure_penalty_msat(&this_ptr_conv, val);
39268 }
39269
39270 int16_t  __attribute__((export_name("TS_ScoringParameters_get_overuse_penalty_start_1024th"))) TS_ScoringParameters_get_overuse_penalty_start_1024th(uint32_t this_ptr) {
39271         LDKScoringParameters this_ptr_conv;
39272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39273         this_ptr_conv.is_owned = false;
39274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39275         int16_t ret_conv = ScoringParameters_get_overuse_penalty_start_1024th(&this_ptr_conv);
39276         return ret_conv;
39277 }
39278
39279 void  __attribute__((export_name("TS_ScoringParameters_set_overuse_penalty_start_1024th"))) TS_ScoringParameters_set_overuse_penalty_start_1024th(uint32_t this_ptr, int16_t val) {
39280         LDKScoringParameters this_ptr_conv;
39281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39282         this_ptr_conv.is_owned = false;
39283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39284         ScoringParameters_set_overuse_penalty_start_1024th(&this_ptr_conv, val);
39285 }
39286
39287 int64_t  __attribute__((export_name("TS_ScoringParameters_get_overuse_penalty_msat_per_1024th"))) TS_ScoringParameters_get_overuse_penalty_msat_per_1024th(uint32_t this_ptr) {
39288         LDKScoringParameters this_ptr_conv;
39289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39290         this_ptr_conv.is_owned = false;
39291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39292         int64_t ret_conv = ScoringParameters_get_overuse_penalty_msat_per_1024th(&this_ptr_conv);
39293         return ret_conv;
39294 }
39295
39296 void  __attribute__((export_name("TS_ScoringParameters_set_overuse_penalty_msat_per_1024th"))) TS_ScoringParameters_set_overuse_penalty_msat_per_1024th(uint32_t this_ptr, int64_t val) {
39297         LDKScoringParameters this_ptr_conv;
39298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39299         this_ptr_conv.is_owned = false;
39300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39301         ScoringParameters_set_overuse_penalty_msat_per_1024th(&this_ptr_conv, val);
39302 }
39303
39304 int64_t  __attribute__((export_name("TS_ScoringParameters_get_failure_penalty_half_life"))) TS_ScoringParameters_get_failure_penalty_half_life(uint32_t this_ptr) {
39305         LDKScoringParameters this_ptr_conv;
39306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39307         this_ptr_conv.is_owned = false;
39308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39309         int64_t ret_conv = ScoringParameters_get_failure_penalty_half_life(&this_ptr_conv);
39310         return ret_conv;
39311 }
39312
39313 void  __attribute__((export_name("TS_ScoringParameters_set_failure_penalty_half_life"))) TS_ScoringParameters_set_failure_penalty_half_life(uint32_t this_ptr, int64_t val) {
39314         LDKScoringParameters this_ptr_conv;
39315         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39316         this_ptr_conv.is_owned = false;
39317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39318         ScoringParameters_set_failure_penalty_half_life(&this_ptr_conv, val);
39319 }
39320
39321 uint32_t  __attribute__((export_name("TS_ScoringParameters_new"))) TS_ScoringParameters_new(int64_t base_penalty_msat_arg, int64_t failure_penalty_msat_arg, int16_t overuse_penalty_start_1024th_arg, int64_t overuse_penalty_msat_per_1024th_arg, int64_t failure_penalty_half_life_arg) {
39322         LDKScoringParameters ret_var = ScoringParameters_new(base_penalty_msat_arg, failure_penalty_msat_arg, overuse_penalty_start_1024th_arg, overuse_penalty_msat_per_1024th_arg, failure_penalty_half_life_arg);
39323         uint32_t ret_ref = 0;
39324         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39325         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39326         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39327         ret_ref = (uintptr_t)ret_var.inner;
39328         if (ret_var.is_owned) {
39329                 ret_ref |= 1;
39330         }
39331         return ret_ref;
39332 }
39333
39334 static inline uintptr_t ScoringParameters_clone_ptr(LDKScoringParameters *NONNULL_PTR arg) {
39335         LDKScoringParameters ret_var = ScoringParameters_clone(arg);
39336 uint32_t ret_ref = 0;
39337 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39338 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39339 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39340 ret_ref = (uintptr_t)ret_var.inner;
39341 if (ret_var.is_owned) {
39342         ret_ref |= 1;
39343 }
39344         return ret_ref;
39345 }
39346 uint32_t  __attribute__((export_name("TS_ScoringParameters_clone_ptr"))) TS_ScoringParameters_clone_ptr(uint32_t arg) {
39347         LDKScoringParameters arg_conv;
39348         arg_conv.inner = (void*)(arg & (~1));
39349         arg_conv.is_owned = false;
39350         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39351         uint32_t ret_conv = ScoringParameters_clone_ptr(&arg_conv);
39352         return ret_conv;
39353 }
39354
39355 uint32_t  __attribute__((export_name("TS_ScoringParameters_clone"))) TS_ScoringParameters_clone(uint32_t orig) {
39356         LDKScoringParameters orig_conv;
39357         orig_conv.inner = (void*)(orig & (~1));
39358         orig_conv.is_owned = false;
39359         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39360         LDKScoringParameters ret_var = ScoringParameters_clone(&orig_conv);
39361         uint32_t ret_ref = 0;
39362         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39363         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39364         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39365         ret_ref = (uintptr_t)ret_var.inner;
39366         if (ret_var.is_owned) {
39367                 ret_ref |= 1;
39368         }
39369         return ret_ref;
39370 }
39371
39372 int8_tArray  __attribute__((export_name("TS_ScoringParameters_write"))) TS_ScoringParameters_write(uint32_t obj) {
39373         LDKScoringParameters obj_conv;
39374         obj_conv.inner = (void*)(obj & (~1));
39375         obj_conv.is_owned = false;
39376         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39377         LDKCVec_u8Z ret_var = ScoringParameters_write(&obj_conv);
39378         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39379         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39380         CVec_u8Z_free(ret_var);
39381         return ret_arr;
39382 }
39383
39384 uint32_t  __attribute__((export_name("TS_ScoringParameters_read"))) TS_ScoringParameters_read(int8_tArray ser) {
39385         LDKu8slice ser_ref;
39386         ser_ref.datalen = ser->arr_len;
39387         ser_ref.data = ser->elems /* XXX ser leaks */;
39388         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
39389         *ret_conv = ScoringParameters_read(ser_ref);
39390         return (uint32_t)ret_conv;
39391 }
39392
39393 uint32_t  __attribute__((export_name("TS_Scorer_new"))) TS_Scorer_new(uint32_t params) {
39394         LDKScoringParameters params_conv;
39395         params_conv.inner = (void*)(params & (~1));
39396         params_conv.is_owned = (params & 1) || (params == 0);
39397         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
39398         params_conv = ScoringParameters_clone(&params_conv);
39399         LDKScorer ret_var = Scorer_new(params_conv);
39400         uint32_t ret_ref = 0;
39401         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39402         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39403         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39404         ret_ref = (uintptr_t)ret_var.inner;
39405         if (ret_var.is_owned) {
39406                 ret_ref |= 1;
39407         }
39408         return ret_ref;
39409 }
39410
39411 uint32_t  __attribute__((export_name("TS_Scorer_default"))) TS_Scorer_default() {
39412         LDKScorer ret_var = Scorer_default();
39413         uint32_t ret_ref = 0;
39414         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39415         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39416         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39417         ret_ref = (uintptr_t)ret_var.inner;
39418         if (ret_var.is_owned) {
39419                 ret_ref |= 1;
39420         }
39421         return ret_ref;
39422 }
39423
39424 uint32_t  __attribute__((export_name("TS_ScoringParameters_default"))) TS_ScoringParameters_default() {
39425         LDKScoringParameters ret_var = ScoringParameters_default();
39426         uint32_t ret_ref = 0;
39427         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39428         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39429         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39430         ret_ref = (uintptr_t)ret_var.inner;
39431         if (ret_var.is_owned) {
39432                 ret_ref |= 1;
39433         }
39434         return ret_ref;
39435 }
39436
39437 uint32_t  __attribute__((export_name("TS_Scorer_as_Score"))) TS_Scorer_as_Score(uint32_t this_arg) {
39438         LDKScorer this_arg_conv;
39439         this_arg_conv.inner = (void*)(this_arg & (~1));
39440         this_arg_conv.is_owned = false;
39441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39442         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
39443         *ret_ret = Scorer_as_Score(&this_arg_conv);
39444         return (uint32_t)ret_ret;
39445 }
39446
39447 int8_tArray  __attribute__((export_name("TS_Scorer_write"))) TS_Scorer_write(uint32_t obj) {
39448         LDKScorer obj_conv;
39449         obj_conv.inner = (void*)(obj & (~1));
39450         obj_conv.is_owned = false;
39451         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39452         LDKCVec_u8Z ret_var = Scorer_write(&obj_conv);
39453         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39454         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39455         CVec_u8Z_free(ret_var);
39456         return ret_arr;
39457 }
39458
39459 uint32_t  __attribute__((export_name("TS_Scorer_read"))) TS_Scorer_read(int8_tArray ser) {
39460         LDKu8slice ser_ref;
39461         ser_ref.datalen = ser->arr_len;
39462         ser_ref.data = ser->elems /* XXX ser leaks */;
39463         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
39464         *ret_conv = Scorer_read(ser_ref);
39465         return (uint32_t)ret_conv;
39466 }
39467
39468 void  __attribute__((export_name("TS_ProbabilisticScorer_free"))) TS_ProbabilisticScorer_free(uint32_t this_obj) {
39469         LDKProbabilisticScorer this_obj_conv;
39470         this_obj_conv.inner = (void*)(this_obj & (~1));
39471         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39473         ProbabilisticScorer_free(this_obj_conv);
39474 }
39475
39476 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_free"))) TS_ProbabilisticScoringParameters_free(uint32_t this_obj) {
39477         LDKProbabilisticScoringParameters this_obj_conv;
39478         this_obj_conv.inner = (void*)(this_obj & (~1));
39479         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39481         ProbabilisticScoringParameters_free(this_obj_conv);
39482 }
39483
39484 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_base_penalty_msat"))) TS_ProbabilisticScoringParameters_get_base_penalty_msat(uint32_t this_ptr) {
39485         LDKProbabilisticScoringParameters this_ptr_conv;
39486         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39487         this_ptr_conv.is_owned = false;
39488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39489         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_msat(&this_ptr_conv);
39490         return ret_conv;
39491 }
39492
39493 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_set_base_penalty_msat"))) TS_ProbabilisticScoringParameters_set_base_penalty_msat(uint32_t this_ptr, int64_t val) {
39494         LDKProbabilisticScoringParameters this_ptr_conv;
39495         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39496         this_ptr_conv.is_owned = false;
39497         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39498         ProbabilisticScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
39499 }
39500
39501 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat"))) TS_ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(uint32_t this_ptr) {
39502         LDKProbabilisticScoringParameters this_ptr_conv;
39503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39504         this_ptr_conv.is_owned = false;
39505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39506         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(&this_ptr_conv);
39507         return ret_conv;
39508 }
39509
39510 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) {
39511         LDKProbabilisticScoringParameters this_ptr_conv;
39512         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39513         this_ptr_conv.is_owned = false;
39514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39515         ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
39516 }
39517
39518 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_liquidity_offset_half_life"))) TS_ProbabilisticScoringParameters_get_liquidity_offset_half_life(uint32_t this_ptr) {
39519         LDKProbabilisticScoringParameters this_ptr_conv;
39520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39521         this_ptr_conv.is_owned = false;
39522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39523         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_offset_half_life(&this_ptr_conv);
39524         return ret_conv;
39525 }
39526
39527 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) {
39528         LDKProbabilisticScoringParameters this_ptr_conv;
39529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39530         this_ptr_conv.is_owned = false;
39531         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39532         ProbabilisticScoringParameters_set_liquidity_offset_half_life(&this_ptr_conv, val);
39533 }
39534
39535 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_amount_penalty_multiplier_msat"))) TS_ProbabilisticScoringParameters_get_amount_penalty_multiplier_msat(uint32_t this_ptr) {
39536         LDKProbabilisticScoringParameters this_ptr_conv;
39537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39538         this_ptr_conv.is_owned = false;
39539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39540         int64_t ret_conv = ProbabilisticScoringParameters_get_amount_penalty_multiplier_msat(&this_ptr_conv);
39541         return ret_conv;
39542 }
39543
39544 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) {
39545         LDKProbabilisticScoringParameters this_ptr_conv;
39546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39547         this_ptr_conv.is_owned = false;
39548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39549         ProbabilisticScoringParameters_set_amount_penalty_multiplier_msat(&this_ptr_conv, val);
39550 }
39551
39552 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) {
39553         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_new(base_penalty_msat_arg, liquidity_penalty_multiplier_msat_arg, liquidity_offset_half_life_arg, amount_penalty_multiplier_msat_arg);
39554         uint32_t ret_ref = 0;
39555         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39556         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39557         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39558         ret_ref = (uintptr_t)ret_var.inner;
39559         if (ret_var.is_owned) {
39560                 ret_ref |= 1;
39561         }
39562         return ret_ref;
39563 }
39564
39565 static inline uintptr_t ProbabilisticScoringParameters_clone_ptr(LDKProbabilisticScoringParameters *NONNULL_PTR arg) {
39566         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(arg);
39567 uint32_t ret_ref = 0;
39568 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39569 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39570 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39571 ret_ref = (uintptr_t)ret_var.inner;
39572 if (ret_var.is_owned) {
39573         ret_ref |= 1;
39574 }
39575         return ret_ref;
39576 }
39577 uint32_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_clone_ptr"))) TS_ProbabilisticScoringParameters_clone_ptr(uint32_t arg) {
39578         LDKProbabilisticScoringParameters arg_conv;
39579         arg_conv.inner = (void*)(arg & (~1));
39580         arg_conv.is_owned = false;
39581         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39582         uint32_t ret_conv = ProbabilisticScoringParameters_clone_ptr(&arg_conv);
39583         return ret_conv;
39584 }
39585
39586 uint32_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_clone"))) TS_ProbabilisticScoringParameters_clone(uint32_t orig) {
39587         LDKProbabilisticScoringParameters orig_conv;
39588         orig_conv.inner = (void*)(orig & (~1));
39589         orig_conv.is_owned = false;
39590         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39591         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(&orig_conv);
39592         uint32_t ret_ref = 0;
39593         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39594         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39595         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39596         ret_ref = (uintptr_t)ret_var.inner;
39597         if (ret_var.is_owned) {
39598                 ret_ref |= 1;
39599         }
39600         return ret_ref;
39601 }
39602
39603 uint32_t  __attribute__((export_name("TS_ProbabilisticScorer_new"))) TS_ProbabilisticScorer_new(uint32_t params, uint32_t network_graph) {
39604         LDKProbabilisticScoringParameters params_conv;
39605         params_conv.inner = (void*)(params & (~1));
39606         params_conv.is_owned = (params & 1) || (params == 0);
39607         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
39608         params_conv = ProbabilisticScoringParameters_clone(&params_conv);
39609         LDKNetworkGraph network_graph_conv;
39610         network_graph_conv.inner = (void*)(network_graph & (~1));
39611         network_graph_conv.is_owned = false;
39612         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
39613         LDKProbabilisticScorer ret_var = ProbabilisticScorer_new(params_conv, &network_graph_conv);
39614         uint32_t ret_ref = 0;
39615         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39616         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39617         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39618         ret_ref = (uintptr_t)ret_var.inner;
39619         if (ret_var.is_owned) {
39620                 ret_ref |= 1;
39621         }
39622         return ret_ref;
39623 }
39624
39625 uint32_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_default"))) TS_ProbabilisticScoringParameters_default() {
39626         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_default();
39627         uint32_t ret_ref = 0;
39628         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39629         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39630         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39631         ret_ref = (uintptr_t)ret_var.inner;
39632         if (ret_var.is_owned) {
39633                 ret_ref |= 1;
39634         }
39635         return ret_ref;
39636 }
39637
39638 uint32_t  __attribute__((export_name("TS_ProbabilisticScorer_as_Score"))) TS_ProbabilisticScorer_as_Score(uint32_t this_arg) {
39639         LDKProbabilisticScorer this_arg_conv;
39640         this_arg_conv.inner = (void*)(this_arg & (~1));
39641         this_arg_conv.is_owned = false;
39642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39643         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
39644         *ret_ret = ProbabilisticScorer_as_Score(&this_arg_conv);
39645         return (uint32_t)ret_ret;
39646 }
39647
39648 int8_tArray  __attribute__((export_name("TS_ProbabilisticScorer_write"))) TS_ProbabilisticScorer_write(uint32_t obj) {
39649         LDKProbabilisticScorer obj_conv;
39650         obj_conv.inner = (void*)(obj & (~1));
39651         obj_conv.is_owned = false;
39652         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39653         LDKCVec_u8Z ret_var = ProbabilisticScorer_write(&obj_conv);
39654         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39655         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39656         CVec_u8Z_free(ret_var);
39657         return ret_arr;
39658 }
39659
39660 uint32_t  __attribute__((export_name("TS_ProbabilisticScorer_read"))) TS_ProbabilisticScorer_read(int8_tArray ser, uint32_t arg_a, uint32_t arg_b) {
39661         LDKu8slice ser_ref;
39662         ser_ref.datalen = ser->arr_len;
39663         ser_ref.data = ser->elems /* XXX ser leaks */;
39664         LDKProbabilisticScoringParameters arg_a_conv;
39665         arg_a_conv.inner = (void*)(arg_a & (~1));
39666         arg_a_conv.is_owned = (arg_a & 1) || (arg_a == 0);
39667         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_a_conv);
39668         arg_a_conv = ProbabilisticScoringParameters_clone(&arg_a_conv);
39669         LDKNetworkGraph arg_b_conv;
39670         arg_b_conv.inner = (void*)(arg_b & (~1));
39671         arg_b_conv.is_owned = false;
39672         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_b_conv);
39673         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
39674         *ret_conv = ProbabilisticScorer_read(ser_ref, arg_a_conv, &arg_b_conv);
39675         return (uint32_t)ret_conv;
39676 }
39677
39678 void  __attribute__((export_name("TS_ParseError_free"))) TS_ParseError_free(uint32_t this_ptr) {
39679         if ((this_ptr & 1) != 0) return;
39680         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39681         CHECK_ACCESS(this_ptr_ptr);
39682         LDKParseError this_ptr_conv = *(LDKParseError*)(this_ptr_ptr);
39683         FREE((void*)this_ptr);
39684         ParseError_free(this_ptr_conv);
39685 }
39686
39687 static inline uintptr_t ParseError_clone_ptr(LDKParseError *NONNULL_PTR arg) {
39688         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39689         *ret_copy = ParseError_clone(arg);
39690 uint32_t ret_ref = (uintptr_t)ret_copy;
39691         return ret_ref;
39692 }
39693 uint32_t  __attribute__((export_name("TS_ParseError_clone_ptr"))) TS_ParseError_clone_ptr(uint32_t arg) {
39694         LDKParseError* arg_conv = (LDKParseError*)arg;
39695         uint32_t ret_conv = ParseError_clone_ptr(arg_conv);
39696         return ret_conv;
39697 }
39698
39699 uint32_t  __attribute__((export_name("TS_ParseError_clone"))) TS_ParseError_clone(uint32_t orig) {
39700         LDKParseError* orig_conv = (LDKParseError*)orig;
39701         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39702         *ret_copy = ParseError_clone(orig_conv);
39703         uint32_t ret_ref = (uintptr_t)ret_copy;
39704         return ret_ref;
39705 }
39706
39707 uint32_t  __attribute__((export_name("TS_ParseError_bech32_error"))) TS_ParseError_bech32_error(uint32_t a) {
39708         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
39709         CHECK_ACCESS(a_ptr);
39710         LDKBech32Error a_conv = *(LDKBech32Error*)(a_ptr);
39711         a_conv = Bech32Error_clone((LDKBech32Error*)(((uintptr_t)a) & ~1));
39712         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39713         *ret_copy = ParseError_bech32_error(a_conv);
39714         uint32_t ret_ref = (uintptr_t)ret_copy;
39715         return ret_ref;
39716 }
39717
39718 uint32_t  __attribute__((export_name("TS_ParseError_parse_amount_error"))) TS_ParseError_parse_amount_error(int32_t a) {
39719         
39720         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39721         *ret_copy = ParseError_parse_amount_error((LDKError){ ._dummy = 0 });
39722         uint32_t ret_ref = (uintptr_t)ret_copy;
39723         return ret_ref;
39724 }
39725
39726 uint32_t  __attribute__((export_name("TS_ParseError_malformed_signature"))) TS_ParseError_malformed_signature(uint32_t a) {
39727         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_js(a);
39728         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39729         *ret_copy = ParseError_malformed_signature(a_conv);
39730         uint32_t ret_ref = (uintptr_t)ret_copy;
39731         return ret_ref;
39732 }
39733
39734 uint32_t  __attribute__((export_name("TS_ParseError_bad_prefix"))) TS_ParseError_bad_prefix() {
39735         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39736         *ret_copy = ParseError_bad_prefix();
39737         uint32_t ret_ref = (uintptr_t)ret_copy;
39738         return ret_ref;
39739 }
39740
39741 uint32_t  __attribute__((export_name("TS_ParseError_unknown_currency"))) TS_ParseError_unknown_currency() {
39742         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39743         *ret_copy = ParseError_unknown_currency();
39744         uint32_t ret_ref = (uintptr_t)ret_copy;
39745         return ret_ref;
39746 }
39747
39748 uint32_t  __attribute__((export_name("TS_ParseError_unknown_si_prefix"))) TS_ParseError_unknown_si_prefix() {
39749         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39750         *ret_copy = ParseError_unknown_si_prefix();
39751         uint32_t ret_ref = (uintptr_t)ret_copy;
39752         return ret_ref;
39753 }
39754
39755 uint32_t  __attribute__((export_name("TS_ParseError_malformed_hrp"))) TS_ParseError_malformed_hrp() {
39756         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39757         *ret_copy = ParseError_malformed_hrp();
39758         uint32_t ret_ref = (uintptr_t)ret_copy;
39759         return ret_ref;
39760 }
39761
39762 uint32_t  __attribute__((export_name("TS_ParseError_too_short_data_part"))) TS_ParseError_too_short_data_part() {
39763         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39764         *ret_copy = ParseError_too_short_data_part();
39765         uint32_t ret_ref = (uintptr_t)ret_copy;
39766         return ret_ref;
39767 }
39768
39769 uint32_t  __attribute__((export_name("TS_ParseError_unexpected_end_of_tagged_fields"))) TS_ParseError_unexpected_end_of_tagged_fields() {
39770         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39771         *ret_copy = ParseError_unexpected_end_of_tagged_fields();
39772         uint32_t ret_ref = (uintptr_t)ret_copy;
39773         return ret_ref;
39774 }
39775
39776 uint32_t  __attribute__((export_name("TS_ParseError_description_decode_error"))) TS_ParseError_description_decode_error(int32_t a) {
39777         
39778         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39779         *ret_copy = ParseError_description_decode_error((LDKError){ ._dummy = 0 });
39780         uint32_t ret_ref = (uintptr_t)ret_copy;
39781         return ret_ref;
39782 }
39783
39784 uint32_t  __attribute__((export_name("TS_ParseError_padding_error"))) TS_ParseError_padding_error() {
39785         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39786         *ret_copy = ParseError_padding_error();
39787         uint32_t ret_ref = (uintptr_t)ret_copy;
39788         return ret_ref;
39789 }
39790
39791 uint32_t  __attribute__((export_name("TS_ParseError_integer_overflow_error"))) TS_ParseError_integer_overflow_error() {
39792         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39793         *ret_copy = ParseError_integer_overflow_error();
39794         uint32_t ret_ref = (uintptr_t)ret_copy;
39795         return ret_ref;
39796 }
39797
39798 uint32_t  __attribute__((export_name("TS_ParseError_invalid_seg_wit_program_length"))) TS_ParseError_invalid_seg_wit_program_length() {
39799         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39800         *ret_copy = ParseError_invalid_seg_wit_program_length();
39801         uint32_t ret_ref = (uintptr_t)ret_copy;
39802         return ret_ref;
39803 }
39804
39805 uint32_t  __attribute__((export_name("TS_ParseError_invalid_pub_key_hash_length"))) TS_ParseError_invalid_pub_key_hash_length() {
39806         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39807         *ret_copy = ParseError_invalid_pub_key_hash_length();
39808         uint32_t ret_ref = (uintptr_t)ret_copy;
39809         return ret_ref;
39810 }
39811
39812 uint32_t  __attribute__((export_name("TS_ParseError_invalid_script_hash_length"))) TS_ParseError_invalid_script_hash_length() {
39813         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39814         *ret_copy = ParseError_invalid_script_hash_length();
39815         uint32_t ret_ref = (uintptr_t)ret_copy;
39816         return ret_ref;
39817 }
39818
39819 uint32_t  __attribute__((export_name("TS_ParseError_invalid_recovery_id"))) TS_ParseError_invalid_recovery_id() {
39820         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39821         *ret_copy = ParseError_invalid_recovery_id();
39822         uint32_t ret_ref = (uintptr_t)ret_copy;
39823         return ret_ref;
39824 }
39825
39826 uint32_t  __attribute__((export_name("TS_ParseError_invalid_slice_length"))) TS_ParseError_invalid_slice_length(jstring a) {
39827         LDKStr a_conv = str_ref_to_owned_c(a);
39828         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39829         *ret_copy = ParseError_invalid_slice_length(a_conv);
39830         uint32_t ret_ref = (uintptr_t)ret_copy;
39831         return ret_ref;
39832 }
39833
39834 uint32_t  __attribute__((export_name("TS_ParseError_skip"))) TS_ParseError_skip() {
39835         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39836         *ret_copy = ParseError_skip();
39837         uint32_t ret_ref = (uintptr_t)ret_copy;
39838         return ret_ref;
39839 }
39840
39841 void  __attribute__((export_name("TS_ParseOrSemanticError_free"))) TS_ParseOrSemanticError_free(uint32_t this_ptr) {
39842         if ((this_ptr & 1) != 0) return;
39843         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39844         CHECK_ACCESS(this_ptr_ptr);
39845         LDKParseOrSemanticError this_ptr_conv = *(LDKParseOrSemanticError*)(this_ptr_ptr);
39846         FREE((void*)this_ptr);
39847         ParseOrSemanticError_free(this_ptr_conv);
39848 }
39849
39850 static inline uintptr_t ParseOrSemanticError_clone_ptr(LDKParseOrSemanticError *NONNULL_PTR arg) {
39851         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
39852         *ret_copy = ParseOrSemanticError_clone(arg);
39853 uint32_t ret_ref = (uintptr_t)ret_copy;
39854         return ret_ref;
39855 }
39856 uint32_t  __attribute__((export_name("TS_ParseOrSemanticError_clone_ptr"))) TS_ParseOrSemanticError_clone_ptr(uint32_t arg) {
39857         LDKParseOrSemanticError* arg_conv = (LDKParseOrSemanticError*)arg;
39858         uint32_t ret_conv = ParseOrSemanticError_clone_ptr(arg_conv);
39859         return ret_conv;
39860 }
39861
39862 uint32_t  __attribute__((export_name("TS_ParseOrSemanticError_clone"))) TS_ParseOrSemanticError_clone(uint32_t orig) {
39863         LDKParseOrSemanticError* orig_conv = (LDKParseOrSemanticError*)orig;
39864         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
39865         *ret_copy = ParseOrSemanticError_clone(orig_conv);
39866         uint32_t ret_ref = (uintptr_t)ret_copy;
39867         return ret_ref;
39868 }
39869
39870 uint32_t  __attribute__((export_name("TS_ParseOrSemanticError_parse_error"))) TS_ParseOrSemanticError_parse_error(uint32_t a) {
39871         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
39872         CHECK_ACCESS(a_ptr);
39873         LDKParseError a_conv = *(LDKParseError*)(a_ptr);
39874         a_conv = ParseError_clone((LDKParseError*)(((uintptr_t)a) & ~1));
39875         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
39876         *ret_copy = ParseOrSemanticError_parse_error(a_conv);
39877         uint32_t ret_ref = (uintptr_t)ret_copy;
39878         return ret_ref;
39879 }
39880
39881 uint32_t  __attribute__((export_name("TS_ParseOrSemanticError_semantic_error"))) TS_ParseOrSemanticError_semantic_error(uint32_t a) {
39882         LDKSemanticError a_conv = LDKSemanticError_from_js(a);
39883         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
39884         *ret_copy = ParseOrSemanticError_semantic_error(a_conv);
39885         uint32_t ret_ref = (uintptr_t)ret_copy;
39886         return ret_ref;
39887 }
39888
39889 void  __attribute__((export_name("TS_Invoice_free"))) TS_Invoice_free(uint32_t this_obj) {
39890         LDKInvoice this_obj_conv;
39891         this_obj_conv.inner = (void*)(this_obj & (~1));
39892         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39894         Invoice_free(this_obj_conv);
39895 }
39896
39897 jboolean  __attribute__((export_name("TS_Invoice_eq"))) TS_Invoice_eq(uint32_t a, uint32_t b) {
39898         LDKInvoice a_conv;
39899         a_conv.inner = (void*)(a & (~1));
39900         a_conv.is_owned = false;
39901         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39902         LDKInvoice b_conv;
39903         b_conv.inner = (void*)(b & (~1));
39904         b_conv.is_owned = false;
39905         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39906         jboolean ret_conv = Invoice_eq(&a_conv, &b_conv);
39907         return ret_conv;
39908 }
39909
39910 static inline uintptr_t Invoice_clone_ptr(LDKInvoice *NONNULL_PTR arg) {
39911         LDKInvoice ret_var = Invoice_clone(arg);
39912 uint32_t ret_ref = 0;
39913 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39914 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39915 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39916 ret_ref = (uintptr_t)ret_var.inner;
39917 if (ret_var.is_owned) {
39918         ret_ref |= 1;
39919 }
39920         return ret_ref;
39921 }
39922 uint32_t  __attribute__((export_name("TS_Invoice_clone_ptr"))) TS_Invoice_clone_ptr(uint32_t arg) {
39923         LDKInvoice arg_conv;
39924         arg_conv.inner = (void*)(arg & (~1));
39925         arg_conv.is_owned = false;
39926         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39927         uint32_t ret_conv = Invoice_clone_ptr(&arg_conv);
39928         return ret_conv;
39929 }
39930
39931 uint32_t  __attribute__((export_name("TS_Invoice_clone"))) TS_Invoice_clone(uint32_t orig) {
39932         LDKInvoice orig_conv;
39933         orig_conv.inner = (void*)(orig & (~1));
39934         orig_conv.is_owned = false;
39935         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39936         LDKInvoice ret_var = Invoice_clone(&orig_conv);
39937         uint32_t ret_ref = 0;
39938         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39939         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39940         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39941         ret_ref = (uintptr_t)ret_var.inner;
39942         if (ret_var.is_owned) {
39943                 ret_ref |= 1;
39944         }
39945         return ret_ref;
39946 }
39947
39948 void  __attribute__((export_name("TS_SignedRawInvoice_free"))) TS_SignedRawInvoice_free(uint32_t this_obj) {
39949         LDKSignedRawInvoice this_obj_conv;
39950         this_obj_conv.inner = (void*)(this_obj & (~1));
39951         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39953         SignedRawInvoice_free(this_obj_conv);
39954 }
39955
39956 jboolean  __attribute__((export_name("TS_SignedRawInvoice_eq"))) TS_SignedRawInvoice_eq(uint32_t a, uint32_t b) {
39957         LDKSignedRawInvoice a_conv;
39958         a_conv.inner = (void*)(a & (~1));
39959         a_conv.is_owned = false;
39960         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39961         LDKSignedRawInvoice b_conv;
39962         b_conv.inner = (void*)(b & (~1));
39963         b_conv.is_owned = false;
39964         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39965         jboolean ret_conv = SignedRawInvoice_eq(&a_conv, &b_conv);
39966         return ret_conv;
39967 }
39968
39969 static inline uintptr_t SignedRawInvoice_clone_ptr(LDKSignedRawInvoice *NONNULL_PTR arg) {
39970         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(arg);
39971 uint32_t ret_ref = 0;
39972 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39973 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39974 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39975 ret_ref = (uintptr_t)ret_var.inner;
39976 if (ret_var.is_owned) {
39977         ret_ref |= 1;
39978 }
39979         return ret_ref;
39980 }
39981 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_clone_ptr"))) TS_SignedRawInvoice_clone_ptr(uint32_t arg) {
39982         LDKSignedRawInvoice arg_conv;
39983         arg_conv.inner = (void*)(arg & (~1));
39984         arg_conv.is_owned = false;
39985         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39986         uint32_t ret_conv = SignedRawInvoice_clone_ptr(&arg_conv);
39987         return ret_conv;
39988 }
39989
39990 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_clone"))) TS_SignedRawInvoice_clone(uint32_t orig) {
39991         LDKSignedRawInvoice orig_conv;
39992         orig_conv.inner = (void*)(orig & (~1));
39993         orig_conv.is_owned = false;
39994         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39995         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
39996         uint32_t ret_ref = 0;
39997         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39998         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39999         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40000         ret_ref = (uintptr_t)ret_var.inner;
40001         if (ret_var.is_owned) {
40002                 ret_ref |= 1;
40003         }
40004         return ret_ref;
40005 }
40006
40007 void  __attribute__((export_name("TS_RawInvoice_free"))) TS_RawInvoice_free(uint32_t this_obj) {
40008         LDKRawInvoice this_obj_conv;
40009         this_obj_conv.inner = (void*)(this_obj & (~1));
40010         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40012         RawInvoice_free(this_obj_conv);
40013 }
40014
40015 uint32_t  __attribute__((export_name("TS_RawInvoice_get_data"))) TS_RawInvoice_get_data(uint32_t this_ptr) {
40016         LDKRawInvoice this_ptr_conv;
40017         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40018         this_ptr_conv.is_owned = false;
40019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40020         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
40021         uint32_t ret_ref = 0;
40022         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40023         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40024         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40025         ret_ref = (uintptr_t)ret_var.inner;
40026         if (ret_var.is_owned) {
40027                 ret_ref |= 1;
40028         }
40029         return ret_ref;
40030 }
40031
40032 void  __attribute__((export_name("TS_RawInvoice_set_data"))) TS_RawInvoice_set_data(uint32_t this_ptr, uint32_t val) {
40033         LDKRawInvoice this_ptr_conv;
40034         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40035         this_ptr_conv.is_owned = false;
40036         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40037         LDKRawDataPart val_conv;
40038         val_conv.inner = (void*)(val & (~1));
40039         val_conv.is_owned = (val & 1) || (val == 0);
40040         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40041         val_conv = RawDataPart_clone(&val_conv);
40042         RawInvoice_set_data(&this_ptr_conv, val_conv);
40043 }
40044
40045 jboolean  __attribute__((export_name("TS_RawInvoice_eq"))) TS_RawInvoice_eq(uint32_t a, uint32_t b) {
40046         LDKRawInvoice a_conv;
40047         a_conv.inner = (void*)(a & (~1));
40048         a_conv.is_owned = false;
40049         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40050         LDKRawInvoice b_conv;
40051         b_conv.inner = (void*)(b & (~1));
40052         b_conv.is_owned = false;
40053         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40054         jboolean ret_conv = RawInvoice_eq(&a_conv, &b_conv);
40055         return ret_conv;
40056 }
40057
40058 static inline uintptr_t RawInvoice_clone_ptr(LDKRawInvoice *NONNULL_PTR arg) {
40059         LDKRawInvoice ret_var = RawInvoice_clone(arg);
40060 uint32_t ret_ref = 0;
40061 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40062 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40063 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40064 ret_ref = (uintptr_t)ret_var.inner;
40065 if (ret_var.is_owned) {
40066         ret_ref |= 1;
40067 }
40068         return ret_ref;
40069 }
40070 uint32_t  __attribute__((export_name("TS_RawInvoice_clone_ptr"))) TS_RawInvoice_clone_ptr(uint32_t arg) {
40071         LDKRawInvoice arg_conv;
40072         arg_conv.inner = (void*)(arg & (~1));
40073         arg_conv.is_owned = false;
40074         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40075         uint32_t ret_conv = RawInvoice_clone_ptr(&arg_conv);
40076         return ret_conv;
40077 }
40078
40079 uint32_t  __attribute__((export_name("TS_RawInvoice_clone"))) TS_RawInvoice_clone(uint32_t orig) {
40080         LDKRawInvoice orig_conv;
40081         orig_conv.inner = (void*)(orig & (~1));
40082         orig_conv.is_owned = false;
40083         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40084         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
40085         uint32_t ret_ref = 0;
40086         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40087         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40088         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40089         ret_ref = (uintptr_t)ret_var.inner;
40090         if (ret_var.is_owned) {
40091                 ret_ref |= 1;
40092         }
40093         return ret_ref;
40094 }
40095
40096 void  __attribute__((export_name("TS_RawDataPart_free"))) TS_RawDataPart_free(uint32_t this_obj) {
40097         LDKRawDataPart this_obj_conv;
40098         this_obj_conv.inner = (void*)(this_obj & (~1));
40099         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40101         RawDataPart_free(this_obj_conv);
40102 }
40103
40104 uint32_t  __attribute__((export_name("TS_RawDataPart_get_timestamp"))) TS_RawDataPart_get_timestamp(uint32_t this_ptr) {
40105         LDKRawDataPart this_ptr_conv;
40106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40107         this_ptr_conv.is_owned = false;
40108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40109         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
40110         uint32_t ret_ref = 0;
40111         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40112         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40113         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40114         ret_ref = (uintptr_t)ret_var.inner;
40115         if (ret_var.is_owned) {
40116                 ret_ref |= 1;
40117         }
40118         return ret_ref;
40119 }
40120
40121 void  __attribute__((export_name("TS_RawDataPart_set_timestamp"))) TS_RawDataPart_set_timestamp(uint32_t this_ptr, uint32_t val) {
40122         LDKRawDataPart this_ptr_conv;
40123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40124         this_ptr_conv.is_owned = false;
40125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40126         LDKPositiveTimestamp val_conv;
40127         val_conv.inner = (void*)(val & (~1));
40128         val_conv.is_owned = (val & 1) || (val == 0);
40129         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40130         val_conv = PositiveTimestamp_clone(&val_conv);
40131         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
40132 }
40133
40134 jboolean  __attribute__((export_name("TS_RawDataPart_eq"))) TS_RawDataPart_eq(uint32_t a, uint32_t b) {
40135         LDKRawDataPart a_conv;
40136         a_conv.inner = (void*)(a & (~1));
40137         a_conv.is_owned = false;
40138         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40139         LDKRawDataPart b_conv;
40140         b_conv.inner = (void*)(b & (~1));
40141         b_conv.is_owned = false;
40142         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40143         jboolean ret_conv = RawDataPart_eq(&a_conv, &b_conv);
40144         return ret_conv;
40145 }
40146
40147 static inline uintptr_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
40148         LDKRawDataPart ret_var = RawDataPart_clone(arg);
40149 uint32_t ret_ref = 0;
40150 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40151 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40152 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40153 ret_ref = (uintptr_t)ret_var.inner;
40154 if (ret_var.is_owned) {
40155         ret_ref |= 1;
40156 }
40157         return ret_ref;
40158 }
40159 uint32_t  __attribute__((export_name("TS_RawDataPart_clone_ptr"))) TS_RawDataPart_clone_ptr(uint32_t arg) {
40160         LDKRawDataPart arg_conv;
40161         arg_conv.inner = (void*)(arg & (~1));
40162         arg_conv.is_owned = false;
40163         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40164         uint32_t ret_conv = RawDataPart_clone_ptr(&arg_conv);
40165         return ret_conv;
40166 }
40167
40168 uint32_t  __attribute__((export_name("TS_RawDataPart_clone"))) TS_RawDataPart_clone(uint32_t orig) {
40169         LDKRawDataPart orig_conv;
40170         orig_conv.inner = (void*)(orig & (~1));
40171         orig_conv.is_owned = false;
40172         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40173         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
40174         uint32_t ret_ref = 0;
40175         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40176         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40177         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40178         ret_ref = (uintptr_t)ret_var.inner;
40179         if (ret_var.is_owned) {
40180                 ret_ref |= 1;
40181         }
40182         return ret_ref;
40183 }
40184
40185 void  __attribute__((export_name("TS_PositiveTimestamp_free"))) TS_PositiveTimestamp_free(uint32_t this_obj) {
40186         LDKPositiveTimestamp this_obj_conv;
40187         this_obj_conv.inner = (void*)(this_obj & (~1));
40188         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40190         PositiveTimestamp_free(this_obj_conv);
40191 }
40192
40193 jboolean  __attribute__((export_name("TS_PositiveTimestamp_eq"))) TS_PositiveTimestamp_eq(uint32_t a, uint32_t b) {
40194         LDKPositiveTimestamp a_conv;
40195         a_conv.inner = (void*)(a & (~1));
40196         a_conv.is_owned = false;
40197         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40198         LDKPositiveTimestamp b_conv;
40199         b_conv.inner = (void*)(b & (~1));
40200         b_conv.is_owned = false;
40201         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40202         jboolean ret_conv = PositiveTimestamp_eq(&a_conv, &b_conv);
40203         return ret_conv;
40204 }
40205
40206 static inline uintptr_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
40207         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
40208 uint32_t ret_ref = 0;
40209 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40210 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40211 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40212 ret_ref = (uintptr_t)ret_var.inner;
40213 if (ret_var.is_owned) {
40214         ret_ref |= 1;
40215 }
40216         return ret_ref;
40217 }
40218 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_clone_ptr"))) TS_PositiveTimestamp_clone_ptr(uint32_t arg) {
40219         LDKPositiveTimestamp arg_conv;
40220         arg_conv.inner = (void*)(arg & (~1));
40221         arg_conv.is_owned = false;
40222         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40223         uint32_t ret_conv = PositiveTimestamp_clone_ptr(&arg_conv);
40224         return ret_conv;
40225 }
40226
40227 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_clone"))) TS_PositiveTimestamp_clone(uint32_t orig) {
40228         LDKPositiveTimestamp orig_conv;
40229         orig_conv.inner = (void*)(orig & (~1));
40230         orig_conv.is_owned = false;
40231         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40232         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
40233         uint32_t ret_ref = 0;
40234         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40235         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40236         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40237         ret_ref = (uintptr_t)ret_var.inner;
40238         if (ret_var.is_owned) {
40239                 ret_ref |= 1;
40240         }
40241         return ret_ref;
40242 }
40243
40244 uint32_t  __attribute__((export_name("TS_SiPrefix_clone"))) TS_SiPrefix_clone(uint32_t orig) {
40245         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
40246         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_clone(orig_conv));
40247         return ret_conv;
40248 }
40249
40250 uint32_t  __attribute__((export_name("TS_SiPrefix_milli"))) TS_SiPrefix_milli() {
40251         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_milli());
40252         return ret_conv;
40253 }
40254
40255 uint32_t  __attribute__((export_name("TS_SiPrefix_micro"))) TS_SiPrefix_micro() {
40256         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_micro());
40257         return ret_conv;
40258 }
40259
40260 uint32_t  __attribute__((export_name("TS_SiPrefix_nano"))) TS_SiPrefix_nano() {
40261         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_nano());
40262         return ret_conv;
40263 }
40264
40265 uint32_t  __attribute__((export_name("TS_SiPrefix_pico"))) TS_SiPrefix_pico() {
40266         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_pico());
40267         return ret_conv;
40268 }
40269
40270 jboolean  __attribute__((export_name("TS_SiPrefix_eq"))) TS_SiPrefix_eq(uint32_t a, uint32_t b) {
40271         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
40272         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
40273         jboolean ret_conv = SiPrefix_eq(a_conv, b_conv);
40274         return ret_conv;
40275 }
40276
40277 int64_t  __attribute__((export_name("TS_SiPrefix_multiplier"))) TS_SiPrefix_multiplier(uint32_t this_arg) {
40278         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
40279         int64_t ret_conv = SiPrefix_multiplier(this_arg_conv);
40280         return ret_conv;
40281 }
40282
40283 uint32_t  __attribute__((export_name("TS_Currency_clone"))) TS_Currency_clone(uint32_t orig) {
40284         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
40285         uint32_t ret_conv = LDKCurrency_to_js(Currency_clone(orig_conv));
40286         return ret_conv;
40287 }
40288
40289 uint32_t  __attribute__((export_name("TS_Currency_bitcoin"))) TS_Currency_bitcoin() {
40290         uint32_t ret_conv = LDKCurrency_to_js(Currency_bitcoin());
40291         return ret_conv;
40292 }
40293
40294 uint32_t  __attribute__((export_name("TS_Currency_bitcoin_testnet"))) TS_Currency_bitcoin_testnet() {
40295         uint32_t ret_conv = LDKCurrency_to_js(Currency_bitcoin_testnet());
40296         return ret_conv;
40297 }
40298
40299 uint32_t  __attribute__((export_name("TS_Currency_regtest"))) TS_Currency_regtest() {
40300         uint32_t ret_conv = LDKCurrency_to_js(Currency_regtest());
40301         return ret_conv;
40302 }
40303
40304 uint32_t  __attribute__((export_name("TS_Currency_simnet"))) TS_Currency_simnet() {
40305         uint32_t ret_conv = LDKCurrency_to_js(Currency_simnet());
40306         return ret_conv;
40307 }
40308
40309 uint32_t  __attribute__((export_name("TS_Currency_signet"))) TS_Currency_signet() {
40310         uint32_t ret_conv = LDKCurrency_to_js(Currency_signet());
40311         return ret_conv;
40312 }
40313
40314 int64_t  __attribute__((export_name("TS_Currency_hash"))) TS_Currency_hash(uint32_t o) {
40315         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
40316         int64_t ret_conv = Currency_hash(o_conv);
40317         return ret_conv;
40318 }
40319
40320 jboolean  __attribute__((export_name("TS_Currency_eq"))) TS_Currency_eq(uint32_t a, uint32_t b) {
40321         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
40322         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
40323         jboolean ret_conv = Currency_eq(a_conv, b_conv);
40324         return ret_conv;
40325 }
40326
40327 void  __attribute__((export_name("TS_Sha256_free"))) TS_Sha256_free(uint32_t this_obj) {
40328         LDKSha256 this_obj_conv;
40329         this_obj_conv.inner = (void*)(this_obj & (~1));
40330         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40332         Sha256_free(this_obj_conv);
40333 }
40334
40335 static inline uintptr_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
40336         LDKSha256 ret_var = Sha256_clone(arg);
40337 uint32_t ret_ref = 0;
40338 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40339 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40340 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40341 ret_ref = (uintptr_t)ret_var.inner;
40342 if (ret_var.is_owned) {
40343         ret_ref |= 1;
40344 }
40345         return ret_ref;
40346 }
40347 uint32_t  __attribute__((export_name("TS_Sha256_clone_ptr"))) TS_Sha256_clone_ptr(uint32_t arg) {
40348         LDKSha256 arg_conv;
40349         arg_conv.inner = (void*)(arg & (~1));
40350         arg_conv.is_owned = false;
40351         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40352         uint32_t ret_conv = Sha256_clone_ptr(&arg_conv);
40353         return ret_conv;
40354 }
40355
40356 uint32_t  __attribute__((export_name("TS_Sha256_clone"))) TS_Sha256_clone(uint32_t orig) {
40357         LDKSha256 orig_conv;
40358         orig_conv.inner = (void*)(orig & (~1));
40359         orig_conv.is_owned = false;
40360         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40361         LDKSha256 ret_var = Sha256_clone(&orig_conv);
40362         uint32_t ret_ref = 0;
40363         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40364         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40365         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40366         ret_ref = (uintptr_t)ret_var.inner;
40367         if (ret_var.is_owned) {
40368                 ret_ref |= 1;
40369         }
40370         return ret_ref;
40371 }
40372
40373 int64_t  __attribute__((export_name("TS_Sha256_hash"))) TS_Sha256_hash(uint32_t o) {
40374         LDKSha256 o_conv;
40375         o_conv.inner = (void*)(o & (~1));
40376         o_conv.is_owned = false;
40377         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40378         int64_t ret_conv = Sha256_hash(&o_conv);
40379         return ret_conv;
40380 }
40381
40382 jboolean  __attribute__((export_name("TS_Sha256_eq"))) TS_Sha256_eq(uint32_t a, uint32_t b) {
40383         LDKSha256 a_conv;
40384         a_conv.inner = (void*)(a & (~1));
40385         a_conv.is_owned = false;
40386         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40387         LDKSha256 b_conv;
40388         b_conv.inner = (void*)(b & (~1));
40389         b_conv.is_owned = false;
40390         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40391         jboolean ret_conv = Sha256_eq(&a_conv, &b_conv);
40392         return ret_conv;
40393 }
40394
40395 void  __attribute__((export_name("TS_Description_free"))) TS_Description_free(uint32_t this_obj) {
40396         LDKDescription this_obj_conv;
40397         this_obj_conv.inner = (void*)(this_obj & (~1));
40398         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40400         Description_free(this_obj_conv);
40401 }
40402
40403 static inline uintptr_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
40404         LDKDescription ret_var = Description_clone(arg);
40405 uint32_t ret_ref = 0;
40406 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40407 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40408 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40409 ret_ref = (uintptr_t)ret_var.inner;
40410 if (ret_var.is_owned) {
40411         ret_ref |= 1;
40412 }
40413         return ret_ref;
40414 }
40415 uint32_t  __attribute__((export_name("TS_Description_clone_ptr"))) TS_Description_clone_ptr(uint32_t arg) {
40416         LDKDescription arg_conv;
40417         arg_conv.inner = (void*)(arg & (~1));
40418         arg_conv.is_owned = false;
40419         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40420         uint32_t ret_conv = Description_clone_ptr(&arg_conv);
40421         return ret_conv;
40422 }
40423
40424 uint32_t  __attribute__((export_name("TS_Description_clone"))) TS_Description_clone(uint32_t orig) {
40425         LDKDescription orig_conv;
40426         orig_conv.inner = (void*)(orig & (~1));
40427         orig_conv.is_owned = false;
40428         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40429         LDKDescription ret_var = Description_clone(&orig_conv);
40430         uint32_t ret_ref = 0;
40431         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40432         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40433         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40434         ret_ref = (uintptr_t)ret_var.inner;
40435         if (ret_var.is_owned) {
40436                 ret_ref |= 1;
40437         }
40438         return ret_ref;
40439 }
40440
40441 int64_t  __attribute__((export_name("TS_Description_hash"))) TS_Description_hash(uint32_t o) {
40442         LDKDescription o_conv;
40443         o_conv.inner = (void*)(o & (~1));
40444         o_conv.is_owned = false;
40445         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40446         int64_t ret_conv = Description_hash(&o_conv);
40447         return ret_conv;
40448 }
40449
40450 jboolean  __attribute__((export_name("TS_Description_eq"))) TS_Description_eq(uint32_t a, uint32_t b) {
40451         LDKDescription a_conv;
40452         a_conv.inner = (void*)(a & (~1));
40453         a_conv.is_owned = false;
40454         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40455         LDKDescription b_conv;
40456         b_conv.inner = (void*)(b & (~1));
40457         b_conv.is_owned = false;
40458         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40459         jboolean ret_conv = Description_eq(&a_conv, &b_conv);
40460         return ret_conv;
40461 }
40462
40463 void  __attribute__((export_name("TS_PayeePubKey_free"))) TS_PayeePubKey_free(uint32_t this_obj) {
40464         LDKPayeePubKey this_obj_conv;
40465         this_obj_conv.inner = (void*)(this_obj & (~1));
40466         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40468         PayeePubKey_free(this_obj_conv);
40469 }
40470
40471 int8_tArray  __attribute__((export_name("TS_PayeePubKey_get_a"))) TS_PayeePubKey_get_a(uint32_t this_ptr) {
40472         LDKPayeePubKey this_ptr_conv;
40473         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40474         this_ptr_conv.is_owned = false;
40475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40476         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
40477         memcpy(ret_arr->elems, PayeePubKey_get_a(&this_ptr_conv).compressed_form, 33);
40478         return ret_arr;
40479 }
40480
40481 void  __attribute__((export_name("TS_PayeePubKey_set_a"))) TS_PayeePubKey_set_a(uint32_t this_ptr, int8_tArray val) {
40482         LDKPayeePubKey this_ptr_conv;
40483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40484         this_ptr_conv.is_owned = false;
40485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40486         LDKPublicKey val_ref;
40487         CHECK(val->arr_len == 33);
40488         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
40489         PayeePubKey_set_a(&this_ptr_conv, val_ref);
40490 }
40491
40492 uint32_t  __attribute__((export_name("TS_PayeePubKey_new"))) TS_PayeePubKey_new(int8_tArray a_arg) {
40493         LDKPublicKey a_arg_ref;
40494         CHECK(a_arg->arr_len == 33);
40495         memcpy(a_arg_ref.compressed_form, a_arg->elems, 33); FREE(a_arg);
40496         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
40497         uint32_t ret_ref = 0;
40498         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40499         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40500         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40501         ret_ref = (uintptr_t)ret_var.inner;
40502         if (ret_var.is_owned) {
40503                 ret_ref |= 1;
40504         }
40505         return ret_ref;
40506 }
40507
40508 static inline uintptr_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
40509         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
40510 uint32_t ret_ref = 0;
40511 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40512 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40513 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40514 ret_ref = (uintptr_t)ret_var.inner;
40515 if (ret_var.is_owned) {
40516         ret_ref |= 1;
40517 }
40518         return ret_ref;
40519 }
40520 uint32_t  __attribute__((export_name("TS_PayeePubKey_clone_ptr"))) TS_PayeePubKey_clone_ptr(uint32_t arg) {
40521         LDKPayeePubKey arg_conv;
40522         arg_conv.inner = (void*)(arg & (~1));
40523         arg_conv.is_owned = false;
40524         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40525         uint32_t ret_conv = PayeePubKey_clone_ptr(&arg_conv);
40526         return ret_conv;
40527 }
40528
40529 uint32_t  __attribute__((export_name("TS_PayeePubKey_clone"))) TS_PayeePubKey_clone(uint32_t orig) {
40530         LDKPayeePubKey orig_conv;
40531         orig_conv.inner = (void*)(orig & (~1));
40532         orig_conv.is_owned = false;
40533         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40534         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
40535         uint32_t ret_ref = 0;
40536         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40537         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40538         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40539         ret_ref = (uintptr_t)ret_var.inner;
40540         if (ret_var.is_owned) {
40541                 ret_ref |= 1;
40542         }
40543         return ret_ref;
40544 }
40545
40546 int64_t  __attribute__((export_name("TS_PayeePubKey_hash"))) TS_PayeePubKey_hash(uint32_t o) {
40547         LDKPayeePubKey o_conv;
40548         o_conv.inner = (void*)(o & (~1));
40549         o_conv.is_owned = false;
40550         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40551         int64_t ret_conv = PayeePubKey_hash(&o_conv);
40552         return ret_conv;
40553 }
40554
40555 jboolean  __attribute__((export_name("TS_PayeePubKey_eq"))) TS_PayeePubKey_eq(uint32_t a, uint32_t b) {
40556         LDKPayeePubKey a_conv;
40557         a_conv.inner = (void*)(a & (~1));
40558         a_conv.is_owned = false;
40559         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40560         LDKPayeePubKey b_conv;
40561         b_conv.inner = (void*)(b & (~1));
40562         b_conv.is_owned = false;
40563         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40564         jboolean ret_conv = PayeePubKey_eq(&a_conv, &b_conv);
40565         return ret_conv;
40566 }
40567
40568 void  __attribute__((export_name("TS_ExpiryTime_free"))) TS_ExpiryTime_free(uint32_t this_obj) {
40569         LDKExpiryTime this_obj_conv;
40570         this_obj_conv.inner = (void*)(this_obj & (~1));
40571         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40573         ExpiryTime_free(this_obj_conv);
40574 }
40575
40576 static inline uintptr_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
40577         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
40578 uint32_t ret_ref = 0;
40579 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40580 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40581 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40582 ret_ref = (uintptr_t)ret_var.inner;
40583 if (ret_var.is_owned) {
40584         ret_ref |= 1;
40585 }
40586         return ret_ref;
40587 }
40588 uint32_t  __attribute__((export_name("TS_ExpiryTime_clone_ptr"))) TS_ExpiryTime_clone_ptr(uint32_t arg) {
40589         LDKExpiryTime arg_conv;
40590         arg_conv.inner = (void*)(arg & (~1));
40591         arg_conv.is_owned = false;
40592         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40593         uint32_t ret_conv = ExpiryTime_clone_ptr(&arg_conv);
40594         return ret_conv;
40595 }
40596
40597 uint32_t  __attribute__((export_name("TS_ExpiryTime_clone"))) TS_ExpiryTime_clone(uint32_t orig) {
40598         LDKExpiryTime orig_conv;
40599         orig_conv.inner = (void*)(orig & (~1));
40600         orig_conv.is_owned = false;
40601         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40602         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
40603         uint32_t ret_ref = 0;
40604         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40605         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40606         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40607         ret_ref = (uintptr_t)ret_var.inner;
40608         if (ret_var.is_owned) {
40609                 ret_ref |= 1;
40610         }
40611         return ret_ref;
40612 }
40613
40614 int64_t  __attribute__((export_name("TS_ExpiryTime_hash"))) TS_ExpiryTime_hash(uint32_t o) {
40615         LDKExpiryTime o_conv;
40616         o_conv.inner = (void*)(o & (~1));
40617         o_conv.is_owned = false;
40618         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40619         int64_t ret_conv = ExpiryTime_hash(&o_conv);
40620         return ret_conv;
40621 }
40622
40623 jboolean  __attribute__((export_name("TS_ExpiryTime_eq"))) TS_ExpiryTime_eq(uint32_t a, uint32_t b) {
40624         LDKExpiryTime a_conv;
40625         a_conv.inner = (void*)(a & (~1));
40626         a_conv.is_owned = false;
40627         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40628         LDKExpiryTime b_conv;
40629         b_conv.inner = (void*)(b & (~1));
40630         b_conv.is_owned = false;
40631         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40632         jboolean ret_conv = ExpiryTime_eq(&a_conv, &b_conv);
40633         return ret_conv;
40634 }
40635
40636 void  __attribute__((export_name("TS_MinFinalCltvExpiry_free"))) TS_MinFinalCltvExpiry_free(uint32_t this_obj) {
40637         LDKMinFinalCltvExpiry this_obj_conv;
40638         this_obj_conv.inner = (void*)(this_obj & (~1));
40639         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40641         MinFinalCltvExpiry_free(this_obj_conv);
40642 }
40643
40644 int64_t  __attribute__((export_name("TS_MinFinalCltvExpiry_get_a"))) TS_MinFinalCltvExpiry_get_a(uint32_t this_ptr) {
40645         LDKMinFinalCltvExpiry this_ptr_conv;
40646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40647         this_ptr_conv.is_owned = false;
40648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40649         int64_t ret_conv = MinFinalCltvExpiry_get_a(&this_ptr_conv);
40650         return ret_conv;
40651 }
40652
40653 void  __attribute__((export_name("TS_MinFinalCltvExpiry_set_a"))) TS_MinFinalCltvExpiry_set_a(uint32_t this_ptr, int64_t val) {
40654         LDKMinFinalCltvExpiry this_ptr_conv;
40655         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40656         this_ptr_conv.is_owned = false;
40657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40658         MinFinalCltvExpiry_set_a(&this_ptr_conv, val);
40659 }
40660
40661 uint32_t  __attribute__((export_name("TS_MinFinalCltvExpiry_new"))) TS_MinFinalCltvExpiry_new(int64_t a_arg) {
40662         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_new(a_arg);
40663         uint32_t ret_ref = 0;
40664         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40665         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40666         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40667         ret_ref = (uintptr_t)ret_var.inner;
40668         if (ret_var.is_owned) {
40669                 ret_ref |= 1;
40670         }
40671         return ret_ref;
40672 }
40673
40674 static inline uintptr_t MinFinalCltvExpiry_clone_ptr(LDKMinFinalCltvExpiry *NONNULL_PTR arg) {
40675         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(arg);
40676 uint32_t ret_ref = 0;
40677 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40678 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40679 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40680 ret_ref = (uintptr_t)ret_var.inner;
40681 if (ret_var.is_owned) {
40682         ret_ref |= 1;
40683 }
40684         return ret_ref;
40685 }
40686 uint32_t  __attribute__((export_name("TS_MinFinalCltvExpiry_clone_ptr"))) TS_MinFinalCltvExpiry_clone_ptr(uint32_t arg) {
40687         LDKMinFinalCltvExpiry arg_conv;
40688         arg_conv.inner = (void*)(arg & (~1));
40689         arg_conv.is_owned = false;
40690         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40691         uint32_t ret_conv = MinFinalCltvExpiry_clone_ptr(&arg_conv);
40692         return ret_conv;
40693 }
40694
40695 uint32_t  __attribute__((export_name("TS_MinFinalCltvExpiry_clone"))) TS_MinFinalCltvExpiry_clone(uint32_t orig) {
40696         LDKMinFinalCltvExpiry orig_conv;
40697         orig_conv.inner = (void*)(orig & (~1));
40698         orig_conv.is_owned = false;
40699         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40700         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
40701         uint32_t ret_ref = 0;
40702         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40703         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40704         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40705         ret_ref = (uintptr_t)ret_var.inner;
40706         if (ret_var.is_owned) {
40707                 ret_ref |= 1;
40708         }
40709         return ret_ref;
40710 }
40711
40712 int64_t  __attribute__((export_name("TS_MinFinalCltvExpiry_hash"))) TS_MinFinalCltvExpiry_hash(uint32_t o) {
40713         LDKMinFinalCltvExpiry o_conv;
40714         o_conv.inner = (void*)(o & (~1));
40715         o_conv.is_owned = false;
40716         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40717         int64_t ret_conv = MinFinalCltvExpiry_hash(&o_conv);
40718         return ret_conv;
40719 }
40720
40721 jboolean  __attribute__((export_name("TS_MinFinalCltvExpiry_eq"))) TS_MinFinalCltvExpiry_eq(uint32_t a, uint32_t b) {
40722         LDKMinFinalCltvExpiry a_conv;
40723         a_conv.inner = (void*)(a & (~1));
40724         a_conv.is_owned = false;
40725         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40726         LDKMinFinalCltvExpiry b_conv;
40727         b_conv.inner = (void*)(b & (~1));
40728         b_conv.is_owned = false;
40729         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40730         jboolean ret_conv = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
40731         return ret_conv;
40732 }
40733
40734 void  __attribute__((export_name("TS_Fallback_free"))) TS_Fallback_free(uint32_t this_ptr) {
40735         if ((this_ptr & 1) != 0) return;
40736         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
40737         CHECK_ACCESS(this_ptr_ptr);
40738         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
40739         FREE((void*)this_ptr);
40740         Fallback_free(this_ptr_conv);
40741 }
40742
40743 static inline uintptr_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
40744         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
40745         *ret_copy = Fallback_clone(arg);
40746 uint32_t ret_ref = (uintptr_t)ret_copy;
40747         return ret_ref;
40748 }
40749 uint32_t  __attribute__((export_name("TS_Fallback_clone_ptr"))) TS_Fallback_clone_ptr(uint32_t arg) {
40750         LDKFallback* arg_conv = (LDKFallback*)arg;
40751         uint32_t ret_conv = Fallback_clone_ptr(arg_conv);
40752         return ret_conv;
40753 }
40754
40755 uint32_t  __attribute__((export_name("TS_Fallback_clone"))) TS_Fallback_clone(uint32_t orig) {
40756         LDKFallback* orig_conv = (LDKFallback*)orig;
40757         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
40758         *ret_copy = Fallback_clone(orig_conv);
40759         uint32_t ret_ref = (uintptr_t)ret_copy;
40760         return ret_ref;
40761 }
40762
40763 uint32_t  __attribute__((export_name("TS_Fallback_seg_wit_program"))) TS_Fallback_seg_wit_program(int8_t version, int8_tArray program) {
40764         
40765         LDKCVec_u8Z program_ref;
40766         program_ref.datalen = program->arr_len;
40767         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
40768         memcpy(program_ref.data, program->elems, program_ref.datalen); FREE(program);
40769         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
40770         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
40771         uint32_t ret_ref = (uintptr_t)ret_copy;
40772         return ret_ref;
40773 }
40774
40775 uint32_t  __attribute__((export_name("TS_Fallback_pub_key_hash"))) TS_Fallback_pub_key_hash(int8_tArray a) {
40776         LDKTwentyBytes a_ref;
40777         CHECK(a->arr_len == 20);
40778         memcpy(a_ref.data, a->elems, 20); FREE(a);
40779         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
40780         *ret_copy = Fallback_pub_key_hash(a_ref);
40781         uint32_t ret_ref = (uintptr_t)ret_copy;
40782         return ret_ref;
40783 }
40784
40785 uint32_t  __attribute__((export_name("TS_Fallback_script_hash"))) TS_Fallback_script_hash(int8_tArray a) {
40786         LDKTwentyBytes a_ref;
40787         CHECK(a->arr_len == 20);
40788         memcpy(a_ref.data, a->elems, 20); FREE(a);
40789         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
40790         *ret_copy = Fallback_script_hash(a_ref);
40791         uint32_t ret_ref = (uintptr_t)ret_copy;
40792         return ret_ref;
40793 }
40794
40795 int64_t  __attribute__((export_name("TS_Fallback_hash"))) TS_Fallback_hash(uint32_t o) {
40796         LDKFallback* o_conv = (LDKFallback*)o;
40797         int64_t ret_conv = Fallback_hash(o_conv);
40798         return ret_conv;
40799 }
40800
40801 jboolean  __attribute__((export_name("TS_Fallback_eq"))) TS_Fallback_eq(uint32_t a, uint32_t b) {
40802         LDKFallback* a_conv = (LDKFallback*)a;
40803         LDKFallback* b_conv = (LDKFallback*)b;
40804         jboolean ret_conv = Fallback_eq(a_conv, b_conv);
40805         return ret_conv;
40806 }
40807
40808 void  __attribute__((export_name("TS_InvoiceSignature_free"))) TS_InvoiceSignature_free(uint32_t this_obj) {
40809         LDKInvoiceSignature this_obj_conv;
40810         this_obj_conv.inner = (void*)(this_obj & (~1));
40811         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40813         InvoiceSignature_free(this_obj_conv);
40814 }
40815
40816 static inline uintptr_t InvoiceSignature_clone_ptr(LDKInvoiceSignature *NONNULL_PTR arg) {
40817         LDKInvoiceSignature ret_var = InvoiceSignature_clone(arg);
40818 uint32_t ret_ref = 0;
40819 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40820 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40821 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40822 ret_ref = (uintptr_t)ret_var.inner;
40823 if (ret_var.is_owned) {
40824         ret_ref |= 1;
40825 }
40826         return ret_ref;
40827 }
40828 uint32_t  __attribute__((export_name("TS_InvoiceSignature_clone_ptr"))) TS_InvoiceSignature_clone_ptr(uint32_t arg) {
40829         LDKInvoiceSignature arg_conv;
40830         arg_conv.inner = (void*)(arg & (~1));
40831         arg_conv.is_owned = false;
40832         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40833         uint32_t ret_conv = InvoiceSignature_clone_ptr(&arg_conv);
40834         return ret_conv;
40835 }
40836
40837 uint32_t  __attribute__((export_name("TS_InvoiceSignature_clone"))) TS_InvoiceSignature_clone(uint32_t orig) {
40838         LDKInvoiceSignature orig_conv;
40839         orig_conv.inner = (void*)(orig & (~1));
40840         orig_conv.is_owned = false;
40841         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40842         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_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 jboolean  __attribute__((export_name("TS_InvoiceSignature_eq"))) TS_InvoiceSignature_eq(uint32_t a, uint32_t b) {
40855         LDKInvoiceSignature a_conv;
40856         a_conv.inner = (void*)(a & (~1));
40857         a_conv.is_owned = false;
40858         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40859         LDKInvoiceSignature b_conv;
40860         b_conv.inner = (void*)(b & (~1));
40861         b_conv.is_owned = false;
40862         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40863         jboolean ret_conv = InvoiceSignature_eq(&a_conv, &b_conv);
40864         return ret_conv;
40865 }
40866
40867 void  __attribute__((export_name("TS_PrivateRoute_free"))) TS_PrivateRoute_free(uint32_t this_obj) {
40868         LDKPrivateRoute this_obj_conv;
40869         this_obj_conv.inner = (void*)(this_obj & (~1));
40870         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40872         PrivateRoute_free(this_obj_conv);
40873 }
40874
40875 static inline uintptr_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
40876         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
40877 uint32_t ret_ref = 0;
40878 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40879 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40880 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40881 ret_ref = (uintptr_t)ret_var.inner;
40882 if (ret_var.is_owned) {
40883         ret_ref |= 1;
40884 }
40885         return ret_ref;
40886 }
40887 uint32_t  __attribute__((export_name("TS_PrivateRoute_clone_ptr"))) TS_PrivateRoute_clone_ptr(uint32_t arg) {
40888         LDKPrivateRoute arg_conv;
40889         arg_conv.inner = (void*)(arg & (~1));
40890         arg_conv.is_owned = false;
40891         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40892         uint32_t ret_conv = PrivateRoute_clone_ptr(&arg_conv);
40893         return ret_conv;
40894 }
40895
40896 uint32_t  __attribute__((export_name("TS_PrivateRoute_clone"))) TS_PrivateRoute_clone(uint32_t orig) {
40897         LDKPrivateRoute orig_conv;
40898         orig_conv.inner = (void*)(orig & (~1));
40899         orig_conv.is_owned = false;
40900         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40901         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
40902         uint32_t ret_ref = 0;
40903         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40904         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40905         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40906         ret_ref = (uintptr_t)ret_var.inner;
40907         if (ret_var.is_owned) {
40908                 ret_ref |= 1;
40909         }
40910         return ret_ref;
40911 }
40912
40913 int64_t  __attribute__((export_name("TS_PrivateRoute_hash"))) TS_PrivateRoute_hash(uint32_t o) {
40914         LDKPrivateRoute o_conv;
40915         o_conv.inner = (void*)(o & (~1));
40916         o_conv.is_owned = false;
40917         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40918         int64_t ret_conv = PrivateRoute_hash(&o_conv);
40919         return ret_conv;
40920 }
40921
40922 jboolean  __attribute__((export_name("TS_PrivateRoute_eq"))) TS_PrivateRoute_eq(uint32_t a, uint32_t b) {
40923         LDKPrivateRoute a_conv;
40924         a_conv.inner = (void*)(a & (~1));
40925         a_conv.is_owned = false;
40926         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40927         LDKPrivateRoute b_conv;
40928         b_conv.inner = (void*)(b & (~1));
40929         b_conv.is_owned = false;
40930         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40931         jboolean ret_conv = PrivateRoute_eq(&a_conv, &b_conv);
40932         return ret_conv;
40933 }
40934
40935 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_into_parts"))) TS_SignedRawInvoice_into_parts(uint32_t this_arg) {
40936         LDKSignedRawInvoice this_arg_conv;
40937         this_arg_conv.inner = (void*)(this_arg & (~1));
40938         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
40939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40940         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
40941         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
40942         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
40943         return ((uint32_t)ret_conv);
40944 }
40945
40946 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_raw_invoice"))) TS_SignedRawInvoice_raw_invoice(uint32_t this_arg) {
40947         LDKSignedRawInvoice this_arg_conv;
40948         this_arg_conv.inner = (void*)(this_arg & (~1));
40949         this_arg_conv.is_owned = false;
40950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40951         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
40952         uint32_t ret_ref = 0;
40953         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40954         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40955         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40956         ret_ref = (uintptr_t)ret_var.inner;
40957         if (ret_var.is_owned) {
40958                 ret_ref |= 1;
40959         }
40960         return ret_ref;
40961 }
40962
40963 int8_tArray  __attribute__((export_name("TS_SignedRawInvoice_hash"))) TS_SignedRawInvoice_hash(uint32_t this_arg) {
40964         LDKSignedRawInvoice this_arg_conv;
40965         this_arg_conv.inner = (void*)(this_arg & (~1));
40966         this_arg_conv.is_owned = false;
40967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40968         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
40969         memcpy(ret_arr->elems, *SignedRawInvoice_hash(&this_arg_conv), 32);
40970         return ret_arr;
40971 }
40972
40973 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_signature"))) TS_SignedRawInvoice_signature(uint32_t this_arg) {
40974         LDKSignedRawInvoice this_arg_conv;
40975         this_arg_conv.inner = (void*)(this_arg & (~1));
40976         this_arg_conv.is_owned = false;
40977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40978         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
40979         uint32_t ret_ref = 0;
40980         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40981         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40982         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40983         ret_ref = (uintptr_t)ret_var.inner;
40984         if (ret_var.is_owned) {
40985                 ret_ref |= 1;
40986         }
40987         return ret_ref;
40988 }
40989
40990 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_recover_payee_pub_key"))) TS_SignedRawInvoice_recover_payee_pub_key(uint32_t this_arg) {
40991         LDKSignedRawInvoice this_arg_conv;
40992         this_arg_conv.inner = (void*)(this_arg & (~1));
40993         this_arg_conv.is_owned = false;
40994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40995         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
40996         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
40997         return (uint32_t)ret_conv;
40998 }
40999
41000 jboolean  __attribute__((export_name("TS_SignedRawInvoice_check_signature"))) TS_SignedRawInvoice_check_signature(uint32_t this_arg) {
41001         LDKSignedRawInvoice this_arg_conv;
41002         this_arg_conv.inner = (void*)(this_arg & (~1));
41003         this_arg_conv.is_owned = false;
41004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41005         jboolean ret_conv = SignedRawInvoice_check_signature(&this_arg_conv);
41006         return ret_conv;
41007 }
41008
41009 int8_tArray  __attribute__((export_name("TS_RawInvoice_hash"))) TS_RawInvoice_hash(uint32_t this_arg) {
41010         LDKRawInvoice this_arg_conv;
41011         this_arg_conv.inner = (void*)(this_arg & (~1));
41012         this_arg_conv.is_owned = false;
41013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41014         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
41015         memcpy(ret_arr->elems, RawInvoice_hash(&this_arg_conv).data, 32);
41016         return ret_arr;
41017 }
41018
41019 uint32_t  __attribute__((export_name("TS_RawInvoice_payment_hash"))) TS_RawInvoice_payment_hash(uint32_t this_arg) {
41020         LDKRawInvoice this_arg_conv;
41021         this_arg_conv.inner = (void*)(this_arg & (~1));
41022         this_arg_conv.is_owned = false;
41023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41024         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
41025         uint32_t ret_ref = 0;
41026         if ((uintptr_t)ret_var.inner > 4096) {
41027                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41028                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41029         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41030                 ret_ref = (uintptr_t)ret_var.inner;
41031                 if (ret_var.is_owned) {
41032                         ret_ref |= 1;
41033                 }
41034         }
41035         return ret_ref;
41036 }
41037
41038 uint32_t  __attribute__((export_name("TS_RawInvoice_description"))) TS_RawInvoice_description(uint32_t this_arg) {
41039         LDKRawInvoice this_arg_conv;
41040         this_arg_conv.inner = (void*)(this_arg & (~1));
41041         this_arg_conv.is_owned = false;
41042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41043         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
41044         uint32_t ret_ref = 0;
41045         if ((uintptr_t)ret_var.inner > 4096) {
41046                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41047                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41048         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41049                 ret_ref = (uintptr_t)ret_var.inner;
41050                 if (ret_var.is_owned) {
41051                         ret_ref |= 1;
41052                 }
41053         }
41054         return ret_ref;
41055 }
41056
41057 uint32_t  __attribute__((export_name("TS_RawInvoice_payee_pub_key"))) TS_RawInvoice_payee_pub_key(uint32_t this_arg) {
41058         LDKRawInvoice this_arg_conv;
41059         this_arg_conv.inner = (void*)(this_arg & (~1));
41060         this_arg_conv.is_owned = false;
41061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41062         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
41063         uint32_t ret_ref = 0;
41064         if ((uintptr_t)ret_var.inner > 4096) {
41065                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41066                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41067         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41068                 ret_ref = (uintptr_t)ret_var.inner;
41069                 if (ret_var.is_owned) {
41070                         ret_ref |= 1;
41071                 }
41072         }
41073         return ret_ref;
41074 }
41075
41076 uint32_t  __attribute__((export_name("TS_RawInvoice_description_hash"))) TS_RawInvoice_description_hash(uint32_t this_arg) {
41077         LDKRawInvoice this_arg_conv;
41078         this_arg_conv.inner = (void*)(this_arg & (~1));
41079         this_arg_conv.is_owned = false;
41080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41081         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
41082         uint32_t ret_ref = 0;
41083         if ((uintptr_t)ret_var.inner > 4096) {
41084                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41085                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41086         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41087                 ret_ref = (uintptr_t)ret_var.inner;
41088                 if (ret_var.is_owned) {
41089                         ret_ref |= 1;
41090                 }
41091         }
41092         return ret_ref;
41093 }
41094
41095 uint32_t  __attribute__((export_name("TS_RawInvoice_expiry_time"))) TS_RawInvoice_expiry_time(uint32_t this_arg) {
41096         LDKRawInvoice this_arg_conv;
41097         this_arg_conv.inner = (void*)(this_arg & (~1));
41098         this_arg_conv.is_owned = false;
41099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41100         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
41101         uint32_t ret_ref = 0;
41102         if ((uintptr_t)ret_var.inner > 4096) {
41103                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41104                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41105         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41106                 ret_ref = (uintptr_t)ret_var.inner;
41107                 if (ret_var.is_owned) {
41108                         ret_ref |= 1;
41109                 }
41110         }
41111         return ret_ref;
41112 }
41113
41114 uint32_t  __attribute__((export_name("TS_RawInvoice_min_final_cltv_expiry"))) TS_RawInvoice_min_final_cltv_expiry(uint32_t this_arg) {
41115         LDKRawInvoice this_arg_conv;
41116         this_arg_conv.inner = (void*)(this_arg & (~1));
41117         this_arg_conv.is_owned = false;
41118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41119         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
41120         uint32_t ret_ref = 0;
41121         if ((uintptr_t)ret_var.inner > 4096) {
41122                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41123                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41124         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41125                 ret_ref = (uintptr_t)ret_var.inner;
41126                 if (ret_var.is_owned) {
41127                         ret_ref |= 1;
41128                 }
41129         }
41130         return ret_ref;
41131 }
41132
41133 int8_tArray  __attribute__((export_name("TS_RawInvoice_payment_secret"))) TS_RawInvoice_payment_secret(uint32_t this_arg) {
41134         LDKRawInvoice this_arg_conv;
41135         this_arg_conv.inner = (void*)(this_arg & (~1));
41136         this_arg_conv.is_owned = false;
41137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41138         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
41139         memcpy(ret_arr->elems, RawInvoice_payment_secret(&this_arg_conv).data, 32);
41140         return ret_arr;
41141 }
41142
41143 uint32_t  __attribute__((export_name("TS_RawInvoice_features"))) TS_RawInvoice_features(uint32_t this_arg) {
41144         LDKRawInvoice this_arg_conv;
41145         this_arg_conv.inner = (void*)(this_arg & (~1));
41146         this_arg_conv.is_owned = false;
41147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41148         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
41149         uint32_t ret_ref = 0;
41150         if ((uintptr_t)ret_var.inner > 4096) {
41151                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41152                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41153         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41154                 ret_ref = (uintptr_t)ret_var.inner;
41155                 if (ret_var.is_owned) {
41156                         ret_ref |= 1;
41157                 }
41158         }
41159         return ret_ref;
41160 }
41161
41162 uint32_tArray  __attribute__((export_name("TS_RawInvoice_private_routes"))) TS_RawInvoice_private_routes(uint32_t this_arg) {
41163         LDKRawInvoice this_arg_conv;
41164         this_arg_conv.inner = (void*)(this_arg & (~1));
41165         this_arg_conv.is_owned = false;
41166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41167         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
41168         uint32_tArray ret_arr = NULL;
41169         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
41170         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
41171         for (size_t o = 0; o < ret_var.datalen; o++) {
41172                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
41173                 uint32_t ret_conv_14_ref = 0;
41174                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41175                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41176                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
41177                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
41178                 if (ret_conv_14_var.is_owned) {
41179                         ret_conv_14_ref |= 1;
41180                 }
41181                 ret_arr_ptr[o] = ret_conv_14_ref;
41182         }
41183         
41184         FREE(ret_var.data);
41185         return ret_arr;
41186 }
41187
41188 uint32_t  __attribute__((export_name("TS_RawInvoice_amount_pico_btc"))) TS_RawInvoice_amount_pico_btc(uint32_t this_arg) {
41189         LDKRawInvoice this_arg_conv;
41190         this_arg_conv.inner = (void*)(this_arg & (~1));
41191         this_arg_conv.is_owned = false;
41192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41193         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
41194         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
41195         uint32_t ret_ref = (uintptr_t)ret_copy;
41196         return ret_ref;
41197 }
41198
41199 uint32_t  __attribute__((export_name("TS_RawInvoice_currency"))) TS_RawInvoice_currency(uint32_t this_arg) {
41200         LDKRawInvoice this_arg_conv;
41201         this_arg_conv.inner = (void*)(this_arg & (~1));
41202         this_arg_conv.is_owned = false;
41203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41204         uint32_t ret_conv = LDKCurrency_to_js(RawInvoice_currency(&this_arg_conv));
41205         return ret_conv;
41206 }
41207
41208 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_from_unix_timestamp"))) TS_PositiveTimestamp_from_unix_timestamp(int64_t unix_seconds) {
41209         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
41210         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
41211         return (uint32_t)ret_conv;
41212 }
41213
41214 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_from_duration_since_epoch"))) TS_PositiveTimestamp_from_duration_since_epoch(int64_t duration) {
41215         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
41216         *ret_conv = PositiveTimestamp_from_duration_since_epoch(duration);
41217         return (uint32_t)ret_conv;
41218 }
41219
41220 int64_t  __attribute__((export_name("TS_PositiveTimestamp_as_unix_timestamp"))) TS_PositiveTimestamp_as_unix_timestamp(uint32_t this_arg) {
41221         LDKPositiveTimestamp this_arg_conv;
41222         this_arg_conv.inner = (void*)(this_arg & (~1));
41223         this_arg_conv.is_owned = false;
41224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41225         int64_t ret_conv = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
41226         return ret_conv;
41227 }
41228
41229 int64_t  __attribute__((export_name("TS_PositiveTimestamp_as_duration_since_epoch"))) TS_PositiveTimestamp_as_duration_since_epoch(uint32_t this_arg) {
41230         LDKPositiveTimestamp this_arg_conv;
41231         this_arg_conv.inner = (void*)(this_arg & (~1));
41232         this_arg_conv.is_owned = false;
41233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41234         int64_t ret_conv = PositiveTimestamp_as_duration_since_epoch(&this_arg_conv);
41235         return ret_conv;
41236 }
41237
41238 uint32_t  __attribute__((export_name("TS_Invoice_into_signed_raw"))) TS_Invoice_into_signed_raw(uint32_t this_arg) {
41239         LDKInvoice this_arg_conv;
41240         this_arg_conv.inner = (void*)(this_arg & (~1));
41241         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
41242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41243         this_arg_conv = Invoice_clone(&this_arg_conv);
41244         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
41245         uint32_t ret_ref = 0;
41246         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41247         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41248         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41249         ret_ref = (uintptr_t)ret_var.inner;
41250         if (ret_var.is_owned) {
41251                 ret_ref |= 1;
41252         }
41253         return ret_ref;
41254 }
41255
41256 uint32_t  __attribute__((export_name("TS_Invoice_check_signature"))) TS_Invoice_check_signature(uint32_t this_arg) {
41257         LDKInvoice this_arg_conv;
41258         this_arg_conv.inner = (void*)(this_arg & (~1));
41259         this_arg_conv.is_owned = false;
41260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41261         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
41262         *ret_conv = Invoice_check_signature(&this_arg_conv);
41263         return (uint32_t)ret_conv;
41264 }
41265
41266 uint32_t  __attribute__((export_name("TS_Invoice_from_signed"))) TS_Invoice_from_signed(uint32_t signed_invoice) {
41267         LDKSignedRawInvoice signed_invoice_conv;
41268         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
41269         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
41270         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
41271         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
41272         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
41273         *ret_conv = Invoice_from_signed(signed_invoice_conv);
41274         return (uint32_t)ret_conv;
41275 }
41276
41277 int64_t  __attribute__((export_name("TS_Invoice_duration_since_epoch"))) TS_Invoice_duration_since_epoch(uint32_t this_arg) {
41278         LDKInvoice this_arg_conv;
41279         this_arg_conv.inner = (void*)(this_arg & (~1));
41280         this_arg_conv.is_owned = false;
41281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41282         int64_t ret_conv = Invoice_duration_since_epoch(&this_arg_conv);
41283         return ret_conv;
41284 }
41285
41286 int8_tArray  __attribute__((export_name("TS_Invoice_payment_hash"))) TS_Invoice_payment_hash(uint32_t this_arg) {
41287         LDKInvoice this_arg_conv;
41288         this_arg_conv.inner = (void*)(this_arg & (~1));
41289         this_arg_conv.is_owned = false;
41290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41291         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
41292         memcpy(ret_arr->elems, *Invoice_payment_hash(&this_arg_conv), 32);
41293         return ret_arr;
41294 }
41295
41296 int8_tArray  __attribute__((export_name("TS_Invoice_payee_pub_key"))) TS_Invoice_payee_pub_key(uint32_t this_arg) {
41297         LDKInvoice this_arg_conv;
41298         this_arg_conv.inner = (void*)(this_arg & (~1));
41299         this_arg_conv.is_owned = false;
41300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41301         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
41302         memcpy(ret_arr->elems, Invoice_payee_pub_key(&this_arg_conv).compressed_form, 33);
41303         return ret_arr;
41304 }
41305
41306 int8_tArray  __attribute__((export_name("TS_Invoice_payment_secret"))) TS_Invoice_payment_secret(uint32_t this_arg) {
41307         LDKInvoice this_arg_conv;
41308         this_arg_conv.inner = (void*)(this_arg & (~1));
41309         this_arg_conv.is_owned = false;
41310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41311         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
41312         memcpy(ret_arr->elems, *Invoice_payment_secret(&this_arg_conv), 32);
41313         return ret_arr;
41314 }
41315
41316 uint32_t  __attribute__((export_name("TS_Invoice_features"))) TS_Invoice_features(uint32_t this_arg) {
41317         LDKInvoice this_arg_conv;
41318         this_arg_conv.inner = (void*)(this_arg & (~1));
41319         this_arg_conv.is_owned = false;
41320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41321         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
41322         uint32_t ret_ref = 0;
41323         if ((uintptr_t)ret_var.inner > 4096) {
41324                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41325                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41326         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41327                 ret_ref = (uintptr_t)ret_var.inner;
41328                 if (ret_var.is_owned) {
41329                         ret_ref |= 1;
41330                 }
41331         }
41332         return ret_ref;
41333 }
41334
41335 int8_tArray  __attribute__((export_name("TS_Invoice_recover_payee_pub_key"))) TS_Invoice_recover_payee_pub_key(uint32_t this_arg) {
41336         LDKInvoice this_arg_conv;
41337         this_arg_conv.inner = (void*)(this_arg & (~1));
41338         this_arg_conv.is_owned = false;
41339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41340         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
41341         memcpy(ret_arr->elems, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form, 33);
41342         return ret_arr;
41343 }
41344
41345 int64_t  __attribute__((export_name("TS_Invoice_expiry_time"))) TS_Invoice_expiry_time(uint32_t this_arg) {
41346         LDKInvoice this_arg_conv;
41347         this_arg_conv.inner = (void*)(this_arg & (~1));
41348         this_arg_conv.is_owned = false;
41349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41350         int64_t ret_conv = Invoice_expiry_time(&this_arg_conv);
41351         return ret_conv;
41352 }
41353
41354 jboolean  __attribute__((export_name("TS_Invoice_would_expire"))) TS_Invoice_would_expire(uint32_t this_arg, int64_t at_time) {
41355         LDKInvoice this_arg_conv;
41356         this_arg_conv.inner = (void*)(this_arg & (~1));
41357         this_arg_conv.is_owned = false;
41358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41359         jboolean ret_conv = Invoice_would_expire(&this_arg_conv, at_time);
41360         return ret_conv;
41361 }
41362
41363 int64_t  __attribute__((export_name("TS_Invoice_min_final_cltv_expiry"))) TS_Invoice_min_final_cltv_expiry(uint32_t this_arg) {
41364         LDKInvoice this_arg_conv;
41365         this_arg_conv.inner = (void*)(this_arg & (~1));
41366         this_arg_conv.is_owned = false;
41367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41368         int64_t ret_conv = Invoice_min_final_cltv_expiry(&this_arg_conv);
41369         return ret_conv;
41370 }
41371
41372 uint32_tArray  __attribute__((export_name("TS_Invoice_private_routes"))) TS_Invoice_private_routes(uint32_t this_arg) {
41373         LDKInvoice this_arg_conv;
41374         this_arg_conv.inner = (void*)(this_arg & (~1));
41375         this_arg_conv.is_owned = false;
41376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41377         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
41378         uint32_tArray ret_arr = NULL;
41379         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
41380         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
41381         for (size_t o = 0; o < ret_var.datalen; o++) {
41382                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
41383                 uint32_t ret_conv_14_ref = 0;
41384                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41385                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41386                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
41387                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
41388                 if (ret_conv_14_var.is_owned) {
41389                         ret_conv_14_ref |= 1;
41390                 }
41391                 ret_arr_ptr[o] = ret_conv_14_ref;
41392         }
41393         
41394         FREE(ret_var.data);
41395         return ret_arr;
41396 }
41397
41398 uint32_tArray  __attribute__((export_name("TS_Invoice_route_hints"))) TS_Invoice_route_hints(uint32_t this_arg) {
41399         LDKInvoice this_arg_conv;
41400         this_arg_conv.inner = (void*)(this_arg & (~1));
41401         this_arg_conv.is_owned = false;
41402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41403         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
41404         uint32_tArray ret_arr = NULL;
41405         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
41406         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
41407         for (size_t l = 0; l < ret_var.datalen; l++) {
41408                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
41409                 uint32_t ret_conv_11_ref = 0;
41410                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41411                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41412                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
41413                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
41414                 if (ret_conv_11_var.is_owned) {
41415                         ret_conv_11_ref |= 1;
41416                 }
41417                 ret_arr_ptr[l] = ret_conv_11_ref;
41418         }
41419         
41420         FREE(ret_var.data);
41421         return ret_arr;
41422 }
41423
41424 uint32_t  __attribute__((export_name("TS_Invoice_currency"))) TS_Invoice_currency(uint32_t this_arg) {
41425         LDKInvoice this_arg_conv;
41426         this_arg_conv.inner = (void*)(this_arg & (~1));
41427         this_arg_conv.is_owned = false;
41428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41429         uint32_t ret_conv = LDKCurrency_to_js(Invoice_currency(&this_arg_conv));
41430         return ret_conv;
41431 }
41432
41433 uint32_t  __attribute__((export_name("TS_Invoice_amount_milli_satoshis"))) TS_Invoice_amount_milli_satoshis(uint32_t this_arg) {
41434         LDKInvoice this_arg_conv;
41435         this_arg_conv.inner = (void*)(this_arg & (~1));
41436         this_arg_conv.is_owned = false;
41437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41438         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
41439         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
41440         uint32_t ret_ref = (uintptr_t)ret_copy;
41441         return ret_ref;
41442 }
41443
41444 uint32_t  __attribute__((export_name("TS_Description_new"))) TS_Description_new(jstring description) {
41445         LDKStr description_conv = str_ref_to_owned_c(description);
41446         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
41447         *ret_conv = Description_new(description_conv);
41448         return (uint32_t)ret_conv;
41449 }
41450
41451 jstring  __attribute__((export_name("TS_Description_into_inner"))) TS_Description_into_inner(uint32_t this_arg) {
41452         LDKDescription this_arg_conv;
41453         this_arg_conv.inner = (void*)(this_arg & (~1));
41454         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
41455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41456         this_arg_conv = Description_clone(&this_arg_conv);
41457         LDKStr ret_str = Description_into_inner(this_arg_conv);
41458         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
41459         Str_free(ret_str);
41460         return ret_conv;
41461 }
41462
41463 uint32_t  __attribute__((export_name("TS_ExpiryTime_from_seconds"))) TS_ExpiryTime_from_seconds(int64_t seconds) {
41464         LDKExpiryTime ret_var = ExpiryTime_from_seconds(seconds);
41465         uint32_t ret_ref = 0;
41466         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41467         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41468         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41469         ret_ref = (uintptr_t)ret_var.inner;
41470         if (ret_var.is_owned) {
41471                 ret_ref |= 1;
41472         }
41473         return ret_ref;
41474 }
41475
41476 uint32_t  __attribute__((export_name("TS_ExpiryTime_from_duration"))) TS_ExpiryTime_from_duration(int64_t duration) {
41477         LDKExpiryTime ret_var = ExpiryTime_from_duration(duration);
41478         uint32_t ret_ref = 0;
41479         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41480         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41481         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41482         ret_ref = (uintptr_t)ret_var.inner;
41483         if (ret_var.is_owned) {
41484                 ret_ref |= 1;
41485         }
41486         return ret_ref;
41487 }
41488
41489 int64_t  __attribute__((export_name("TS_ExpiryTime_as_seconds"))) TS_ExpiryTime_as_seconds(uint32_t this_arg) {
41490         LDKExpiryTime this_arg_conv;
41491         this_arg_conv.inner = (void*)(this_arg & (~1));
41492         this_arg_conv.is_owned = false;
41493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41494         int64_t ret_conv = ExpiryTime_as_seconds(&this_arg_conv);
41495         return ret_conv;
41496 }
41497
41498 int64_t  __attribute__((export_name("TS_ExpiryTime_as_duration"))) TS_ExpiryTime_as_duration(uint32_t this_arg) {
41499         LDKExpiryTime this_arg_conv;
41500         this_arg_conv.inner = (void*)(this_arg & (~1));
41501         this_arg_conv.is_owned = false;
41502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41503         int64_t ret_conv = ExpiryTime_as_duration(&this_arg_conv);
41504         return ret_conv;
41505 }
41506
41507 uint32_t  __attribute__((export_name("TS_PrivateRoute_new"))) TS_PrivateRoute_new(uint32_t hops) {
41508         LDKRouteHint hops_conv;
41509         hops_conv.inner = (void*)(hops & (~1));
41510         hops_conv.is_owned = (hops & 1) || (hops == 0);
41511         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
41512         hops_conv = RouteHint_clone(&hops_conv);
41513         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
41514         *ret_conv = PrivateRoute_new(hops_conv);
41515         return (uint32_t)ret_conv;
41516 }
41517
41518 uint32_t  __attribute__((export_name("TS_PrivateRoute_into_inner"))) TS_PrivateRoute_into_inner(uint32_t this_arg) {
41519         LDKPrivateRoute this_arg_conv;
41520         this_arg_conv.inner = (void*)(this_arg & (~1));
41521         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
41522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41523         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
41524         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_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_CreationError_clone"))) TS_CreationError_clone(uint32_t orig) {
41537         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
41538         uint32_t ret_conv = LDKCreationError_to_js(CreationError_clone(orig_conv));
41539         return ret_conv;
41540 }
41541
41542 uint32_t  __attribute__((export_name("TS_CreationError_description_too_long"))) TS_CreationError_description_too_long() {
41543         uint32_t ret_conv = LDKCreationError_to_js(CreationError_description_too_long());
41544         return ret_conv;
41545 }
41546
41547 uint32_t  __attribute__((export_name("TS_CreationError_route_too_long"))) TS_CreationError_route_too_long() {
41548         uint32_t ret_conv = LDKCreationError_to_js(CreationError_route_too_long());
41549         return ret_conv;
41550 }
41551
41552 uint32_t  __attribute__((export_name("TS_CreationError_timestamp_out_of_bounds"))) TS_CreationError_timestamp_out_of_bounds() {
41553         uint32_t ret_conv = LDKCreationError_to_js(CreationError_timestamp_out_of_bounds());
41554         return ret_conv;
41555 }
41556
41557 uint32_t  __attribute__((export_name("TS_CreationError_invalid_amount"))) TS_CreationError_invalid_amount() {
41558         uint32_t ret_conv = LDKCreationError_to_js(CreationError_invalid_amount());
41559         return ret_conv;
41560 }
41561
41562 uint32_t  __attribute__((export_name("TS_CreationError_missing_route_hints"))) TS_CreationError_missing_route_hints() {
41563         uint32_t ret_conv = LDKCreationError_to_js(CreationError_missing_route_hints());
41564         return ret_conv;
41565 }
41566
41567 jboolean  __attribute__((export_name("TS_CreationError_eq"))) TS_CreationError_eq(uint32_t a, uint32_t b) {
41568         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
41569         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
41570         jboolean ret_conv = CreationError_eq(a_conv, b_conv);
41571         return ret_conv;
41572 }
41573
41574 jstring  __attribute__((export_name("TS_CreationError_to_str"))) TS_CreationError_to_str(uint32_t o) {
41575         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
41576         LDKStr ret_str = CreationError_to_str(o_conv);
41577         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
41578         Str_free(ret_str);
41579         return ret_conv;
41580 }
41581
41582 uint32_t  __attribute__((export_name("TS_SemanticError_clone"))) TS_SemanticError_clone(uint32_t orig) {
41583         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
41584         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_clone(orig_conv));
41585         return ret_conv;
41586 }
41587
41588 uint32_t  __attribute__((export_name("TS_SemanticError_no_payment_hash"))) TS_SemanticError_no_payment_hash() {
41589         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_payment_hash());
41590         return ret_conv;
41591 }
41592
41593 uint32_t  __attribute__((export_name("TS_SemanticError_multiple_payment_hashes"))) TS_SemanticError_multiple_payment_hashes() {
41594         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_hashes());
41595         return ret_conv;
41596 }
41597
41598 uint32_t  __attribute__((export_name("TS_SemanticError_no_description"))) TS_SemanticError_no_description() {
41599         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_description());
41600         return ret_conv;
41601 }
41602
41603 uint32_t  __attribute__((export_name("TS_SemanticError_multiple_descriptions"))) TS_SemanticError_multiple_descriptions() {
41604         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_descriptions());
41605         return ret_conv;
41606 }
41607
41608 uint32_t  __attribute__((export_name("TS_SemanticError_no_payment_secret"))) TS_SemanticError_no_payment_secret() {
41609         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_payment_secret());
41610         return ret_conv;
41611 }
41612
41613 uint32_t  __attribute__((export_name("TS_SemanticError_multiple_payment_secrets"))) TS_SemanticError_multiple_payment_secrets() {
41614         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_secrets());
41615         return ret_conv;
41616 }
41617
41618 uint32_t  __attribute__((export_name("TS_SemanticError_invalid_features"))) TS_SemanticError_invalid_features() {
41619         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_features());
41620         return ret_conv;
41621 }
41622
41623 uint32_t  __attribute__((export_name("TS_SemanticError_invalid_recovery_id"))) TS_SemanticError_invalid_recovery_id() {
41624         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_recovery_id());
41625         return ret_conv;
41626 }
41627
41628 uint32_t  __attribute__((export_name("TS_SemanticError_invalid_signature"))) TS_SemanticError_invalid_signature() {
41629         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_signature());
41630         return ret_conv;
41631 }
41632
41633 uint32_t  __attribute__((export_name("TS_SemanticError_imprecise_amount"))) TS_SemanticError_imprecise_amount() {
41634         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_imprecise_amount());
41635         return ret_conv;
41636 }
41637
41638 jboolean  __attribute__((export_name("TS_SemanticError_eq"))) TS_SemanticError_eq(uint32_t a, uint32_t b) {
41639         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
41640         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
41641         jboolean ret_conv = SemanticError_eq(a_conv, b_conv);
41642         return ret_conv;
41643 }
41644
41645 jstring  __attribute__((export_name("TS_SemanticError_to_str"))) TS_SemanticError_to_str(uint32_t o) {
41646         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
41647         LDKStr ret_str = SemanticError_to_str(o_conv);
41648         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
41649         Str_free(ret_str);
41650         return ret_conv;
41651 }
41652
41653 void  __attribute__((export_name("TS_SignOrCreationError_free"))) TS_SignOrCreationError_free(uint32_t this_ptr) {
41654         if ((this_ptr & 1) != 0) return;
41655         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
41656         CHECK_ACCESS(this_ptr_ptr);
41657         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
41658         FREE((void*)this_ptr);
41659         SignOrCreationError_free(this_ptr_conv);
41660 }
41661
41662 static inline uintptr_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
41663         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
41664         *ret_copy = SignOrCreationError_clone(arg);
41665 uint32_t ret_ref = (uintptr_t)ret_copy;
41666         return ret_ref;
41667 }
41668 uint32_t  __attribute__((export_name("TS_SignOrCreationError_clone_ptr"))) TS_SignOrCreationError_clone_ptr(uint32_t arg) {
41669         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)arg;
41670         uint32_t ret_conv = SignOrCreationError_clone_ptr(arg_conv);
41671         return ret_conv;
41672 }
41673
41674 uint32_t  __attribute__((export_name("TS_SignOrCreationError_clone"))) TS_SignOrCreationError_clone(uint32_t orig) {
41675         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
41676         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
41677         *ret_copy = SignOrCreationError_clone(orig_conv);
41678         uint32_t ret_ref = (uintptr_t)ret_copy;
41679         return ret_ref;
41680 }
41681
41682 uint32_t  __attribute__((export_name("TS_SignOrCreationError_sign_error"))) TS_SignOrCreationError_sign_error() {
41683         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
41684         *ret_copy = SignOrCreationError_sign_error();
41685         uint32_t ret_ref = (uintptr_t)ret_copy;
41686         return ret_ref;
41687 }
41688
41689 uint32_t  __attribute__((export_name("TS_SignOrCreationError_creation_error"))) TS_SignOrCreationError_creation_error(uint32_t a) {
41690         LDKCreationError a_conv = LDKCreationError_from_js(a);
41691         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
41692         *ret_copy = SignOrCreationError_creation_error(a_conv);
41693         uint32_t ret_ref = (uintptr_t)ret_copy;
41694         return ret_ref;
41695 }
41696
41697 jboolean  __attribute__((export_name("TS_SignOrCreationError_eq"))) TS_SignOrCreationError_eq(uint32_t a, uint32_t b) {
41698         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
41699         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
41700         jboolean ret_conv = SignOrCreationError_eq(a_conv, b_conv);
41701         return ret_conv;
41702 }
41703
41704 jstring  __attribute__((export_name("TS_SignOrCreationError_to_str"))) TS_SignOrCreationError_to_str(uint32_t o) {
41705         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
41706         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
41707         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
41708         Str_free(ret_str);
41709         return ret_conv;
41710 }
41711
41712 void  __attribute__((export_name("TS_InvoicePayer_free"))) TS_InvoicePayer_free(uint32_t this_obj) {
41713         LDKInvoicePayer this_obj_conv;
41714         this_obj_conv.inner = (void*)(this_obj & (~1));
41715         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41717         InvoicePayer_free(this_obj_conv);
41718 }
41719
41720 void  __attribute__((export_name("TS_Payer_free"))) TS_Payer_free(uint32_t this_ptr) {
41721         if ((this_ptr & 1) != 0) return;
41722         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
41723         CHECK_ACCESS(this_ptr_ptr);
41724         LDKPayer this_ptr_conv = *(LDKPayer*)(this_ptr_ptr);
41725         FREE((void*)this_ptr);
41726         Payer_free(this_ptr_conv);
41727 }
41728
41729 void  __attribute__((export_name("TS_Router_free"))) TS_Router_free(uint32_t this_ptr) {
41730         if ((this_ptr & 1) != 0) return;
41731         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
41732         CHECK_ACCESS(this_ptr_ptr);
41733         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
41734         FREE((void*)this_ptr);
41735         Router_free(this_ptr_conv);
41736 }
41737
41738 void  __attribute__((export_name("TS_RetryAttempts_free"))) TS_RetryAttempts_free(uint32_t this_obj) {
41739         LDKRetryAttempts this_obj_conv;
41740         this_obj_conv.inner = (void*)(this_obj & (~1));
41741         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41743         RetryAttempts_free(this_obj_conv);
41744 }
41745
41746 uint32_t  __attribute__((export_name("TS_RetryAttempts_get_a"))) TS_RetryAttempts_get_a(uint32_t this_ptr) {
41747         LDKRetryAttempts this_ptr_conv;
41748         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41749         this_ptr_conv.is_owned = false;
41750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41751         uint32_t ret_conv = RetryAttempts_get_a(&this_ptr_conv);
41752         return ret_conv;
41753 }
41754
41755 void  __attribute__((export_name("TS_RetryAttempts_set_a"))) TS_RetryAttempts_set_a(uint32_t this_ptr, uint32_t val) {
41756         LDKRetryAttempts this_ptr_conv;
41757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41758         this_ptr_conv.is_owned = false;
41759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41760         RetryAttempts_set_a(&this_ptr_conv, val);
41761 }
41762
41763 uint32_t  __attribute__((export_name("TS_RetryAttempts_new"))) TS_RetryAttempts_new(uint32_t a_arg) {
41764         LDKRetryAttempts ret_var = RetryAttempts_new(a_arg);
41765         uint32_t ret_ref = 0;
41766         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41767         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41768         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41769         ret_ref = (uintptr_t)ret_var.inner;
41770         if (ret_var.is_owned) {
41771                 ret_ref |= 1;
41772         }
41773         return ret_ref;
41774 }
41775
41776 static inline uintptr_t RetryAttempts_clone_ptr(LDKRetryAttempts *NONNULL_PTR arg) {
41777         LDKRetryAttempts ret_var = RetryAttempts_clone(arg);
41778 uint32_t ret_ref = 0;
41779 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41780 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41781 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41782 ret_ref = (uintptr_t)ret_var.inner;
41783 if (ret_var.is_owned) {
41784         ret_ref |= 1;
41785 }
41786         return ret_ref;
41787 }
41788 uint32_t  __attribute__((export_name("TS_RetryAttempts_clone_ptr"))) TS_RetryAttempts_clone_ptr(uint32_t arg) {
41789         LDKRetryAttempts arg_conv;
41790         arg_conv.inner = (void*)(arg & (~1));
41791         arg_conv.is_owned = false;
41792         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41793         uint32_t ret_conv = RetryAttempts_clone_ptr(&arg_conv);
41794         return ret_conv;
41795 }
41796
41797 uint32_t  __attribute__((export_name("TS_RetryAttempts_clone"))) TS_RetryAttempts_clone(uint32_t orig) {
41798         LDKRetryAttempts orig_conv;
41799         orig_conv.inner = (void*)(orig & (~1));
41800         orig_conv.is_owned = false;
41801         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41802         LDKRetryAttempts ret_var = RetryAttempts_clone(&orig_conv);
41803         uint32_t ret_ref = 0;
41804         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41805         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41806         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41807         ret_ref = (uintptr_t)ret_var.inner;
41808         if (ret_var.is_owned) {
41809                 ret_ref |= 1;
41810         }
41811         return ret_ref;
41812 }
41813
41814 jboolean  __attribute__((export_name("TS_RetryAttempts_eq"))) TS_RetryAttempts_eq(uint32_t a, uint32_t b) {
41815         LDKRetryAttempts a_conv;
41816         a_conv.inner = (void*)(a & (~1));
41817         a_conv.is_owned = false;
41818         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41819         LDKRetryAttempts b_conv;
41820         b_conv.inner = (void*)(b & (~1));
41821         b_conv.is_owned = false;
41822         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41823         jboolean ret_conv = RetryAttempts_eq(&a_conv, &b_conv);
41824         return ret_conv;
41825 }
41826
41827 int64_t  __attribute__((export_name("TS_RetryAttempts_hash"))) TS_RetryAttempts_hash(uint32_t o) {
41828         LDKRetryAttempts o_conv;
41829         o_conv.inner = (void*)(o & (~1));
41830         o_conv.is_owned = false;
41831         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41832         int64_t ret_conv = RetryAttempts_hash(&o_conv);
41833         return ret_conv;
41834 }
41835
41836 void  __attribute__((export_name("TS_PaymentError_free"))) TS_PaymentError_free(uint32_t this_ptr) {
41837         if ((this_ptr & 1) != 0) return;
41838         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
41839         CHECK_ACCESS(this_ptr_ptr);
41840         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
41841         FREE((void*)this_ptr);
41842         PaymentError_free(this_ptr_conv);
41843 }
41844
41845 static inline uintptr_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
41846         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
41847         *ret_copy = PaymentError_clone(arg);
41848 uint32_t ret_ref = (uintptr_t)ret_copy;
41849         return ret_ref;
41850 }
41851 uint32_t  __attribute__((export_name("TS_PaymentError_clone_ptr"))) TS_PaymentError_clone_ptr(uint32_t arg) {
41852         LDKPaymentError* arg_conv = (LDKPaymentError*)arg;
41853         uint32_t ret_conv = PaymentError_clone_ptr(arg_conv);
41854         return ret_conv;
41855 }
41856
41857 uint32_t  __attribute__((export_name("TS_PaymentError_clone"))) TS_PaymentError_clone(uint32_t orig) {
41858         LDKPaymentError* orig_conv = (LDKPaymentError*)orig;
41859         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
41860         *ret_copy = PaymentError_clone(orig_conv);
41861         uint32_t ret_ref = (uintptr_t)ret_copy;
41862         return ret_ref;
41863 }
41864
41865 uint32_t  __attribute__((export_name("TS_PaymentError_invoice"))) TS_PaymentError_invoice(jstring a) {
41866         LDKStr a_conv = str_ref_to_owned_c(a);
41867         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
41868         *ret_copy = PaymentError_invoice(a_conv);
41869         uint32_t ret_ref = (uintptr_t)ret_copy;
41870         return ret_ref;
41871 }
41872
41873 uint32_t  __attribute__((export_name("TS_PaymentError_routing"))) TS_PaymentError_routing(uint32_t a) {
41874         LDKLightningError a_conv;
41875         a_conv.inner = (void*)(a & (~1));
41876         a_conv.is_owned = (a & 1) || (a == 0);
41877         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41878         a_conv = LightningError_clone(&a_conv);
41879         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
41880         *ret_copy = PaymentError_routing(a_conv);
41881         uint32_t ret_ref = (uintptr_t)ret_copy;
41882         return ret_ref;
41883 }
41884
41885 uint32_t  __attribute__((export_name("TS_PaymentError_sending"))) TS_PaymentError_sending(uint32_t a) {
41886         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
41887         CHECK_ACCESS(a_ptr);
41888         LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
41889         a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)a) & ~1));
41890         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
41891         *ret_copy = PaymentError_sending(a_conv);
41892         uint32_t ret_ref = (uintptr_t)ret_copy;
41893         return ret_ref;
41894 }
41895
41896 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_attempts) {
41897         void* payer_ptr = (void*)(((uintptr_t)payer) & ~1);
41898         CHECK_ACCESS(payer_ptr);
41899         LDKPayer payer_conv = *(LDKPayer*)(payer_ptr);
41900         if (payer_conv.free == LDKPayer_JCalls_free) {
41901                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41902                 LDKPayer_JCalls_cloned(&payer_conv);
41903         }
41904         void* router_ptr = (void*)(((uintptr_t)router) & ~1);
41905         CHECK_ACCESS(router_ptr);
41906         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
41907         if (router_conv.free == LDKRouter_JCalls_free) {
41908                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41909                 LDKRouter_JCalls_cloned(&router_conv);
41910         }
41911         LDKMultiThreadedLockableScore scorer_conv;
41912         scorer_conv.inner = (void*)(scorer & (~1));
41913         scorer_conv.is_owned = false;
41914         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
41915         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
41916         CHECK_ACCESS(logger_ptr);
41917         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
41918         if (logger_conv.free == LDKLogger_JCalls_free) {
41919                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41920                 LDKLogger_JCalls_cloned(&logger_conv);
41921         }
41922         void* event_handler_ptr = (void*)(((uintptr_t)event_handler) & ~1);
41923         CHECK_ACCESS(event_handler_ptr);
41924         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
41925         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
41926                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41927                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
41928         }
41929         LDKRetryAttempts retry_attempts_conv;
41930         retry_attempts_conv.inner = (void*)(retry_attempts & (~1));
41931         retry_attempts_conv.is_owned = (retry_attempts & 1) || (retry_attempts == 0);
41932         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_attempts_conv);
41933         retry_attempts_conv = RetryAttempts_clone(&retry_attempts_conv);
41934         LDKInvoicePayer ret_var = InvoicePayer_new(payer_conv, router_conv, &scorer_conv, logger_conv, event_handler_conv, retry_attempts_conv);
41935         uint32_t ret_ref = 0;
41936         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41937         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41938         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41939         ret_ref = (uintptr_t)ret_var.inner;
41940         if (ret_var.is_owned) {
41941                 ret_ref |= 1;
41942         }
41943         return ret_ref;
41944 }
41945
41946 uint32_t  __attribute__((export_name("TS_InvoicePayer_pay_invoice"))) TS_InvoicePayer_pay_invoice(uint32_t this_arg, uint32_t invoice) {
41947         LDKInvoicePayer this_arg_conv;
41948         this_arg_conv.inner = (void*)(this_arg & (~1));
41949         this_arg_conv.is_owned = false;
41950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41951         LDKInvoice invoice_conv;
41952         invoice_conv.inner = (void*)(invoice & (~1));
41953         invoice_conv.is_owned = false;
41954         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
41955         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
41956         *ret_conv = InvoicePayer_pay_invoice(&this_arg_conv, &invoice_conv);
41957         return (uint32_t)ret_conv;
41958 }
41959
41960 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) {
41961         LDKInvoicePayer this_arg_conv;
41962         this_arg_conv.inner = (void*)(this_arg & (~1));
41963         this_arg_conv.is_owned = false;
41964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41965         LDKInvoice invoice_conv;
41966         invoice_conv.inner = (void*)(invoice & (~1));
41967         invoice_conv.is_owned = false;
41968         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
41969         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
41970         *ret_conv = InvoicePayer_pay_zero_value_invoice(&this_arg_conv, &invoice_conv, amount_msats);
41971         return (uint32_t)ret_conv;
41972 }
41973
41974 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) {
41975         LDKInvoicePayer this_arg_conv;
41976         this_arg_conv.inner = (void*)(this_arg & (~1));
41977         this_arg_conv.is_owned = false;
41978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41979         LDKPublicKey pubkey_ref;
41980         CHECK(pubkey->arr_len == 33);
41981         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
41982         LDKThirtyTwoBytes payment_preimage_ref;
41983         CHECK(payment_preimage->arr_len == 32);
41984         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
41985         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
41986         *ret_conv = InvoicePayer_pay_pubkey(&this_arg_conv, pubkey_ref, payment_preimage_ref, amount_msats, final_cltv_expiry_delta);
41987         return (uint32_t)ret_conv;
41988 }
41989
41990 void  __attribute__((export_name("TS_InvoicePayer_remove_cached_payment"))) TS_InvoicePayer_remove_cached_payment(uint32_t this_arg, int8_tArray payment_hash) {
41991         LDKInvoicePayer this_arg_conv;
41992         this_arg_conv.inner = (void*)(this_arg & (~1));
41993         this_arg_conv.is_owned = false;
41994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41995         unsigned char payment_hash_arr[32];
41996         CHECK(payment_hash->arr_len == 32);
41997         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
41998         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
41999         InvoicePayer_remove_cached_payment(&this_arg_conv, payment_hash_ref);
42000 }
42001
42002 uint32_t  __attribute__((export_name("TS_InvoicePayer_as_EventHandler"))) TS_InvoicePayer_as_EventHandler(uint32_t this_arg) {
42003         LDKInvoicePayer this_arg_conv;
42004         this_arg_conv.inner = (void*)(this_arg & (~1));
42005         this_arg_conv.is_owned = false;
42006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42007         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
42008         *ret_ret = InvoicePayer_as_EventHandler(&this_arg_conv);
42009         return (uint32_t)ret_ret;
42010 }
42011
42012 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) {
42013         LDKChannelManager channelmanager_conv;
42014         channelmanager_conv.inner = (void*)(channelmanager & (~1));
42015         channelmanager_conv.is_owned = false;
42016         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
42017         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
42018         CHECK_ACCESS(keys_manager_ptr);
42019         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
42020         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
42021                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42022                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
42023         }
42024         LDKCurrency network_conv = LDKCurrency_from_js(network);
42025         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
42026         CHECK_ACCESS(amt_msat_ptr);
42027         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
42028         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
42029         LDKSha256 description_hash_conv;
42030         description_hash_conv.inner = (void*)(description_hash & (~1));
42031         description_hash_conv.is_owned = (description_hash & 1) || (description_hash == 0);
42032         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
42033         description_hash_conv = Sha256_clone(&description_hash_conv);
42034         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
42035         *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);
42036         return (uint32_t)ret_conv;
42037 }
42038
42039 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) {
42040         LDKChannelManager channelmanager_conv;
42041         channelmanager_conv.inner = (void*)(channelmanager & (~1));
42042         channelmanager_conv.is_owned = false;
42043         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
42044         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
42045         CHECK_ACCESS(keys_manager_ptr);
42046         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
42047         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
42048                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42049                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
42050         }
42051         LDKCurrency network_conv = LDKCurrency_from_js(network);
42052         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
42053         CHECK_ACCESS(amt_msat_ptr);
42054         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
42055         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
42056         LDKStr description_conv = str_ref_to_owned_c(description);
42057         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
42058         *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);
42059         return (uint32_t)ret_conv;
42060 }
42061
42062 void  __attribute__((export_name("TS_DefaultRouter_free"))) TS_DefaultRouter_free(uint32_t this_obj) {
42063         LDKDefaultRouter this_obj_conv;
42064         this_obj_conv.inner = (void*)(this_obj & (~1));
42065         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42067         DefaultRouter_free(this_obj_conv);
42068 }
42069
42070 uint32_t  __attribute__((export_name("TS_DefaultRouter_new"))) TS_DefaultRouter_new(uint32_t network_graph, uint32_t logger, int8_tArray random_seed_bytes) {
42071         LDKNetworkGraph network_graph_conv;
42072         network_graph_conv.inner = (void*)(network_graph & (~1));
42073         network_graph_conv.is_owned = false;
42074         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
42075         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
42076         CHECK_ACCESS(logger_ptr);
42077         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
42078         if (logger_conv.free == LDKLogger_JCalls_free) {
42079                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42080                 LDKLogger_JCalls_cloned(&logger_conv);
42081         }
42082         LDKThirtyTwoBytes random_seed_bytes_ref;
42083         CHECK(random_seed_bytes->arr_len == 32);
42084         memcpy(random_seed_bytes_ref.data, random_seed_bytes->elems, 32); FREE(random_seed_bytes);
42085         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv, random_seed_bytes_ref);
42086         uint32_t ret_ref = 0;
42087         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42088         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42089         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42090         ret_ref = (uintptr_t)ret_var.inner;
42091         if (ret_var.is_owned) {
42092                 ret_ref |= 1;
42093         }
42094         return ret_ref;
42095 }
42096
42097 uint32_t  __attribute__((export_name("TS_DefaultRouter_as_Router"))) TS_DefaultRouter_as_Router(uint32_t this_arg) {
42098         LDKDefaultRouter this_arg_conv;
42099         this_arg_conv.inner = (void*)(this_arg & (~1));
42100         this_arg_conv.is_owned = false;
42101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42102         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
42103         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
42104         return (uint32_t)ret_ret;
42105 }
42106
42107 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Payer"))) TS_ChannelManager_as_Payer(uint32_t this_arg) {
42108         LDKChannelManager this_arg_conv;
42109         this_arg_conv.inner = (void*)(this_arg & (~1));
42110         this_arg_conv.is_owned = false;
42111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42112         LDKPayer* ret_ret = MALLOC(sizeof(LDKPayer), "LDKPayer");
42113         *ret_ret = ChannelManager_as_Payer(&this_arg_conv);
42114         return (uint32_t)ret_ret;
42115 }
42116
42117 uint32_t  __attribute__((export_name("TS_SiPrefix_from_str"))) TS_SiPrefix_from_str(jstring s) {
42118         LDKStr s_conv = str_ref_to_owned_c(s);
42119         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
42120         *ret_conv = SiPrefix_from_str(s_conv);
42121         return (uint32_t)ret_conv;
42122 }
42123
42124 uint32_t  __attribute__((export_name("TS_Invoice_from_str"))) TS_Invoice_from_str(jstring s) {
42125         LDKStr s_conv = str_ref_to_owned_c(s);
42126         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
42127         *ret_conv = Invoice_from_str(s_conv);
42128         return (uint32_t)ret_conv;
42129 }
42130
42131 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_from_str"))) TS_SignedRawInvoice_from_str(jstring s) {
42132         LDKStr s_conv = str_ref_to_owned_c(s);
42133         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
42134         *ret_conv = SignedRawInvoice_from_str(s_conv);
42135         return (uint32_t)ret_conv;
42136 }
42137
42138 jstring  __attribute__((export_name("TS_ParseError_to_str"))) TS_ParseError_to_str(uint32_t o) {
42139         LDKParseError* o_conv = (LDKParseError*)o;
42140         LDKStr ret_str = ParseError_to_str(o_conv);
42141         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
42142         Str_free(ret_str);
42143         return ret_conv;
42144 }
42145
42146 jstring  __attribute__((export_name("TS_ParseOrSemanticError_to_str"))) TS_ParseOrSemanticError_to_str(uint32_t o) {
42147         LDKParseOrSemanticError* o_conv = (LDKParseOrSemanticError*)o;
42148         LDKStr ret_str = ParseOrSemanticError_to_str(o_conv);
42149         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
42150         Str_free(ret_str);
42151         return ret_conv;
42152 }
42153
42154 jstring  __attribute__((export_name("TS_Invoice_to_str"))) TS_Invoice_to_str(uint32_t o) {
42155         LDKInvoice o_conv;
42156         o_conv.inner = (void*)(o & (~1));
42157         o_conv.is_owned = false;
42158         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42159         LDKStr ret_str = Invoice_to_str(&o_conv);
42160         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
42161         Str_free(ret_str);
42162         return ret_conv;
42163 }
42164
42165 jstring  __attribute__((export_name("TS_SignedRawInvoice_to_str"))) TS_SignedRawInvoice_to_str(uint32_t o) {
42166         LDKSignedRawInvoice o_conv;
42167         o_conv.inner = (void*)(o & (~1));
42168         o_conv.is_owned = false;
42169         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42170         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
42171         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
42172         Str_free(ret_str);
42173         return ret_conv;
42174 }
42175
42176 jstring  __attribute__((export_name("TS_Currency_to_str"))) TS_Currency_to_str(uint32_t o) {
42177         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
42178         LDKStr ret_str = Currency_to_str(o_conv);
42179         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
42180         Str_free(ret_str);
42181         return ret_conv;
42182 }
42183
42184 jstring  __attribute__((export_name("TS_SiPrefix_to_str"))) TS_SiPrefix_to_str(uint32_t o) {
42185         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
42186         LDKStr ret_str = SiPrefix_to_str(o_conv);
42187         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
42188         Str_free(ret_str);
42189         return ret_conv;
42190 }
42191