[TS] Update auto-generated bindings
[ldk-java] / ts / bindings.c
1 #define LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ LDKCVec_TransactionOutputsZ
2 #define CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free CVec_TransactionOutputsZ_free
3 #include "js-wasm.h"
4 #include <stdatomic.h>
5 #include <lightning.h>
6
7 // These should be provided...somehow...
8 void *memset(void *s, int c, size_t n);
9 void *memcpy(void *dest, const void *src, size_t n);
10 int memcmp(const void *s1, const void *s2, size_t n);
11
12 extern void __attribute__((noreturn)) abort(void);
13 static inline void assert(bool expression) {
14         if (!expression) { abort(); }
15 }
16
17 uint32_t __attribute__((export_name("test_bigint_pass_deadbeef0badf00d"))) test_bigint_pass_deadbeef0badf00d(uint64_t val) {
18         return val == 0xdeadbeef0badf00dULL;
19 }
20
21
22 void *malloc(size_t size);
23 void free(void *ptr);
24
25 #define MALLOC(a, _) malloc(a)
26 #define do_MALLOC(a, _b, _c) malloc(a)
27 #define FREE(p) if ((unsigned long)(p) > 4096) { free(p); }
28 #define DO_ASSERT(a) (void)(a)
29 #define CHECK(a)
30 #define CHECK_ACCESS(p)
31 #define CHECK_INNER_FIELD_ACCESS_OR_NULL(v)
32
33 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
34 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
35 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
36 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
37
38 _Static_assert(sizeof(void*) == 4, "Pointers mut be 32 bits");
39
40 #define DECL_ARR_TYPE(ty, name) \
41         struct name##array { \
42                 uint32_t arr_len; \
43                 ty elems[]; \
44         }; \
45         typedef struct name##array * name##Array; \
46         static inline name##Array init_##name##Array(size_t arr_len, int lineno) { \
47                 name##Array arr = (name##Array)do_MALLOC(arr_len * sizeof(ty) + sizeof(uint32_t), #name" array init", lineno); \
48                 arr->arr_len = arr_len; \
49                 return arr; \
50         }
51
52 DECL_ARR_TYPE(int64_t, int64_t);
53 DECL_ARR_TYPE(int8_t, int8_t);
54 DECL_ARR_TYPE(uint32_t, uint32_t);
55 DECL_ARR_TYPE(void*, ptr);
56 DECL_ARR_TYPE(char, char);
57 typedef charArray jstring;
58
59 static inline jstring str_ref_to_ts(const char* chars, size_t len) {
60         charArray arr = init_charArray(len, __LINE__);
61         memcpy(arr->elems, chars, len);
62         return arr;
63 }
64 static inline LDKStr str_ref_to_owned_c(const jstring str) {
65         char* newchars = MALLOC(str->arr_len + 1, "String chars");
66         memcpy(newchars, str->elems, str->arr_len);
67         newchars[str->arr_len] = 0;
68         LDKStr res = {
69                 .chars = newchars,
70                 .len = str->arr_len,
71                 .chars_is_owned = true
72         };
73         return res;
74 }
75
76 typedef bool jboolean;
77
78 uint32_t __attribute__((export_name("TS_malloc"))) TS_malloc(uint32_t size) {
79         return (uint32_t)MALLOC(size, "JS-Called malloc");
80 }
81 void __attribute__((export_name("TS_free"))) TS_free(uint32_t ptr) {
82         FREE((void*)ptr);
83 }
84
85 jstring __attribute__((export_name("TS_get_ldk_c_bindings_version"))) TS_get_ldk_c_bindings_version() {
86         const char *res = check_get_ldk_bindings_version();
87         if (res == NULL) return NULL;
88         return str_ref_to_ts(res, strlen(res));
89 }
90 jstring __attribute__((export_name("TS_get_ldk_version"))) get_ldk_version() {
91         const char *res = check_get_ldk_version();
92         if (res == NULL) return NULL;
93         return str_ref_to_ts(res, strlen(res));
94 }
95 #include "version.c"
96 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
97 static inline LDKAccessError LDKAccessError_from_js(int32_t ord) {
98         switch (ord) {
99                 case 0: return LDKAccessError_UnknownChain;
100                 case 1: return LDKAccessError_UnknownTx;
101         }
102         abort();
103 }
104 static inline int32_t LDKAccessError_to_js(LDKAccessError val) {
105         switch (val) {
106                 case LDKAccessError_UnknownChain: return 0;
107                 case LDKAccessError_UnknownTx: return 1;
108                 default: abort();
109         }
110 }
111 static inline LDKCOption_NoneZ LDKCOption_NoneZ_from_js(int32_t ord) {
112         switch (ord) {
113                 case 0: return LDKCOption_NoneZ_Some;
114                 case 1: return LDKCOption_NoneZ_None;
115         }
116         abort();
117 }
118 static inline int32_t LDKCOption_NoneZ_to_js(LDKCOption_NoneZ val) {
119         switch (val) {
120                 case LDKCOption_NoneZ_Some: return 0;
121                 case LDKCOption_NoneZ_None: return 1;
122                 default: abort();
123         }
124 }
125 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_js(int32_t ord) {
126         switch (ord) {
127                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
128                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
129         }
130         abort();
131 }
132 static inline int32_t LDKChannelMonitorUpdateErr_to_js(LDKChannelMonitorUpdateErr val) {
133         switch (val) {
134                 case LDKChannelMonitorUpdateErr_TemporaryFailure: return 0;
135                 case LDKChannelMonitorUpdateErr_PermanentFailure: return 1;
136                 default: abort();
137         }
138 }
139 static inline LDKConfirmationTarget LDKConfirmationTarget_from_js(int32_t ord) {
140         switch (ord) {
141                 case 0: return LDKConfirmationTarget_Background;
142                 case 1: return LDKConfirmationTarget_Normal;
143                 case 2: return LDKConfirmationTarget_HighPriority;
144         }
145         abort();
146 }
147 static inline int32_t LDKConfirmationTarget_to_js(LDKConfirmationTarget val) {
148         switch (val) {
149                 case LDKConfirmationTarget_Background: return 0;
150                 case LDKConfirmationTarget_Normal: return 1;
151                 case LDKConfirmationTarget_HighPriority: return 2;
152                 default: abort();
153         }
154 }
155 static inline LDKCreationError LDKCreationError_from_js(int32_t ord) {
156         switch (ord) {
157                 case 0: return LDKCreationError_DescriptionTooLong;
158                 case 1: return LDKCreationError_RouteTooLong;
159                 case 2: return LDKCreationError_TimestampOutOfBounds;
160                 case 3: return LDKCreationError_InvalidAmount;
161                 case 4: return LDKCreationError_MissingRouteHints;
162         }
163         abort();
164 }
165 static inline int32_t LDKCreationError_to_js(LDKCreationError val) {
166         switch (val) {
167                 case LDKCreationError_DescriptionTooLong: return 0;
168                 case LDKCreationError_RouteTooLong: return 1;
169                 case LDKCreationError_TimestampOutOfBounds: return 2;
170                 case LDKCreationError_InvalidAmount: return 3;
171                 case LDKCreationError_MissingRouteHints: return 4;
172                 default: abort();
173         }
174 }
175 static inline LDKCurrency LDKCurrency_from_js(int32_t ord) {
176         switch (ord) {
177                 case 0: return LDKCurrency_Bitcoin;
178                 case 1: return LDKCurrency_BitcoinTestnet;
179                 case 2: return LDKCurrency_Regtest;
180                 case 3: return LDKCurrency_Simnet;
181                 case 4: return LDKCurrency_Signet;
182         }
183         abort();
184 }
185 static inline int32_t LDKCurrency_to_js(LDKCurrency val) {
186         switch (val) {
187                 case LDKCurrency_Bitcoin: return 0;
188                 case LDKCurrency_BitcoinTestnet: return 1;
189                 case LDKCurrency_Regtest: return 2;
190                 case LDKCurrency_Simnet: return 3;
191                 case LDKCurrency_Signet: return 4;
192                 default: abort();
193         }
194 }
195 static inline LDKLevel LDKLevel_from_js(int32_t ord) {
196         switch (ord) {
197                 case 0: return LDKLevel_Gossip;
198                 case 1: return LDKLevel_Trace;
199                 case 2: return LDKLevel_Debug;
200                 case 3: return LDKLevel_Info;
201                 case 4: return LDKLevel_Warn;
202                 case 5: return LDKLevel_Error;
203         }
204         abort();
205 }
206 static inline int32_t LDKLevel_to_js(LDKLevel val) {
207         switch (val) {
208                 case LDKLevel_Gossip: return 0;
209                 case LDKLevel_Trace: return 1;
210                 case LDKLevel_Debug: return 2;
211                 case LDKLevel_Info: return 3;
212                 case LDKLevel_Warn: return 4;
213                 case LDKLevel_Error: return 5;
214                 default: abort();
215         }
216 }
217 static inline LDKNetwork LDKNetwork_from_js(int32_t ord) {
218         switch (ord) {
219                 case 0: return LDKNetwork_Bitcoin;
220                 case 1: return LDKNetwork_Testnet;
221                 case 2: return LDKNetwork_Regtest;
222                 case 3: return LDKNetwork_Signet;
223         }
224         abort();
225 }
226 static inline int32_t LDKNetwork_to_js(LDKNetwork val) {
227         switch (val) {
228                 case LDKNetwork_Bitcoin: return 0;
229                 case LDKNetwork_Testnet: return 1;
230                 case LDKNetwork_Regtest: return 2;
231                 case LDKNetwork_Signet: return 3;
232                 default: abort();
233         }
234 }
235 static inline LDKRecipient LDKRecipient_from_js(int32_t ord) {
236         switch (ord) {
237                 case 0: return LDKRecipient_Node;
238                 case 1: return LDKRecipient_PhantomNode;
239         }
240         abort();
241 }
242 static inline int32_t LDKRecipient_to_js(LDKRecipient val) {
243         switch (val) {
244                 case LDKRecipient_Node: return 0;
245                 case LDKRecipient_PhantomNode: return 1;
246                 default: abort();
247         }
248 }
249 static inline LDKSecp256k1Error LDKSecp256k1Error_from_js(int32_t ord) {
250         switch (ord) {
251                 case 0: return LDKSecp256k1Error_IncorrectSignature;
252                 case 1: return LDKSecp256k1Error_InvalidMessage;
253                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
254                 case 3: return LDKSecp256k1Error_InvalidSignature;
255                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
256                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
257                 case 6: return LDKSecp256k1Error_InvalidTweak;
258                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
259                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
260         }
261         abort();
262 }
263 static inline int32_t LDKSecp256k1Error_to_js(LDKSecp256k1Error val) {
264         switch (val) {
265                 case LDKSecp256k1Error_IncorrectSignature: return 0;
266                 case LDKSecp256k1Error_InvalidMessage: return 1;
267                 case LDKSecp256k1Error_InvalidPublicKey: return 2;
268                 case LDKSecp256k1Error_InvalidSignature: return 3;
269                 case LDKSecp256k1Error_InvalidSecretKey: return 4;
270                 case LDKSecp256k1Error_InvalidRecoveryId: return 5;
271                 case LDKSecp256k1Error_InvalidTweak: return 6;
272                 case LDKSecp256k1Error_TweakCheckFailed: return 7;
273                 case LDKSecp256k1Error_NotEnoughMemory: return 8;
274                 default: abort();
275         }
276 }
277 static inline LDKSemanticError LDKSemanticError_from_js(int32_t ord) {
278         switch (ord) {
279                 case 0: return LDKSemanticError_NoPaymentHash;
280                 case 1: return LDKSemanticError_MultiplePaymentHashes;
281                 case 2: return LDKSemanticError_NoDescription;
282                 case 3: return LDKSemanticError_MultipleDescriptions;
283                 case 4: return LDKSemanticError_NoPaymentSecret;
284                 case 5: return LDKSemanticError_MultiplePaymentSecrets;
285                 case 6: return LDKSemanticError_InvalidFeatures;
286                 case 7: return LDKSemanticError_InvalidRecoveryId;
287                 case 8: return LDKSemanticError_InvalidSignature;
288                 case 9: return LDKSemanticError_ImpreciseAmount;
289         }
290         abort();
291 }
292 static inline int32_t LDKSemanticError_to_js(LDKSemanticError val) {
293         switch (val) {
294                 case LDKSemanticError_NoPaymentHash: return 0;
295                 case LDKSemanticError_MultiplePaymentHashes: return 1;
296                 case LDKSemanticError_NoDescription: return 2;
297                 case LDKSemanticError_MultipleDescriptions: return 3;
298                 case LDKSemanticError_NoPaymentSecret: return 4;
299                 case LDKSemanticError_MultiplePaymentSecrets: return 5;
300                 case LDKSemanticError_InvalidFeatures: return 6;
301                 case LDKSemanticError_InvalidRecoveryId: return 7;
302                 case LDKSemanticError_InvalidSignature: return 8;
303                 case LDKSemanticError_ImpreciseAmount: return 9;
304                 default: abort();
305         }
306 }
307 static inline LDKSiPrefix LDKSiPrefix_from_js(int32_t ord) {
308         switch (ord) {
309                 case 0: return LDKSiPrefix_Milli;
310                 case 1: return LDKSiPrefix_Micro;
311                 case 2: return LDKSiPrefix_Nano;
312                 case 3: return LDKSiPrefix_Pico;
313         }
314         abort();
315 }
316 static inline int32_t LDKSiPrefix_to_js(LDKSiPrefix val) {
317         switch (val) {
318                 case LDKSiPrefix_Milli: return 0;
319                 case LDKSiPrefix_Micro: return 1;
320                 case LDKSiPrefix_Nano: return 2;
321                 case LDKSiPrefix_Pico: return 3;
322                 default: abort();
323         }
324 }
325 uint32_t __attribute__((export_name("TS_LDKBech32Error_ty_from_ptr"))) TS_LDKBech32Error_ty_from_ptr(uint32_t ptr) {
326         LDKBech32Error *obj = (LDKBech32Error*)(ptr & ~1);
327         switch(obj->tag) {
328                 case LDKBech32Error_MissingSeparator: return 0;
329                 case LDKBech32Error_InvalidChecksum: return 1;
330                 case LDKBech32Error_InvalidLength: return 2;
331                 case LDKBech32Error_InvalidChar: return 3;
332                 case LDKBech32Error_InvalidData: return 4;
333                 case LDKBech32Error_InvalidPadding: return 5;
334                 case LDKBech32Error_MixedCase: return 6;
335                 default: abort();
336         }
337 }
338 int32_t __attribute__((export_name("TS_LDKBech32Error_InvalidChar_get_invalid_char"))) TS_LDKBech32Error_InvalidChar_get_invalid_char(uint32_t ptr) {
339         LDKBech32Error *obj = (LDKBech32Error*)(ptr & ~1);
340         assert(obj->tag == LDKBech32Error_InvalidChar);
341                         int32_t invalid_char_conv = obj->invalid_char;
342         return invalid_char_conv;
343 }
344 int8_t __attribute__((export_name("TS_LDKBech32Error_InvalidData_get_invalid_data"))) TS_LDKBech32Error_InvalidData_get_invalid_data(uint32_t ptr) {
345         LDKBech32Error *obj = (LDKBech32Error*)(ptr & ~1);
346         assert(obj->tag == LDKBech32Error_InvalidData);
347                         int8_t invalid_data_conv = obj->invalid_data;
348         return invalid_data_conv;
349 }
350 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
351         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
352         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
353         return ret;
354 }
355 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) {
356         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
357         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
358         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
359         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
360         CVec_u8Z_free(ret_var);
361         return ret_arr;
362 }
363
364 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) {
365         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
366         int64_t ret_conv = TxOut_get_value(thing_conv);
367         return ret_conv;
368 }
369
370 static inline void CResult_NoneNoneZ_get_ok(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
371 CHECK(owner->result_ok);
372         return *owner->contents.result;
373 }
374 void  __attribute__((export_name("TS_CResult_NoneNoneZ_get_ok"))) TS_CResult_NoneNoneZ_get_ok(uint32_t owner) {
375         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
376         CResult_NoneNoneZ_get_ok(owner_conv);
377 }
378
379 static inline void CResult_NoneNoneZ_get_err(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
380 CHECK(!owner->result_ok);
381         return *owner->contents.err;
382 }
383 void  __attribute__((export_name("TS_CResult_NoneNoneZ_get_err"))) TS_CResult_NoneNoneZ_get_err(uint32_t owner) {
384         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)(owner & ~1);
385         CResult_NoneNoneZ_get_err(owner_conv);
386 }
387
388 static inline struct LDKCounterpartyCommitmentSecrets CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
389 CHECK(owner->result_ok);
390         return CounterpartyCommitmentSecrets_clone(&*owner->contents.result);
391 }
392 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(uint32_t owner) {
393         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(owner & ~1);
394         LDKCounterpartyCommitmentSecrets ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(owner_conv);
395         uint32_t ret_ref = 0;
396         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
397         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
398         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
399         ret_ref = (uintptr_t)ret_var.inner;
400         if (ret_var.is_owned) {
401                 ret_ref |= 1;
402         }
403         return ret_ref;
404 }
405
406 static inline struct LDKDecodeError CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
407 CHECK(!owner->result_ok);
408         return DecodeError_clone(&*owner->contents.err);
409 }
410 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(uint32_t owner) {
411         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(owner & ~1);
412         LDKDecodeError ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(owner_conv);
413         uint32_t ret_ref = 0;
414         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
415         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
416         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
417         ret_ref = (uintptr_t)ret_var.inner;
418         if (ret_var.is_owned) {
419                 ret_ref |= 1;
420         }
421         return ret_ref;
422 }
423
424 static inline struct LDKSecretKey CResult_SecretKeyErrorZ_get_ok(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
425 CHECK(owner->result_ok);
426         return *owner->contents.result;
427 }
428 int8_tArray  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_get_ok"))) TS_CResult_SecretKeyErrorZ_get_ok(uint32_t owner) {
429         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
430         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
431         memcpy(ret_arr->elems, CResult_SecretKeyErrorZ_get_ok(owner_conv).bytes, 32);
432         return ret_arr;
433 }
434
435 static inline enum LDKSecp256k1Error CResult_SecretKeyErrorZ_get_err(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
436 CHECK(!owner->result_ok);
437         return *owner->contents.err;
438 }
439 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_get_err"))) TS_CResult_SecretKeyErrorZ_get_err(uint32_t owner) {
440         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)(owner & ~1);
441         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_SecretKeyErrorZ_get_err(owner_conv));
442         return ret_conv;
443 }
444
445 static inline struct LDKPublicKey CResult_PublicKeyErrorZ_get_ok(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
446 CHECK(owner->result_ok);
447         return *owner->contents.result;
448 }
449 int8_tArray  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_get_ok"))) TS_CResult_PublicKeyErrorZ_get_ok(uint32_t owner) {
450         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
451         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
452         memcpy(ret_arr->elems, CResult_PublicKeyErrorZ_get_ok(owner_conv).compressed_form, 33);
453         return ret_arr;
454 }
455
456 static inline enum LDKSecp256k1Error CResult_PublicKeyErrorZ_get_err(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
457 CHECK(!owner->result_ok);
458         return *owner->contents.err;
459 }
460 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_get_err"))) TS_CResult_PublicKeyErrorZ_get_err(uint32_t owner) {
461         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)(owner & ~1);
462         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_PublicKeyErrorZ_get_err(owner_conv));
463         return ret_conv;
464 }
465
466 static inline struct LDKTxCreationKeys CResult_TxCreationKeysDecodeErrorZ_get_ok(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
467 CHECK(owner->result_ok);
468         return TxCreationKeys_clone(&*owner->contents.result);
469 }
470 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_get_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_get_ok(uint32_t owner) {
471         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
472         LDKTxCreationKeys ret_var = CResult_TxCreationKeysDecodeErrorZ_get_ok(owner_conv);
473         uint32_t ret_ref = 0;
474         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
475         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
476         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
477         ret_ref = (uintptr_t)ret_var.inner;
478         if (ret_var.is_owned) {
479                 ret_ref |= 1;
480         }
481         return ret_ref;
482 }
483
484 static inline struct LDKDecodeError CResult_TxCreationKeysDecodeErrorZ_get_err(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
485 CHECK(!owner->result_ok);
486         return DecodeError_clone(&*owner->contents.err);
487 }
488 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_get_err"))) TS_CResult_TxCreationKeysDecodeErrorZ_get_err(uint32_t owner) {
489         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(owner & ~1);
490         LDKDecodeError ret_var = CResult_TxCreationKeysDecodeErrorZ_get_err(owner_conv);
491         uint32_t ret_ref = 0;
492         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
493         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
494         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
495         ret_ref = (uintptr_t)ret_var.inner;
496         if (ret_var.is_owned) {
497                 ret_ref |= 1;
498         }
499         return ret_ref;
500 }
501
502 static inline struct LDKChannelPublicKeys CResult_ChannelPublicKeysDecodeErrorZ_get_ok(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
503 CHECK(owner->result_ok);
504         return ChannelPublicKeys_clone(&*owner->contents.result);
505 }
506 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_get_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_get_ok(uint32_t owner) {
507         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
508         LDKChannelPublicKeys ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_ok(owner_conv);
509         uint32_t ret_ref = 0;
510         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
511         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
512         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
513         ret_ref = (uintptr_t)ret_var.inner;
514         if (ret_var.is_owned) {
515                 ret_ref |= 1;
516         }
517         return ret_ref;
518 }
519
520 static inline struct LDKDecodeError CResult_ChannelPublicKeysDecodeErrorZ_get_err(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
521 CHECK(!owner->result_ok);
522         return DecodeError_clone(&*owner->contents.err);
523 }
524 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_get_err"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_get_err(uint32_t owner) {
525         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(owner & ~1);
526         LDKDecodeError ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_err(owner_conv);
527         uint32_t ret_ref = 0;
528         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
529         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
530         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
531         ret_ref = (uintptr_t)ret_var.inner;
532         if (ret_var.is_owned) {
533                 ret_ref |= 1;
534         }
535         return ret_ref;
536 }
537
538 static inline struct LDKTxCreationKeys CResult_TxCreationKeysErrorZ_get_ok(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
539 CHECK(owner->result_ok);
540         return TxCreationKeys_clone(&*owner->contents.result);
541 }
542 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_get_ok"))) TS_CResult_TxCreationKeysErrorZ_get_ok(uint32_t owner) {
543         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
544         LDKTxCreationKeys ret_var = CResult_TxCreationKeysErrorZ_get_ok(owner_conv);
545         uint32_t ret_ref = 0;
546         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
547         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
548         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
549         ret_ref = (uintptr_t)ret_var.inner;
550         if (ret_var.is_owned) {
551                 ret_ref |= 1;
552         }
553         return ret_ref;
554 }
555
556 static inline enum LDKSecp256k1Error CResult_TxCreationKeysErrorZ_get_err(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
557 CHECK(!owner->result_ok);
558         return *owner->contents.err;
559 }
560 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_get_err"))) TS_CResult_TxCreationKeysErrorZ_get_err(uint32_t owner) {
561         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)(owner & ~1);
562         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_TxCreationKeysErrorZ_get_err(owner_conv));
563         return ret_conv;
564 }
565
566 uint32_t __attribute__((export_name("TS_LDKCOption_u32Z_ty_from_ptr"))) TS_LDKCOption_u32Z_ty_from_ptr(uint32_t ptr) {
567         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
568         switch(obj->tag) {
569                 case LDKCOption_u32Z_Some: return 0;
570                 case LDKCOption_u32Z_None: return 1;
571                 default: abort();
572         }
573 }
574 int32_t __attribute__((export_name("TS_LDKCOption_u32Z_Some_get_some"))) TS_LDKCOption_u32Z_Some_get_some(uint32_t ptr) {
575         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
576         assert(obj->tag == LDKCOption_u32Z_Some);
577                         int32_t some_conv = obj->some;
578         return some_conv;
579 }
580 static inline struct LDKHTLCOutputInCommitment CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
581 CHECK(owner->result_ok);
582         return HTLCOutputInCommitment_clone(&*owner->contents.result);
583 }
584 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(uint32_t owner) {
585         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
586         LDKHTLCOutputInCommitment ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(owner_conv);
587         uint32_t ret_ref = 0;
588         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
589         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
590         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
591         ret_ref = (uintptr_t)ret_var.inner;
592         if (ret_var.is_owned) {
593                 ret_ref |= 1;
594         }
595         return ret_ref;
596 }
597
598 static inline struct LDKDecodeError CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
599 CHECK(!owner->result_ok);
600         return DecodeError_clone(&*owner->contents.err);
601 }
602 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(uint32_t owner) {
603         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(owner & ~1);
604         LDKDecodeError ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(owner_conv);
605         uint32_t ret_ref = 0;
606         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
607         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
608         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
609         ret_ref = (uintptr_t)ret_var.inner;
610         if (ret_var.is_owned) {
611                 ret_ref |= 1;
612         }
613         return ret_ref;
614 }
615
616 static inline struct LDKCounterpartyChannelTransactionParameters CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
617 CHECK(owner->result_ok);
618         return CounterpartyChannelTransactionParameters_clone(&*owner->contents.result);
619 }
620 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t owner) {
621         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
622         LDKCounterpartyChannelTransactionParameters ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
623         uint32_t ret_ref = 0;
624         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
625         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
626         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
627         ret_ref = (uintptr_t)ret_var.inner;
628         if (ret_var.is_owned) {
629                 ret_ref |= 1;
630         }
631         return ret_ref;
632 }
633
634 static inline struct LDKDecodeError CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
635 CHECK(!owner->result_ok);
636         return DecodeError_clone(&*owner->contents.err);
637 }
638 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(uint32_t owner) {
639         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
640         LDKDecodeError ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
641         uint32_t ret_ref = 0;
642         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
643         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
644         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
645         ret_ref = (uintptr_t)ret_var.inner;
646         if (ret_var.is_owned) {
647                 ret_ref |= 1;
648         }
649         return ret_ref;
650 }
651
652 static inline struct LDKChannelTransactionParameters CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
653 CHECK(owner->result_ok);
654         return ChannelTransactionParameters_clone(&*owner->contents.result);
655 }
656 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(uint32_t owner) {
657         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
658         LDKChannelTransactionParameters ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
659         uint32_t ret_ref = 0;
660         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
661         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
662         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
663         ret_ref = (uintptr_t)ret_var.inner;
664         if (ret_var.is_owned) {
665                 ret_ref |= 1;
666         }
667         return ret_ref;
668 }
669
670 static inline struct LDKDecodeError CResult_ChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
671 CHECK(!owner->result_ok);
672         return DecodeError_clone(&*owner->contents.err);
673 }
674 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_err"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_get_err(uint32_t owner) {
675         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(owner & ~1);
676         LDKDecodeError ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
677         uint32_t ret_ref = 0;
678         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
679         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
680         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
681         ret_ref = (uintptr_t)ret_var.inner;
682         if (ret_var.is_owned) {
683                 ret_ref |= 1;
684         }
685         return ret_ref;
686 }
687
688 static inline struct LDKHolderCommitmentTransaction CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
689 CHECK(owner->result_ok);
690         return HolderCommitmentTransaction_clone(&*owner->contents.result);
691 }
692 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(uint32_t owner) {
693         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
694         LDKHolderCommitmentTransaction ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
695         uint32_t ret_ref = 0;
696         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
697         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
698         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
699         ret_ref = (uintptr_t)ret_var.inner;
700         if (ret_var.is_owned) {
701                 ret_ref |= 1;
702         }
703         return ret_ref;
704 }
705
706 static inline struct LDKDecodeError CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
707 CHECK(!owner->result_ok);
708         return DecodeError_clone(&*owner->contents.err);
709 }
710 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(uint32_t owner) {
711         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(owner & ~1);
712         LDKDecodeError ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
713         uint32_t ret_ref = 0;
714         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
715         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
716         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
717         ret_ref = (uintptr_t)ret_var.inner;
718         if (ret_var.is_owned) {
719                 ret_ref |= 1;
720         }
721         return ret_ref;
722 }
723
724 static inline struct LDKBuiltCommitmentTransaction CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
725 CHECK(owner->result_ok);
726         return BuiltCommitmentTransaction_clone(&*owner->contents.result);
727 }
728 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(uint32_t owner) {
729         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
730         LDKBuiltCommitmentTransaction ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
731         uint32_t ret_ref = 0;
732         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
733         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
734         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
735         ret_ref = (uintptr_t)ret_var.inner;
736         if (ret_var.is_owned) {
737                 ret_ref |= 1;
738         }
739         return ret_ref;
740 }
741
742 static inline struct LDKDecodeError CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
743 CHECK(!owner->result_ok);
744         return DecodeError_clone(&*owner->contents.err);
745 }
746 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(uint32_t owner) {
747         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(owner & ~1);
748         LDKDecodeError ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
749         uint32_t ret_ref = 0;
750         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
751         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
752         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
753         ret_ref = (uintptr_t)ret_var.inner;
754         if (ret_var.is_owned) {
755                 ret_ref |= 1;
756         }
757         return ret_ref;
758 }
759
760 static inline struct LDKTrustedClosingTransaction *CResult_TrustedClosingTransactionNoneZ_get_ok(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
761 CHECK(owner->result_ok);
762         return &*owner->contents.result;
763 }
764 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_get_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_get_ok(uint32_t owner) {
765         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
766         LDKTrustedClosingTransaction ret_var = *CResult_TrustedClosingTransactionNoneZ_get_ok(owner_conv);
767         uint32_t ret_ref = 0;
768         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
769         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
770         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
771         ret_ref = (uintptr_t)ret_var.inner & ~1;
772         return ret_ref;
773 }
774
775 static inline void CResult_TrustedClosingTransactionNoneZ_get_err(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
776 CHECK(!owner->result_ok);
777         return *owner->contents.err;
778 }
779 void  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_get_err"))) TS_CResult_TrustedClosingTransactionNoneZ_get_err(uint32_t owner) {
780         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(owner & ~1);
781         CResult_TrustedClosingTransactionNoneZ_get_err(owner_conv);
782 }
783
784 static inline struct LDKCommitmentTransaction CResult_CommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
785 CHECK(owner->result_ok);
786         return CommitmentTransaction_clone(&*owner->contents.result);
787 }
788 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_get_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_get_ok(uint32_t owner) {
789         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
790         LDKCommitmentTransaction ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
791         uint32_t ret_ref = 0;
792         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
793         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
794         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
795         ret_ref = (uintptr_t)ret_var.inner;
796         if (ret_var.is_owned) {
797                 ret_ref |= 1;
798         }
799         return ret_ref;
800 }
801
802 static inline struct LDKDecodeError CResult_CommitmentTransactionDecodeErrorZ_get_err(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
803 CHECK(!owner->result_ok);
804         return DecodeError_clone(&*owner->contents.err);
805 }
806 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_get_err"))) TS_CResult_CommitmentTransactionDecodeErrorZ_get_err(uint32_t owner) {
807         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(owner & ~1);
808         LDKDecodeError ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_err(owner_conv);
809         uint32_t ret_ref = 0;
810         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
811         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
812         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
813         ret_ref = (uintptr_t)ret_var.inner;
814         if (ret_var.is_owned) {
815                 ret_ref |= 1;
816         }
817         return ret_ref;
818 }
819
820 static inline struct LDKTrustedCommitmentTransaction *CResult_TrustedCommitmentTransactionNoneZ_get_ok(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
821 CHECK(owner->result_ok);
822         return &*owner->contents.result;
823 }
824 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_get_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_get_ok(uint32_t owner) {
825         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
826         LDKTrustedCommitmentTransaction ret_var = *CResult_TrustedCommitmentTransactionNoneZ_get_ok(owner_conv);
827         uint32_t ret_ref = 0;
828         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
829         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
830         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
831         ret_ref = (uintptr_t)ret_var.inner & ~1;
832         return ret_ref;
833 }
834
835 static inline void CResult_TrustedCommitmentTransactionNoneZ_get_err(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
836 CHECK(!owner->result_ok);
837         return *owner->contents.err;
838 }
839 void  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_get_err"))) TS_CResult_TrustedCommitmentTransactionNoneZ_get_err(uint32_t owner) {
840         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(owner & ~1);
841         CResult_TrustedCommitmentTransactionNoneZ_get_err(owner_conv);
842 }
843
844 static inline struct LDKCVec_SignatureZ CResult_CVec_SignatureZNoneZ_get_ok(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
845 CHECK(owner->result_ok);
846         return *owner->contents.result;
847 }
848 ptrArray  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_get_ok"))) TS_CResult_CVec_SignatureZNoneZ_get_ok(uint32_t owner) {
849         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
850         LDKCVec_SignatureZ ret_var = CResult_CVec_SignatureZNoneZ_get_ok(owner_conv);
851         ptrArray ret_arr = NULL;
852         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
853         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
854         for (size_t m = 0; m < ret_var.datalen; m++) {
855                 int8_tArray ret_conv_12_arr = init_int8_tArray(64, __LINE__);
856                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compact_form, 64);
857                 ret_arr_ptr[m] = ret_conv_12_arr;
858         }
859         
860         return ret_arr;
861 }
862
863 static inline void CResult_CVec_SignatureZNoneZ_get_err(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
864 CHECK(!owner->result_ok);
865         return *owner->contents.err;
866 }
867 void  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_get_err"))) TS_CResult_CVec_SignatureZNoneZ_get_err(uint32_t owner) {
868         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)(owner & ~1);
869         CResult_CVec_SignatureZNoneZ_get_err(owner_conv);
870 }
871
872 static inline struct LDKShutdownScript CResult_ShutdownScriptDecodeErrorZ_get_ok(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
873 CHECK(owner->result_ok);
874         return ShutdownScript_clone(&*owner->contents.result);
875 }
876 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_get_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_get_ok(uint32_t owner) {
877         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
878         LDKShutdownScript ret_var = CResult_ShutdownScriptDecodeErrorZ_get_ok(owner_conv);
879         uint32_t ret_ref = 0;
880         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
881         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
882         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
883         ret_ref = (uintptr_t)ret_var.inner;
884         if (ret_var.is_owned) {
885                 ret_ref |= 1;
886         }
887         return ret_ref;
888 }
889
890 static inline struct LDKDecodeError CResult_ShutdownScriptDecodeErrorZ_get_err(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
891 CHECK(!owner->result_ok);
892         return DecodeError_clone(&*owner->contents.err);
893 }
894 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_get_err"))) TS_CResult_ShutdownScriptDecodeErrorZ_get_err(uint32_t owner) {
895         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(owner & ~1);
896         LDKDecodeError ret_var = CResult_ShutdownScriptDecodeErrorZ_get_err(owner_conv);
897         uint32_t ret_ref = 0;
898         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
899         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
900         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
901         ret_ref = (uintptr_t)ret_var.inner;
902         if (ret_var.is_owned) {
903                 ret_ref |= 1;
904         }
905         return ret_ref;
906 }
907
908 static inline struct LDKShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
909 CHECK(owner->result_ok);
910         return ShutdownScript_clone(&*owner->contents.result);
911 }
912 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(uint32_t owner) {
913         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
914         LDKShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(owner_conv);
915         uint32_t ret_ref = 0;
916         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
917         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
918         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
919         ret_ref = (uintptr_t)ret_var.inner;
920         if (ret_var.is_owned) {
921                 ret_ref |= 1;
922         }
923         return ret_ref;
924 }
925
926 static inline struct LDKInvalidShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
927 CHECK(!owner->result_ok);
928         return InvalidShutdownScript_clone(&*owner->contents.err);
929 }
930 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_err"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(uint32_t owner) {
931         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(owner & ~1);
932         LDKInvalidShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(owner_conv);
933         uint32_t ret_ref = 0;
934         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
935         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
936         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
937         ret_ref = (uintptr_t)ret_var.inner;
938         if (ret_var.is_owned) {
939                 ret_ref |= 1;
940         }
941         return ret_ref;
942 }
943
944 static inline struct LDKRouteHop CResult_RouteHopDecodeErrorZ_get_ok(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
945 CHECK(owner->result_ok);
946         return RouteHop_clone(&*owner->contents.result);
947 }
948 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_get_ok"))) TS_CResult_RouteHopDecodeErrorZ_get_ok(uint32_t owner) {
949         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
950         LDKRouteHop ret_var = CResult_RouteHopDecodeErrorZ_get_ok(owner_conv);
951         uint32_t ret_ref = 0;
952         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
953         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
954         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
955         ret_ref = (uintptr_t)ret_var.inner;
956         if (ret_var.is_owned) {
957                 ret_ref |= 1;
958         }
959         return ret_ref;
960 }
961
962 static inline struct LDKDecodeError CResult_RouteHopDecodeErrorZ_get_err(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
963 CHECK(!owner->result_ok);
964         return DecodeError_clone(&*owner->contents.err);
965 }
966 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_get_err"))) TS_CResult_RouteHopDecodeErrorZ_get_err(uint32_t owner) {
967         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)(owner & ~1);
968         LDKDecodeError ret_var = CResult_RouteHopDecodeErrorZ_get_err(owner_conv);
969         uint32_t ret_ref = 0;
970         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
971         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
972         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
973         ret_ref = (uintptr_t)ret_var.inner;
974         if (ret_var.is_owned) {
975                 ret_ref |= 1;
976         }
977         return ret_ref;
978 }
979
980 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
981         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
982         for (size_t i = 0; i < ret.datalen; i++) {
983                 ret.data[i] = RouteHop_clone(&orig->data[i]);
984         }
985         return ret;
986 }
987 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
988         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
989         for (size_t i = 0; i < ret.datalen; i++) {
990                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
991         }
992         return ret;
993 }
994 static inline struct LDKRoute CResult_RouteDecodeErrorZ_get_ok(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
995 CHECK(owner->result_ok);
996         return Route_clone(&*owner->contents.result);
997 }
998 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_get_ok"))) TS_CResult_RouteDecodeErrorZ_get_ok(uint32_t owner) {
999         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
1000         LDKRoute ret_var = CResult_RouteDecodeErrorZ_get_ok(owner_conv);
1001         uint32_t ret_ref = 0;
1002         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1003         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1004         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1005         ret_ref = (uintptr_t)ret_var.inner;
1006         if (ret_var.is_owned) {
1007                 ret_ref |= 1;
1008         }
1009         return ret_ref;
1010 }
1011
1012 static inline struct LDKDecodeError CResult_RouteDecodeErrorZ_get_err(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
1013 CHECK(!owner->result_ok);
1014         return DecodeError_clone(&*owner->contents.err);
1015 }
1016 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_get_err"))) TS_CResult_RouteDecodeErrorZ_get_err(uint32_t owner) {
1017         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)(owner & ~1);
1018         LDKDecodeError ret_var = CResult_RouteDecodeErrorZ_get_err(owner_conv);
1019         uint32_t ret_ref = 0;
1020         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1021         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1022         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1023         ret_ref = (uintptr_t)ret_var.inner;
1024         if (ret_var.is_owned) {
1025                 ret_ref |= 1;
1026         }
1027         return ret_ref;
1028 }
1029
1030 static inline struct LDKRouteParameters CResult_RouteParametersDecodeErrorZ_get_ok(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1031 CHECK(owner->result_ok);
1032         return RouteParameters_clone(&*owner->contents.result);
1033 }
1034 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_get_ok"))) TS_CResult_RouteParametersDecodeErrorZ_get_ok(uint32_t owner) {
1035         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
1036         LDKRouteParameters ret_var = CResult_RouteParametersDecodeErrorZ_get_ok(owner_conv);
1037         uint32_t ret_ref = 0;
1038         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1039         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1040         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1041         ret_ref = (uintptr_t)ret_var.inner;
1042         if (ret_var.is_owned) {
1043                 ret_ref |= 1;
1044         }
1045         return ret_ref;
1046 }
1047
1048 static inline struct LDKDecodeError CResult_RouteParametersDecodeErrorZ_get_err(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
1049 CHECK(!owner->result_ok);
1050         return DecodeError_clone(&*owner->contents.err);
1051 }
1052 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_get_err"))) TS_CResult_RouteParametersDecodeErrorZ_get_err(uint32_t owner) {
1053         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(owner & ~1);
1054         LDKDecodeError ret_var = CResult_RouteParametersDecodeErrorZ_get_err(owner_conv);
1055         uint32_t ret_ref = 0;
1056         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1057         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1058         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1059         ret_ref = (uintptr_t)ret_var.inner;
1060         if (ret_var.is_owned) {
1061                 ret_ref |= 1;
1062         }
1063         return ret_ref;
1064 }
1065
1066 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
1067         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
1068         for (size_t i = 0; i < ret.datalen; i++) {
1069                 ret.data[i] = RouteHint_clone(&orig->data[i]);
1070         }
1071         return ret;
1072 }
1073 uint32_t __attribute__((export_name("TS_LDKCOption_u64Z_ty_from_ptr"))) TS_LDKCOption_u64Z_ty_from_ptr(uint32_t ptr) {
1074         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1075         switch(obj->tag) {
1076                 case LDKCOption_u64Z_Some: return 0;
1077                 case LDKCOption_u64Z_None: return 1;
1078                 default: abort();
1079         }
1080 }
1081 int64_t __attribute__((export_name("TS_LDKCOption_u64Z_Some_get_some"))) TS_LDKCOption_u64Z_Some_get_some(uint32_t ptr) {
1082         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1083         assert(obj->tag == LDKCOption_u64Z_Some);
1084                         int64_t some_conv = obj->some;
1085         return some_conv;
1086 }
1087 static inline struct LDKPaymentParameters CResult_PaymentParametersDecodeErrorZ_get_ok(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1088 CHECK(owner->result_ok);
1089         return PaymentParameters_clone(&*owner->contents.result);
1090 }
1091 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_get_ok"))) TS_CResult_PaymentParametersDecodeErrorZ_get_ok(uint32_t owner) {
1092         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1093         LDKPaymentParameters ret_var = CResult_PaymentParametersDecodeErrorZ_get_ok(owner_conv);
1094         uint32_t ret_ref = 0;
1095         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1096         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1097         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1098         ret_ref = (uintptr_t)ret_var.inner;
1099         if (ret_var.is_owned) {
1100                 ret_ref |= 1;
1101         }
1102         return ret_ref;
1103 }
1104
1105 static inline struct LDKDecodeError CResult_PaymentParametersDecodeErrorZ_get_err(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
1106 CHECK(!owner->result_ok);
1107         return DecodeError_clone(&*owner->contents.err);
1108 }
1109 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_get_err"))) TS_CResult_PaymentParametersDecodeErrorZ_get_err(uint32_t owner) {
1110         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(owner & ~1);
1111         LDKDecodeError ret_var = CResult_PaymentParametersDecodeErrorZ_get_err(owner_conv);
1112         uint32_t ret_ref = 0;
1113         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1114         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1115         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1116         ret_ref = (uintptr_t)ret_var.inner;
1117         if (ret_var.is_owned) {
1118                 ret_ref |= 1;
1119         }
1120         return ret_ref;
1121 }
1122
1123 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
1124         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
1125         for (size_t i = 0; i < ret.datalen; i++) {
1126                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
1127         }
1128         return ret;
1129 }
1130 static inline struct LDKRouteHint CResult_RouteHintDecodeErrorZ_get_ok(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1131 CHECK(owner->result_ok);
1132         return RouteHint_clone(&*owner->contents.result);
1133 }
1134 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_get_ok"))) TS_CResult_RouteHintDecodeErrorZ_get_ok(uint32_t owner) {
1135         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1136         LDKRouteHint ret_var = CResult_RouteHintDecodeErrorZ_get_ok(owner_conv);
1137         uint32_t ret_ref = 0;
1138         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1139         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1140         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1141         ret_ref = (uintptr_t)ret_var.inner;
1142         if (ret_var.is_owned) {
1143                 ret_ref |= 1;
1144         }
1145         return ret_ref;
1146 }
1147
1148 static inline struct LDKDecodeError CResult_RouteHintDecodeErrorZ_get_err(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
1149 CHECK(!owner->result_ok);
1150         return DecodeError_clone(&*owner->contents.err);
1151 }
1152 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_get_err"))) TS_CResult_RouteHintDecodeErrorZ_get_err(uint32_t owner) {
1153         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)(owner & ~1);
1154         LDKDecodeError ret_var = CResult_RouteHintDecodeErrorZ_get_err(owner_conv);
1155         uint32_t ret_ref = 0;
1156         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1157         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1158         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1159         ret_ref = (uintptr_t)ret_var.inner;
1160         if (ret_var.is_owned) {
1161                 ret_ref |= 1;
1162         }
1163         return ret_ref;
1164 }
1165
1166 static inline struct LDKRouteHintHop CResult_RouteHintHopDecodeErrorZ_get_ok(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1167 CHECK(owner->result_ok);
1168         return RouteHintHop_clone(&*owner->contents.result);
1169 }
1170 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_get_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_get_ok(uint32_t owner) {
1171         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1172         LDKRouteHintHop ret_var = CResult_RouteHintHopDecodeErrorZ_get_ok(owner_conv);
1173         uint32_t ret_ref = 0;
1174         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1175         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1176         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1177         ret_ref = (uintptr_t)ret_var.inner;
1178         if (ret_var.is_owned) {
1179                 ret_ref |= 1;
1180         }
1181         return ret_ref;
1182 }
1183
1184 static inline struct LDKDecodeError CResult_RouteHintHopDecodeErrorZ_get_err(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
1185 CHECK(!owner->result_ok);
1186         return DecodeError_clone(&*owner->contents.err);
1187 }
1188 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_get_err"))) TS_CResult_RouteHintHopDecodeErrorZ_get_err(uint32_t owner) {
1189         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(owner & ~1);
1190         LDKDecodeError ret_var = CResult_RouteHintHopDecodeErrorZ_get_err(owner_conv);
1191         uint32_t ret_ref = 0;
1192         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1193         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1194         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1195         ret_ref = (uintptr_t)ret_var.inner;
1196         if (ret_var.is_owned) {
1197                 ret_ref |= 1;
1198         }
1199         return ret_ref;
1200 }
1201
1202 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1203         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1204         for (size_t i = 0; i < ret.datalen; i++) {
1205                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1206         }
1207         return ret;
1208 }
1209 static inline struct LDKRoute CResult_RouteLightningErrorZ_get_ok(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1210 CHECK(owner->result_ok);
1211         return Route_clone(&*owner->contents.result);
1212 }
1213 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_get_ok"))) TS_CResult_RouteLightningErrorZ_get_ok(uint32_t owner) {
1214         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1215         LDKRoute ret_var = CResult_RouteLightningErrorZ_get_ok(owner_conv);
1216         uint32_t ret_ref = 0;
1217         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1218         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1219         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1220         ret_ref = (uintptr_t)ret_var.inner;
1221         if (ret_var.is_owned) {
1222                 ret_ref |= 1;
1223         }
1224         return ret_ref;
1225 }
1226
1227 static inline struct LDKLightningError CResult_RouteLightningErrorZ_get_err(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
1228 CHECK(!owner->result_ok);
1229         return LightningError_clone(&*owner->contents.err);
1230 }
1231 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_get_err"))) TS_CResult_RouteLightningErrorZ_get_err(uint32_t owner) {
1232         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)(owner & ~1);
1233         LDKLightningError ret_var = CResult_RouteLightningErrorZ_get_err(owner_conv);
1234         uint32_t ret_ref = 0;
1235         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1236         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1237         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1238         ret_ref = (uintptr_t)ret_var.inner;
1239         if (ret_var.is_owned) {
1240                 ret_ref |= 1;
1241         }
1242         return ret_ref;
1243 }
1244
1245 static inline struct LDKTxOut CResult_TxOutAccessErrorZ_get_ok(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
1246 CHECK(owner->result_ok);
1247         return TxOut_clone(&*owner->contents.result);
1248 }
1249 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_get_ok"))) TS_CResult_TxOutAccessErrorZ_get_ok(uint32_t owner) {
1250         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
1251         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
1252         *ret_ref = CResult_TxOutAccessErrorZ_get_ok(owner_conv);
1253         return (uint32_t)ret_ref;
1254 }
1255
1256 static inline enum LDKAccessError CResult_TxOutAccessErrorZ_get_err(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
1257 CHECK(!owner->result_ok);
1258         return AccessError_clone(&*owner->contents.err);
1259 }
1260 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_get_err"))) TS_CResult_TxOutAccessErrorZ_get_err(uint32_t owner) {
1261         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)(owner & ~1);
1262         uint32_t ret_conv = LDKAccessError_to_js(CResult_TxOutAccessErrorZ_get_err(owner_conv));
1263         return ret_conv;
1264 }
1265
1266 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
1267         return owner->a;
1268 }
1269 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_get_a"))) TS_C2Tuple_usizeTransactionZ_get_a(uint32_t owner) {
1270         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
1271         uint32_t ret_conv = C2Tuple_usizeTransactionZ_get_a(owner_conv);
1272         return ret_conv;
1273 }
1274
1275 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
1276         return owner->b;
1277 }
1278 int8_tArray  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_get_b"))) TS_C2Tuple_usizeTransactionZ_get_b(uint32_t owner) {
1279         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)(owner & ~1);
1280         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(owner_conv);
1281         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
1282         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
1283         return ret_arr;
1284 }
1285
1286 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
1287         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
1288         for (size_t i = 0; i < ret.datalen; i++) {
1289                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
1290         }
1291         return ret;
1292 }
1293 static inline LDKCVec_TxidZ CVec_TxidZ_clone(const LDKCVec_TxidZ *orig) {
1294         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
1295         for (size_t i = 0; i < ret.datalen; i++) {
1296                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
1297         }
1298         return ret;
1299 }
1300 static inline void CResult_NoneChannelMonitorUpdateErrZ_get_ok(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
1301 CHECK(owner->result_ok);
1302         return *owner->contents.result;
1303 }
1304 void  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_get_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_get_ok(uint32_t owner) {
1305         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
1306         CResult_NoneChannelMonitorUpdateErrZ_get_ok(owner_conv);
1307 }
1308
1309 static inline enum LDKChannelMonitorUpdateErr CResult_NoneChannelMonitorUpdateErrZ_get_err(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
1310 CHECK(!owner->result_ok);
1311         return ChannelMonitorUpdateErr_clone(&*owner->contents.err);
1312 }
1313 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_get_err"))) TS_CResult_NoneChannelMonitorUpdateErrZ_get_err(uint32_t owner) {
1314         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(owner & ~1);
1315         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(CResult_NoneChannelMonitorUpdateErrZ_get_err(owner_conv));
1316         return ret_conv;
1317 }
1318
1319 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_ty_from_ptr"))) TS_LDKMonitorEvent_ty_from_ptr(uint32_t ptr) {
1320         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1321         switch(obj->tag) {
1322                 case LDKMonitorEvent_HTLCEvent: return 0;
1323                 case LDKMonitorEvent_CommitmentTxConfirmed: return 1;
1324                 case LDKMonitorEvent_UpdateCompleted: return 2;
1325                 case LDKMonitorEvent_UpdateFailed: return 3;
1326                 default: abort();
1327         }
1328 }
1329 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_HTLCEvent_get_htlc_event"))) TS_LDKMonitorEvent_HTLCEvent_get_htlc_event(uint32_t ptr) {
1330         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1331         assert(obj->tag == LDKMonitorEvent_HTLCEvent);
1332                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
1333                         uint32_t htlc_event_ref = 0;
1334                         CHECK((((uintptr_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1335                         CHECK((((uintptr_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1336                         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
1337                         htlc_event_ref = (uintptr_t)htlc_event_var.inner & ~1;
1338         return htlc_event_ref;
1339 }
1340 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_CommitmentTxConfirmed_get_commitment_tx_confirmed"))) TS_LDKMonitorEvent_CommitmentTxConfirmed_get_commitment_tx_confirmed(uint32_t ptr) {
1341         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1342         assert(obj->tag == LDKMonitorEvent_CommitmentTxConfirmed);
1343                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
1344                         uint32_t commitment_tx_confirmed_ref = 0;
1345                         CHECK((((uintptr_t)commitment_tx_confirmed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1346                         CHECK((((uintptr_t)&commitment_tx_confirmed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1347                         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_confirmed_var);
1348                         commitment_tx_confirmed_ref = (uintptr_t)commitment_tx_confirmed_var.inner & ~1;
1349         return commitment_tx_confirmed_ref;
1350 }
1351 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateCompleted_get_funding_txo"))) TS_LDKMonitorEvent_UpdateCompleted_get_funding_txo(uint32_t ptr) {
1352         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1353         assert(obj->tag == LDKMonitorEvent_UpdateCompleted);
1354                         LDKOutPoint funding_txo_var = obj->update_completed.funding_txo;
1355                         uint32_t funding_txo_ref = 0;
1356                         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1357                         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1358                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
1359                         funding_txo_ref = (uintptr_t)funding_txo_var.inner & ~1;
1360         return funding_txo_ref;
1361 }
1362 int64_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateCompleted_get_monitor_update_id"))) TS_LDKMonitorEvent_UpdateCompleted_get_monitor_update_id(uint32_t ptr) {
1363         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1364         assert(obj->tag == LDKMonitorEvent_UpdateCompleted);
1365                         int64_t monitor_update_id_conv = obj->update_completed.monitor_update_id;
1366         return monitor_update_id_conv;
1367 }
1368 uint32_t __attribute__((export_name("TS_LDKMonitorEvent_UpdateFailed_get_update_failed"))) TS_LDKMonitorEvent_UpdateFailed_get_update_failed(uint32_t ptr) {
1369         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1370         assert(obj->tag == LDKMonitorEvent_UpdateFailed);
1371                         LDKOutPoint update_failed_var = obj->update_failed;
1372                         uint32_t update_failed_ref = 0;
1373                         CHECK((((uintptr_t)update_failed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1374                         CHECK((((uintptr_t)&update_failed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1375                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_failed_var);
1376                         update_failed_ref = (uintptr_t)update_failed_var.inner & ~1;
1377         return update_failed_ref;
1378 }
1379 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
1380         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
1381         for (size_t i = 0; i < ret.datalen; i++) {
1382                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
1383         }
1384         return ret;
1385 }
1386 uint32_t __attribute__((export_name("TS_LDKCOption_C2Tuple_usizeTransactionZZ_ty_from_ptr"))) TS_LDKCOption_C2Tuple_usizeTransactionZZ_ty_from_ptr(uint32_t ptr) {
1387         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
1388         switch(obj->tag) {
1389                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: return 0;
1390                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: return 1;
1391                 default: abort();
1392         }
1393 }
1394 uint32_t __attribute__((export_name("TS_LDKCOption_C2Tuple_usizeTransactionZZ_Some_get_some"))) TS_LDKCOption_C2Tuple_usizeTransactionZZ_Some_get_some(uint32_t ptr) {
1395         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
1396         assert(obj->tag == LDKCOption_C2Tuple_usizeTransactionZZ_Some);
1397                         LDKC2Tuple_usizeTransactionZ* some_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
1398                         *some_conv = obj->some;
1399                         *some_conv = C2Tuple_usizeTransactionZ_clone(some_conv);
1400         return ((uint32_t)some_conv);
1401 }
1402 uint32_t __attribute__((export_name("TS_LDKClosureReason_ty_from_ptr"))) TS_LDKClosureReason_ty_from_ptr(uint32_t ptr) {
1403         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1404         switch(obj->tag) {
1405                 case LDKClosureReason_CounterpartyForceClosed: return 0;
1406                 case LDKClosureReason_HolderForceClosed: return 1;
1407                 case LDKClosureReason_CooperativeClosure: return 2;
1408                 case LDKClosureReason_CommitmentTxConfirmed: return 3;
1409                 case LDKClosureReason_FundingTimedOut: return 4;
1410                 case LDKClosureReason_ProcessingError: return 5;
1411                 case LDKClosureReason_DisconnectedPeer: return 6;
1412                 case LDKClosureReason_OutdatedChannelManager: return 7;
1413                 default: abort();
1414         }
1415 }
1416 jstring __attribute__((export_name("TS_LDKClosureReason_CounterpartyForceClosed_get_peer_msg"))) TS_LDKClosureReason_CounterpartyForceClosed_get_peer_msg(uint32_t ptr) {
1417         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1418         assert(obj->tag == LDKClosureReason_CounterpartyForceClosed);
1419                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
1420                         jstring peer_msg_conv = str_ref_to_ts(peer_msg_str.chars, peer_msg_str.len);
1421         return peer_msg_conv;
1422 }
1423 jstring __attribute__((export_name("TS_LDKClosureReason_ProcessingError_get_err"))) TS_LDKClosureReason_ProcessingError_get_err(uint32_t ptr) {
1424         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1425         assert(obj->tag == LDKClosureReason_ProcessingError);
1426                         LDKStr err_str = obj->processing_error.err;
1427                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
1428         return err_conv;
1429 }
1430 uint32_t __attribute__((export_name("TS_LDKCOption_ClosureReasonZ_ty_from_ptr"))) TS_LDKCOption_ClosureReasonZ_ty_from_ptr(uint32_t ptr) {
1431         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
1432         switch(obj->tag) {
1433                 case LDKCOption_ClosureReasonZ_Some: return 0;
1434                 case LDKCOption_ClosureReasonZ_None: return 1;
1435                 default: abort();
1436         }
1437 }
1438 uint32_t __attribute__((export_name("TS_LDKCOption_ClosureReasonZ_Some_get_some"))) TS_LDKCOption_ClosureReasonZ_Some_get_some(uint32_t ptr) {
1439         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
1440         assert(obj->tag == LDKCOption_ClosureReasonZ_Some);
1441                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
1442         return some_ref;
1443 }
1444 static inline struct LDKCOption_ClosureReasonZ CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
1445 CHECK(owner->result_ok);
1446         return COption_ClosureReasonZ_clone(&*owner->contents.result);
1447 }
1448 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(uint32_t owner) {
1449         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
1450         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
1451         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(owner_conv);
1452         uint32_t ret_ref = (uintptr_t)ret_copy;
1453         return ret_ref;
1454 }
1455
1456 static inline struct LDKDecodeError CResult_COption_ClosureReasonZDecodeErrorZ_get_err(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
1457 CHECK(!owner->result_ok);
1458         return DecodeError_clone(&*owner->contents.err);
1459 }
1460 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_err"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_get_err(uint32_t owner) {
1461         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(owner & ~1);
1462         LDKDecodeError ret_var = CResult_COption_ClosureReasonZDecodeErrorZ_get_err(owner_conv);
1463         uint32_t ret_ref = 0;
1464         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1465         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1466         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1467         ret_ref = (uintptr_t)ret_var.inner;
1468         if (ret_var.is_owned) {
1469                 ret_ref |= 1;
1470         }
1471         return ret_ref;
1472 }
1473
1474 uint32_t __attribute__((export_name("TS_LDKNetworkUpdate_ty_from_ptr"))) TS_LDKNetworkUpdate_ty_from_ptr(uint32_t ptr) {
1475         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1476         switch(obj->tag) {
1477                 case LDKNetworkUpdate_ChannelUpdateMessage: return 0;
1478                 case LDKNetworkUpdate_ChannelClosed: return 1;
1479                 case LDKNetworkUpdate_NodeFailure: return 2;
1480                 default: abort();
1481         }
1482 }
1483 uint32_t __attribute__((export_name("TS_LDKNetworkUpdate_ChannelUpdateMessage_get_msg"))) TS_LDKNetworkUpdate_ChannelUpdateMessage_get_msg(uint32_t ptr) {
1484         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1485         assert(obj->tag == LDKNetworkUpdate_ChannelUpdateMessage);
1486                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
1487                         uint32_t msg_ref = 0;
1488                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1489                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1490                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1491                         msg_ref = (uintptr_t)msg_var.inner & ~1;
1492         return msg_ref;
1493 }
1494 int64_t __attribute__((export_name("TS_LDKNetworkUpdate_ChannelClosed_get_short_channel_id"))) TS_LDKNetworkUpdate_ChannelClosed_get_short_channel_id(uint32_t ptr) {
1495         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1496         assert(obj->tag == LDKNetworkUpdate_ChannelClosed);
1497                         int64_t short_channel_id_conv = obj->channel_closed.short_channel_id;
1498         return short_channel_id_conv;
1499 }
1500 jboolean __attribute__((export_name("TS_LDKNetworkUpdate_ChannelClosed_get_is_permanent"))) TS_LDKNetworkUpdate_ChannelClosed_get_is_permanent(uint32_t ptr) {
1501         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1502         assert(obj->tag == LDKNetworkUpdate_ChannelClosed);
1503                         jboolean is_permanent_conv = obj->channel_closed.is_permanent;
1504         return is_permanent_conv;
1505 }
1506 int8_tArray __attribute__((export_name("TS_LDKNetworkUpdate_NodeFailure_get_node_id"))) TS_LDKNetworkUpdate_NodeFailure_get_node_id(uint32_t ptr) {
1507         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1508         assert(obj->tag == LDKNetworkUpdate_NodeFailure);
1509                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
1510                         memcpy(node_id_arr->elems, obj->node_failure.node_id.compressed_form, 33);
1511         return node_id_arr;
1512 }
1513 jboolean __attribute__((export_name("TS_LDKNetworkUpdate_NodeFailure_get_is_permanent"))) TS_LDKNetworkUpdate_NodeFailure_get_is_permanent(uint32_t ptr) {
1514         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1515         assert(obj->tag == LDKNetworkUpdate_NodeFailure);
1516                         jboolean is_permanent_conv = obj->node_failure.is_permanent;
1517         return is_permanent_conv;
1518 }
1519 uint32_t __attribute__((export_name("TS_LDKCOption_NetworkUpdateZ_ty_from_ptr"))) TS_LDKCOption_NetworkUpdateZ_ty_from_ptr(uint32_t ptr) {
1520         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
1521         switch(obj->tag) {
1522                 case LDKCOption_NetworkUpdateZ_Some: return 0;
1523                 case LDKCOption_NetworkUpdateZ_None: return 1;
1524                 default: abort();
1525         }
1526 }
1527 uint32_t __attribute__((export_name("TS_LDKCOption_NetworkUpdateZ_Some_get_some"))) TS_LDKCOption_NetworkUpdateZ_Some_get_some(uint32_t ptr) {
1528         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
1529         assert(obj->tag == LDKCOption_NetworkUpdateZ_Some);
1530                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
1531         return some_ref;
1532 }
1533 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_ty_from_ptr"))) TS_LDKSpendableOutputDescriptor_ty_from_ptr(uint32_t ptr) {
1534         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1535         switch(obj->tag) {
1536                 case LDKSpendableOutputDescriptor_StaticOutput: return 0;
1537                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: return 1;
1538                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: return 2;
1539                 default: abort();
1540         }
1541 }
1542 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticOutput_get_outpoint"))) TS_LDKSpendableOutputDescriptor_StaticOutput_get_outpoint(uint32_t ptr) {
1543         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1544         assert(obj->tag == LDKSpendableOutputDescriptor_StaticOutput);
1545                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1546                         uint32_t outpoint_ref = 0;
1547                         CHECK((((uintptr_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1548                         CHECK((((uintptr_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1549                         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
1550                         outpoint_ref = (uintptr_t)outpoint_var.inner & ~1;
1551         return outpoint_ref;
1552 }
1553 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticOutput_get_output"))) TS_LDKSpendableOutputDescriptor_StaticOutput_get_output(uint32_t ptr) {
1554         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1555         assert(obj->tag == LDKSpendableOutputDescriptor_StaticOutput);
1556                         uint32_t output_ref = ((uintptr_t)&obj->static_output.output) | 1;
1557         return (uint32_t)output_ref;
1558 }
1559 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_DelayedPaymentOutput_get_delayed_payment_output"))) TS_LDKSpendableOutputDescriptor_DelayedPaymentOutput_get_delayed_payment_output(uint32_t ptr) {
1560         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1561         assert(obj->tag == LDKSpendableOutputDescriptor_DelayedPaymentOutput);
1562                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
1563                         uint32_t delayed_payment_output_ref = 0;
1564                         CHECK((((uintptr_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1565                         CHECK((((uintptr_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1566                         CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
1567                         delayed_payment_output_ref = (uintptr_t)delayed_payment_output_var.inner & ~1;
1568         return delayed_payment_output_ref;
1569 }
1570 uint32_t __attribute__((export_name("TS_LDKSpendableOutputDescriptor_StaticPaymentOutput_get_static_payment_output"))) TS_LDKSpendableOutputDescriptor_StaticPaymentOutput_get_static_payment_output(uint32_t ptr) {
1571         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1572         assert(obj->tag == LDKSpendableOutputDescriptor_StaticPaymentOutput);
1573                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
1574                         uint32_t static_payment_output_ref = 0;
1575                         CHECK((((uintptr_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1576                         CHECK((((uintptr_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1577                         CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
1578                         static_payment_output_ref = (uintptr_t)static_payment_output_var.inner & ~1;
1579         return static_payment_output_ref;
1580 }
1581 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1582         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1583         for (size_t i = 0; i < ret.datalen; i++) {
1584                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1585         }
1586         return ret;
1587 }
1588 uint32_t __attribute__((export_name("TS_LDKPaymentPurpose_ty_from_ptr"))) TS_LDKPaymentPurpose_ty_from_ptr(uint32_t ptr) {
1589         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1590         switch(obj->tag) {
1591                 case LDKPaymentPurpose_InvoicePayment: return 0;
1592                 case LDKPaymentPurpose_SpontaneousPayment: return 1;
1593                 default: abort();
1594         }
1595 }
1596 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_InvoicePayment_get_payment_preimage"))) TS_LDKPaymentPurpose_InvoicePayment_get_payment_preimage(uint32_t ptr) {
1597         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1598         assert(obj->tag == LDKPaymentPurpose_InvoicePayment);
1599                         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
1600                         memcpy(payment_preimage_arr->elems, obj->invoice_payment.payment_preimage.data, 32);
1601         return payment_preimage_arr;
1602 }
1603 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_InvoicePayment_get_payment_secret"))) TS_LDKPaymentPurpose_InvoicePayment_get_payment_secret(uint32_t ptr) {
1604         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1605         assert(obj->tag == LDKPaymentPurpose_InvoicePayment);
1606                         int8_tArray payment_secret_arr = init_int8_tArray(32, __LINE__);
1607                         memcpy(payment_secret_arr->elems, obj->invoice_payment.payment_secret.data, 32);
1608         return payment_secret_arr;
1609 }
1610 int8_tArray __attribute__((export_name("TS_LDKPaymentPurpose_SpontaneousPayment_get_spontaneous_payment"))) TS_LDKPaymentPurpose_SpontaneousPayment_get_spontaneous_payment(uint32_t ptr) {
1611         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1612         assert(obj->tag == LDKPaymentPurpose_SpontaneousPayment);
1613                         int8_tArray spontaneous_payment_arr = init_int8_tArray(32, __LINE__);
1614                         memcpy(spontaneous_payment_arr->elems, obj->spontaneous_payment.data, 32);
1615         return spontaneous_payment_arr;
1616 }
1617 uint32_t __attribute__((export_name("TS_LDKEvent_ty_from_ptr"))) TS_LDKEvent_ty_from_ptr(uint32_t ptr) {
1618         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1619         switch(obj->tag) {
1620                 case LDKEvent_FundingGenerationReady: return 0;
1621                 case LDKEvent_PaymentReceived: return 1;
1622                 case LDKEvent_PaymentSent: return 2;
1623                 case LDKEvent_PaymentPathFailed: return 3;
1624                 case LDKEvent_PaymentFailed: return 4;
1625                 case LDKEvent_PendingHTLCsForwardable: return 5;
1626                 case LDKEvent_SpendableOutputs: return 6;
1627                 case LDKEvent_PaymentForwarded: return 7;
1628                 case LDKEvent_ChannelClosed: return 8;
1629                 case LDKEvent_DiscardFunding: return 9;
1630                 case LDKEvent_PaymentPathSuccessful: return 10;
1631                 case LDKEvent_OpenChannelRequest: return 11;
1632                 default: abort();
1633         }
1634 }
1635 int8_tArray __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_temporary_channel_id"))) TS_LDKEvent_FundingGenerationReady_get_temporary_channel_id(uint32_t ptr) {
1636         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1637         assert(obj->tag == LDKEvent_FundingGenerationReady);
1638                         int8_tArray temporary_channel_id_arr = init_int8_tArray(32, __LINE__);
1639                         memcpy(temporary_channel_id_arr->elems, obj->funding_generation_ready.temporary_channel_id.data, 32);
1640         return temporary_channel_id_arr;
1641 }
1642 int64_t __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_channel_value_satoshis"))) TS_LDKEvent_FundingGenerationReady_get_channel_value_satoshis(uint32_t ptr) {
1643         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1644         assert(obj->tag == LDKEvent_FundingGenerationReady);
1645                         int64_t channel_value_satoshis_conv = obj->funding_generation_ready.channel_value_satoshis;
1646         return channel_value_satoshis_conv;
1647 }
1648 int8_tArray __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_output_script"))) TS_LDKEvent_FundingGenerationReady_get_output_script(uint32_t ptr) {
1649         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1650         assert(obj->tag == LDKEvent_FundingGenerationReady);
1651                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
1652                         int8_tArray output_script_arr = init_int8_tArray(output_script_var.datalen, __LINE__);
1653                         memcpy(output_script_arr->elems, output_script_var.data, output_script_var.datalen);
1654         return output_script_arr;
1655 }
1656 int64_t __attribute__((export_name("TS_LDKEvent_FundingGenerationReady_get_user_channel_id"))) TS_LDKEvent_FundingGenerationReady_get_user_channel_id(uint32_t ptr) {
1657         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1658         assert(obj->tag == LDKEvent_FundingGenerationReady);
1659                         int64_t user_channel_id_conv = obj->funding_generation_ready.user_channel_id;
1660         return user_channel_id_conv;
1661 }
1662 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_payment_hash"))) TS_LDKEvent_PaymentReceived_get_payment_hash(uint32_t ptr) {
1663         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1664         assert(obj->tag == LDKEvent_PaymentReceived);
1665                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1666                         memcpy(payment_hash_arr->elems, obj->payment_received.payment_hash.data, 32);
1667         return payment_hash_arr;
1668 }
1669 int64_t __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_amt"))) TS_LDKEvent_PaymentReceived_get_amt(uint32_t ptr) {
1670         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1671         assert(obj->tag == LDKEvent_PaymentReceived);
1672                         int64_t amt_conv = obj->payment_received.amt;
1673         return amt_conv;
1674 }
1675 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentReceived_get_purpose"))) TS_LDKEvent_PaymentReceived_get_purpose(uint32_t ptr) {
1676         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1677         assert(obj->tag == LDKEvent_PaymentReceived);
1678                         uint32_t purpose_ref = ((uintptr_t)&obj->payment_received.purpose) | 1;
1679         return purpose_ref;
1680 }
1681 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_id"))) TS_LDKEvent_PaymentSent_get_payment_id(uint32_t ptr) {
1682         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1683         assert(obj->tag == LDKEvent_PaymentSent);
1684                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1685                         memcpy(payment_id_arr->elems, obj->payment_sent.payment_id.data, 32);
1686         return payment_id_arr;
1687 }
1688 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_preimage"))) TS_LDKEvent_PaymentSent_get_payment_preimage(uint32_t ptr) {
1689         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1690         assert(obj->tag == LDKEvent_PaymentSent);
1691                         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
1692                         memcpy(payment_preimage_arr->elems, obj->payment_sent.payment_preimage.data, 32);
1693         return payment_preimage_arr;
1694 }
1695 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentSent_get_payment_hash"))) TS_LDKEvent_PaymentSent_get_payment_hash(uint32_t ptr) {
1696         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1697         assert(obj->tag == LDKEvent_PaymentSent);
1698                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1699                         memcpy(payment_hash_arr->elems, obj->payment_sent.payment_hash.data, 32);
1700         return payment_hash_arr;
1701 }
1702 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentSent_get_fee_paid_msat"))) TS_LDKEvent_PaymentSent_get_fee_paid_msat(uint32_t ptr) {
1703         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1704         assert(obj->tag == LDKEvent_PaymentSent);
1705                         uint32_t fee_paid_msat_ref = ((uintptr_t)&obj->payment_sent.fee_paid_msat) | 1;
1706         return fee_paid_msat_ref;
1707 }
1708 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_payment_id"))) TS_LDKEvent_PaymentPathFailed_get_payment_id(uint32_t ptr) {
1709         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1710         assert(obj->tag == LDKEvent_PaymentPathFailed);
1711                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1712                         memcpy(payment_id_arr->elems, obj->payment_path_failed.payment_id.data, 32);
1713         return payment_id_arr;
1714 }
1715 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_payment_hash"))) TS_LDKEvent_PaymentPathFailed_get_payment_hash(uint32_t ptr) {
1716         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1717         assert(obj->tag == LDKEvent_PaymentPathFailed);
1718                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1719                         memcpy(payment_hash_arr->elems, obj->payment_path_failed.payment_hash.data, 32);
1720         return payment_hash_arr;
1721 }
1722 jboolean __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_rejected_by_dest"))) TS_LDKEvent_PaymentPathFailed_get_rejected_by_dest(uint32_t ptr) {
1723         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1724         assert(obj->tag == LDKEvent_PaymentPathFailed);
1725                         jboolean rejected_by_dest_conv = obj->payment_path_failed.rejected_by_dest;
1726         return rejected_by_dest_conv;
1727 }
1728 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_network_update"))) TS_LDKEvent_PaymentPathFailed_get_network_update(uint32_t ptr) {
1729         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1730         assert(obj->tag == LDKEvent_PaymentPathFailed);
1731                         uint32_t network_update_ref = ((uintptr_t)&obj->payment_path_failed.network_update) | 1;
1732         return network_update_ref;
1733 }
1734 jboolean __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_all_paths_failed"))) TS_LDKEvent_PaymentPathFailed_get_all_paths_failed(uint32_t ptr) {
1735         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1736         assert(obj->tag == LDKEvent_PaymentPathFailed);
1737                         jboolean all_paths_failed_conv = obj->payment_path_failed.all_paths_failed;
1738         return all_paths_failed_conv;
1739 }
1740 uint32_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_path"))) TS_LDKEvent_PaymentPathFailed_get_path(uint32_t ptr) {
1741         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1742         assert(obj->tag == LDKEvent_PaymentPathFailed);
1743                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
1744                         uint32_tArray path_arr = NULL;
1745                         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
1746                         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
1747                         for (size_t k = 0; k < path_var.datalen; k++) {
1748                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1749                                 uint32_t path_conv_10_ref = 0;
1750                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1751                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1752                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1753                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
1754                                 path_arr_ptr[k] = path_conv_10_ref;
1755                         }
1756                         
1757         return path_arr;
1758 }
1759 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_short_channel_id"))) TS_LDKEvent_PaymentPathFailed_get_short_channel_id(uint32_t ptr) {
1760         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1761         assert(obj->tag == LDKEvent_PaymentPathFailed);
1762                         uint32_t short_channel_id_ref = ((uintptr_t)&obj->payment_path_failed.short_channel_id) | 1;
1763         return short_channel_id_ref;
1764 }
1765 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentPathFailed_get_retry"))) TS_LDKEvent_PaymentPathFailed_get_retry(uint32_t ptr) {
1766         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1767         assert(obj->tag == LDKEvent_PaymentPathFailed);
1768                         LDKRouteParameters retry_var = obj->payment_path_failed.retry;
1769                         uint32_t retry_ref = 0;
1770                         if ((uintptr_t)retry_var.inner > 4096) {
1771                                 CHECK((((uintptr_t)retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1772                                 CHECK((((uintptr_t)&retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1773                         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_var);
1774                                 retry_ref = (uintptr_t)retry_var.inner & ~1;
1775                         }
1776         return retry_ref;
1777 }
1778 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentFailed_get_payment_id"))) TS_LDKEvent_PaymentFailed_get_payment_id(uint32_t ptr) {
1779         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1780         assert(obj->tag == LDKEvent_PaymentFailed);
1781                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1782                         memcpy(payment_id_arr->elems, obj->payment_failed.payment_id.data, 32);
1783         return payment_id_arr;
1784 }
1785 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentFailed_get_payment_hash"))) TS_LDKEvent_PaymentFailed_get_payment_hash(uint32_t ptr) {
1786         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1787         assert(obj->tag == LDKEvent_PaymentFailed);
1788                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1789                         memcpy(payment_hash_arr->elems, obj->payment_failed.payment_hash.data, 32);
1790         return payment_hash_arr;
1791 }
1792 int64_t __attribute__((export_name("TS_LDKEvent_PendingHTLCsForwardable_get_time_forwardable"))) TS_LDKEvent_PendingHTLCsForwardable_get_time_forwardable(uint32_t ptr) {
1793         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1794         assert(obj->tag == LDKEvent_PendingHTLCsForwardable);
1795                         int64_t time_forwardable_conv = obj->pending_htl_cs_forwardable.time_forwardable;
1796         return time_forwardable_conv;
1797 }
1798 uint32_tArray __attribute__((export_name("TS_LDKEvent_SpendableOutputs_get_outputs"))) TS_LDKEvent_SpendableOutputs_get_outputs(uint32_t ptr) {
1799         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1800         assert(obj->tag == LDKEvent_SpendableOutputs);
1801                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
1802                         uint32_tArray outputs_arr = NULL;
1803                         outputs_arr = init_uint32_tArray(outputs_var.datalen, __LINE__);
1804                         uint32_t *outputs_arr_ptr = (uint32_t*)(((uint8_t*)outputs_arr) + 4);
1805                         for (size_t b = 0; b < outputs_var.datalen; b++) {
1806                                 uint32_t outputs_conv_27_ref = ((uintptr_t)&outputs_var.data[b]) | 1;
1807                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
1808                         }
1809                         
1810         return outputs_arr;
1811 }
1812 uint32_t __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_fee_earned_msat"))) TS_LDKEvent_PaymentForwarded_get_fee_earned_msat(uint32_t ptr) {
1813         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1814         assert(obj->tag == LDKEvent_PaymentForwarded);
1815                         uint32_t fee_earned_msat_ref = ((uintptr_t)&obj->payment_forwarded.fee_earned_msat) | 1;
1816         return fee_earned_msat_ref;
1817 }
1818 jboolean __attribute__((export_name("TS_LDKEvent_PaymentForwarded_get_claim_from_onchain_tx"))) TS_LDKEvent_PaymentForwarded_get_claim_from_onchain_tx(uint32_t ptr) {
1819         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1820         assert(obj->tag == LDKEvent_PaymentForwarded);
1821                         jboolean claim_from_onchain_tx_conv = obj->payment_forwarded.claim_from_onchain_tx;
1822         return claim_from_onchain_tx_conv;
1823 }
1824 int8_tArray __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_channel_id"))) TS_LDKEvent_ChannelClosed_get_channel_id(uint32_t ptr) {
1825         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1826         assert(obj->tag == LDKEvent_ChannelClosed);
1827                         int8_tArray channel_id_arr = init_int8_tArray(32, __LINE__);
1828                         memcpy(channel_id_arr->elems, obj->channel_closed.channel_id.data, 32);
1829         return channel_id_arr;
1830 }
1831 int64_t __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_user_channel_id"))) TS_LDKEvent_ChannelClosed_get_user_channel_id(uint32_t ptr) {
1832         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1833         assert(obj->tag == LDKEvent_ChannelClosed);
1834                         int64_t user_channel_id_conv = obj->channel_closed.user_channel_id;
1835         return user_channel_id_conv;
1836 }
1837 uint32_t __attribute__((export_name("TS_LDKEvent_ChannelClosed_get_reason"))) TS_LDKEvent_ChannelClosed_get_reason(uint32_t ptr) {
1838         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1839         assert(obj->tag == LDKEvent_ChannelClosed);
1840                         uint32_t reason_ref = ((uintptr_t)&obj->channel_closed.reason) | 1;
1841         return reason_ref;
1842 }
1843 int8_tArray __attribute__((export_name("TS_LDKEvent_DiscardFunding_get_channel_id"))) TS_LDKEvent_DiscardFunding_get_channel_id(uint32_t ptr) {
1844         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1845         assert(obj->tag == LDKEvent_DiscardFunding);
1846                         int8_tArray channel_id_arr = init_int8_tArray(32, __LINE__);
1847                         memcpy(channel_id_arr->elems, obj->discard_funding.channel_id.data, 32);
1848         return channel_id_arr;
1849 }
1850 int8_tArray __attribute__((export_name("TS_LDKEvent_DiscardFunding_get_transaction"))) TS_LDKEvent_DiscardFunding_get_transaction(uint32_t ptr) {
1851         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1852         assert(obj->tag == LDKEvent_DiscardFunding);
1853                         LDKTransaction transaction_var = obj->discard_funding.transaction;
1854                         int8_tArray transaction_arr = init_int8_tArray(transaction_var.datalen, __LINE__);
1855                         memcpy(transaction_arr->elems, transaction_var.data, transaction_var.datalen);
1856         return transaction_arr;
1857 }
1858 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_payment_id"))) TS_LDKEvent_PaymentPathSuccessful_get_payment_id(uint32_t ptr) {
1859         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1860         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1861                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
1862                         memcpy(payment_id_arr->elems, obj->payment_path_successful.payment_id.data, 32);
1863         return payment_id_arr;
1864 }
1865 int8_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_payment_hash"))) TS_LDKEvent_PaymentPathSuccessful_get_payment_hash(uint32_t ptr) {
1866         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1867         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1868                         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
1869                         memcpy(payment_hash_arr->elems, obj->payment_path_successful.payment_hash.data, 32);
1870         return payment_hash_arr;
1871 }
1872 uint32_tArray __attribute__((export_name("TS_LDKEvent_PaymentPathSuccessful_get_path"))) TS_LDKEvent_PaymentPathSuccessful_get_path(uint32_t ptr) {
1873         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1874         assert(obj->tag == LDKEvent_PaymentPathSuccessful);
1875                         LDKCVec_RouteHopZ path_var = obj->payment_path_successful.path;
1876                         uint32_tArray path_arr = NULL;
1877                         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
1878                         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
1879                         for (size_t k = 0; k < path_var.datalen; k++) {
1880                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1881                                 uint32_t path_conv_10_ref = 0;
1882                                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1883                                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1884                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1885                                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner & ~1;
1886                                 path_arr_ptr[k] = path_conv_10_ref;
1887                         }
1888                         
1889         return path_arr;
1890 }
1891 int8_tArray __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_temporary_channel_id"))) TS_LDKEvent_OpenChannelRequest_get_temporary_channel_id(uint32_t ptr) {
1892         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1893         assert(obj->tag == LDKEvent_OpenChannelRequest);
1894                         int8_tArray temporary_channel_id_arr = init_int8_tArray(32, __LINE__);
1895                         memcpy(temporary_channel_id_arr->elems, obj->open_channel_request.temporary_channel_id.data, 32);
1896         return temporary_channel_id_arr;
1897 }
1898 int8_tArray __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_counterparty_node_id"))) TS_LDKEvent_OpenChannelRequest_get_counterparty_node_id(uint32_t ptr) {
1899         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1900         assert(obj->tag == LDKEvent_OpenChannelRequest);
1901                         int8_tArray counterparty_node_id_arr = init_int8_tArray(33, __LINE__);
1902                         memcpy(counterparty_node_id_arr->elems, obj->open_channel_request.counterparty_node_id.compressed_form, 33);
1903         return counterparty_node_id_arr;
1904 }
1905 int64_t __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_funding_satoshis"))) TS_LDKEvent_OpenChannelRequest_get_funding_satoshis(uint32_t ptr) {
1906         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1907         assert(obj->tag == LDKEvent_OpenChannelRequest);
1908                         int64_t funding_satoshis_conv = obj->open_channel_request.funding_satoshis;
1909         return funding_satoshis_conv;
1910 }
1911 int64_t __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_push_msat"))) TS_LDKEvent_OpenChannelRequest_get_push_msat(uint32_t ptr) {
1912         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1913         assert(obj->tag == LDKEvent_OpenChannelRequest);
1914                         int64_t push_msat_conv = obj->open_channel_request.push_msat;
1915         return push_msat_conv;
1916 }
1917 uint32_t __attribute__((export_name("TS_LDKEvent_OpenChannelRequest_get_channel_type"))) TS_LDKEvent_OpenChannelRequest_get_channel_type(uint32_t ptr) {
1918         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1919         assert(obj->tag == LDKEvent_OpenChannelRequest);
1920                         LDKChannelTypeFeatures channel_type_var = obj->open_channel_request.channel_type;
1921                         uint32_t channel_type_ref = 0;
1922                         CHECK((((uintptr_t)channel_type_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1923                         CHECK((((uintptr_t)&channel_type_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1924                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_var);
1925                         channel_type_ref = (uintptr_t)channel_type_var.inner & ~1;
1926         return channel_type_ref;
1927 }
1928 uint32_t __attribute__((export_name("TS_LDKCOption_EventZ_ty_from_ptr"))) TS_LDKCOption_EventZ_ty_from_ptr(uint32_t ptr) {
1929         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
1930         switch(obj->tag) {
1931                 case LDKCOption_EventZ_Some: return 0;
1932                 case LDKCOption_EventZ_None: return 1;
1933                 default: abort();
1934         }
1935 }
1936 uint32_t __attribute__((export_name("TS_LDKCOption_EventZ_Some_get_some"))) TS_LDKCOption_EventZ_Some_get_some(uint32_t ptr) {
1937         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
1938         assert(obj->tag == LDKCOption_EventZ_Some);
1939                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
1940         return some_ref;
1941 }
1942 static inline struct LDKCOption_EventZ CResult_COption_EventZDecodeErrorZ_get_ok(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
1943 CHECK(owner->result_ok);
1944         return COption_EventZ_clone(&*owner->contents.result);
1945 }
1946 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_get_ok"))) TS_CResult_COption_EventZDecodeErrorZ_get_ok(uint32_t owner) {
1947         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
1948         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
1949         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_ok(owner_conv);
1950         uint32_t ret_ref = (uintptr_t)ret_copy;
1951         return ret_ref;
1952 }
1953
1954 static inline struct LDKDecodeError CResult_COption_EventZDecodeErrorZ_get_err(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
1955 CHECK(!owner->result_ok);
1956         return DecodeError_clone(&*owner->contents.err);
1957 }
1958 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_get_err"))) TS_CResult_COption_EventZDecodeErrorZ_get_err(uint32_t owner) {
1959         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(owner & ~1);
1960         LDKDecodeError ret_var = CResult_COption_EventZDecodeErrorZ_get_err(owner_conv);
1961         uint32_t ret_ref = 0;
1962         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1963         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1964         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1965         ret_ref = (uintptr_t)ret_var.inner;
1966         if (ret_var.is_owned) {
1967                 ret_ref |= 1;
1968         }
1969         return ret_ref;
1970 }
1971
1972 uint32_t __attribute__((export_name("TS_LDKErrorAction_ty_from_ptr"))) TS_LDKErrorAction_ty_from_ptr(uint32_t ptr) {
1973         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1974         switch(obj->tag) {
1975                 case LDKErrorAction_DisconnectPeer: return 0;
1976                 case LDKErrorAction_IgnoreError: return 1;
1977                 case LDKErrorAction_IgnoreAndLog: return 2;
1978                 case LDKErrorAction_IgnoreDuplicateGossip: return 3;
1979                 case LDKErrorAction_SendErrorMessage: return 4;
1980                 case LDKErrorAction_SendWarningMessage: return 5;
1981                 default: abort();
1982         }
1983 }
1984 uint32_t __attribute__((export_name("TS_LDKErrorAction_DisconnectPeer_get_msg"))) TS_LDKErrorAction_DisconnectPeer_get_msg(uint32_t ptr) {
1985         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1986         assert(obj->tag == LDKErrorAction_DisconnectPeer);
1987                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
1988                         uint32_t msg_ref = 0;
1989                         if ((uintptr_t)msg_var.inner > 4096) {
1990                                 CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1991                                 CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1992                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1993                                 msg_ref = (uintptr_t)msg_var.inner & ~1;
1994                         }
1995         return msg_ref;
1996 }
1997 uint32_t __attribute__((export_name("TS_LDKErrorAction_IgnoreAndLog_get_ignore_and_log"))) TS_LDKErrorAction_IgnoreAndLog_get_ignore_and_log(uint32_t ptr) {
1998         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
1999         assert(obj->tag == LDKErrorAction_IgnoreAndLog);
2000                         uint32_t ignore_and_log_conv = LDKLevel_to_js(obj->ignore_and_log);
2001         return ignore_and_log_conv;
2002 }
2003 uint32_t __attribute__((export_name("TS_LDKErrorAction_SendErrorMessage_get_msg"))) TS_LDKErrorAction_SendErrorMessage_get_msg(uint32_t ptr) {
2004         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2005         assert(obj->tag == LDKErrorAction_SendErrorMessage);
2006                         LDKErrorMessage msg_var = obj->send_error_message.msg;
2007                         uint32_t msg_ref = 0;
2008                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2009                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2010                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2011                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2012         return msg_ref;
2013 }
2014 uint32_t __attribute__((export_name("TS_LDKErrorAction_SendWarningMessage_get_msg"))) TS_LDKErrorAction_SendWarningMessage_get_msg(uint32_t ptr) {
2015         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2016         assert(obj->tag == LDKErrorAction_SendWarningMessage);
2017                         LDKWarningMessage msg_var = obj->send_warning_message.msg;
2018                         uint32_t msg_ref = 0;
2019                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2020                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2021                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2022                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2023         return msg_ref;
2024 }
2025 uint32_t __attribute__((export_name("TS_LDKErrorAction_SendWarningMessage_get_log_level"))) TS_LDKErrorAction_SendWarningMessage_get_log_level(uint32_t ptr) {
2026         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2027         assert(obj->tag == LDKErrorAction_SendWarningMessage);
2028                         uint32_t log_level_conv = LDKLevel_to_js(obj->send_warning_message.log_level);
2029         return log_level_conv;
2030 }
2031 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_ty_from_ptr"))) TS_LDKMessageSendEvent_ty_from_ptr(uint32_t ptr) {
2032         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2033         switch(obj->tag) {
2034                 case LDKMessageSendEvent_SendAcceptChannel: return 0;
2035                 case LDKMessageSendEvent_SendOpenChannel: return 1;
2036                 case LDKMessageSendEvent_SendFundingCreated: return 2;
2037                 case LDKMessageSendEvent_SendFundingSigned: return 3;
2038                 case LDKMessageSendEvent_SendFundingLocked: return 4;
2039                 case LDKMessageSendEvent_SendAnnouncementSignatures: return 5;
2040                 case LDKMessageSendEvent_UpdateHTLCs: return 6;
2041                 case LDKMessageSendEvent_SendRevokeAndACK: return 7;
2042                 case LDKMessageSendEvent_SendClosingSigned: return 8;
2043                 case LDKMessageSendEvent_SendShutdown: return 9;
2044                 case LDKMessageSendEvent_SendChannelReestablish: return 10;
2045                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: return 11;
2046                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: return 12;
2047                 case LDKMessageSendEvent_BroadcastChannelUpdate: return 13;
2048                 case LDKMessageSendEvent_SendChannelUpdate: return 14;
2049                 case LDKMessageSendEvent_HandleError: return 15;
2050                 case LDKMessageSendEvent_SendChannelRangeQuery: return 16;
2051                 case LDKMessageSendEvent_SendShortIdsQuery: return 17;
2052                 case LDKMessageSendEvent_SendReplyChannelRange: return 18;
2053                 case LDKMessageSendEvent_SendGossipTimestampFilter: return 19;
2054                 default: abort();
2055         }
2056 }
2057 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendAcceptChannel_get_node_id"))) TS_LDKMessageSendEvent_SendAcceptChannel_get_node_id(uint32_t ptr) {
2058         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2059         assert(obj->tag == LDKMessageSendEvent_SendAcceptChannel);
2060                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2061                         memcpy(node_id_arr->elems, obj->send_accept_channel.node_id.compressed_form, 33);
2062         return node_id_arr;
2063 }
2064 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendAcceptChannel_get_msg"))) TS_LDKMessageSendEvent_SendAcceptChannel_get_msg(uint32_t ptr) {
2065         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2066         assert(obj->tag == LDKMessageSendEvent_SendAcceptChannel);
2067                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
2068                         uint32_t msg_ref = 0;
2069                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2070                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2071                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2072                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2073         return msg_ref;
2074 }
2075 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendOpenChannel_get_node_id"))) TS_LDKMessageSendEvent_SendOpenChannel_get_node_id(uint32_t ptr) {
2076         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2077         assert(obj->tag == LDKMessageSendEvent_SendOpenChannel);
2078                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2079                         memcpy(node_id_arr->elems, obj->send_open_channel.node_id.compressed_form, 33);
2080         return node_id_arr;
2081 }
2082 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendOpenChannel_get_msg"))) TS_LDKMessageSendEvent_SendOpenChannel_get_msg(uint32_t ptr) {
2083         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2084         assert(obj->tag == LDKMessageSendEvent_SendOpenChannel);
2085                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
2086                         uint32_t msg_ref = 0;
2087                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2088                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2089                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2090                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2091         return msg_ref;
2092 }
2093 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingCreated_get_node_id"))) TS_LDKMessageSendEvent_SendFundingCreated_get_node_id(uint32_t ptr) {
2094         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2095         assert(obj->tag == LDKMessageSendEvent_SendFundingCreated);
2096                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2097                         memcpy(node_id_arr->elems, obj->send_funding_created.node_id.compressed_form, 33);
2098         return node_id_arr;
2099 }
2100 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingCreated_get_msg"))) TS_LDKMessageSendEvent_SendFundingCreated_get_msg(uint32_t ptr) {
2101         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2102         assert(obj->tag == LDKMessageSendEvent_SendFundingCreated);
2103                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
2104                         uint32_t msg_ref = 0;
2105                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2106                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2107                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2108                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2109         return msg_ref;
2110 }
2111 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingSigned_get_node_id"))) TS_LDKMessageSendEvent_SendFundingSigned_get_node_id(uint32_t ptr) {
2112         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2113         assert(obj->tag == LDKMessageSendEvent_SendFundingSigned);
2114                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2115                         memcpy(node_id_arr->elems, obj->send_funding_signed.node_id.compressed_form, 33);
2116         return node_id_arr;
2117 }
2118 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingSigned_get_msg"))) TS_LDKMessageSendEvent_SendFundingSigned_get_msg(uint32_t ptr) {
2119         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2120         assert(obj->tag == LDKMessageSendEvent_SendFundingSigned);
2121                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
2122                         uint32_t msg_ref = 0;
2123                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2124                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2125                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2126                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2127         return msg_ref;
2128 }
2129 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingLocked_get_node_id"))) TS_LDKMessageSendEvent_SendFundingLocked_get_node_id(uint32_t ptr) {
2130         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2131         assert(obj->tag == LDKMessageSendEvent_SendFundingLocked);
2132                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2133                         memcpy(node_id_arr->elems, obj->send_funding_locked.node_id.compressed_form, 33);
2134         return node_id_arr;
2135 }
2136 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendFundingLocked_get_msg"))) TS_LDKMessageSendEvent_SendFundingLocked_get_msg(uint32_t ptr) {
2137         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2138         assert(obj->tag == LDKMessageSendEvent_SendFundingLocked);
2139                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
2140                         uint32_t msg_ref = 0;
2141                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2142                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2143                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2144                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2145         return msg_ref;
2146 }
2147 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_node_id"))) TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_node_id(uint32_t ptr) {
2148         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2149         assert(obj->tag == LDKMessageSendEvent_SendAnnouncementSignatures);
2150                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2151                         memcpy(node_id_arr->elems, obj->send_announcement_signatures.node_id.compressed_form, 33);
2152         return node_id_arr;
2153 }
2154 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_msg"))) TS_LDKMessageSendEvent_SendAnnouncementSignatures_get_msg(uint32_t ptr) {
2155         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2156         assert(obj->tag == LDKMessageSendEvent_SendAnnouncementSignatures);
2157                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
2158                         uint32_t msg_ref = 0;
2159                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2160                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2161                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2162                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2163         return msg_ref;
2164 }
2165 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_UpdateHTLCs_get_node_id"))) TS_LDKMessageSendEvent_UpdateHTLCs_get_node_id(uint32_t ptr) {
2166         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2167         assert(obj->tag == LDKMessageSendEvent_UpdateHTLCs);
2168                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2169                         memcpy(node_id_arr->elems, obj->update_htl_cs.node_id.compressed_form, 33);
2170         return node_id_arr;
2171 }
2172 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_UpdateHTLCs_get_updates"))) TS_LDKMessageSendEvent_UpdateHTLCs_get_updates(uint32_t ptr) {
2173         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2174         assert(obj->tag == LDKMessageSendEvent_UpdateHTLCs);
2175                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
2176                         uint32_t updates_ref = 0;
2177                         CHECK((((uintptr_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2178                         CHECK((((uintptr_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2179                         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
2180                         updates_ref = (uintptr_t)updates_var.inner & ~1;
2181         return updates_ref;
2182 }
2183 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendRevokeAndACK_get_node_id"))) TS_LDKMessageSendEvent_SendRevokeAndACK_get_node_id(uint32_t ptr) {
2184         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2185         assert(obj->tag == LDKMessageSendEvent_SendRevokeAndACK);
2186                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2187                         memcpy(node_id_arr->elems, obj->send_revoke_and_ack.node_id.compressed_form, 33);
2188         return node_id_arr;
2189 }
2190 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendRevokeAndACK_get_msg"))) TS_LDKMessageSendEvent_SendRevokeAndACK_get_msg(uint32_t ptr) {
2191         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2192         assert(obj->tag == LDKMessageSendEvent_SendRevokeAndACK);
2193                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
2194                         uint32_t msg_ref = 0;
2195                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2196                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2197                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2198                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2199         return msg_ref;
2200 }
2201 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendClosingSigned_get_node_id"))) TS_LDKMessageSendEvent_SendClosingSigned_get_node_id(uint32_t ptr) {
2202         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2203         assert(obj->tag == LDKMessageSendEvent_SendClosingSigned);
2204                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2205                         memcpy(node_id_arr->elems, obj->send_closing_signed.node_id.compressed_form, 33);
2206         return node_id_arr;
2207 }
2208 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendClosingSigned_get_msg"))) TS_LDKMessageSendEvent_SendClosingSigned_get_msg(uint32_t ptr) {
2209         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2210         assert(obj->tag == LDKMessageSendEvent_SendClosingSigned);
2211                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
2212                         uint32_t msg_ref = 0;
2213                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2214                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2215                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2216                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2217         return msg_ref;
2218 }
2219 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendShutdown_get_node_id"))) TS_LDKMessageSendEvent_SendShutdown_get_node_id(uint32_t ptr) {
2220         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2221         assert(obj->tag == LDKMessageSendEvent_SendShutdown);
2222                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2223                         memcpy(node_id_arr->elems, obj->send_shutdown.node_id.compressed_form, 33);
2224         return node_id_arr;
2225 }
2226 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendShutdown_get_msg"))) TS_LDKMessageSendEvent_SendShutdown_get_msg(uint32_t ptr) {
2227         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2228         assert(obj->tag == LDKMessageSendEvent_SendShutdown);
2229                         LDKShutdown msg_var = obj->send_shutdown.msg;
2230                         uint32_t msg_ref = 0;
2231                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2232                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2233                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2234                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2235         return msg_ref;
2236 }
2237 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReestablish_get_node_id"))) TS_LDKMessageSendEvent_SendChannelReestablish_get_node_id(uint32_t ptr) {
2238         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2239         assert(obj->tag == LDKMessageSendEvent_SendChannelReestablish);
2240                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2241                         memcpy(node_id_arr->elems, obj->send_channel_reestablish.node_id.compressed_form, 33);
2242         return node_id_arr;
2243 }
2244 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelReestablish_get_msg"))) TS_LDKMessageSendEvent_SendChannelReestablish_get_msg(uint32_t ptr) {
2245         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2246         assert(obj->tag == LDKMessageSendEvent_SendChannelReestablish);
2247                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
2248                         uint32_t msg_ref = 0;
2249                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2250                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2251                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2252                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2253         return msg_ref;
2254 }
2255 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_msg"))) TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_msg(uint32_t ptr) {
2256         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2257         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelAnnouncement);
2258                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
2259                         uint32_t msg_ref = 0;
2260                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2261                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2262                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2263                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2264         return msg_ref;
2265 }
2266 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_update_msg"))) TS_LDKMessageSendEvent_BroadcastChannelAnnouncement_get_update_msg(uint32_t ptr) {
2267         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2268         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelAnnouncement);
2269                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
2270                         uint32_t update_msg_ref = 0;
2271                         CHECK((((uintptr_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2272                         CHECK((((uintptr_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2273                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
2274                         update_msg_ref = (uintptr_t)update_msg_var.inner & ~1;
2275         return update_msg_ref;
2276 }
2277 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastNodeAnnouncement_get_msg"))) TS_LDKMessageSendEvent_BroadcastNodeAnnouncement_get_msg(uint32_t ptr) {
2278         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2279         assert(obj->tag == LDKMessageSendEvent_BroadcastNodeAnnouncement);
2280                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
2281                         uint32_t msg_ref = 0;
2282                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2283                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2284                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2285                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2286         return msg_ref;
2287 }
2288 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_BroadcastChannelUpdate_get_msg"))) TS_LDKMessageSendEvent_BroadcastChannelUpdate_get_msg(uint32_t ptr) {
2289         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2290         assert(obj->tag == LDKMessageSendEvent_BroadcastChannelUpdate);
2291                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
2292                         uint32_t msg_ref = 0;
2293                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2294                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2295                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2296                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2297         return msg_ref;
2298 }
2299 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelUpdate_get_node_id"))) TS_LDKMessageSendEvent_SendChannelUpdate_get_node_id(uint32_t ptr) {
2300         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2301         assert(obj->tag == LDKMessageSendEvent_SendChannelUpdate);
2302                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2303                         memcpy(node_id_arr->elems, obj->send_channel_update.node_id.compressed_form, 33);
2304         return node_id_arr;
2305 }
2306 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelUpdate_get_msg"))) TS_LDKMessageSendEvent_SendChannelUpdate_get_msg(uint32_t ptr) {
2307         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2308         assert(obj->tag == LDKMessageSendEvent_SendChannelUpdate);
2309                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
2310                         uint32_t msg_ref = 0;
2311                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2312                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2313                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2314                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2315         return msg_ref;
2316 }
2317 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_HandleError_get_node_id"))) TS_LDKMessageSendEvent_HandleError_get_node_id(uint32_t ptr) {
2318         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2319         assert(obj->tag == LDKMessageSendEvent_HandleError);
2320                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2321                         memcpy(node_id_arr->elems, obj->handle_error.node_id.compressed_form, 33);
2322         return node_id_arr;
2323 }
2324 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_HandleError_get_action"))) TS_LDKMessageSendEvent_HandleError_get_action(uint32_t ptr) {
2325         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2326         assert(obj->tag == LDKMessageSendEvent_HandleError);
2327                         uint32_t action_ref = ((uintptr_t)&obj->handle_error.action) | 1;
2328         return action_ref;
2329 }
2330 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelRangeQuery_get_node_id"))) TS_LDKMessageSendEvent_SendChannelRangeQuery_get_node_id(uint32_t ptr) {
2331         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2332         assert(obj->tag == LDKMessageSendEvent_SendChannelRangeQuery);
2333                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2334                         memcpy(node_id_arr->elems, obj->send_channel_range_query.node_id.compressed_form, 33);
2335         return node_id_arr;
2336 }
2337 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendChannelRangeQuery_get_msg"))) TS_LDKMessageSendEvent_SendChannelRangeQuery_get_msg(uint32_t ptr) {
2338         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2339         assert(obj->tag == LDKMessageSendEvent_SendChannelRangeQuery);
2340                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
2341                         uint32_t msg_ref = 0;
2342                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2343                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2344                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2345                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2346         return msg_ref;
2347 }
2348 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendShortIdsQuery_get_node_id"))) TS_LDKMessageSendEvent_SendShortIdsQuery_get_node_id(uint32_t ptr) {
2349         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2350         assert(obj->tag == LDKMessageSendEvent_SendShortIdsQuery);
2351                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2352                         memcpy(node_id_arr->elems, obj->send_short_ids_query.node_id.compressed_form, 33);
2353         return node_id_arr;
2354 }
2355 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendShortIdsQuery_get_msg"))) TS_LDKMessageSendEvent_SendShortIdsQuery_get_msg(uint32_t ptr) {
2356         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2357         assert(obj->tag == LDKMessageSendEvent_SendShortIdsQuery);
2358                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
2359                         uint32_t msg_ref = 0;
2360                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2361                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2362                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2363                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2364         return msg_ref;
2365 }
2366 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendReplyChannelRange_get_node_id"))) TS_LDKMessageSendEvent_SendReplyChannelRange_get_node_id(uint32_t ptr) {
2367         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2368         assert(obj->tag == LDKMessageSendEvent_SendReplyChannelRange);
2369                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2370                         memcpy(node_id_arr->elems, obj->send_reply_channel_range.node_id.compressed_form, 33);
2371         return node_id_arr;
2372 }
2373 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendReplyChannelRange_get_msg"))) TS_LDKMessageSendEvent_SendReplyChannelRange_get_msg(uint32_t ptr) {
2374         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2375         assert(obj->tag == LDKMessageSendEvent_SendReplyChannelRange);
2376                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
2377                         uint32_t msg_ref = 0;
2378                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2379                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2380                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2381                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2382         return msg_ref;
2383 }
2384 int8_tArray __attribute__((export_name("TS_LDKMessageSendEvent_SendGossipTimestampFilter_get_node_id"))) TS_LDKMessageSendEvent_SendGossipTimestampFilter_get_node_id(uint32_t ptr) {
2385         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2386         assert(obj->tag == LDKMessageSendEvent_SendGossipTimestampFilter);
2387                         int8_tArray node_id_arr = init_int8_tArray(33, __LINE__);
2388                         memcpy(node_id_arr->elems, obj->send_gossip_timestamp_filter.node_id.compressed_form, 33);
2389         return node_id_arr;
2390 }
2391 uint32_t __attribute__((export_name("TS_LDKMessageSendEvent_SendGossipTimestampFilter_get_msg"))) TS_LDKMessageSendEvent_SendGossipTimestampFilter_get_msg(uint32_t ptr) {
2392         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2393         assert(obj->tag == LDKMessageSendEvent_SendGossipTimestampFilter);
2394                         LDKGossipTimestampFilter msg_var = obj->send_gossip_timestamp_filter.msg;
2395                         uint32_t msg_ref = 0;
2396                         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2397                         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2398                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2399                         msg_ref = (uintptr_t)msg_var.inner & ~1;
2400         return msg_ref;
2401 }
2402 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
2403         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
2404         for (size_t i = 0; i < ret.datalen; i++) {
2405                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
2406         }
2407         return ret;
2408 }
2409 static inline struct LDKFixedPenaltyScorer CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
2410 CHECK(owner->result_ok);
2411         return FixedPenaltyScorer_clone(&*owner->contents.result);
2412 }
2413 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_ok"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(uint32_t owner) {
2414         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
2415         LDKFixedPenaltyScorer ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(owner_conv);
2416         uint32_t ret_ref = 0;
2417         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2418         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2419         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2420         ret_ref = (uintptr_t)ret_var.inner;
2421         if (ret_var.is_owned) {
2422                 ret_ref |= 1;
2423         }
2424         return ret_ref;
2425 }
2426
2427 static inline struct LDKDecodeError CResult_FixedPenaltyScorerDecodeErrorZ_get_err(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
2428 CHECK(!owner->result_ok);
2429         return DecodeError_clone(&*owner->contents.err);
2430 }
2431 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_err"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_get_err(uint32_t owner) {
2432         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(owner & ~1);
2433         LDKDecodeError ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_err(owner_conv);
2434         uint32_t ret_ref = 0;
2435         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2436         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2437         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2438         ret_ref = (uintptr_t)ret_var.inner;
2439         if (ret_var.is_owned) {
2440                 ret_ref |= 1;
2441         }
2442         return ret_ref;
2443 }
2444
2445 static inline struct LDKScoringParameters CResult_ScoringParametersDecodeErrorZ_get_ok(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR owner){
2446 CHECK(owner->result_ok);
2447         return ScoringParameters_clone(&*owner->contents.result);
2448 }
2449 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_get_ok"))) TS_CResult_ScoringParametersDecodeErrorZ_get_ok(uint32_t owner) {
2450         LDKCResult_ScoringParametersDecodeErrorZ* owner_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(owner & ~1);
2451         LDKScoringParameters ret_var = CResult_ScoringParametersDecodeErrorZ_get_ok(owner_conv);
2452         uint32_t ret_ref = 0;
2453         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2454         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2455         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2456         ret_ref = (uintptr_t)ret_var.inner;
2457         if (ret_var.is_owned) {
2458                 ret_ref |= 1;
2459         }
2460         return ret_ref;
2461 }
2462
2463 static inline struct LDKDecodeError CResult_ScoringParametersDecodeErrorZ_get_err(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR owner){
2464 CHECK(!owner->result_ok);
2465         return DecodeError_clone(&*owner->contents.err);
2466 }
2467 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_get_err"))) TS_CResult_ScoringParametersDecodeErrorZ_get_err(uint32_t owner) {
2468         LDKCResult_ScoringParametersDecodeErrorZ* owner_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(owner & ~1);
2469         LDKDecodeError ret_var = CResult_ScoringParametersDecodeErrorZ_get_err(owner_conv);
2470         uint32_t ret_ref = 0;
2471         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2472         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2473         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2474         ret_ref = (uintptr_t)ret_var.inner;
2475         if (ret_var.is_owned) {
2476                 ret_ref |= 1;
2477         }
2478         return ret_ref;
2479 }
2480
2481 static inline struct LDKScorer *CResult_ScorerDecodeErrorZ_get_ok(LDKCResult_ScorerDecodeErrorZ *NONNULL_PTR owner){
2482 CHECK(owner->result_ok);
2483         return &*owner->contents.result;
2484 }
2485 uint32_t  __attribute__((export_name("TS_CResult_ScorerDecodeErrorZ_get_ok"))) TS_CResult_ScorerDecodeErrorZ_get_ok(uint32_t owner) {
2486         LDKCResult_ScorerDecodeErrorZ* owner_conv = (LDKCResult_ScorerDecodeErrorZ*)(owner & ~1);
2487         LDKScorer ret_var = *CResult_ScorerDecodeErrorZ_get_ok(owner_conv);
2488         uint32_t ret_ref = 0;
2489         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2490         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2491         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2492         ret_ref = (uintptr_t)ret_var.inner & ~1;
2493         return ret_ref;
2494 }
2495
2496 static inline struct LDKDecodeError CResult_ScorerDecodeErrorZ_get_err(LDKCResult_ScorerDecodeErrorZ *NONNULL_PTR owner){
2497 CHECK(!owner->result_ok);
2498         return DecodeError_clone(&*owner->contents.err);
2499 }
2500 uint32_t  __attribute__((export_name("TS_CResult_ScorerDecodeErrorZ_get_err"))) TS_CResult_ScorerDecodeErrorZ_get_err(uint32_t owner) {
2501         LDKCResult_ScorerDecodeErrorZ* owner_conv = (LDKCResult_ScorerDecodeErrorZ*)(owner & ~1);
2502         LDKDecodeError ret_var = CResult_ScorerDecodeErrorZ_get_err(owner_conv);
2503         uint32_t ret_ref = 0;
2504         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2505         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2506         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2507         ret_ref = (uintptr_t)ret_var.inner;
2508         if (ret_var.is_owned) {
2509                 ret_ref |= 1;
2510         }
2511         return ret_ref;
2512 }
2513
2514 static inline struct LDKProbabilisticScorer *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
2515 CHECK(owner->result_ok);
2516         return &*owner->contents.result;
2517 }
2518 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_get_ok"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_get_ok(uint32_t owner) {
2519         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(owner & ~1);
2520         LDKProbabilisticScorer ret_var = *CResult_ProbabilisticScorerDecodeErrorZ_get_ok(owner_conv);
2521         uint32_t ret_ref = 0;
2522         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2523         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2524         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2525         ret_ref = (uintptr_t)ret_var.inner & ~1;
2526         return ret_ref;
2527 }
2528
2529 static inline struct LDKDecodeError CResult_ProbabilisticScorerDecodeErrorZ_get_err(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
2530 CHECK(!owner->result_ok);
2531         return DecodeError_clone(&*owner->contents.err);
2532 }
2533 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_get_err"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_get_err(uint32_t owner) {
2534         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(owner & ~1);
2535         LDKDecodeError ret_var = CResult_ProbabilisticScorerDecodeErrorZ_get_err(owner_conv);
2536         uint32_t ret_ref = 0;
2537         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2538         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2539         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2540         ret_ref = (uintptr_t)ret_var.inner;
2541         if (ret_var.is_owned) {
2542                 ret_ref |= 1;
2543         }
2544         return ret_ref;
2545 }
2546
2547 static inline struct LDKInitFeatures CResult_InitFeaturesDecodeErrorZ_get_ok(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
2548 CHECK(owner->result_ok);
2549         return InitFeatures_clone(&*owner->contents.result);
2550 }
2551 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_get_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2552         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
2553         LDKInitFeatures ret_var = CResult_InitFeaturesDecodeErrorZ_get_ok(owner_conv);
2554         uint32_t ret_ref = 0;
2555         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2556         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2557         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2558         ret_ref = (uintptr_t)ret_var.inner;
2559         if (ret_var.is_owned) {
2560                 ret_ref |= 1;
2561         }
2562         return ret_ref;
2563 }
2564
2565 static inline struct LDKDecodeError CResult_InitFeaturesDecodeErrorZ_get_err(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
2566 CHECK(!owner->result_ok);
2567         return DecodeError_clone(&*owner->contents.err);
2568 }
2569 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_get_err"))) TS_CResult_InitFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2570         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(owner & ~1);
2571         LDKDecodeError ret_var = CResult_InitFeaturesDecodeErrorZ_get_err(owner_conv);
2572         uint32_t ret_ref = 0;
2573         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2574         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2575         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2576         ret_ref = (uintptr_t)ret_var.inner;
2577         if (ret_var.is_owned) {
2578                 ret_ref |= 1;
2579         }
2580         return ret_ref;
2581 }
2582
2583 static inline struct LDKChannelFeatures CResult_ChannelFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
2584 CHECK(owner->result_ok);
2585         return ChannelFeatures_clone(&*owner->contents.result);
2586 }
2587 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_get_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2588         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
2589         LDKChannelFeatures ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_ok(owner_conv);
2590         uint32_t ret_ref = 0;
2591         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2592         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2593         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2594         ret_ref = (uintptr_t)ret_var.inner;
2595         if (ret_var.is_owned) {
2596                 ret_ref |= 1;
2597         }
2598         return ret_ref;
2599 }
2600
2601 static inline struct LDKDecodeError CResult_ChannelFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
2602 CHECK(!owner->result_ok);
2603         return DecodeError_clone(&*owner->contents.err);
2604 }
2605 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_get_err"))) TS_CResult_ChannelFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2606         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(owner & ~1);
2607         LDKDecodeError ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_err(owner_conv);
2608         uint32_t ret_ref = 0;
2609         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2610         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2611         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2612         ret_ref = (uintptr_t)ret_var.inner;
2613         if (ret_var.is_owned) {
2614                 ret_ref |= 1;
2615         }
2616         return ret_ref;
2617 }
2618
2619 static inline struct LDKNodeFeatures CResult_NodeFeaturesDecodeErrorZ_get_ok(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2620 CHECK(owner->result_ok);
2621         return NodeFeatures_clone(&*owner->contents.result);
2622 }
2623 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_get_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2624         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
2625         LDKNodeFeatures ret_var = CResult_NodeFeaturesDecodeErrorZ_get_ok(owner_conv);
2626         uint32_t ret_ref = 0;
2627         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2628         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2629         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2630         ret_ref = (uintptr_t)ret_var.inner;
2631         if (ret_var.is_owned) {
2632                 ret_ref |= 1;
2633         }
2634         return ret_ref;
2635 }
2636
2637 static inline struct LDKDecodeError CResult_NodeFeaturesDecodeErrorZ_get_err(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2638 CHECK(!owner->result_ok);
2639         return DecodeError_clone(&*owner->contents.err);
2640 }
2641 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_get_err"))) TS_CResult_NodeFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2642         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(owner & ~1);
2643         LDKDecodeError ret_var = CResult_NodeFeaturesDecodeErrorZ_get_err(owner_conv);
2644         uint32_t ret_ref = 0;
2645         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2646         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2647         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2648         ret_ref = (uintptr_t)ret_var.inner;
2649         if (ret_var.is_owned) {
2650                 ret_ref |= 1;
2651         }
2652         return ret_ref;
2653 }
2654
2655 static inline struct LDKInvoiceFeatures CResult_InvoiceFeaturesDecodeErrorZ_get_ok(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
2656 CHECK(owner->result_ok);
2657         return InvoiceFeatures_clone(&*owner->contents.result);
2658 }
2659 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_get_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2660         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
2661         LDKInvoiceFeatures ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_ok(owner_conv);
2662         uint32_t ret_ref = 0;
2663         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2664         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2665         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2666         ret_ref = (uintptr_t)ret_var.inner;
2667         if (ret_var.is_owned) {
2668                 ret_ref |= 1;
2669         }
2670         return ret_ref;
2671 }
2672
2673 static inline struct LDKDecodeError CResult_InvoiceFeaturesDecodeErrorZ_get_err(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
2674 CHECK(!owner->result_ok);
2675         return DecodeError_clone(&*owner->contents.err);
2676 }
2677 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_get_err"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2678         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(owner & ~1);
2679         LDKDecodeError ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_err(owner_conv);
2680         uint32_t ret_ref = 0;
2681         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2682         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2683         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2684         ret_ref = (uintptr_t)ret_var.inner;
2685         if (ret_var.is_owned) {
2686                 ret_ref |= 1;
2687         }
2688         return ret_ref;
2689 }
2690
2691 static inline struct LDKChannelTypeFeatures CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2692 CHECK(owner->result_ok);
2693         return ChannelTypeFeatures_clone(&*owner->contents.result);
2694 }
2695 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(uint32_t owner) {
2696         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
2697         LDKChannelTypeFeatures ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(owner_conv);
2698         uint32_t ret_ref = 0;
2699         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2700         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2701         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2702         ret_ref = (uintptr_t)ret_var.inner;
2703         if (ret_var.is_owned) {
2704                 ret_ref |= 1;
2705         }
2706         return ret_ref;
2707 }
2708
2709 static inline struct LDKDecodeError CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
2710 CHECK(!owner->result_ok);
2711         return DecodeError_clone(&*owner->contents.err);
2712 }
2713 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_err"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(uint32_t owner) {
2714         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(owner & ~1);
2715         LDKDecodeError ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(owner_conv);
2716         uint32_t ret_ref = 0;
2717         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2718         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2719         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2720         ret_ref = (uintptr_t)ret_var.inner;
2721         if (ret_var.is_owned) {
2722                 ret_ref |= 1;
2723         }
2724         return ret_ref;
2725 }
2726
2727 static inline struct LDKDelayedPaymentOutputDescriptor CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
2728 CHECK(owner->result_ok);
2729         return DelayedPaymentOutputDescriptor_clone(&*owner->contents.result);
2730 }
2731 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
2732         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
2733         LDKDelayedPaymentOutputDescriptor ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
2734         uint32_t ret_ref = 0;
2735         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2736         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2737         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2738         ret_ref = (uintptr_t)ret_var.inner;
2739         if (ret_var.is_owned) {
2740                 ret_ref |= 1;
2741         }
2742         return ret_ref;
2743 }
2744
2745 static inline struct LDKDecodeError CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
2746 CHECK(!owner->result_ok);
2747         return DecodeError_clone(&*owner->contents.err);
2748 }
2749 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
2750         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
2751         LDKDecodeError ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
2752         uint32_t ret_ref = 0;
2753         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2754         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2755         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2756         ret_ref = (uintptr_t)ret_var.inner;
2757         if (ret_var.is_owned) {
2758                 ret_ref |= 1;
2759         }
2760         return ret_ref;
2761 }
2762
2763 static inline struct LDKStaticPaymentOutputDescriptor CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
2764 CHECK(owner->result_ok);
2765         return StaticPaymentOutputDescriptor_clone(&*owner->contents.result);
2766 }
2767 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
2768         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
2769         LDKStaticPaymentOutputDescriptor ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
2770         uint32_t ret_ref = 0;
2771         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2772         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2773         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2774         ret_ref = (uintptr_t)ret_var.inner;
2775         if (ret_var.is_owned) {
2776                 ret_ref |= 1;
2777         }
2778         return ret_ref;
2779 }
2780
2781 static inline struct LDKDecodeError CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
2782 CHECK(!owner->result_ok);
2783         return DecodeError_clone(&*owner->contents.err);
2784 }
2785 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
2786         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(owner & ~1);
2787         LDKDecodeError ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
2788         uint32_t ret_ref = 0;
2789         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2790         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2791         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2792         ret_ref = (uintptr_t)ret_var.inner;
2793         if (ret_var.is_owned) {
2794                 ret_ref |= 1;
2795         }
2796         return ret_ref;
2797 }
2798
2799 static inline struct LDKSpendableOutputDescriptor CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
2800 CHECK(owner->result_ok);
2801         return SpendableOutputDescriptor_clone(&*owner->contents.result);
2802 }
2803 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(uint32_t owner) {
2804         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
2805         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
2806         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
2807         uint32_t ret_ref = (uintptr_t)ret_copy;
2808         return ret_ref;
2809 }
2810
2811 static inline struct LDKDecodeError CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
2812 CHECK(!owner->result_ok);
2813         return DecodeError_clone(&*owner->contents.err);
2814 }
2815 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_err"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(uint32_t owner) {
2816         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(owner & ~1);
2817         LDKDecodeError ret_var = CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(owner_conv);
2818         uint32_t ret_ref = 0;
2819         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2820         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2821         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2822         ret_ref = (uintptr_t)ret_var.inner;
2823         if (ret_var.is_owned) {
2824                 ret_ref |= 1;
2825         }
2826         return ret_ref;
2827 }
2828
2829 static inline LDKCVec_PaymentPreimageZ CVec_PaymentPreimageZ_clone(const LDKCVec_PaymentPreimageZ *orig) {
2830         LDKCVec_PaymentPreimageZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_PaymentPreimageZ clone bytes"), .datalen = orig->datalen };
2831         for (size_t i = 0; i < ret.datalen; i++) {
2832                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
2833         }
2834         return ret;
2835 }
2836 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
2837         return owner->a;
2838 }
2839 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_get_a"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_a(uint32_t owner) {
2840         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
2841         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
2842         memcpy(ret_arr->elems, C2Tuple_SignatureCVec_SignatureZZ_get_a(owner_conv).compact_form, 64);
2843         return ret_arr;
2844 }
2845
2846 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
2847         return owner->b;
2848 }
2849 ptrArray  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_get_b"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_b(uint32_t owner) {
2850         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(owner & ~1);
2851         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(owner_conv);
2852         ptrArray ret_arr = NULL;
2853         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
2854         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
2855         for (size_t m = 0; m < ret_var.datalen; m++) {
2856                 int8_tArray ret_conv_12_arr = init_int8_tArray(64, __LINE__);
2857                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compact_form, 64);
2858                 ret_arr_ptr[m] = ret_conv_12_arr;
2859         }
2860         
2861         return ret_arr;
2862 }
2863
2864 static inline struct LDKC2Tuple_SignatureCVec_SignatureZZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
2865 CHECK(owner->result_ok);
2866         return C2Tuple_SignatureCVec_SignatureZZ_clone(&*owner->contents.result);
2867 }
2868 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(uint32_t owner) {
2869         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
2870         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
2871         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(owner_conv);
2872         return ((uint32_t)ret_conv);
2873 }
2874
2875 static inline void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
2876 CHECK(!owner->result_ok);
2877         return *owner->contents.err;
2878 }
2879 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(uint32_t owner) {
2880         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(owner & ~1);
2881         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(owner_conv);
2882 }
2883
2884 static inline struct LDKSignature CResult_SignatureNoneZ_get_ok(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
2885 CHECK(owner->result_ok);
2886         return *owner->contents.result;
2887 }
2888 int8_tArray  __attribute__((export_name("TS_CResult_SignatureNoneZ_get_ok"))) TS_CResult_SignatureNoneZ_get_ok(uint32_t owner) {
2889         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
2890         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
2891         memcpy(ret_arr->elems, CResult_SignatureNoneZ_get_ok(owner_conv).compact_form, 64);
2892         return ret_arr;
2893 }
2894
2895 static inline void CResult_SignatureNoneZ_get_err(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
2896 CHECK(!owner->result_ok);
2897         return *owner->contents.err;
2898 }
2899 void  __attribute__((export_name("TS_CResult_SignatureNoneZ_get_err"))) TS_CResult_SignatureNoneZ_get_err(uint32_t owner) {
2900         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)(owner & ~1);
2901         CResult_SignatureNoneZ_get_err(owner_conv);
2902 }
2903
2904 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_a(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
2905         return owner->a;
2906 }
2907 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_get_a"))) TS_C2Tuple_SignatureSignatureZ_get_a(uint32_t owner) {
2908         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
2909         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
2910         memcpy(ret_arr->elems, C2Tuple_SignatureSignatureZ_get_a(owner_conv).compact_form, 64);
2911         return ret_arr;
2912 }
2913
2914 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_b(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
2915         return owner->b;
2916 }
2917 int8_tArray  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_get_b"))) TS_C2Tuple_SignatureSignatureZ_get_b(uint32_t owner) {
2918         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)(owner & ~1);
2919         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
2920         memcpy(ret_arr->elems, C2Tuple_SignatureSignatureZ_get_b(owner_conv).compact_form, 64);
2921         return ret_arr;
2922 }
2923
2924 static inline struct LDKC2Tuple_SignatureSignatureZ CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
2925 CHECK(owner->result_ok);
2926         return C2Tuple_SignatureSignatureZ_clone(&*owner->contents.result);
2927 }
2928 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(uint32_t owner) {
2929         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
2930         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
2931         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(owner_conv);
2932         return ((uint32_t)ret_conv);
2933 }
2934
2935 static inline void CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
2936 CHECK(!owner->result_ok);
2937         return *owner->contents.err;
2938 }
2939 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_err"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(uint32_t owner) {
2940         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(owner & ~1);
2941         CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(owner_conv);
2942 }
2943
2944 static inline struct LDKSecretKey CResult_SecretKeyNoneZ_get_ok(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
2945 CHECK(owner->result_ok);
2946         return *owner->contents.result;
2947 }
2948 int8_tArray  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_get_ok"))) TS_CResult_SecretKeyNoneZ_get_ok(uint32_t owner) {
2949         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
2950         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
2951         memcpy(ret_arr->elems, CResult_SecretKeyNoneZ_get_ok(owner_conv).bytes, 32);
2952         return ret_arr;
2953 }
2954
2955 static inline void CResult_SecretKeyNoneZ_get_err(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
2956 CHECK(!owner->result_ok);
2957         return *owner->contents.err;
2958 }
2959 void  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_get_err"))) TS_CResult_SecretKeyNoneZ_get_err(uint32_t owner) {
2960         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)(owner & ~1);
2961         CResult_SecretKeyNoneZ_get_err(owner_conv);
2962 }
2963
2964 typedef struct LDKBaseSign_JCalls {
2965         atomic_size_t refcnt;
2966         uint32_t instance_ptr;
2967 } LDKBaseSign_JCalls;
2968 static void LDKBaseSign_JCalls_free(void* this_arg) {
2969         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2970         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2971                 FREE(j_calls);
2972         }
2973 }
2974 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2975         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2976         int64_t idx_conv = idx;
2977         int8_tArray ret = (int8_tArray)js_invoke_function_1(j_calls->instance_ptr, 0, (uint32_t)idx_conv);
2978         LDKPublicKey ret_ref;
2979         CHECK(ret->arr_len == 33);
2980         memcpy(ret_ref.compressed_form, ret->elems, 33); FREE(ret);
2981         return ret_ref;
2982 }
2983 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2984         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2985         int64_t idx_conv = idx;
2986         int8_tArray ret = (int8_tArray)js_invoke_function_1(j_calls->instance_ptr, 1, (uint32_t)idx_conv);
2987         LDKThirtyTwoBytes ret_ref;
2988         CHECK(ret->arr_len == 32);
2989         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
2990         return ret_ref;
2991 }
2992 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx, LDKCVec_PaymentPreimageZ preimages) {
2993         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2994         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
2995         uint32_t holder_tx_ref = 0;
2996         holder_tx_var = HolderCommitmentTransaction_clone(&holder_tx_var);
2997         CHECK((((uintptr_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2998         CHECK((((uintptr_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2999         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
3000         holder_tx_ref = (uintptr_t)holder_tx_var.inner;
3001         if (holder_tx_var.is_owned) {
3002                 holder_tx_ref |= 1;
3003         }
3004         LDKCVec_PaymentPreimageZ preimages_var = preimages;
3005         ptrArray preimages_arr = NULL;
3006         preimages_arr = init_ptrArray(preimages_var.datalen, __LINE__);
3007         int8_tArray *preimages_arr_ptr = (int8_tArray*)(((uint8_t*)preimages_arr) + 4);
3008         for (size_t m = 0; m < preimages_var.datalen; m++) {
3009                 int8_tArray preimages_conv_12_arr = init_int8_tArray(32, __LINE__);
3010                 memcpy(preimages_conv_12_arr->elems, preimages_var.data[m].data, 32);
3011                 preimages_arr_ptr[m] = preimages_conv_12_arr;
3012         }
3013         
3014         FREE(preimages_var.data);
3015         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 2, (uint32_t)holder_tx_ref, (uint32_t)preimages_arr);
3016         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3017         CHECK_ACCESS(ret_ptr);
3018         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
3019         FREE((void*)ret);
3020         return ret_conv;
3021 }
3022 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
3023         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3024         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 3);
3025         LDKThirtyTwoBytes ret_ref;
3026         CHECK(ret->arr_len == 32);
3027         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
3028         return ret_ref;
3029 }
3030 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx, LDKCVec_PaymentPreimageZ preimages) {
3031         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3032         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
3033         uint32_t commitment_tx_ref = 0;
3034         commitment_tx_var = CommitmentTransaction_clone(&commitment_tx_var);
3035         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3036         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3037         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
3038         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
3039         if (commitment_tx_var.is_owned) {
3040                 commitment_tx_ref |= 1;
3041         }
3042         LDKCVec_PaymentPreimageZ preimages_var = preimages;
3043         ptrArray preimages_arr = NULL;
3044         preimages_arr = init_ptrArray(preimages_var.datalen, __LINE__);
3045         int8_tArray *preimages_arr_ptr = (int8_tArray*)(((uint8_t*)preimages_arr) + 4);
3046         for (size_t m = 0; m < preimages_var.datalen; m++) {
3047                 int8_tArray preimages_conv_12_arr = init_int8_tArray(32, __LINE__);
3048                 memcpy(preimages_conv_12_arr->elems, preimages_var.data[m].data, 32);
3049                 preimages_arr_ptr[m] = preimages_conv_12_arr;
3050         }
3051         
3052         FREE(preimages_var.data);
3053         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 4, (uint32_t)commitment_tx_ref, (uint32_t)preimages_arr);
3054         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3055         CHECK_ACCESS(ret_ptr);
3056         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
3057         FREE((void*)ret);
3058         return ret_conv;
3059 }
3060 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
3061         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3062         int64_t idx_conv = idx;
3063         int8_tArray secret_arr = init_int8_tArray(32, __LINE__);
3064         memcpy(secret_arr->elems, *secret, 32);
3065         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 5, (uint32_t)idx_conv, (uint32_t)secret_arr);
3066         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3067         CHECK_ACCESS(ret_ptr);
3068         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
3069         FREE((void*)ret);
3070         return ret_conv;
3071 }
3072 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
3073         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3074         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
3075         uint32_t commitment_tx_ref = 0;
3076         commitment_tx_var = HolderCommitmentTransaction_clone(&commitment_tx_var);
3077         CHECK((((uintptr_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3078         CHECK((((uintptr_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3079         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
3080         commitment_tx_ref = (uintptr_t)commitment_tx_var.inner;
3081         if (commitment_tx_var.is_owned) {
3082                 commitment_tx_ref |= 1;
3083         }
3084         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 6, (uint32_t)commitment_tx_ref);
3085         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3086         CHECK_ACCESS(ret_ptr);
3087         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
3088         FREE((void*)ret);
3089         return ret_conv;
3090 }
3091 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]) {
3092         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3093         LDKTransaction justice_tx_var = justice_tx;
3094         int8_tArray justice_tx_arr = init_int8_tArray(justice_tx_var.datalen, __LINE__);
3095         memcpy(justice_tx_arr->elems, justice_tx_var.data, justice_tx_var.datalen);
3096         Transaction_free(justice_tx_var);
3097         uint32_t input_conv = input;
3098         int64_t amount_conv = amount;
3099         int8_tArray per_commitment_key_arr = init_int8_tArray(32, __LINE__);
3100         memcpy(per_commitment_key_arr->elems, *per_commitment_key, 32);
3101         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);
3102         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3103         CHECK_ACCESS(ret_ptr);
3104         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3105         FREE((void*)ret);
3106         return ret_conv;
3107 }
3108 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) {
3109         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3110         LDKTransaction justice_tx_var = justice_tx;
3111         int8_tArray justice_tx_arr = init_int8_tArray(justice_tx_var.datalen, __LINE__);
3112         memcpy(justice_tx_arr->elems, justice_tx_var.data, justice_tx_var.datalen);
3113         Transaction_free(justice_tx_var);
3114         uint32_t input_conv = input;
3115         int64_t amount_conv = amount;
3116         int8_tArray per_commitment_key_arr = init_int8_tArray(32, __LINE__);
3117         memcpy(per_commitment_key_arr->elems, *per_commitment_key, 32);
3118         LDKHTLCOutputInCommitment htlc_var = *htlc;
3119         uint32_t htlc_ref = 0;
3120         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
3121         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3122         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3123         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
3124         htlc_ref = (uintptr_t)htlc_var.inner;
3125         if (htlc_var.is_owned) {
3126                 htlc_ref |= 1;
3127         }
3128         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);
3129         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3130         CHECK_ACCESS(ret_ptr);
3131         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3132         FREE((void*)ret);
3133         return ret_conv;
3134 }
3135 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) {
3136         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3137         LDKTransaction htlc_tx_var = htlc_tx;
3138         int8_tArray htlc_tx_arr = init_int8_tArray(htlc_tx_var.datalen, __LINE__);
3139         memcpy(htlc_tx_arr->elems, htlc_tx_var.data, htlc_tx_var.datalen);
3140         Transaction_free(htlc_tx_var);
3141         uint32_t input_conv = input;
3142         int64_t amount_conv = amount;
3143         int8_tArray per_commitment_point_arr = init_int8_tArray(33, __LINE__);
3144         memcpy(per_commitment_point_arr->elems, per_commitment_point.compressed_form, 33);
3145         LDKHTLCOutputInCommitment htlc_var = *htlc;
3146         uint32_t htlc_ref = 0;
3147         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
3148         CHECK((((uintptr_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3149         CHECK((((uintptr_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3150         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
3151         htlc_ref = (uintptr_t)htlc_var.inner;
3152         if (htlc_var.is_owned) {
3153                 htlc_ref |= 1;
3154         }
3155         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);
3156         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3157         CHECK_ACCESS(ret_ptr);
3158         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3159         FREE((void*)ret);
3160         return ret_conv;
3161 }
3162 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
3163         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3164         LDKClosingTransaction closing_tx_var = *closing_tx;
3165         uint32_t closing_tx_ref = 0;
3166         closing_tx_var = ClosingTransaction_clone(&closing_tx_var);
3167         CHECK((((uintptr_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3168         CHECK((((uintptr_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3169         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
3170         closing_tx_ref = (uintptr_t)closing_tx_var.inner;
3171         if (closing_tx_var.is_owned) {
3172                 closing_tx_ref |= 1;
3173         }
3174         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 10, (uint32_t)closing_tx_ref);
3175         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3176         CHECK_ACCESS(ret_ptr);
3177         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3178         FREE((void*)ret);
3179         return ret_conv;
3180 }
3181 LDKCResult_C2Tuple_SignatureSignatureZNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
3182         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3183         LDKUnsignedChannelAnnouncement msg_var = *msg;
3184         uint32_t msg_ref = 0;
3185         msg_var = UnsignedChannelAnnouncement_clone(&msg_var);
3186         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3187         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3188         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3189         msg_ref = (uintptr_t)msg_var.inner;
3190         if (msg_var.is_owned) {
3191                 msg_ref |= 1;
3192         }
3193         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 11, (uint32_t)msg_ref);
3194         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
3195         CHECK_ACCESS(ret_ptr);
3196         LDKCResult_C2Tuple_SignatureSignatureZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(ret_ptr);
3197         FREE((void*)ret);
3198         return ret_conv;
3199 }
3200 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
3201         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3202         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
3203         uint32_t channel_parameters_ref = 0;
3204         channel_parameters_var = ChannelTransactionParameters_clone(&channel_parameters_var);
3205         CHECK((((uintptr_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3206         CHECK((((uintptr_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3207         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
3208         channel_parameters_ref = (uintptr_t)channel_parameters_var.inner;
3209         if (channel_parameters_var.is_owned) {
3210                 channel_parameters_ref |= 1;
3211         }
3212         js_invoke_function_1(j_calls->instance_ptr, 12, (uint32_t)channel_parameters_ref);
3213 }
3214 static void LDKBaseSign_JCalls_cloned(LDKBaseSign* new_obj) {
3215         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) new_obj->this_arg;
3216         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3217 }
3218 static inline LDKBaseSign LDKBaseSign_init (JSValue o, uint32_t pubkeys) {
3219         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
3220         atomic_init(&calls->refcnt, 1);
3221         calls->instance_ptr = o;
3222
3223         LDKChannelPublicKeys pubkeys_conv;
3224         pubkeys_conv.inner = (void*)(pubkeys & (~1));
3225         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
3226         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
3227
3228         LDKBaseSign ret = {
3229                 .this_arg = (void*) calls,
3230                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
3231                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
3232                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
3233                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
3234                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
3235                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
3236                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
3237                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
3238                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
3239                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
3240                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
3241                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
3242                 .ready_channel = ready_channel_LDKBaseSign_jcall,
3243                 .free = LDKBaseSign_JCalls_free,
3244                 .pubkeys = pubkeys_conv,
3245                 .set_pubkeys = NULL,
3246         };
3247         return ret;
3248 }
3249 long  __attribute__((export_name("TS_LDKBaseSign_new"))) TS_LDKBaseSign_new(JSValue o, uint32_t pubkeys) {
3250         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
3251         *res_ptr = LDKBaseSign_init(o, pubkeys);
3252         return (long)res_ptr;
3253 }
3254 int8_tArray  __attribute__((export_name("TS_BaseSign_get_per_commitment_point"))) TS_BaseSign_get_per_commitment_point(uint32_t this_arg, int64_t idx) {
3255         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3256         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3257         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3258         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
3259         memcpy(ret_arr->elems, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form, 33);
3260         return ret_arr;
3261 }
3262
3263 int8_tArray  __attribute__((export_name("TS_BaseSign_release_commitment_secret"))) TS_BaseSign_release_commitment_secret(uint32_t this_arg, int64_t idx) {
3264         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3265         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3266         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3267         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3268         memcpy(ret_arr->elems, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data, 32);
3269         return ret_arr;
3270 }
3271
3272 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) {
3273         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3274         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3275         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3276         LDKHolderCommitmentTransaction holder_tx_conv;
3277         holder_tx_conv.inner = (void*)(holder_tx & (~1));
3278         holder_tx_conv.is_owned = false;
3279         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
3280         LDKCVec_PaymentPreimageZ preimages_constr;
3281         preimages_constr.datalen = preimages->arr_len;
3282         if (preimages_constr.datalen > 0)
3283                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
3284         else
3285                 preimages_constr.data = NULL;
3286         int8_tArray* preimages_vals = (void*) preimages->elems /* XXX preimages leaks */;
3287         for (size_t m = 0; m < preimages_constr.datalen; m++) {
3288                 int8_tArray preimages_conv_12 = preimages_vals[m];
3289                 LDKThirtyTwoBytes preimages_conv_12_ref;
3290                 CHECK(preimages_conv_12->arr_len == 32);
3291                 memcpy(preimages_conv_12_ref.data, preimages_conv_12->elems, 32); FREE(preimages_conv_12);
3292                 preimages_constr.data[m] = preimages_conv_12_ref;
3293         }
3294         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
3295         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv, preimages_constr);
3296         return (uint32_t)ret_conv;
3297 }
3298
3299 int8_tArray  __attribute__((export_name("TS_BaseSign_channel_keys_id"))) TS_BaseSign_channel_keys_id(uint32_t this_arg) {
3300         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3301         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3302         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3303         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3304         memcpy(ret_arr->elems, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data, 32);
3305         return ret_arr;
3306 }
3307
3308 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) {
3309         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3310         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3311         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3312         LDKCommitmentTransaction commitment_tx_conv;
3313         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
3314         commitment_tx_conv.is_owned = false;
3315         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
3316         LDKCVec_PaymentPreimageZ preimages_constr;
3317         preimages_constr.datalen = preimages->arr_len;
3318         if (preimages_constr.datalen > 0)
3319                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
3320         else
3321                 preimages_constr.data = NULL;
3322         int8_tArray* preimages_vals = (void*) preimages->elems /* XXX preimages leaks */;
3323         for (size_t m = 0; m < preimages_constr.datalen; m++) {
3324                 int8_tArray preimages_conv_12 = preimages_vals[m];
3325                 LDKThirtyTwoBytes preimages_conv_12_ref;
3326                 CHECK(preimages_conv_12->arr_len == 32);
3327                 memcpy(preimages_conv_12_ref.data, preimages_conv_12->elems, 32); FREE(preimages_conv_12);
3328                 preimages_constr.data[m] = preimages_conv_12_ref;
3329         }
3330         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
3331         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv, preimages_constr);
3332         return (uint32_t)ret_conv;
3333 }
3334
3335 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) {
3336         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3337         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3338         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3339         unsigned char secret_arr[32];
3340         CHECK(secret->arr_len == 32);
3341         memcpy(secret_arr, secret->elems, 32); FREE(secret);
3342         unsigned char (*secret_ref)[32] = &secret_arr;
3343         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
3344         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
3345         return (uint32_t)ret_conv;
3346 }
3347
3348 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) {
3349         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3350         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3351         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3352         LDKHolderCommitmentTransaction commitment_tx_conv;
3353         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
3354         commitment_tx_conv.is_owned = false;
3355         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
3356         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
3357         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
3358         return (uint32_t)ret_conv;
3359 }
3360
3361 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) {
3362         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3363         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3364         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3365         LDKTransaction justice_tx_ref;
3366         justice_tx_ref.datalen = justice_tx->arr_len;
3367         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
3368         memcpy(justice_tx_ref.data, justice_tx->elems, justice_tx_ref.datalen); FREE(justice_tx);
3369         justice_tx_ref.data_is_owned = true;
3370         unsigned char per_commitment_key_arr[32];
3371         CHECK(per_commitment_key->arr_len == 32);
3372         memcpy(per_commitment_key_arr, per_commitment_key->elems, 32); FREE(per_commitment_key);
3373         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
3374         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3375         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
3376         return (uint32_t)ret_conv;
3377 }
3378
3379 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) {
3380         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3381         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3382         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3383         LDKTransaction justice_tx_ref;
3384         justice_tx_ref.datalen = justice_tx->arr_len;
3385         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
3386         memcpy(justice_tx_ref.data, justice_tx->elems, justice_tx_ref.datalen); FREE(justice_tx);
3387         justice_tx_ref.data_is_owned = true;
3388         unsigned char per_commitment_key_arr[32];
3389         CHECK(per_commitment_key->arr_len == 32);
3390         memcpy(per_commitment_key_arr, per_commitment_key->elems, 32); FREE(per_commitment_key);
3391         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
3392         LDKHTLCOutputInCommitment htlc_conv;
3393         htlc_conv.inner = (void*)(htlc & (~1));
3394         htlc_conv.is_owned = false;
3395         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
3396         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3397         *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);
3398         return (uint32_t)ret_conv;
3399 }
3400
3401 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) {
3402         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3403         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3404         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3405         LDKTransaction htlc_tx_ref;
3406         htlc_tx_ref.datalen = htlc_tx->arr_len;
3407         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
3408         memcpy(htlc_tx_ref.data, htlc_tx->elems, htlc_tx_ref.datalen); FREE(htlc_tx);
3409         htlc_tx_ref.data_is_owned = true;
3410         LDKPublicKey per_commitment_point_ref;
3411         CHECK(per_commitment_point->arr_len == 33);
3412         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
3413         LDKHTLCOutputInCommitment htlc_conv;
3414         htlc_conv.inner = (void*)(htlc & (~1));
3415         htlc_conv.is_owned = false;
3416         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
3417         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3418         *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);
3419         return (uint32_t)ret_conv;
3420 }
3421
3422 uint32_t  __attribute__((export_name("TS_BaseSign_sign_closing_transaction"))) TS_BaseSign_sign_closing_transaction(uint32_t this_arg, uint32_t closing_tx) {
3423         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3424         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3425         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3426         LDKClosingTransaction closing_tx_conv;
3427         closing_tx_conv.inner = (void*)(closing_tx & (~1));
3428         closing_tx_conv.is_owned = false;
3429         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
3430         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3431         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
3432         return (uint32_t)ret_conv;
3433 }
3434
3435 uint32_t  __attribute__((export_name("TS_BaseSign_sign_channel_announcement"))) TS_BaseSign_sign_channel_announcement(uint32_t this_arg, uint32_t msg) {
3436         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3437         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3438         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3439         LDKUnsignedChannelAnnouncement msg_conv;
3440         msg_conv.inner = (void*)(msg & (~1));
3441         msg_conv.is_owned = false;
3442         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
3443         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
3444         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
3445         return (uint32_t)ret_conv;
3446 }
3447
3448 void  __attribute__((export_name("TS_BaseSign_ready_channel"))) TS_BaseSign_ready_channel(uint32_t this_arg, uint32_t channel_parameters) {
3449         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3450         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3451         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3452         LDKChannelTransactionParameters channel_parameters_conv;
3453         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
3454         channel_parameters_conv.is_owned = false;
3455         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
3456         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
3457 }
3458
3459 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
3460         if (this_arg->set_pubkeys != NULL)
3461                 this_arg->set_pubkeys(this_arg);
3462         return this_arg->pubkeys;
3463 }
3464 uint32_t  __attribute__((export_name("TS_BaseSign_get_pubkeys"))) TS_BaseSign_get_pubkeys(uint32_t this_arg) {
3465         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3466         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3467         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3468         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
3469         uint32_t ret_ref = 0;
3470         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3471         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3472         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3473         ret_ref = (uintptr_t)ret_var.inner;
3474         if (ret_var.is_owned) {
3475                 ret_ref |= 1;
3476         }
3477         return ret_ref;
3478 }
3479
3480 typedef struct LDKSign_JCalls {
3481         atomic_size_t refcnt;
3482         uint32_t instance_ptr;
3483         LDKBaseSign_JCalls* BaseSign;
3484 } LDKSign_JCalls;
3485 static void LDKSign_JCalls_free(void* this_arg) {
3486         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
3487         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3488                 FREE(j_calls);
3489         }
3490 }
3491 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
3492         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
3493         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 13);
3494         LDKCVec_u8Z ret_ref;
3495         ret_ref.datalen = ret->arr_len;
3496         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
3497         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
3498         return ret_ref;
3499 }
3500 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
3501         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
3502         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3503         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
3504 }
3505 static inline LDKSign LDKSign_init (JSValue o, JSValue BaseSign, uint32_t pubkeys) {
3506         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
3507         atomic_init(&calls->refcnt, 1);
3508         calls->instance_ptr = o;
3509
3510         LDKChannelPublicKeys pubkeys_conv;
3511         pubkeys_conv.inner = (void*)(pubkeys & (~1));
3512         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
3513         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
3514
3515         LDKSign ret = {
3516                 .this_arg = (void*) calls,
3517                 .write = write_LDKSign_jcall,
3518                 .cloned = LDKSign_JCalls_cloned,
3519                 .free = LDKSign_JCalls_free,
3520                 .BaseSign = LDKBaseSign_init(BaseSign, pubkeys),
3521         };
3522         calls->BaseSign = ret.BaseSign.this_arg;
3523         return ret;
3524 }
3525 long  __attribute__((export_name("TS_LDKSign_new"))) TS_LDKSign_new(JSValue o, JSValue BaseSign, uint32_t pubkeys) {
3526         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
3527         *res_ptr = LDKSign_init(o, BaseSign, pubkeys);
3528         return (long)res_ptr;
3529 }
3530 int8_tArray  __attribute__((export_name("TS_Sign_write"))) TS_Sign_write(uint32_t this_arg) {
3531         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
3532         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3533         LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
3534         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
3535         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
3536         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
3537         CVec_u8Z_free(ret_var);
3538         return ret_arr;
3539 }
3540
3541 static inline struct LDKSign CResult_SignDecodeErrorZ_get_ok(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
3542 CHECK(owner->result_ok);
3543         return Sign_clone(&*owner->contents.result);
3544 }
3545 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_get_ok"))) TS_CResult_SignDecodeErrorZ_get_ok(uint32_t owner) {
3546         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
3547         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
3548         *ret_ret = CResult_SignDecodeErrorZ_get_ok(owner_conv);
3549         return (uint32_t)ret_ret;
3550 }
3551
3552 static inline struct LDKDecodeError CResult_SignDecodeErrorZ_get_err(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
3553 CHECK(!owner->result_ok);
3554         return DecodeError_clone(&*owner->contents.err);
3555 }
3556 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_get_err"))) TS_CResult_SignDecodeErrorZ_get_err(uint32_t owner) {
3557         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)(owner & ~1);
3558         LDKDecodeError ret_var = CResult_SignDecodeErrorZ_get_err(owner_conv);
3559         uint32_t ret_ref = 0;
3560         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3561         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3562         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3563         ret_ref = (uintptr_t)ret_var.inner;
3564         if (ret_var.is_owned) {
3565                 ret_ref |= 1;
3566         }
3567         return ret_ref;
3568 }
3569
3570 static inline struct LDKRecoverableSignature CResult_RecoverableSignatureNoneZ_get_ok(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
3571 CHECK(owner->result_ok);
3572         return *owner->contents.result;
3573 }
3574 int8_tArray  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_get_ok"))) TS_CResult_RecoverableSignatureNoneZ_get_ok(uint32_t owner) {
3575         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
3576         int8_tArray ret_arr = init_int8_tArray(68, __LINE__);
3577         memcpy(ret_arr->elems, CResult_RecoverableSignatureNoneZ_get_ok(owner_conv).serialized_form, 68);
3578         return ret_arr;
3579 }
3580
3581 static inline void CResult_RecoverableSignatureNoneZ_get_err(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
3582 CHECK(!owner->result_ok);
3583         return *owner->contents.err;
3584 }
3585 void  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_get_err"))) TS_CResult_RecoverableSignatureNoneZ_get_err(uint32_t owner) {
3586         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)(owner & ~1);
3587         CResult_RecoverableSignatureNoneZ_get_err(owner_conv);
3588 }
3589
3590 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
3591         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
3592         for (size_t i = 0; i < ret.datalen; i++) {
3593                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
3594         }
3595         return ret;
3596 }
3597 static inline struct LDKCVec_CVec_u8ZZ CResult_CVec_CVec_u8ZZNoneZ_get_ok(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
3598 CHECK(owner->result_ok);
3599         return CVec_CVec_u8ZZ_clone(&*owner->contents.result);
3600 }
3601 ptrArray  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_get_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_get_ok(uint32_t owner) {
3602         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
3603         LDKCVec_CVec_u8ZZ ret_var = CResult_CVec_CVec_u8ZZNoneZ_get_ok(owner_conv);
3604         ptrArray ret_arr = NULL;
3605         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
3606         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
3607         for (size_t m = 0; m < ret_var.datalen; m++) {
3608                 LDKCVec_u8Z ret_conv_12_var = ret_var.data[m];
3609                 int8_tArray ret_conv_12_arr = init_int8_tArray(ret_conv_12_var.datalen, __LINE__);
3610                 memcpy(ret_conv_12_arr->elems, ret_conv_12_var.data, ret_conv_12_var.datalen);
3611                 CVec_u8Z_free(ret_conv_12_var);
3612                 ret_arr_ptr[m] = ret_conv_12_arr;
3613         }
3614         
3615         FREE(ret_var.data);
3616         return ret_arr;
3617 }
3618
3619 static inline void CResult_CVec_CVec_u8ZZNoneZ_get_err(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
3620 CHECK(!owner->result_ok);
3621         return *owner->contents.err;
3622 }
3623 void  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_get_err"))) TS_CResult_CVec_CVec_u8ZZNoneZ_get_err(uint32_t owner) {
3624         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(owner & ~1);
3625         CResult_CVec_CVec_u8ZZNoneZ_get_err(owner_conv);
3626 }
3627
3628 static inline struct LDKInMemorySigner CResult_InMemorySignerDecodeErrorZ_get_ok(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
3629 CHECK(owner->result_ok);
3630         return InMemorySigner_clone(&*owner->contents.result);
3631 }
3632 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_get_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_get_ok(uint32_t owner) {
3633         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
3634         LDKInMemorySigner ret_var = CResult_InMemorySignerDecodeErrorZ_get_ok(owner_conv);
3635         uint32_t ret_ref = 0;
3636         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3637         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3638         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3639         ret_ref = (uintptr_t)ret_var.inner;
3640         if (ret_var.is_owned) {
3641                 ret_ref |= 1;
3642         }
3643         return ret_ref;
3644 }
3645
3646 static inline struct LDKDecodeError CResult_InMemorySignerDecodeErrorZ_get_err(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
3647 CHECK(!owner->result_ok);
3648         return DecodeError_clone(&*owner->contents.err);
3649 }
3650 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_get_err"))) TS_CResult_InMemorySignerDecodeErrorZ_get_err(uint32_t owner) {
3651         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(owner & ~1);
3652         LDKDecodeError ret_var = CResult_InMemorySignerDecodeErrorZ_get_err(owner_conv);
3653         uint32_t ret_ref = 0;
3654         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3655         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3656         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3657         ret_ref = (uintptr_t)ret_var.inner;
3658         if (ret_var.is_owned) {
3659                 ret_ref |= 1;
3660         }
3661         return ret_ref;
3662 }
3663
3664 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
3665         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
3666         for (size_t i = 0; i < ret.datalen; i++) {
3667                 ret.data[i] = TxOut_clone(&orig->data[i]);
3668         }
3669         return ret;
3670 }
3671 static inline struct LDKTransaction CResult_TransactionNoneZ_get_ok(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
3672 CHECK(owner->result_ok);
3673         return *owner->contents.result;
3674 }
3675 int8_tArray  __attribute__((export_name("TS_CResult_TransactionNoneZ_get_ok"))) TS_CResult_TransactionNoneZ_get_ok(uint32_t owner) {
3676         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
3677         LDKTransaction ret_var = CResult_TransactionNoneZ_get_ok(owner_conv);
3678         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
3679         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
3680         return ret_arr;
3681 }
3682
3683 static inline void CResult_TransactionNoneZ_get_err(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
3684 CHECK(!owner->result_ok);
3685         return *owner->contents.err;
3686 }
3687 void  __attribute__((export_name("TS_CResult_TransactionNoneZ_get_err"))) TS_CResult_TransactionNoneZ_get_err(uint32_t owner) {
3688         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)(owner & ~1);
3689         CResult_TransactionNoneZ_get_err(owner_conv);
3690 }
3691
3692 uint32_t __attribute__((export_name("TS_LDKCOption_u16Z_ty_from_ptr"))) TS_LDKCOption_u16Z_ty_from_ptr(uint32_t ptr) {
3693         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
3694         switch(obj->tag) {
3695                 case LDKCOption_u16Z_Some: return 0;
3696                 case LDKCOption_u16Z_None: return 1;
3697                 default: abort();
3698         }
3699 }
3700 int16_t __attribute__((export_name("TS_LDKCOption_u16Z_Some_get_some"))) TS_LDKCOption_u16Z_Some_get_some(uint32_t ptr) {
3701         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
3702         assert(obj->tag == LDKCOption_u16Z_Some);
3703                         int16_t some_conv = obj->some;
3704         return some_conv;
3705 }
3706 uint32_t __attribute__((export_name("TS_LDKAPIError_ty_from_ptr"))) TS_LDKAPIError_ty_from_ptr(uint32_t ptr) {
3707         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3708         switch(obj->tag) {
3709                 case LDKAPIError_APIMisuseError: return 0;
3710                 case LDKAPIError_FeeRateTooHigh: return 1;
3711                 case LDKAPIError_RouteError: return 2;
3712                 case LDKAPIError_ChannelUnavailable: return 3;
3713                 case LDKAPIError_MonitorUpdateFailed: return 4;
3714                 case LDKAPIError_IncompatibleShutdownScript: return 5;
3715                 default: abort();
3716         }
3717 }
3718 jstring __attribute__((export_name("TS_LDKAPIError_APIMisuseError_get_err"))) TS_LDKAPIError_APIMisuseError_get_err(uint32_t ptr) {
3719         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3720         assert(obj->tag == LDKAPIError_APIMisuseError);
3721                         LDKStr err_str = obj->api_misuse_error.err;
3722                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
3723         return err_conv;
3724 }
3725 jstring __attribute__((export_name("TS_LDKAPIError_FeeRateTooHigh_get_err"))) TS_LDKAPIError_FeeRateTooHigh_get_err(uint32_t ptr) {
3726         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3727         assert(obj->tag == LDKAPIError_FeeRateTooHigh);
3728                         LDKStr err_str = obj->fee_rate_too_high.err;
3729                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
3730         return err_conv;
3731 }
3732 int32_t __attribute__((export_name("TS_LDKAPIError_FeeRateTooHigh_get_feerate"))) TS_LDKAPIError_FeeRateTooHigh_get_feerate(uint32_t ptr) {
3733         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3734         assert(obj->tag == LDKAPIError_FeeRateTooHigh);
3735                         int32_t feerate_conv = obj->fee_rate_too_high.feerate;
3736         return feerate_conv;
3737 }
3738 jstring __attribute__((export_name("TS_LDKAPIError_RouteError_get_err"))) TS_LDKAPIError_RouteError_get_err(uint32_t ptr) {
3739         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3740         assert(obj->tag == LDKAPIError_RouteError);
3741                         LDKStr err_str = obj->route_error.err;
3742                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
3743         return err_conv;
3744 }
3745 jstring __attribute__((export_name("TS_LDKAPIError_ChannelUnavailable_get_err"))) TS_LDKAPIError_ChannelUnavailable_get_err(uint32_t ptr) {
3746         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3747         assert(obj->tag == LDKAPIError_ChannelUnavailable);
3748                         LDKStr err_str = obj->channel_unavailable.err;
3749                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
3750         return err_conv;
3751 }
3752 uint32_t __attribute__((export_name("TS_LDKAPIError_IncompatibleShutdownScript_get_script"))) TS_LDKAPIError_IncompatibleShutdownScript_get_script(uint32_t ptr) {
3753         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3754         assert(obj->tag == LDKAPIError_IncompatibleShutdownScript);
3755                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
3756                         uint32_t script_ref = 0;
3757                         CHECK((((uintptr_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3758                         CHECK((((uintptr_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3759                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
3760                         script_ref = (uintptr_t)script_var.inner & ~1;
3761         return script_ref;
3762 }
3763 static inline void CResult_NoneAPIErrorZ_get_ok(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
3764 CHECK(owner->result_ok);
3765         return *owner->contents.result;
3766 }
3767 void  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_get_ok"))) TS_CResult_NoneAPIErrorZ_get_ok(uint32_t owner) {
3768         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
3769         CResult_NoneAPIErrorZ_get_ok(owner_conv);
3770 }
3771
3772 static inline struct LDKAPIError CResult_NoneAPIErrorZ_get_err(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
3773 CHECK(!owner->result_ok);
3774         return APIError_clone(&*owner->contents.err);
3775 }
3776 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_get_err"))) TS_CResult_NoneAPIErrorZ_get_err(uint32_t owner) {
3777         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)(owner & ~1);
3778         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
3779         *ret_copy = CResult_NoneAPIErrorZ_get_err(owner_conv);
3780         uint32_t ret_ref = (uintptr_t)ret_copy;
3781         return ret_ref;
3782 }
3783
3784 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
3785         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
3786         for (size_t i = 0; i < ret.datalen; i++) {
3787                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
3788         }
3789         return ret;
3790 }
3791 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
3792         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
3793         for (size_t i = 0; i < ret.datalen; i++) {
3794                 ret.data[i] = APIError_clone(&orig->data[i]);
3795         }
3796         return ret;
3797 }
3798 static inline struct LDKThirtyTwoBytes CResult__u832APIErrorZ_get_ok(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
3799 CHECK(owner->result_ok);
3800         return ThirtyTwoBytes_clone(&*owner->contents.result);
3801 }
3802 int8_tArray  __attribute__((export_name("TS_CResult__u832APIErrorZ_get_ok"))) TS_CResult__u832APIErrorZ_get_ok(uint32_t owner) {
3803         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
3804         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3805         memcpy(ret_arr->elems, CResult__u832APIErrorZ_get_ok(owner_conv).data, 32);
3806         return ret_arr;
3807 }
3808
3809 static inline struct LDKAPIError CResult__u832APIErrorZ_get_err(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
3810 CHECK(!owner->result_ok);
3811         return APIError_clone(&*owner->contents.err);
3812 }
3813 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_get_err"))) TS_CResult__u832APIErrorZ_get_err(uint32_t owner) {
3814         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)(owner & ~1);
3815         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
3816         *ret_copy = CResult__u832APIErrorZ_get_err(owner_conv);
3817         uint32_t ret_ref = (uintptr_t)ret_copy;
3818         return ret_ref;
3819 }
3820
3821 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_ty_from_ptr"))) TS_LDKPaymentSendFailure_ty_from_ptr(uint32_t ptr) {
3822         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3823         switch(obj->tag) {
3824                 case LDKPaymentSendFailure_ParameterError: return 0;
3825                 case LDKPaymentSendFailure_PathParameterError: return 1;
3826                 case LDKPaymentSendFailure_AllFailedRetrySafe: return 2;
3827                 case LDKPaymentSendFailure_PartialFailure: return 3;
3828                 default: abort();
3829         }
3830 }
3831 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_ParameterError_get_parameter_error"))) TS_LDKPaymentSendFailure_ParameterError_get_parameter_error(uint32_t ptr) {
3832         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3833         assert(obj->tag == LDKPaymentSendFailure_ParameterError);
3834                         uint32_t parameter_error_ref = ((uintptr_t)&obj->parameter_error) | 1;
3835         return parameter_error_ref;
3836 }
3837 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PathParameterError_get_path_parameter_error"))) TS_LDKPaymentSendFailure_PathParameterError_get_path_parameter_error(uint32_t ptr) {
3838         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3839         assert(obj->tag == LDKPaymentSendFailure_PathParameterError);
3840                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
3841                         uint32_tArray path_parameter_error_arr = NULL;
3842                         path_parameter_error_arr = init_uint32_tArray(path_parameter_error_var.datalen, __LINE__);
3843                         uint32_t *path_parameter_error_arr_ptr = (uint32_t*)(((uint8_t*)path_parameter_error_arr) + 4);
3844                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
3845                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3846                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
3847                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
3848                                 path_parameter_error_arr_ptr[w] = (uint32_t)path_parameter_error_conv_22_conv;
3849                         }
3850                         
3851         return path_parameter_error_arr;
3852 }
3853 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_AllFailedRetrySafe_get_all_failed_retry_safe"))) TS_LDKPaymentSendFailure_AllFailedRetrySafe_get_all_failed_retry_safe(uint32_t ptr) {
3854         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3855         assert(obj->tag == LDKPaymentSendFailure_AllFailedRetrySafe);
3856                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
3857                         uint32_tArray all_failed_retry_safe_arr = NULL;
3858                         all_failed_retry_safe_arr = init_uint32_tArray(all_failed_retry_safe_var.datalen, __LINE__);
3859                         uint32_t *all_failed_retry_safe_arr_ptr = (uint32_t*)(((uint8_t*)all_failed_retry_safe_arr) + 4);
3860                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
3861                                 uint32_t all_failed_retry_safe_conv_10_ref = ((uintptr_t)&all_failed_retry_safe_var.data[k]) | 1;
3862                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
3863                         }
3864                         
3865         return all_failed_retry_safe_arr;
3866 }
3867 uint32_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_results"))) TS_LDKPaymentSendFailure_PartialFailure_get_results(uint32_t ptr) {
3868         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3869         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
3870                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
3871                         uint32_tArray results_arr = NULL;
3872                         results_arr = init_uint32_tArray(results_var.datalen, __LINE__);
3873                         uint32_t *results_arr_ptr = (uint32_t*)(((uint8_t*)results_arr) + 4);
3874                         for (size_t w = 0; w < results_var.datalen; w++) {
3875                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3876                                 *results_conv_22_conv = results_var.data[w];
3877                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
3878                                 results_arr_ptr[w] = (uint32_t)results_conv_22_conv;
3879                         }
3880                         
3881         return results_arr;
3882 }
3883 uint32_t __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_failed_paths_retry"))) TS_LDKPaymentSendFailure_PartialFailure_get_failed_paths_retry(uint32_t ptr) {
3884         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3885         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
3886                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
3887                         uint32_t failed_paths_retry_ref = 0;
3888                         if ((uintptr_t)failed_paths_retry_var.inner > 4096) {
3889                                 CHECK((((uintptr_t)failed_paths_retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3890                                 CHECK((((uintptr_t)&failed_paths_retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3891                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
3892                                 failed_paths_retry_ref = (uintptr_t)failed_paths_retry_var.inner & ~1;
3893                         }
3894         return failed_paths_retry_ref;
3895 }
3896 int8_tArray __attribute__((export_name("TS_LDKPaymentSendFailure_PartialFailure_get_payment_id"))) TS_LDKPaymentSendFailure_PartialFailure_get_payment_id(uint32_t ptr) {
3897         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3898         assert(obj->tag == LDKPaymentSendFailure_PartialFailure);
3899                         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
3900                         memcpy(payment_id_arr->elems, obj->partial_failure.payment_id.data, 32);
3901         return payment_id_arr;
3902 }
3903 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentSendFailureZ_get_ok(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
3904 CHECK(owner->result_ok);
3905         return ThirtyTwoBytes_clone(&*owner->contents.result);
3906 }
3907 int8_tArray  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_get_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_get_ok(uint32_t owner) {
3908         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
3909         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3910         memcpy(ret_arr->elems, CResult_PaymentIdPaymentSendFailureZ_get_ok(owner_conv).data, 32);
3911         return ret_arr;
3912 }
3913
3914 static inline struct LDKPaymentSendFailure CResult_PaymentIdPaymentSendFailureZ_get_err(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
3915 CHECK(!owner->result_ok);
3916         return PaymentSendFailure_clone(&*owner->contents.err);
3917 }
3918 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_get_err"))) TS_CResult_PaymentIdPaymentSendFailureZ_get_err(uint32_t owner) {
3919         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(owner & ~1);
3920         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
3921         *ret_copy = CResult_PaymentIdPaymentSendFailureZ_get_err(owner_conv);
3922         uint32_t ret_ref = (uintptr_t)ret_copy;
3923         return ret_ref;
3924 }
3925
3926 static inline void CResult_NonePaymentSendFailureZ_get_ok(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
3927 CHECK(owner->result_ok);
3928         return *owner->contents.result;
3929 }
3930 void  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_get_ok"))) TS_CResult_NonePaymentSendFailureZ_get_ok(uint32_t owner) {
3931         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
3932         CResult_NonePaymentSendFailureZ_get_ok(owner_conv);
3933 }
3934
3935 static inline struct LDKPaymentSendFailure CResult_NonePaymentSendFailureZ_get_err(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
3936 CHECK(!owner->result_ok);
3937         return PaymentSendFailure_clone(&*owner->contents.err);
3938 }
3939 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_get_err"))) TS_CResult_NonePaymentSendFailureZ_get_err(uint32_t owner) {
3940         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)(owner & ~1);
3941         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
3942         *ret_copy = CResult_NonePaymentSendFailureZ_get_err(owner_conv);
3943         uint32_t ret_ref = (uintptr_t)ret_copy;
3944         return ret_ref;
3945 }
3946
3947 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
3948         return ThirtyTwoBytes_clone(&owner->a);
3949 }
3950 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_get_a"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_a(uint32_t owner) {
3951         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
3952         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3953         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentIdZ_get_a(owner_conv).data, 32);
3954         return ret_arr;
3955 }
3956
3957 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
3958         return ThirtyTwoBytes_clone(&owner->b);
3959 }
3960 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_get_b"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_b(uint32_t owner) {
3961         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(owner & ~1);
3962         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
3963         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentIdZ_get_b(owner_conv).data, 32);
3964         return ret_arr;
3965 }
3966
3967 static inline struct LDKC2Tuple_PaymentHashPaymentIdZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
3968 CHECK(owner->result_ok);
3969         return C2Tuple_PaymentHashPaymentIdZ_clone(&*owner->contents.result);
3970 }
3971 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(uint32_t owner) {
3972         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
3973         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
3974         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(owner_conv);
3975         return ((uint32_t)ret_conv);
3976 }
3977
3978 static inline struct LDKPaymentSendFailure CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
3979 CHECK(!owner->result_ok);
3980         return PaymentSendFailure_clone(&*owner->contents.err);
3981 }
3982 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(uint32_t owner) {
3983         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(owner & ~1);
3984         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
3985         *ret_copy = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(owner_conv);
3986         uint32_t ret_ref = (uintptr_t)ret_copy;
3987         return ret_ref;
3988 }
3989
3990 uint32_t __attribute__((export_name("TS_LDKNetAddress_ty_from_ptr"))) TS_LDKNetAddress_ty_from_ptr(uint32_t ptr) {
3991         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3992         switch(obj->tag) {
3993                 case LDKNetAddress_IPv4: return 0;
3994                 case LDKNetAddress_IPv6: return 1;
3995                 case LDKNetAddress_OnionV2: return 2;
3996                 case LDKNetAddress_OnionV3: return 3;
3997                 default: abort();
3998         }
3999 }
4000 int8_tArray __attribute__((export_name("TS_LDKNetAddress_IPv4_get_addr"))) TS_LDKNetAddress_IPv4_get_addr(uint32_t ptr) {
4001         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
4002         assert(obj->tag == LDKNetAddress_IPv4);
4003                         int8_tArray addr_arr = init_int8_tArray(4, __LINE__);
4004                         memcpy(addr_arr->elems, obj->i_pv4.addr.data, 4);
4005         return addr_arr;
4006 }
4007 int16_t __attribute__((export_name("TS_LDKNetAddress_IPv4_get_port"))) TS_LDKNetAddress_IPv4_get_port(uint32_t ptr) {
4008         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
4009         assert(obj->tag == LDKNetAddress_IPv4);
4010                         int16_t port_conv = obj->i_pv4.port;
4011         return port_conv;
4012 }
4013 int8_tArray __attribute__((export_name("TS_LDKNetAddress_IPv6_get_addr"))) TS_LDKNetAddress_IPv6_get_addr(uint32_t ptr) {
4014         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
4015         assert(obj->tag == LDKNetAddress_IPv6);
4016                         int8_tArray addr_arr = init_int8_tArray(16, __LINE__);
4017                         memcpy(addr_arr->elems, obj->i_pv6.addr.data, 16);
4018         return addr_arr;
4019 }
4020 int16_t __attribute__((export_name("TS_LDKNetAddress_IPv6_get_port"))) TS_LDKNetAddress_IPv6_get_port(uint32_t ptr) {
4021         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
4022         assert(obj->tag == LDKNetAddress_IPv6);
4023                         int16_t port_conv = obj->i_pv6.port;
4024         return port_conv;
4025 }
4026 int8_tArray __attribute__((export_name("TS_LDKNetAddress_OnionV2_get_onion_v2"))) TS_LDKNetAddress_OnionV2_get_onion_v2(uint32_t ptr) {
4027         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
4028         assert(obj->tag == LDKNetAddress_OnionV2);
4029                         int8_tArray onion_v2_arr = init_int8_tArray(12, __LINE__);
4030                         memcpy(onion_v2_arr->elems, obj->onion_v2.data, 12);
4031         return onion_v2_arr;
4032 }
4033 int8_tArray __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_ed25519_pubkey"))) TS_LDKNetAddress_OnionV3_get_ed25519_pubkey(uint32_t ptr) {
4034         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
4035         assert(obj->tag == LDKNetAddress_OnionV3);
4036                         int8_tArray ed25519_pubkey_arr = init_int8_tArray(32, __LINE__);
4037                         memcpy(ed25519_pubkey_arr->elems, obj->onion_v3.ed25519_pubkey.data, 32);
4038         return ed25519_pubkey_arr;
4039 }
4040 int16_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_checksum"))) TS_LDKNetAddress_OnionV3_get_checksum(uint32_t ptr) {
4041         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
4042         assert(obj->tag == LDKNetAddress_OnionV3);
4043                         int16_t checksum_conv = obj->onion_v3.checksum;
4044         return checksum_conv;
4045 }
4046 int8_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_version"))) TS_LDKNetAddress_OnionV3_get_version(uint32_t ptr) {
4047         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
4048         assert(obj->tag == LDKNetAddress_OnionV3);
4049                         int8_t version_conv = obj->onion_v3.version;
4050         return version_conv;
4051 }
4052 int16_t __attribute__((export_name("TS_LDKNetAddress_OnionV3_get_port"))) TS_LDKNetAddress_OnionV3_get_port(uint32_t ptr) {
4053         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
4054         assert(obj->tag == LDKNetAddress_OnionV3);
4055                         int16_t port_conv = obj->onion_v3.port;
4056         return port_conv;
4057 }
4058 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
4059         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
4060         for (size_t i = 0; i < ret.datalen; i++) {
4061                 ret.data[i] = NetAddress_clone(&orig->data[i]);
4062         }
4063         return ret;
4064 }
4065 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
4066         return ThirtyTwoBytes_clone(&owner->a);
4067 }
4068 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_get_a"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_a(uint32_t owner) {
4069         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
4070         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4071         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentSecretZ_get_a(owner_conv).data, 32);
4072         return ret_arr;
4073 }
4074
4075 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
4076         return ThirtyTwoBytes_clone(&owner->b);
4077 }
4078 int8_tArray  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_get_b"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_b(uint32_t owner) {
4079         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(owner & ~1);
4080         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4081         memcpy(ret_arr->elems, C2Tuple_PaymentHashPaymentSecretZ_get_b(owner_conv).data, 32);
4082         return ret_arr;
4083 }
4084
4085 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
4086 CHECK(owner->result_ok);
4087         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
4088 }
4089 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(uint32_t owner) {
4090         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
4091         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
4092         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(owner_conv);
4093         return ((uint32_t)ret_conv);
4094 }
4095
4096 static inline void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
4097 CHECK(!owner->result_ok);
4098         return *owner->contents.err;
4099 }
4100 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(uint32_t owner) {
4101         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(owner & ~1);
4102         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(owner_conv);
4103 }
4104
4105 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
4106 CHECK(owner->result_ok);
4107         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
4108 }
4109 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(uint32_t owner) {
4110         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
4111         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
4112         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(owner_conv);
4113         return ((uint32_t)ret_conv);
4114 }
4115
4116 static inline struct LDKAPIError CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
4117 CHECK(!owner->result_ok);
4118         return APIError_clone(&*owner->contents.err);
4119 }
4120 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(uint32_t owner) {
4121         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(owner & ~1);
4122         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4123         *ret_copy = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(owner_conv);
4124         uint32_t ret_ref = (uintptr_t)ret_copy;
4125         return ret_ref;
4126 }
4127
4128 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretNoneZ_get_ok(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
4129 CHECK(owner->result_ok);
4130         return ThirtyTwoBytes_clone(&*owner->contents.result);
4131 }
4132 int8_tArray  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_get_ok"))) TS_CResult_PaymentSecretNoneZ_get_ok(uint32_t owner) {
4133         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
4134         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4135         memcpy(ret_arr->elems, CResult_PaymentSecretNoneZ_get_ok(owner_conv).data, 32);
4136         return ret_arr;
4137 }
4138
4139 static inline void CResult_PaymentSecretNoneZ_get_err(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
4140 CHECK(!owner->result_ok);
4141         return *owner->contents.err;
4142 }
4143 void  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_get_err"))) TS_CResult_PaymentSecretNoneZ_get_err(uint32_t owner) {
4144         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)(owner & ~1);
4145         CResult_PaymentSecretNoneZ_get_err(owner_conv);
4146 }
4147
4148 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretAPIErrorZ_get_ok(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
4149 CHECK(owner->result_ok);
4150         return ThirtyTwoBytes_clone(&*owner->contents.result);
4151 }
4152 int8_tArray  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_get_ok"))) TS_CResult_PaymentSecretAPIErrorZ_get_ok(uint32_t owner) {
4153         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
4154         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4155         memcpy(ret_arr->elems, CResult_PaymentSecretAPIErrorZ_get_ok(owner_conv).data, 32);
4156         return ret_arr;
4157 }
4158
4159 static inline struct LDKAPIError CResult_PaymentSecretAPIErrorZ_get_err(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
4160 CHECK(!owner->result_ok);
4161         return APIError_clone(&*owner->contents.err);
4162 }
4163 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_get_err"))) TS_CResult_PaymentSecretAPIErrorZ_get_err(uint32_t owner) {
4164         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(owner & ~1);
4165         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4166         *ret_copy = CResult_PaymentSecretAPIErrorZ_get_err(owner_conv);
4167         uint32_t ret_ref = (uintptr_t)ret_copy;
4168         return ret_ref;
4169 }
4170
4171 static inline struct LDKThirtyTwoBytes CResult_PaymentPreimageAPIErrorZ_get_ok(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
4172 CHECK(owner->result_ok);
4173         return ThirtyTwoBytes_clone(&*owner->contents.result);
4174 }
4175 int8_tArray  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_get_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_get_ok(uint32_t owner) {
4176         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
4177         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4178         memcpy(ret_arr->elems, CResult_PaymentPreimageAPIErrorZ_get_ok(owner_conv).data, 32);
4179         return ret_arr;
4180 }
4181
4182 static inline struct LDKAPIError CResult_PaymentPreimageAPIErrorZ_get_err(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
4183 CHECK(!owner->result_ok);
4184         return APIError_clone(&*owner->contents.err);
4185 }
4186 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_get_err"))) TS_CResult_PaymentPreimageAPIErrorZ_get_err(uint32_t owner) {
4187         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(owner & ~1);
4188         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4189         *ret_copy = CResult_PaymentPreimageAPIErrorZ_get_err(owner_conv);
4190         uint32_t ret_ref = (uintptr_t)ret_copy;
4191         return ret_ref;
4192 }
4193
4194 static inline struct LDKCounterpartyForwardingInfo CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
4195 CHECK(owner->result_ok);
4196         return CounterpartyForwardingInfo_clone(&*owner->contents.result);
4197 }
4198 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(uint32_t owner) {
4199         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
4200         LDKCounterpartyForwardingInfo ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(owner_conv);
4201         uint32_t ret_ref = 0;
4202         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4203         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4204         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4205         ret_ref = (uintptr_t)ret_var.inner;
4206         if (ret_var.is_owned) {
4207                 ret_ref |= 1;
4208         }
4209         return ret_ref;
4210 }
4211
4212 static inline struct LDKDecodeError CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
4213 CHECK(!owner->result_ok);
4214         return DecodeError_clone(&*owner->contents.err);
4215 }
4216 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(uint32_t owner) {
4217         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(owner & ~1);
4218         LDKDecodeError ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(owner_conv);
4219         uint32_t ret_ref = 0;
4220         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4221         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4222         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4223         ret_ref = (uintptr_t)ret_var.inner;
4224         if (ret_var.is_owned) {
4225                 ret_ref |= 1;
4226         }
4227         return ret_ref;
4228 }
4229
4230 static inline struct LDKChannelCounterparty CResult_ChannelCounterpartyDecodeErrorZ_get_ok(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
4231 CHECK(owner->result_ok);
4232         return ChannelCounterparty_clone(&*owner->contents.result);
4233 }
4234 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_get_ok"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_get_ok(uint32_t owner) {
4235         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
4236         LDKChannelCounterparty ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_ok(owner_conv);
4237         uint32_t ret_ref = 0;
4238         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4239         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4240         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4241         ret_ref = (uintptr_t)ret_var.inner;
4242         if (ret_var.is_owned) {
4243                 ret_ref |= 1;
4244         }
4245         return ret_ref;
4246 }
4247
4248 static inline struct LDKDecodeError CResult_ChannelCounterpartyDecodeErrorZ_get_err(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
4249 CHECK(!owner->result_ok);
4250         return DecodeError_clone(&*owner->contents.err);
4251 }
4252 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_get_err"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_get_err(uint32_t owner) {
4253         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(owner & ~1);
4254         LDKDecodeError ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_err(owner_conv);
4255         uint32_t ret_ref = 0;
4256         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4257         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4258         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4259         ret_ref = (uintptr_t)ret_var.inner;
4260         if (ret_var.is_owned) {
4261                 ret_ref |= 1;
4262         }
4263         return ret_ref;
4264 }
4265
4266 static inline struct LDKChannelDetails CResult_ChannelDetailsDecodeErrorZ_get_ok(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
4267 CHECK(owner->result_ok);
4268         return ChannelDetails_clone(&*owner->contents.result);
4269 }
4270 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_get_ok"))) TS_CResult_ChannelDetailsDecodeErrorZ_get_ok(uint32_t owner) {
4271         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
4272         LDKChannelDetails ret_var = CResult_ChannelDetailsDecodeErrorZ_get_ok(owner_conv);
4273         uint32_t ret_ref = 0;
4274         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4275         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4276         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4277         ret_ref = (uintptr_t)ret_var.inner;
4278         if (ret_var.is_owned) {
4279                 ret_ref |= 1;
4280         }
4281         return ret_ref;
4282 }
4283
4284 static inline struct LDKDecodeError CResult_ChannelDetailsDecodeErrorZ_get_err(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
4285 CHECK(!owner->result_ok);
4286         return DecodeError_clone(&*owner->contents.err);
4287 }
4288 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_get_err"))) TS_CResult_ChannelDetailsDecodeErrorZ_get_err(uint32_t owner) {
4289         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(owner & ~1);
4290         LDKDecodeError ret_var = CResult_ChannelDetailsDecodeErrorZ_get_err(owner_conv);
4291         uint32_t ret_ref = 0;
4292         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4293         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4294         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4295         ret_ref = (uintptr_t)ret_var.inner;
4296         if (ret_var.is_owned) {
4297                 ret_ref |= 1;
4298         }
4299         return ret_ref;
4300 }
4301
4302 static inline struct LDKPhantomRouteHints CResult_PhantomRouteHintsDecodeErrorZ_get_ok(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
4303 CHECK(owner->result_ok);
4304         return PhantomRouteHints_clone(&*owner->contents.result);
4305 }
4306 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_get_ok"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_get_ok(uint32_t owner) {
4307         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
4308         LDKPhantomRouteHints ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_ok(owner_conv);
4309         uint32_t ret_ref = 0;
4310         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4311         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4312         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4313         ret_ref = (uintptr_t)ret_var.inner;
4314         if (ret_var.is_owned) {
4315                 ret_ref |= 1;
4316         }
4317         return ret_ref;
4318 }
4319
4320 static inline struct LDKDecodeError CResult_PhantomRouteHintsDecodeErrorZ_get_err(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
4321 CHECK(!owner->result_ok);
4322         return DecodeError_clone(&*owner->contents.err);
4323 }
4324 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_get_err"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_get_err(uint32_t owner) {
4325         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(owner & ~1);
4326         LDKDecodeError ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_err(owner_conv);
4327         uint32_t ret_ref = 0;
4328         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4329         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4330         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4331         ret_ref = (uintptr_t)ret_var.inner;
4332         if (ret_var.is_owned) {
4333                 ret_ref |= 1;
4334         }
4335         return ret_ref;
4336 }
4337
4338 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
4339         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
4340         for (size_t i = 0; i < ret.datalen; i++) {
4341                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
4342         }
4343         return ret;
4344 }
4345 typedef struct LDKWatch_JCalls {
4346         atomic_size_t refcnt;
4347         uint32_t instance_ptr;
4348 } LDKWatch_JCalls;
4349 static void LDKWatch_JCalls_free(void* this_arg) {
4350         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4351         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4352                 FREE(j_calls);
4353         }
4354 }
4355 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
4356         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4357         LDKOutPoint funding_txo_var = funding_txo;
4358         uint32_t funding_txo_ref = 0;
4359         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4360         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4361         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
4362         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
4363         if (funding_txo_var.is_owned) {
4364                 funding_txo_ref |= 1;
4365         }
4366         LDKChannelMonitor monitor_var = monitor;
4367         uint32_t monitor_ref = 0;
4368         CHECK((((uintptr_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4369         CHECK((((uintptr_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4370         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
4371         monitor_ref = (uintptr_t)monitor_var.inner;
4372         if (monitor_var.is_owned) {
4373                 monitor_ref |= 1;
4374         }
4375         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 14, (uint32_t)funding_txo_ref, (uint32_t)monitor_ref);
4376         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4377         CHECK_ACCESS(ret_ptr);
4378         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
4379         FREE((void*)ret);
4380         return ret_conv;
4381 }
4382 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
4383         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4384         LDKOutPoint funding_txo_var = funding_txo;
4385         uint32_t funding_txo_ref = 0;
4386         CHECK((((uintptr_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4387         CHECK((((uintptr_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4388         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
4389         funding_txo_ref = (uintptr_t)funding_txo_var.inner;
4390         if (funding_txo_var.is_owned) {
4391                 funding_txo_ref |= 1;
4392         }
4393         LDKChannelMonitorUpdate update_var = update;
4394         uint32_t update_ref = 0;
4395         CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4396         CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4397         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
4398         update_ref = (uintptr_t)update_var.inner;
4399         if (update_var.is_owned) {
4400                 update_ref |= 1;
4401         }
4402         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 15, (uint32_t)funding_txo_ref, (uint32_t)update_ref);
4403         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4404         CHECK_ACCESS(ret_ptr);
4405         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
4406         FREE((void*)ret);
4407         return ret_conv;
4408 }
4409 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
4410         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4411         uint32_tArray ret = (uint32_tArray)js_invoke_function_0(j_calls->instance_ptr, 16);
4412         LDKCVec_MonitorEventZ ret_constr;
4413         ret_constr.datalen = ret->arr_len;
4414         if (ret_constr.datalen > 0)
4415                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
4416         else
4417                 ret_constr.data = NULL;
4418         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
4419         for (size_t o = 0; o < ret_constr.datalen; o++) {
4420                 uint32_t ret_conv_14 = ret_vals[o];
4421                 void* ret_conv_14_ptr = (void*)(((uintptr_t)ret_conv_14) & ~1);
4422                 CHECK_ACCESS(ret_conv_14_ptr);
4423                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(ret_conv_14_ptr);
4424                 FREE((void*)ret_conv_14);
4425                 ret_constr.data[o] = ret_conv_14_conv;
4426         }
4427         return ret_constr;
4428 }
4429 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
4430         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
4431         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4432 }
4433 static inline LDKWatch LDKWatch_init (JSValue o) {
4434         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
4435         atomic_init(&calls->refcnt, 1);
4436         calls->instance_ptr = o;
4437
4438         LDKWatch ret = {
4439                 .this_arg = (void*) calls,
4440                 .watch_channel = watch_channel_LDKWatch_jcall,
4441                 .update_channel = update_channel_LDKWatch_jcall,
4442                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
4443                 .free = LDKWatch_JCalls_free,
4444         };
4445         return ret;
4446 }
4447 long  __attribute__((export_name("TS_LDKWatch_new"))) TS_LDKWatch_new(JSValue o) {
4448         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
4449         *res_ptr = LDKWatch_init(o);
4450         return (long)res_ptr;
4451 }
4452 uint32_t  __attribute__((export_name("TS_Watch_watch_channel"))) TS_Watch_watch_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t monitor) {
4453         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4454         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4455         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
4456         LDKOutPoint funding_txo_conv;
4457         funding_txo_conv.inner = (void*)(funding_txo & (~1));
4458         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
4459         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
4460         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
4461         LDKChannelMonitor monitor_conv;
4462         monitor_conv.inner = (void*)(monitor & (~1));
4463         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
4464         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
4465         monitor_conv = ChannelMonitor_clone(&monitor_conv);
4466         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4467         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
4468         return (uint32_t)ret_conv;
4469 }
4470
4471 uint32_t  __attribute__((export_name("TS_Watch_update_channel"))) TS_Watch_update_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t update) {
4472         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4473         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4474         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
4475         LDKOutPoint funding_txo_conv;
4476         funding_txo_conv.inner = (void*)(funding_txo & (~1));
4477         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
4478         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
4479         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
4480         LDKChannelMonitorUpdate update_conv;
4481         update_conv.inner = (void*)(update & (~1));
4482         update_conv.is_owned = (update & 1) || (update == 0);
4483         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
4484         update_conv = ChannelMonitorUpdate_clone(&update_conv);
4485         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4486         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
4487         return (uint32_t)ret_conv;
4488 }
4489
4490 uint32_tArray  __attribute__((export_name("TS_Watch_release_pending_monitor_events"))) TS_Watch_release_pending_monitor_events(uint32_t this_arg) {
4491         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4492         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4493         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
4494         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
4495         uint32_tArray ret_arr = NULL;
4496         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
4497         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
4498         for (size_t o = 0; o < ret_var.datalen; o++) {
4499                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
4500                 *ret_conv_14_copy = ret_var.data[o];
4501                 uint32_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
4502                 ret_arr_ptr[o] = ret_conv_14_ref;
4503         }
4504         
4505         FREE(ret_var.data);
4506         return ret_arr;
4507 }
4508
4509 typedef struct LDKBroadcasterInterface_JCalls {
4510         atomic_size_t refcnt;
4511         uint32_t instance_ptr;
4512 } LDKBroadcasterInterface_JCalls;
4513 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
4514         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
4515         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4516                 FREE(j_calls);
4517         }
4518 }
4519 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
4520         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
4521         LDKTransaction tx_var = tx;
4522         int8_tArray tx_arr = init_int8_tArray(tx_var.datalen, __LINE__);
4523         memcpy(tx_arr->elems, tx_var.data, tx_var.datalen);
4524         Transaction_free(tx_var);
4525         js_invoke_function_1(j_calls->instance_ptr, 17, (uint32_t)tx_arr);
4526 }
4527 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
4528         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
4529         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4530 }
4531 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JSValue o) {
4532         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
4533         atomic_init(&calls->refcnt, 1);
4534         calls->instance_ptr = o;
4535
4536         LDKBroadcasterInterface ret = {
4537                 .this_arg = (void*) calls,
4538                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
4539                 .free = LDKBroadcasterInterface_JCalls_free,
4540         };
4541         return ret;
4542 }
4543 long  __attribute__((export_name("TS_LDKBroadcasterInterface_new"))) TS_LDKBroadcasterInterface_new(JSValue o) {
4544         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
4545         *res_ptr = LDKBroadcasterInterface_init(o);
4546         return (long)res_ptr;
4547 }
4548 void  __attribute__((export_name("TS_BroadcasterInterface_broadcast_transaction"))) TS_BroadcasterInterface_broadcast_transaction(uint32_t this_arg, int8_tArray tx) {
4549         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4550         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4551         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
4552         LDKTransaction tx_ref;
4553         tx_ref.datalen = tx->arr_len;
4554         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
4555         memcpy(tx_ref.data, tx->elems, tx_ref.datalen); FREE(tx);
4556         tx_ref.data_is_owned = true;
4557         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
4558 }
4559
4560 typedef struct LDKKeysInterface_JCalls {
4561         atomic_size_t refcnt;
4562         uint32_t instance_ptr;
4563 } LDKKeysInterface_JCalls;
4564 static void LDKKeysInterface_JCalls_free(void* this_arg) {
4565         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4566         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4567                 FREE(j_calls);
4568         }
4569 }
4570 LDKCResult_SecretKeyNoneZ get_node_secret_LDKKeysInterface_jcall(const void* this_arg, LDKRecipient recipient) {
4571         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4572         uint32_t recipient_conv = LDKRecipient_to_js(recipient);
4573         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 18, (uint32_t)recipient_conv);
4574         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4575         CHECK_ACCESS(ret_ptr);
4576         LDKCResult_SecretKeyNoneZ ret_conv = *(LDKCResult_SecretKeyNoneZ*)(ret_ptr);
4577         FREE((void*)ret);
4578         return ret_conv;
4579 }
4580 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
4581         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4582         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 19);
4583         LDKCVec_u8Z ret_ref;
4584         ret_ref.datalen = ret->arr_len;
4585         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
4586         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
4587         return ret_ref;
4588 }
4589 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
4590         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4591         uint32_t ret = js_invoke_function_0(j_calls->instance_ptr, 20);
4592         LDKShutdownScript ret_conv;
4593         ret_conv.inner = (void*)(ret & (~1));
4594         ret_conv.is_owned = (ret & 1) || (ret == 0);
4595         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
4596         return ret_conv;
4597 }
4598 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
4599         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4600         jboolean inbound_conv = inbound;
4601         int64_t channel_value_satoshis_conv = channel_value_satoshis;
4602         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 21, (uint32_t)inbound_conv, (uint32_t)channel_value_satoshis_conv);
4603         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4604         CHECK_ACCESS(ret_ptr);
4605         LDKSign ret_conv = *(LDKSign*)(ret_ptr);
4606         FREE((void*)ret);
4607         return ret_conv;
4608 }
4609 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
4610         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4611         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 22);
4612         LDKThirtyTwoBytes ret_ref;
4613         CHECK(ret->arr_len == 32);
4614         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
4615         return ret_ref;
4616 }
4617 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
4618         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4619         LDKu8slice reader_var = reader;
4620         int8_tArray reader_arr = init_int8_tArray(reader_var.datalen, __LINE__);
4621         memcpy(reader_arr->elems, reader_var.data, reader_var.datalen);
4622         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 23, (uint32_t)reader_arr);
4623         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4624         CHECK_ACCESS(ret_ptr);
4625         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
4626         FREE((void*)ret);
4627         return ret_conv;
4628 }
4629 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice hrp_bytes, LDKCVec_u5Z invoice_data, LDKRecipient receipient) {
4630         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4631         LDKu8slice hrp_bytes_var = hrp_bytes;
4632         int8_tArray hrp_bytes_arr = init_int8_tArray(hrp_bytes_var.datalen, __LINE__);
4633         memcpy(hrp_bytes_arr->elems, hrp_bytes_var.data, hrp_bytes_var.datalen);
4634         LDKCVec_u5Z invoice_data_var = invoice_data;
4635         ptrArray invoice_data_arr = NULL;
4636         invoice_data_arr = init_ptrArray(invoice_data_var.datalen, __LINE__);
4637         int8_t *invoice_data_arr_ptr = (int8_t*)(((uint8_t*)invoice_data_arr) + 4);
4638         for (size_t h = 0; h < invoice_data_var.datalen; h++) {
4639                 uint8_t invoice_data_conv_7_val = invoice_data_var.data[h]._0;
4640                 invoice_data_arr_ptr[h] = invoice_data_conv_7_val;
4641         }
4642         
4643         FREE(invoice_data_var.data);
4644         uint32_t receipient_conv = LDKRecipient_to_js(receipient);
4645         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);
4646         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
4647         CHECK_ACCESS(ret_ptr);
4648         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
4649         FREE((void*)ret);
4650         return ret_conv;
4651 }
4652 LDKThirtyTwoBytes get_inbound_payment_key_material_LDKKeysInterface_jcall(const void* this_arg) {
4653         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4654         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 25);
4655         LDKThirtyTwoBytes ret_ref;
4656         CHECK(ret->arr_len == 32);
4657         memcpy(ret_ref.data, ret->elems, 32); FREE(ret);
4658         return ret_ref;
4659 }
4660 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
4661         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
4662         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4663 }
4664 static inline LDKKeysInterface LDKKeysInterface_init (JSValue o) {
4665         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
4666         atomic_init(&calls->refcnt, 1);
4667         calls->instance_ptr = o;
4668
4669         LDKKeysInterface ret = {
4670                 .this_arg = (void*) calls,
4671                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
4672                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
4673                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
4674                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
4675                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
4676                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
4677                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
4678                 .get_inbound_payment_key_material = get_inbound_payment_key_material_LDKKeysInterface_jcall,
4679                 .free = LDKKeysInterface_JCalls_free,
4680         };
4681         return ret;
4682 }
4683 long  __attribute__((export_name("TS_LDKKeysInterface_new"))) TS_LDKKeysInterface_new(JSValue o) {
4684         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
4685         *res_ptr = LDKKeysInterface_init(o);
4686         return (long)res_ptr;
4687 }
4688 uint32_t  __attribute__((export_name("TS_KeysInterface_get_node_secret"))) TS_KeysInterface_get_node_secret(uint32_t this_arg, uint32_t recipient) {
4689         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4690         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4691         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4692         LDKRecipient recipient_conv = LDKRecipient_from_js(recipient);
4693         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
4694         *ret_conv = (this_arg_conv->get_node_secret)(this_arg_conv->this_arg, recipient_conv);
4695         return (uint32_t)ret_conv;
4696 }
4697
4698 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_destination_script"))) TS_KeysInterface_get_destination_script(uint32_t this_arg) {
4699         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4700         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4701         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4702         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
4703         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
4704         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
4705         CVec_u8Z_free(ret_var);
4706         return ret_arr;
4707 }
4708
4709 uint32_t  __attribute__((export_name("TS_KeysInterface_get_shutdown_scriptpubkey"))) TS_KeysInterface_get_shutdown_scriptpubkey(uint32_t this_arg) {
4710         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4711         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4712         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4713         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
4714         uint32_t ret_ref = 0;
4715         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4716         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4717         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4718         ret_ref = (uintptr_t)ret_var.inner;
4719         if (ret_var.is_owned) {
4720                 ret_ref |= 1;
4721         }
4722         return ret_ref;
4723 }
4724
4725 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) {
4726         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4727         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4728         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4729         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
4730         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
4731         return (uint32_t)ret_ret;
4732 }
4733
4734 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_secure_random_bytes"))) TS_KeysInterface_get_secure_random_bytes(uint32_t this_arg) {
4735         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4736         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4737         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4738         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4739         memcpy(ret_arr->elems, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data, 32);
4740         return ret_arr;
4741 }
4742
4743 uint32_t  __attribute__((export_name("TS_KeysInterface_read_chan_signer"))) TS_KeysInterface_read_chan_signer(uint32_t this_arg, int8_tArray reader) {
4744         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4745         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4746         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4747         LDKu8slice reader_ref;
4748         reader_ref.datalen = reader->arr_len;
4749         reader_ref.data = reader->elems /* XXX reader leaks */;
4750         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
4751         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
4752         return (uint32_t)ret_conv;
4753 }
4754
4755 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) {
4756         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4757         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4758         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4759         LDKu8slice hrp_bytes_ref;
4760         hrp_bytes_ref.datalen = hrp_bytes->arr_len;
4761         hrp_bytes_ref.data = hrp_bytes->elems /* XXX hrp_bytes leaks */;
4762         LDKCVec_u5Z invoice_data_constr;
4763         invoice_data_constr.datalen = invoice_data->arr_len;
4764         if (invoice_data_constr.datalen > 0)
4765                 invoice_data_constr.data = MALLOC(invoice_data_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
4766         else
4767                 invoice_data_constr.data = NULL;
4768         int8_t* invoice_data_vals = (void*) invoice_data->elems /* XXX invoice_data leaks */;
4769         for (size_t h = 0; h < invoice_data_constr.datalen; h++) {
4770                 int8_t invoice_data_conv_7 = invoice_data_vals[h];
4771                 
4772                 invoice_data_constr.data[h] = (LDKu5){ ._0 = invoice_data_conv_7 };
4773         }
4774         LDKRecipient receipient_conv = LDKRecipient_from_js(receipient);
4775         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
4776         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, hrp_bytes_ref, invoice_data_constr, receipient_conv);
4777         return (uint32_t)ret_conv;
4778 }
4779
4780 int8_tArray  __attribute__((export_name("TS_KeysInterface_get_inbound_payment_key_material"))) TS_KeysInterface_get_inbound_payment_key_material(uint32_t this_arg) {
4781         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4782         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4783         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4784         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4785         memcpy(ret_arr->elems, (this_arg_conv->get_inbound_payment_key_material)(this_arg_conv->this_arg).data, 32);
4786         return ret_arr;
4787 }
4788
4789 typedef struct LDKFeeEstimator_JCalls {
4790         atomic_size_t refcnt;
4791         uint32_t instance_ptr;
4792 } LDKFeeEstimator_JCalls;
4793 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
4794         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
4795         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4796                 FREE(j_calls);
4797         }
4798 }
4799 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
4800         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
4801         uint32_t confirmation_target_conv = LDKConfirmationTarget_to_js(confirmation_target);
4802         return js_invoke_function_1(j_calls->instance_ptr, 26, (uint32_t)confirmation_target_conv);
4803 }
4804 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
4805         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
4806         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4807 }
4808 static inline LDKFeeEstimator LDKFeeEstimator_init (JSValue o) {
4809         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
4810         atomic_init(&calls->refcnt, 1);
4811         calls->instance_ptr = o;
4812
4813         LDKFeeEstimator ret = {
4814                 .this_arg = (void*) calls,
4815                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
4816                 .free = LDKFeeEstimator_JCalls_free,
4817         };
4818         return ret;
4819 }
4820 long  __attribute__((export_name("TS_LDKFeeEstimator_new"))) TS_LDKFeeEstimator_new(JSValue o) {
4821         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
4822         *res_ptr = LDKFeeEstimator_init(o);
4823         return (long)res_ptr;
4824 }
4825 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) {
4826         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
4827         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4828         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
4829         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_js(confirmation_target);
4830         int32_t ret_conv = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
4831         return ret_conv;
4832 }
4833
4834 typedef struct LDKLogger_JCalls {
4835         atomic_size_t refcnt;
4836         uint32_t instance_ptr;
4837 } LDKLogger_JCalls;
4838 static void LDKLogger_JCalls_free(void* this_arg) {
4839         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4840         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4841                 FREE(j_calls);
4842         }
4843 }
4844 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
4845         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4846         LDKRecord record_var = *record;
4847         uint32_t record_ref = 0;
4848         record_var = Record_clone(&record_var);
4849         CHECK((((uintptr_t)record_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4850         CHECK((((uintptr_t)&record_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4851         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
4852         record_ref = (uintptr_t)record_var.inner;
4853         if (record_var.is_owned) {
4854                 record_ref |= 1;
4855         }
4856         js_invoke_function_1(j_calls->instance_ptr, 27, (uint32_t)record_ref);
4857 }
4858 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
4859         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
4860         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4861 }
4862 static inline LDKLogger LDKLogger_init (JSValue o) {
4863         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
4864         atomic_init(&calls->refcnt, 1);
4865         calls->instance_ptr = o;
4866
4867         LDKLogger ret = {
4868                 .this_arg = (void*) calls,
4869                 .log = log_LDKLogger_jcall,
4870                 .free = LDKLogger_JCalls_free,
4871         };
4872         return ret;
4873 }
4874 long  __attribute__((export_name("TS_LDKLogger_new"))) TS_LDKLogger_new(JSValue o) {
4875         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
4876         *res_ptr = LDKLogger_init(o);
4877         return (long)res_ptr;
4878 }
4879 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
4880         return ThirtyTwoBytes_clone(&owner->a);
4881 }
4882 int8_tArray  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_get_a"))) TS_C2Tuple_BlockHashChannelManagerZ_get_a(uint32_t owner) {
4883         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
4884         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
4885         memcpy(ret_arr->elems, C2Tuple_BlockHashChannelManagerZ_get_a(owner_conv).data, 32);
4886         return ret_arr;
4887 }
4888
4889 static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
4890         return &owner->b;
4891 }
4892 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_get_b"))) TS_C2Tuple_BlockHashChannelManagerZ_get_b(uint32_t owner) {
4893         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(owner & ~1);
4894         LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(owner_conv);
4895         uint32_t ret_ref = 0;
4896         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4897         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4898         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4899         ret_ref = (uintptr_t)ret_var.inner & ~1;
4900         return ret_ref;
4901 }
4902
4903 static inline struct LDKC2Tuple_BlockHashChannelManagerZ *CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
4904 CHECK(owner->result_ok);
4905         return &*owner->contents.result;
4906 }
4907 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(uint32_t owner) {
4908         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
4909         uint32_t ret_ret = (uintptr_t)CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(owner_conv) | 1;
4910         return ret_ret;
4911 }
4912
4913 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
4914 CHECK(!owner->result_ok);
4915         return DecodeError_clone(&*owner->contents.err);
4916 }
4917 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(uint32_t owner) {
4918         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(owner & ~1);
4919         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(owner_conv);
4920         uint32_t ret_ref = 0;
4921         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4922         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4923         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4924         ret_ref = (uintptr_t)ret_var.inner;
4925         if (ret_var.is_owned) {
4926                 ret_ref |= 1;
4927         }
4928         return ret_ref;
4929 }
4930
4931 static inline struct LDKChannelConfig CResult_ChannelConfigDecodeErrorZ_get_ok(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
4932 CHECK(owner->result_ok);
4933         return ChannelConfig_clone(&*owner->contents.result);
4934 }
4935 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_get_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_get_ok(uint32_t owner) {
4936         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
4937         LDKChannelConfig ret_var = CResult_ChannelConfigDecodeErrorZ_get_ok(owner_conv);
4938         uint32_t ret_ref = 0;
4939         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4940         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4941         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4942         ret_ref = (uintptr_t)ret_var.inner;
4943         if (ret_var.is_owned) {
4944                 ret_ref |= 1;
4945         }
4946         return ret_ref;
4947 }
4948
4949 static inline struct LDKDecodeError CResult_ChannelConfigDecodeErrorZ_get_err(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
4950 CHECK(!owner->result_ok);
4951         return DecodeError_clone(&*owner->contents.err);
4952 }
4953 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_get_err"))) TS_CResult_ChannelConfigDecodeErrorZ_get_err(uint32_t owner) {
4954         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(owner & ~1);
4955         LDKDecodeError ret_var = CResult_ChannelConfigDecodeErrorZ_get_err(owner_conv);
4956         uint32_t ret_ref = 0;
4957         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4958         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4959         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4960         ret_ref = (uintptr_t)ret_var.inner;
4961         if (ret_var.is_owned) {
4962                 ret_ref |= 1;
4963         }
4964         return ret_ref;
4965 }
4966
4967 static inline struct LDKOutPoint CResult_OutPointDecodeErrorZ_get_ok(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
4968 CHECK(owner->result_ok);
4969         return OutPoint_clone(&*owner->contents.result);
4970 }
4971 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_get_ok"))) TS_CResult_OutPointDecodeErrorZ_get_ok(uint32_t owner) {
4972         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
4973         LDKOutPoint ret_var = CResult_OutPointDecodeErrorZ_get_ok(owner_conv);
4974         uint32_t ret_ref = 0;
4975         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4976         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4977         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4978         ret_ref = (uintptr_t)ret_var.inner;
4979         if (ret_var.is_owned) {
4980                 ret_ref |= 1;
4981         }
4982         return ret_ref;
4983 }
4984
4985 static inline struct LDKDecodeError CResult_OutPointDecodeErrorZ_get_err(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
4986 CHECK(!owner->result_ok);
4987         return DecodeError_clone(&*owner->contents.err);
4988 }
4989 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_get_err"))) TS_CResult_OutPointDecodeErrorZ_get_err(uint32_t owner) {
4990         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)(owner & ~1);
4991         LDKDecodeError ret_var = CResult_OutPointDecodeErrorZ_get_err(owner_conv);
4992         uint32_t ret_ref = 0;
4993         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4994         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4995         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4996         ret_ref = (uintptr_t)ret_var.inner;
4997         if (ret_var.is_owned) {
4998                 ret_ref |= 1;
4999         }
5000         return ret_ref;
5001 }
5002
5003 typedef struct LDKType_JCalls {
5004         atomic_size_t refcnt;
5005         uint32_t instance_ptr;
5006 } LDKType_JCalls;
5007 static void LDKType_JCalls_free(void* this_arg) {
5008         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5009         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5010                 FREE(j_calls);
5011         }
5012 }
5013 uint16_t type_id_LDKType_jcall(const void* this_arg) {
5014         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5015         return js_invoke_function_0(j_calls->instance_ptr, 28);
5016 }
5017 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
5018         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5019         jstring ret = (jstring)js_invoke_function_0(j_calls->instance_ptr, 29);
5020         LDKStr ret_conv = str_ref_to_owned_c(ret);
5021         return ret_conv;
5022 }
5023 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
5024         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5025         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 30);
5026         LDKCVec_u8Z ret_ref;
5027         ret_ref.datalen = ret->arr_len;
5028         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
5029         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
5030         return ret_ref;
5031 }
5032 static void LDKType_JCalls_cloned(LDKType* new_obj) {
5033         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
5034         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5035 }
5036 static inline LDKType LDKType_init (JSValue o) {
5037         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
5038         atomic_init(&calls->refcnt, 1);
5039         calls->instance_ptr = o;
5040
5041         LDKType ret = {
5042                 .this_arg = (void*) calls,
5043                 .type_id = type_id_LDKType_jcall,
5044                 .debug_str = debug_str_LDKType_jcall,
5045                 .write = write_LDKType_jcall,
5046                 .cloned = LDKType_JCalls_cloned,
5047                 .free = LDKType_JCalls_free,
5048         };
5049         return ret;
5050 }
5051 long  __attribute__((export_name("TS_LDKType_new"))) TS_LDKType_new(JSValue o) {
5052         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
5053         *res_ptr = LDKType_init(o);
5054         return (long)res_ptr;
5055 }
5056 int16_t  __attribute__((export_name("TS_Type_type_id"))) TS_Type_type_id(uint32_t this_arg) {
5057         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5058         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5059         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5060         int16_t ret_conv = (this_arg_conv->type_id)(this_arg_conv->this_arg);
5061         return ret_conv;
5062 }
5063
5064 jstring  __attribute__((export_name("TS_Type_debug_str"))) TS_Type_debug_str(uint32_t this_arg) {
5065         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5066         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5067         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5068         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
5069         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
5070         Str_free(ret_str);
5071         return ret_conv;
5072 }
5073
5074 int8_tArray  __attribute__((export_name("TS_Type_write"))) TS_Type_write(uint32_t this_arg) {
5075         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
5076         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5077         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5078         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
5079         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
5080         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
5081         CVec_u8Z_free(ret_var);
5082         return ret_arr;
5083 }
5084
5085 uint32_t __attribute__((export_name("TS_LDKCOption_TypeZ_ty_from_ptr"))) TS_LDKCOption_TypeZ_ty_from_ptr(uint32_t ptr) {
5086         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
5087         switch(obj->tag) {
5088                 case LDKCOption_TypeZ_Some: return 0;
5089                 case LDKCOption_TypeZ_None: return 1;
5090                 default: abort();
5091         }
5092 }
5093 uint32_t __attribute__((export_name("TS_LDKCOption_TypeZ_Some_get_some"))) TS_LDKCOption_TypeZ_Some_get_some(uint32_t ptr) {
5094         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
5095         assert(obj->tag == LDKCOption_TypeZ_Some);
5096                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
5097                         *some_ret = Type_clone(&obj->some);
5098         return (uint32_t)some_ret;
5099 }
5100 static inline struct LDKCOption_TypeZ CResult_COption_TypeZDecodeErrorZ_get_ok(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
5101 CHECK(owner->result_ok);
5102         return COption_TypeZ_clone(&*owner->contents.result);
5103 }
5104 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_get_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_get_ok(uint32_t owner) {
5105         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
5106         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
5107         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_ok(owner_conv);
5108         uint32_t ret_ref = (uintptr_t)ret_copy;
5109         return ret_ref;
5110 }
5111
5112 static inline struct LDKDecodeError CResult_COption_TypeZDecodeErrorZ_get_err(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
5113 CHECK(!owner->result_ok);
5114         return DecodeError_clone(&*owner->contents.err);
5115 }
5116 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_get_err"))) TS_CResult_COption_TypeZDecodeErrorZ_get_err(uint32_t owner) {
5117         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(owner & ~1);
5118         LDKDecodeError ret_var = CResult_COption_TypeZDecodeErrorZ_get_err(owner_conv);
5119         uint32_t ret_ref = 0;
5120         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5121         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5122         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5123         ret_ref = (uintptr_t)ret_var.inner;
5124         if (ret_var.is_owned) {
5125                 ret_ref |= 1;
5126         }
5127         return ret_ref;
5128 }
5129
5130 uint32_t __attribute__((export_name("TS_LDKPaymentError_ty_from_ptr"))) TS_LDKPaymentError_ty_from_ptr(uint32_t ptr) {
5131         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
5132         switch(obj->tag) {
5133                 case LDKPaymentError_Invoice: return 0;
5134                 case LDKPaymentError_Routing: return 1;
5135                 case LDKPaymentError_Sending: return 2;
5136                 default: abort();
5137         }
5138 }
5139 jstring __attribute__((export_name("TS_LDKPaymentError_Invoice_get_invoice"))) TS_LDKPaymentError_Invoice_get_invoice(uint32_t ptr) {
5140         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
5141         assert(obj->tag == LDKPaymentError_Invoice);
5142                         LDKStr invoice_str = obj->invoice;
5143                         jstring invoice_conv = str_ref_to_ts(invoice_str.chars, invoice_str.len);
5144         return invoice_conv;
5145 }
5146 uint32_t __attribute__((export_name("TS_LDKPaymentError_Routing_get_routing"))) TS_LDKPaymentError_Routing_get_routing(uint32_t ptr) {
5147         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
5148         assert(obj->tag == LDKPaymentError_Routing);
5149                         LDKLightningError routing_var = obj->routing;
5150                         uint32_t routing_ref = 0;
5151                         CHECK((((uintptr_t)routing_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5152                         CHECK((((uintptr_t)&routing_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5153                         CHECK_INNER_FIELD_ACCESS_OR_NULL(routing_var);
5154                         routing_ref = (uintptr_t)routing_var.inner & ~1;
5155         return routing_ref;
5156 }
5157 uint32_t __attribute__((export_name("TS_LDKPaymentError_Sending_get_sending"))) TS_LDKPaymentError_Sending_get_sending(uint32_t ptr) {
5158         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
5159         assert(obj->tag == LDKPaymentError_Sending);
5160                         uint32_t sending_ref = ((uintptr_t)&obj->sending) | 1;
5161         return sending_ref;
5162 }
5163 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentErrorZ_get_ok(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
5164 CHECK(owner->result_ok);
5165         return ThirtyTwoBytes_clone(&*owner->contents.result);
5166 }
5167 int8_tArray  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_get_ok"))) TS_CResult_PaymentIdPaymentErrorZ_get_ok(uint32_t owner) {
5168         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
5169         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5170         memcpy(ret_arr->elems, CResult_PaymentIdPaymentErrorZ_get_ok(owner_conv).data, 32);
5171         return ret_arr;
5172 }
5173
5174 static inline struct LDKPaymentError CResult_PaymentIdPaymentErrorZ_get_err(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
5175 CHECK(!owner->result_ok);
5176         return PaymentError_clone(&*owner->contents.err);
5177 }
5178 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_get_err"))) TS_CResult_PaymentIdPaymentErrorZ_get_err(uint32_t owner) {
5179         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(owner & ~1);
5180         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
5181         *ret_copy = CResult_PaymentIdPaymentErrorZ_get_err(owner_conv);
5182         uint32_t ret_ref = (uintptr_t)ret_copy;
5183         return ret_ref;
5184 }
5185
5186 uint32_t __attribute__((export_name("TS_LDKParseError_ty_from_ptr"))) TS_LDKParseError_ty_from_ptr(uint32_t ptr) {
5187         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
5188         switch(obj->tag) {
5189                 case LDKParseError_Bech32Error: return 0;
5190                 case LDKParseError_ParseAmountError: return 1;
5191                 case LDKParseError_MalformedSignature: return 2;
5192                 case LDKParseError_BadPrefix: return 3;
5193                 case LDKParseError_UnknownCurrency: return 4;
5194                 case LDKParseError_UnknownSiPrefix: return 5;
5195                 case LDKParseError_MalformedHRP: return 6;
5196                 case LDKParseError_TooShortDataPart: return 7;
5197                 case LDKParseError_UnexpectedEndOfTaggedFields: return 8;
5198                 case LDKParseError_DescriptionDecodeError: return 9;
5199                 case LDKParseError_PaddingError: return 10;
5200                 case LDKParseError_IntegerOverflowError: return 11;
5201                 case LDKParseError_InvalidSegWitProgramLength: return 12;
5202                 case LDKParseError_InvalidPubKeyHashLength: return 13;
5203                 case LDKParseError_InvalidScriptHashLength: return 14;
5204                 case LDKParseError_InvalidRecoveryId: return 15;
5205                 case LDKParseError_InvalidSliceLength: return 16;
5206                 case LDKParseError_Skip: return 17;
5207                 default: abort();
5208         }
5209 }
5210 uint32_t __attribute__((export_name("TS_LDKParseError_Bech32Error_get_bech32_error"))) TS_LDKParseError_Bech32Error_get_bech32_error(uint32_t ptr) {
5211         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
5212         assert(obj->tag == LDKParseError_Bech32Error);
5213                         uint32_t bech32_error_ref = ((uintptr_t)&obj->bech32_error) | 1;
5214         return bech32_error_ref;
5215 }
5216 int32_t __attribute__((export_name("TS_LDKParseError_ParseAmountError_get_parse_amount_error"))) TS_LDKParseError_ParseAmountError_get_parse_amount_error(uint32_t ptr) {
5217         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
5218         assert(obj->tag == LDKParseError_ParseAmountError);
5219                         /*obj->parse_amount_error*/
5220         return 0;
5221 }
5222 uint32_t __attribute__((export_name("TS_LDKParseError_MalformedSignature_get_malformed_signature"))) TS_LDKParseError_MalformedSignature_get_malformed_signature(uint32_t ptr) {
5223         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
5224         assert(obj->tag == LDKParseError_MalformedSignature);
5225                         uint32_t malformed_signature_conv = LDKSecp256k1Error_to_js(obj->malformed_signature);
5226         return malformed_signature_conv;
5227 }
5228 int32_t __attribute__((export_name("TS_LDKParseError_DescriptionDecodeError_get_description_decode_error"))) TS_LDKParseError_DescriptionDecodeError_get_description_decode_error(uint32_t ptr) {
5229         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
5230         assert(obj->tag == LDKParseError_DescriptionDecodeError);
5231                         /*obj->description_decode_error*/
5232         return 0;
5233 }
5234 jstring __attribute__((export_name("TS_LDKParseError_InvalidSliceLength_get_invalid_slice_length"))) TS_LDKParseError_InvalidSliceLength_get_invalid_slice_length(uint32_t ptr) {
5235         LDKParseError *obj = (LDKParseError*)(ptr & ~1);
5236         assert(obj->tag == LDKParseError_InvalidSliceLength);
5237                         LDKStr invalid_slice_length_str = obj->invalid_slice_length;
5238                         jstring invalid_slice_length_conv = str_ref_to_ts(invalid_slice_length_str.chars, invalid_slice_length_str.len);
5239         return invalid_slice_length_conv;
5240 }
5241 static inline enum LDKSiPrefix CResult_SiPrefixParseErrorZ_get_ok(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
5242 CHECK(owner->result_ok);
5243         return SiPrefix_clone(&*owner->contents.result);
5244 }
5245 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_get_ok"))) TS_CResult_SiPrefixParseErrorZ_get_ok(uint32_t owner) {
5246         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)(owner & ~1);
5247         uint32_t ret_conv = LDKSiPrefix_to_js(CResult_SiPrefixParseErrorZ_get_ok(owner_conv));
5248         return ret_conv;
5249 }
5250
5251 static inline struct LDKParseError CResult_SiPrefixParseErrorZ_get_err(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
5252 CHECK(!owner->result_ok);
5253         return ParseError_clone(&*owner->contents.err);
5254 }
5255 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_get_err"))) TS_CResult_SiPrefixParseErrorZ_get_err(uint32_t owner) {
5256         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)(owner & ~1);
5257         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
5258         *ret_copy = CResult_SiPrefixParseErrorZ_get_err(owner_conv);
5259         uint32_t ret_ref = (uintptr_t)ret_copy;
5260         return ret_ref;
5261 }
5262
5263 uint32_t __attribute__((export_name("TS_LDKParseOrSemanticError_ty_from_ptr"))) TS_LDKParseOrSemanticError_ty_from_ptr(uint32_t ptr) {
5264         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)(ptr & ~1);
5265         switch(obj->tag) {
5266                 case LDKParseOrSemanticError_ParseError: return 0;
5267                 case LDKParseOrSemanticError_SemanticError: return 1;
5268                 default: abort();
5269         }
5270 }
5271 uint32_t __attribute__((export_name("TS_LDKParseOrSemanticError_ParseError_get_parse_error"))) TS_LDKParseOrSemanticError_ParseError_get_parse_error(uint32_t ptr) {
5272         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)(ptr & ~1);
5273         assert(obj->tag == LDKParseOrSemanticError_ParseError);
5274                         uint32_t parse_error_ref = ((uintptr_t)&obj->parse_error) | 1;
5275         return parse_error_ref;
5276 }
5277 uint32_t __attribute__((export_name("TS_LDKParseOrSemanticError_SemanticError_get_semantic_error"))) TS_LDKParseOrSemanticError_SemanticError_get_semantic_error(uint32_t ptr) {
5278         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)(ptr & ~1);
5279         assert(obj->tag == LDKParseOrSemanticError_SemanticError);
5280                         uint32_t semantic_error_conv = LDKSemanticError_to_js(obj->semantic_error);
5281         return semantic_error_conv;
5282 }
5283 static inline struct LDKInvoice CResult_InvoiceParseOrSemanticErrorZ_get_ok(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
5284 CHECK(owner->result_ok);
5285         return Invoice_clone(&*owner->contents.result);
5286 }
5287 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_get_ok"))) TS_CResult_InvoiceParseOrSemanticErrorZ_get_ok(uint32_t owner) {
5288         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(owner & ~1);
5289         LDKInvoice ret_var = CResult_InvoiceParseOrSemanticErrorZ_get_ok(owner_conv);
5290         uint32_t ret_ref = 0;
5291         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5292         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5293         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5294         ret_ref = (uintptr_t)ret_var.inner;
5295         if (ret_var.is_owned) {
5296                 ret_ref |= 1;
5297         }
5298         return ret_ref;
5299 }
5300
5301 static inline struct LDKParseOrSemanticError CResult_InvoiceParseOrSemanticErrorZ_get_err(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
5302 CHECK(!owner->result_ok);
5303         return ParseOrSemanticError_clone(&*owner->contents.err);
5304 }
5305 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_get_err"))) TS_CResult_InvoiceParseOrSemanticErrorZ_get_err(uint32_t owner) {
5306         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(owner & ~1);
5307         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
5308         *ret_copy = CResult_InvoiceParseOrSemanticErrorZ_get_err(owner_conv);
5309         uint32_t ret_ref = (uintptr_t)ret_copy;
5310         return ret_ref;
5311 }
5312
5313 static inline struct LDKSignedRawInvoice CResult_SignedRawInvoiceParseErrorZ_get_ok(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
5314 CHECK(owner->result_ok);
5315         return SignedRawInvoice_clone(&*owner->contents.result);
5316 }
5317 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_get_ok"))) TS_CResult_SignedRawInvoiceParseErrorZ_get_ok(uint32_t owner) {
5318         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(owner & ~1);
5319         LDKSignedRawInvoice ret_var = CResult_SignedRawInvoiceParseErrorZ_get_ok(owner_conv);
5320         uint32_t ret_ref = 0;
5321         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5322         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5323         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5324         ret_ref = (uintptr_t)ret_var.inner;
5325         if (ret_var.is_owned) {
5326                 ret_ref |= 1;
5327         }
5328         return ret_ref;
5329 }
5330
5331 static inline struct LDKParseError CResult_SignedRawInvoiceParseErrorZ_get_err(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
5332 CHECK(!owner->result_ok);
5333         return ParseError_clone(&*owner->contents.err);
5334 }
5335 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_get_err"))) TS_CResult_SignedRawInvoiceParseErrorZ_get_err(uint32_t owner) {
5336         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(owner & ~1);
5337         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
5338         *ret_copy = CResult_SignedRawInvoiceParseErrorZ_get_err(owner_conv);
5339         uint32_t ret_ref = (uintptr_t)ret_copy;
5340         return ret_ref;
5341 }
5342
5343 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
5344         return RawInvoice_clone(&owner->a);
5345 }
5346 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(uint32_t owner) {
5347         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
5348         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(owner_conv);
5349         uint32_t ret_ref = 0;
5350         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5351         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5352         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5353         ret_ref = (uintptr_t)ret_var.inner;
5354         if (ret_var.is_owned) {
5355                 ret_ref |= 1;
5356         }
5357         return ret_ref;
5358 }
5359
5360 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
5361         return ThirtyTwoBytes_clone(&owner->b);
5362 }
5363 int8_tArray  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(uint32_t owner) {
5364         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
5365         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5366         memcpy(ret_arr->elems, C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(owner_conv).data, 32);
5367         return ret_arr;
5368 }
5369
5370 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
5371         return InvoiceSignature_clone(&owner->c);
5372 }
5373 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(uint32_t owner) {
5374         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(owner & ~1);
5375         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(owner_conv);
5376         uint32_t ret_ref = 0;
5377         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5378         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5379         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5380         ret_ref = (uintptr_t)ret_var.inner;
5381         if (ret_var.is_owned) {
5382                 ret_ref |= 1;
5383         }
5384         return ret_ref;
5385 }
5386
5387 static inline struct LDKPayeePubKey CResult_PayeePubKeyErrorZ_get_ok(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
5388 CHECK(owner->result_ok);
5389         return PayeePubKey_clone(&*owner->contents.result);
5390 }
5391 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_get_ok"))) TS_CResult_PayeePubKeyErrorZ_get_ok(uint32_t owner) {
5392         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
5393         LDKPayeePubKey ret_var = CResult_PayeePubKeyErrorZ_get_ok(owner_conv);
5394         uint32_t ret_ref = 0;
5395         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5396         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5397         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5398         ret_ref = (uintptr_t)ret_var.inner;
5399         if (ret_var.is_owned) {
5400                 ret_ref |= 1;
5401         }
5402         return ret_ref;
5403 }
5404
5405 static inline enum LDKSecp256k1Error CResult_PayeePubKeyErrorZ_get_err(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
5406 CHECK(!owner->result_ok);
5407         return *owner->contents.err;
5408 }
5409 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_get_err"))) TS_CResult_PayeePubKeyErrorZ_get_err(uint32_t owner) {
5410         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)(owner & ~1);
5411         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_PayeePubKeyErrorZ_get_err(owner_conv));
5412         return ret_conv;
5413 }
5414
5415 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
5416         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
5417         for (size_t i = 0; i < ret.datalen; i++) {
5418                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
5419         }
5420         return ret;
5421 }
5422 static inline struct LDKPositiveTimestamp CResult_PositiveTimestampCreationErrorZ_get_ok(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
5423 CHECK(owner->result_ok);
5424         return PositiveTimestamp_clone(&*owner->contents.result);
5425 }
5426 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_get_ok"))) TS_CResult_PositiveTimestampCreationErrorZ_get_ok(uint32_t owner) {
5427         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
5428         LDKPositiveTimestamp ret_var = CResult_PositiveTimestampCreationErrorZ_get_ok(owner_conv);
5429         uint32_t ret_ref = 0;
5430         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5431         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5432         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5433         ret_ref = (uintptr_t)ret_var.inner;
5434         if (ret_var.is_owned) {
5435                 ret_ref |= 1;
5436         }
5437         return ret_ref;
5438 }
5439
5440 static inline enum LDKCreationError CResult_PositiveTimestampCreationErrorZ_get_err(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
5441 CHECK(!owner->result_ok);
5442         return CreationError_clone(&*owner->contents.err);
5443 }
5444 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_get_err"))) TS_CResult_PositiveTimestampCreationErrorZ_get_err(uint32_t owner) {
5445         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(owner & ~1);
5446         uint32_t ret_conv = LDKCreationError_to_js(CResult_PositiveTimestampCreationErrorZ_get_err(owner_conv));
5447         return ret_conv;
5448 }
5449
5450 static inline void CResult_NoneSemanticErrorZ_get_ok(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
5451 CHECK(owner->result_ok);
5452         return *owner->contents.result;
5453 }
5454 void  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_get_ok"))) TS_CResult_NoneSemanticErrorZ_get_ok(uint32_t owner) {
5455         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
5456         CResult_NoneSemanticErrorZ_get_ok(owner_conv);
5457 }
5458
5459 static inline enum LDKSemanticError CResult_NoneSemanticErrorZ_get_err(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
5460 CHECK(!owner->result_ok);
5461         return SemanticError_clone(&*owner->contents.err);
5462 }
5463 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_get_err"))) TS_CResult_NoneSemanticErrorZ_get_err(uint32_t owner) {
5464         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)(owner & ~1);
5465         uint32_t ret_conv = LDKSemanticError_to_js(CResult_NoneSemanticErrorZ_get_err(owner_conv));
5466         return ret_conv;
5467 }
5468
5469 static inline struct LDKInvoice CResult_InvoiceSemanticErrorZ_get_ok(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
5470 CHECK(owner->result_ok);
5471         return Invoice_clone(&*owner->contents.result);
5472 }
5473 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_get_ok"))) TS_CResult_InvoiceSemanticErrorZ_get_ok(uint32_t owner) {
5474         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
5475         LDKInvoice ret_var = CResult_InvoiceSemanticErrorZ_get_ok(owner_conv);
5476         uint32_t ret_ref = 0;
5477         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5478         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5479         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5480         ret_ref = (uintptr_t)ret_var.inner;
5481         if (ret_var.is_owned) {
5482                 ret_ref |= 1;
5483         }
5484         return ret_ref;
5485 }
5486
5487 static inline enum LDKSemanticError CResult_InvoiceSemanticErrorZ_get_err(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
5488 CHECK(!owner->result_ok);
5489         return SemanticError_clone(&*owner->contents.err);
5490 }
5491 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_get_err"))) TS_CResult_InvoiceSemanticErrorZ_get_err(uint32_t owner) {
5492         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)(owner & ~1);
5493         uint32_t ret_conv = LDKSemanticError_to_js(CResult_InvoiceSemanticErrorZ_get_err(owner_conv));
5494         return ret_conv;
5495 }
5496
5497 static inline struct LDKDescription CResult_DescriptionCreationErrorZ_get_ok(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
5498 CHECK(owner->result_ok);
5499         return Description_clone(&*owner->contents.result);
5500 }
5501 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_get_ok"))) TS_CResult_DescriptionCreationErrorZ_get_ok(uint32_t owner) {
5502         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
5503         LDKDescription ret_var = CResult_DescriptionCreationErrorZ_get_ok(owner_conv);
5504         uint32_t ret_ref = 0;
5505         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5506         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5507         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5508         ret_ref = (uintptr_t)ret_var.inner;
5509         if (ret_var.is_owned) {
5510                 ret_ref |= 1;
5511         }
5512         return ret_ref;
5513 }
5514
5515 static inline enum LDKCreationError CResult_DescriptionCreationErrorZ_get_err(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
5516 CHECK(!owner->result_ok);
5517         return CreationError_clone(&*owner->contents.err);
5518 }
5519 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_get_err"))) TS_CResult_DescriptionCreationErrorZ_get_err(uint32_t owner) {
5520         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)(owner & ~1);
5521         uint32_t ret_conv = LDKCreationError_to_js(CResult_DescriptionCreationErrorZ_get_err(owner_conv));
5522         return ret_conv;
5523 }
5524
5525 static inline struct LDKPrivateRoute CResult_PrivateRouteCreationErrorZ_get_ok(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
5526 CHECK(owner->result_ok);
5527         return PrivateRoute_clone(&*owner->contents.result);
5528 }
5529 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_get_ok"))) TS_CResult_PrivateRouteCreationErrorZ_get_ok(uint32_t owner) {
5530         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
5531         LDKPrivateRoute ret_var = CResult_PrivateRouteCreationErrorZ_get_ok(owner_conv);
5532         uint32_t ret_ref = 0;
5533         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5534         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5535         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5536         ret_ref = (uintptr_t)ret_var.inner;
5537         if (ret_var.is_owned) {
5538                 ret_ref |= 1;
5539         }
5540         return ret_ref;
5541 }
5542
5543 static inline enum LDKCreationError CResult_PrivateRouteCreationErrorZ_get_err(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
5544 CHECK(!owner->result_ok);
5545         return CreationError_clone(&*owner->contents.err);
5546 }
5547 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_get_err"))) TS_CResult_PrivateRouteCreationErrorZ_get_err(uint32_t owner) {
5548         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(owner & ~1);
5549         uint32_t ret_conv = LDKCreationError_to_js(CResult_PrivateRouteCreationErrorZ_get_err(owner_conv));
5550         return ret_conv;
5551 }
5552
5553 static inline struct LDKStr CResult_StringErrorZ_get_ok(LDKCResult_StringErrorZ *NONNULL_PTR owner){
5554 CHECK(owner->result_ok);
5555         return *owner->contents.result;
5556 }
5557 jstring  __attribute__((export_name("TS_CResult_StringErrorZ_get_ok"))) TS_CResult_StringErrorZ_get_ok(uint32_t owner) {
5558         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
5559         LDKStr ret_str = CResult_StringErrorZ_get_ok(owner_conv);
5560         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
5561         return ret_conv;
5562 }
5563
5564 static inline enum LDKSecp256k1Error CResult_StringErrorZ_get_err(LDKCResult_StringErrorZ *NONNULL_PTR owner){
5565 CHECK(!owner->result_ok);
5566         return *owner->contents.err;
5567 }
5568 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_get_err"))) TS_CResult_StringErrorZ_get_err(uint32_t owner) {
5569         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)(owner & ~1);
5570         uint32_t ret_conv = LDKSecp256k1Error_to_js(CResult_StringErrorZ_get_err(owner_conv));
5571         return ret_conv;
5572 }
5573
5574 static inline struct LDKChannelMonitorUpdate CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
5575 CHECK(owner->result_ok);
5576         return ChannelMonitorUpdate_clone(&*owner->contents.result);
5577 }
5578 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(uint32_t owner) {
5579         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
5580         LDKChannelMonitorUpdate ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(owner_conv);
5581         uint32_t ret_ref = 0;
5582         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5583         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5584         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5585         ret_ref = (uintptr_t)ret_var.inner;
5586         if (ret_var.is_owned) {
5587                 ret_ref |= 1;
5588         }
5589         return ret_ref;
5590 }
5591
5592 static inline struct LDKDecodeError CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
5593 CHECK(!owner->result_ok);
5594         return DecodeError_clone(&*owner->contents.err);
5595 }
5596 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_err"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(uint32_t owner) {
5597         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(owner & ~1);
5598         LDKDecodeError ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(owner_conv);
5599         uint32_t ret_ref = 0;
5600         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5601         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5602         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5603         ret_ref = (uintptr_t)ret_var.inner;
5604         if (ret_var.is_owned) {
5605                 ret_ref |= 1;
5606         }
5607         return ret_ref;
5608 }
5609
5610 uint32_t __attribute__((export_name("TS_LDKCOption_MonitorEventZ_ty_from_ptr"))) TS_LDKCOption_MonitorEventZ_ty_from_ptr(uint32_t ptr) {
5611         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
5612         switch(obj->tag) {
5613                 case LDKCOption_MonitorEventZ_Some: return 0;
5614                 case LDKCOption_MonitorEventZ_None: return 1;
5615                 default: abort();
5616         }
5617 }
5618 uint32_t __attribute__((export_name("TS_LDKCOption_MonitorEventZ_Some_get_some"))) TS_LDKCOption_MonitorEventZ_Some_get_some(uint32_t ptr) {
5619         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
5620         assert(obj->tag == LDKCOption_MonitorEventZ_Some);
5621                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
5622         return some_ref;
5623 }
5624 static inline struct LDKCOption_MonitorEventZ CResult_COption_MonitorEventZDecodeErrorZ_get_ok(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
5625 CHECK(owner->result_ok);
5626         return COption_MonitorEventZ_clone(&*owner->contents.result);
5627 }
5628 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_get_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_get_ok(uint32_t owner) {
5629         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
5630         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
5631         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_ok(owner_conv);
5632         uint32_t ret_ref = (uintptr_t)ret_copy;
5633         return ret_ref;
5634 }
5635
5636 static inline struct LDKDecodeError CResult_COption_MonitorEventZDecodeErrorZ_get_err(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
5637 CHECK(!owner->result_ok);
5638         return DecodeError_clone(&*owner->contents.err);
5639 }
5640 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_get_err"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_get_err(uint32_t owner) {
5641         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(owner & ~1);
5642         LDKDecodeError ret_var = CResult_COption_MonitorEventZDecodeErrorZ_get_err(owner_conv);
5643         uint32_t ret_ref = 0;
5644         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5645         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5646         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5647         ret_ref = (uintptr_t)ret_var.inner;
5648         if (ret_var.is_owned) {
5649                 ret_ref |= 1;
5650         }
5651         return ret_ref;
5652 }
5653
5654 static inline struct LDKHTLCUpdate CResult_HTLCUpdateDecodeErrorZ_get_ok(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
5655 CHECK(owner->result_ok);
5656         return HTLCUpdate_clone(&*owner->contents.result);
5657 }
5658 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_get_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_get_ok(uint32_t owner) {
5659         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
5660         LDKHTLCUpdate ret_var = CResult_HTLCUpdateDecodeErrorZ_get_ok(owner_conv);
5661         uint32_t ret_ref = 0;
5662         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5663         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5664         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5665         ret_ref = (uintptr_t)ret_var.inner;
5666         if (ret_var.is_owned) {
5667                 ret_ref |= 1;
5668         }
5669         return ret_ref;
5670 }
5671
5672 static inline struct LDKDecodeError CResult_HTLCUpdateDecodeErrorZ_get_err(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
5673 CHECK(!owner->result_ok);
5674         return DecodeError_clone(&*owner->contents.err);
5675 }
5676 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_get_err"))) TS_CResult_HTLCUpdateDecodeErrorZ_get_err(uint32_t owner) {
5677         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(owner & ~1);
5678         LDKDecodeError ret_var = CResult_HTLCUpdateDecodeErrorZ_get_err(owner_conv);
5679         uint32_t ret_ref = 0;
5680         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5681         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5682         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5683         ret_ref = (uintptr_t)ret_var.inner;
5684         if (ret_var.is_owned) {
5685                 ret_ref |= 1;
5686         }
5687         return ret_ref;
5688 }
5689
5690 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
5691         return OutPoint_clone(&owner->a);
5692 }
5693 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_get_a"))) TS_C2Tuple_OutPointScriptZ_get_a(uint32_t owner) {
5694         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
5695         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(owner_conv);
5696         uint32_t ret_ref = 0;
5697         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5698         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5699         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5700         ret_ref = (uintptr_t)ret_var.inner;
5701         if (ret_var.is_owned) {
5702                 ret_ref |= 1;
5703         }
5704         return ret_ref;
5705 }
5706
5707 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
5708         return CVec_u8Z_clone(&owner->b);
5709 }
5710 int8_tArray  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_get_b"))) TS_C2Tuple_OutPointScriptZ_get_b(uint32_t owner) {
5711         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)(owner & ~1);
5712         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(owner_conv);
5713         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
5714         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
5715         CVec_u8Z_free(ret_var);
5716         return ret_arr;
5717 }
5718
5719 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
5720         return owner->a;
5721 }
5722 int32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_get_a"))) TS_C2Tuple_u32ScriptZ_get_a(uint32_t owner) {
5723         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
5724         int32_t ret_conv = C2Tuple_u32ScriptZ_get_a(owner_conv);
5725         return ret_conv;
5726 }
5727
5728 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
5729         return CVec_u8Z_clone(&owner->b);
5730 }
5731 int8_tArray  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_get_b"))) TS_C2Tuple_u32ScriptZ_get_b(uint32_t owner) {
5732         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)(owner & ~1);
5733         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(owner_conv);
5734         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
5735         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
5736         CVec_u8Z_free(ret_var);
5737         return ret_arr;
5738 }
5739
5740 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
5741         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
5742         for (size_t i = 0; i < ret.datalen; i++) {
5743                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
5744         }
5745         return ret;
5746 }
5747 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
5748         return ThirtyTwoBytes_clone(&owner->a);
5749 }
5750 int8_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(uint32_t owner) {
5751         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
5752         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5753         memcpy(ret_arr->elems, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(owner_conv).data, 32);
5754         return ret_arr;
5755 }
5756
5757 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
5758         return CVec_C2Tuple_u32ScriptZZ_clone(&owner->b);
5759 }
5760 uint32_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(uint32_t owner) {
5761         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(owner & ~1);
5762         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(owner_conv);
5763         uint32_tArray ret_arr = NULL;
5764         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
5765         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
5766         for (size_t v = 0; v < ret_var.datalen; v++) {
5767                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
5768                 *ret_conv_21_conv = ret_var.data[v];
5769                 ret_arr_ptr[v] = ((uint32_t)ret_conv_21_conv);
5770         }
5771         
5772         FREE(ret_var.data);
5773         return ret_arr;
5774 }
5775
5776 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
5777         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 };
5778         for (size_t i = 0; i < ret.datalen; i++) {
5779                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
5780         }
5781         return ret;
5782 }
5783 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
5784         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
5785         for (size_t i = 0; i < ret.datalen; i++) {
5786                 ret.data[i] = Event_clone(&orig->data[i]);
5787         }
5788         return ret;
5789 }
5790 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
5791         return owner->a;
5792 }
5793 int32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_get_a"))) TS_C2Tuple_u32TxOutZ_get_a(uint32_t owner) {
5794         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
5795         int32_t ret_conv = C2Tuple_u32TxOutZ_get_a(owner_conv);
5796         return ret_conv;
5797 }
5798
5799 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
5800         return TxOut_clone(&owner->b);
5801 }
5802 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_get_b"))) TS_C2Tuple_u32TxOutZ_get_b(uint32_t owner) {
5803         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)(owner & ~1);
5804         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
5805         *ret_ref = C2Tuple_u32TxOutZ_get_b(owner_conv);
5806         return (uint32_t)ret_ref;
5807 }
5808
5809 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
5810         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
5811         for (size_t i = 0; i < ret.datalen; i++) {
5812                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
5813         }
5814         return ret;
5815 }
5816 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
5817         return ThirtyTwoBytes_clone(&owner->a);
5818 }
5819 int8_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(uint32_t owner) {
5820         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
5821         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5822         memcpy(ret_arr->elems, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(owner_conv).data, 32);
5823         return ret_arr;
5824 }
5825
5826 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
5827         return CVec_C2Tuple_u32TxOutZZ_clone(&owner->b);
5828 }
5829 uint32_tArray  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(uint32_t owner) {
5830         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(owner & ~1);
5831         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(owner_conv);
5832         uint32_tArray ret_arr = NULL;
5833         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
5834         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
5835         for (size_t u = 0; u < ret_var.datalen; u++) {
5836                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
5837                 *ret_conv_20_conv = ret_var.data[u];
5838                 ret_arr_ptr[u] = ((uint32_t)ret_conv_20_conv);
5839         }
5840         
5841         FREE(ret_var.data);
5842         return ret_arr;
5843 }
5844
5845 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
5846         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 };
5847         for (size_t i = 0; i < ret.datalen; i++) {
5848                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
5849         }
5850         return ret;
5851 }
5852 uint32_t __attribute__((export_name("TS_LDKBalance_ty_from_ptr"))) TS_LDKBalance_ty_from_ptr(uint32_t ptr) {
5853         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5854         switch(obj->tag) {
5855                 case LDKBalance_ClaimableOnChannelClose: return 0;
5856                 case LDKBalance_ClaimableAwaitingConfirmations: return 1;
5857                 case LDKBalance_ContentiousClaimable: return 2;
5858                 case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: return 3;
5859                 default: abort();
5860         }
5861 }
5862 int64_t __attribute__((export_name("TS_LDKBalance_ClaimableOnChannelClose_get_claimable_amount_satoshis"))) TS_LDKBalance_ClaimableOnChannelClose_get_claimable_amount_satoshis(uint32_t ptr) {
5863         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5864         assert(obj->tag == LDKBalance_ClaimableOnChannelClose);
5865                         int64_t claimable_amount_satoshis_conv = obj->claimable_on_channel_close.claimable_amount_satoshis;
5866         return claimable_amount_satoshis_conv;
5867 }
5868 int64_t __attribute__((export_name("TS_LDKBalance_ClaimableAwaitingConfirmations_get_claimable_amount_satoshis"))) TS_LDKBalance_ClaimableAwaitingConfirmations_get_claimable_amount_satoshis(uint32_t ptr) {
5869         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5870         assert(obj->tag == LDKBalance_ClaimableAwaitingConfirmations);
5871                         int64_t claimable_amount_satoshis_conv = obj->claimable_awaiting_confirmations.claimable_amount_satoshis;
5872         return claimable_amount_satoshis_conv;
5873 }
5874 int32_t __attribute__((export_name("TS_LDKBalance_ClaimableAwaitingConfirmations_get_confirmation_height"))) TS_LDKBalance_ClaimableAwaitingConfirmations_get_confirmation_height(uint32_t ptr) {
5875         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5876         assert(obj->tag == LDKBalance_ClaimableAwaitingConfirmations);
5877                         int32_t confirmation_height_conv = obj->claimable_awaiting_confirmations.confirmation_height;
5878         return confirmation_height_conv;
5879 }
5880 int64_t __attribute__((export_name("TS_LDKBalance_ContentiousClaimable_get_claimable_amount_satoshis"))) TS_LDKBalance_ContentiousClaimable_get_claimable_amount_satoshis(uint32_t ptr) {
5881         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5882         assert(obj->tag == LDKBalance_ContentiousClaimable);
5883                         int64_t claimable_amount_satoshis_conv = obj->contentious_claimable.claimable_amount_satoshis;
5884         return claimable_amount_satoshis_conv;
5885 }
5886 int32_t __attribute__((export_name("TS_LDKBalance_ContentiousClaimable_get_timeout_height"))) TS_LDKBalance_ContentiousClaimable_get_timeout_height(uint32_t ptr) {
5887         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5888         assert(obj->tag == LDKBalance_ContentiousClaimable);
5889                         int32_t timeout_height_conv = obj->contentious_claimable.timeout_height;
5890         return timeout_height_conv;
5891 }
5892 int64_t __attribute__((export_name("TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_amount_satoshis"))) TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_amount_satoshis(uint32_t ptr) {
5893         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5894         assert(obj->tag == LDKBalance_MaybeClaimableHTLCAwaitingTimeout);
5895                         int64_t claimable_amount_satoshis_conv = obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis;
5896         return claimable_amount_satoshis_conv;
5897 }
5898 int32_t __attribute__((export_name("TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_height"))) TS_LDKBalance_MaybeClaimableHTLCAwaitingTimeout_get_claimable_height(uint32_t ptr) {
5899         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5900         assert(obj->tag == LDKBalance_MaybeClaimableHTLCAwaitingTimeout);
5901                         int32_t claimable_height_conv = obj->maybe_claimable_htlc_awaiting_timeout.claimable_height;
5902         return claimable_height_conv;
5903 }
5904 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
5905         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
5906         for (size_t i = 0; i < ret.datalen; i++) {
5907                 ret.data[i] = Balance_clone(&orig->data[i]);
5908         }
5909         return ret;
5910 }
5911 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
5912         return ThirtyTwoBytes_clone(&owner->a);
5913 }
5914 int8_tArray  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_get_a"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_a(uint32_t owner) {
5915         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
5916         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
5917         memcpy(ret_arr->elems, C2Tuple_BlockHashChannelMonitorZ_get_a(owner_conv).data, 32);
5918         return ret_arr;
5919 }
5920
5921 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
5922         return ChannelMonitor_clone(&owner->b);
5923 }
5924 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_get_b"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_b(uint32_t owner) {
5925         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(owner & ~1);
5926         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(owner_conv);
5927         uint32_t ret_ref = 0;
5928         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5929         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5930         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5931         ret_ref = (uintptr_t)ret_var.inner;
5932         if (ret_var.is_owned) {
5933                 ret_ref |= 1;
5934         }
5935         return ret_ref;
5936 }
5937
5938 static inline struct LDKC2Tuple_BlockHashChannelMonitorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
5939 CHECK(owner->result_ok);
5940         return C2Tuple_BlockHashChannelMonitorZ_clone(&*owner->contents.result);
5941 }
5942 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(uint32_t owner) {
5943         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
5944         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
5945         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(owner_conv);
5946         return ((uint32_t)ret_conv);
5947 }
5948
5949 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
5950 CHECK(!owner->result_ok);
5951         return DecodeError_clone(&*owner->contents.err);
5952 }
5953 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(uint32_t owner) {
5954         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(owner & ~1);
5955         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(owner_conv);
5956         uint32_t ret_ref = 0;
5957         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5958         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5959         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5960         ret_ref = (uintptr_t)ret_var.inner;
5961         if (ret_var.is_owned) {
5962                 ret_ref |= 1;
5963         }
5964         return ret_ref;
5965 }
5966
5967 static inline void CResult_NoneLightningErrorZ_get_ok(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
5968 CHECK(owner->result_ok);
5969         return *owner->contents.result;
5970 }
5971 void  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_get_ok"))) TS_CResult_NoneLightningErrorZ_get_ok(uint32_t owner) {
5972         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
5973         CResult_NoneLightningErrorZ_get_ok(owner_conv);
5974 }
5975
5976 static inline struct LDKLightningError CResult_NoneLightningErrorZ_get_err(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
5977 CHECK(!owner->result_ok);
5978         return LightningError_clone(&*owner->contents.err);
5979 }
5980 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_get_err"))) TS_CResult_NoneLightningErrorZ_get_err(uint32_t owner) {
5981         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)(owner & ~1);
5982         LDKLightningError ret_var = CResult_NoneLightningErrorZ_get_err(owner_conv);
5983         uint32_t ret_ref = 0;
5984         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5985         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5986         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5987         ret_ref = (uintptr_t)ret_var.inner;
5988         if (ret_var.is_owned) {
5989                 ret_ref |= 1;
5990         }
5991         return ret_ref;
5992 }
5993
5994 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
5995         return owner->a;
5996 }
5997 int8_tArray  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_get_a"))) TS_C2Tuple_PublicKeyTypeZ_get_a(uint32_t owner) {
5998         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
5999         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
6000         memcpy(ret_arr->elems, C2Tuple_PublicKeyTypeZ_get_a(owner_conv).compressed_form, 33);
6001         return ret_arr;
6002 }
6003
6004 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
6005         return Type_clone(&owner->b);
6006 }
6007 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_get_b"))) TS_C2Tuple_PublicKeyTypeZ_get_b(uint32_t owner) {
6008         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)(owner & ~1);
6009         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
6010         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(owner_conv);
6011         return (uint32_t)ret_ret;
6012 }
6013
6014 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
6015         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
6016         for (size_t i = 0; i < ret.datalen; i++) {
6017                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
6018         }
6019         return ret;
6020 }
6021 static inline bool CResult_boolLightningErrorZ_get_ok(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
6022 CHECK(owner->result_ok);
6023         return *owner->contents.result;
6024 }
6025 jboolean  __attribute__((export_name("TS_CResult_boolLightningErrorZ_get_ok"))) TS_CResult_boolLightningErrorZ_get_ok(uint32_t owner) {
6026         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
6027         jboolean ret_conv = CResult_boolLightningErrorZ_get_ok(owner_conv);
6028         return ret_conv;
6029 }
6030
6031 static inline struct LDKLightningError CResult_boolLightningErrorZ_get_err(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
6032 CHECK(!owner->result_ok);
6033         return LightningError_clone(&*owner->contents.err);
6034 }
6035 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_get_err"))) TS_CResult_boolLightningErrorZ_get_err(uint32_t owner) {
6036         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)(owner & ~1);
6037         LDKLightningError ret_var = CResult_boolLightningErrorZ_get_err(owner_conv);
6038         uint32_t ret_ref = 0;
6039         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6040         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6041         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6042         ret_ref = (uintptr_t)ret_var.inner;
6043         if (ret_var.is_owned) {
6044                 ret_ref |= 1;
6045         }
6046         return ret_ref;
6047 }
6048
6049 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
6050         return ChannelAnnouncement_clone(&owner->a);
6051 }
6052 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(uint32_t owner) {
6053         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
6054         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(owner_conv);
6055         uint32_t ret_ref = 0;
6056         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6057         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6058         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6059         ret_ref = (uintptr_t)ret_var.inner;
6060         if (ret_var.is_owned) {
6061                 ret_ref |= 1;
6062         }
6063         return ret_ref;
6064 }
6065
6066 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
6067         return ChannelUpdate_clone(&owner->b);
6068 }
6069 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(uint32_t owner) {
6070         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
6071         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(owner_conv);
6072         uint32_t ret_ref = 0;
6073         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6074         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6075         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6076         ret_ref = (uintptr_t)ret_var.inner;
6077         if (ret_var.is_owned) {
6078                 ret_ref |= 1;
6079         }
6080         return ret_ref;
6081 }
6082
6083 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
6084         return ChannelUpdate_clone(&owner->c);
6085 }
6086 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(uint32_t owner) {
6087         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(owner & ~1);
6088         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(owner_conv);
6089         uint32_t ret_ref = 0;
6090         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6091         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6092         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6093         ret_ref = (uintptr_t)ret_var.inner;
6094         if (ret_var.is_owned) {
6095                 ret_ref |= 1;
6096         }
6097         return ret_ref;
6098 }
6099
6100 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
6101         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
6102         for (size_t i = 0; i < ret.datalen; i++) {
6103                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
6104         }
6105         return ret;
6106 }
6107 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
6108         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
6109         for (size_t i = 0; i < ret.datalen; i++) {
6110                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
6111         }
6112         return ret;
6113 }
6114 uint32_t __attribute__((export_name("TS_LDKCOption_NetAddressZ_ty_from_ptr"))) TS_LDKCOption_NetAddressZ_ty_from_ptr(uint32_t ptr) {
6115         LDKCOption_NetAddressZ *obj = (LDKCOption_NetAddressZ*)(ptr & ~1);
6116         switch(obj->tag) {
6117                 case LDKCOption_NetAddressZ_Some: return 0;
6118                 case LDKCOption_NetAddressZ_None: return 1;
6119                 default: abort();
6120         }
6121 }
6122 uint32_t __attribute__((export_name("TS_LDKCOption_NetAddressZ_Some_get_some"))) TS_LDKCOption_NetAddressZ_Some_get_some(uint32_t ptr) {
6123         LDKCOption_NetAddressZ *obj = (LDKCOption_NetAddressZ*)(ptr & ~1);
6124         assert(obj->tag == LDKCOption_NetAddressZ_Some);
6125                         uint32_t some_ref = ((uintptr_t)&obj->some) | 1;
6126         return some_ref;
6127 }
6128 static inline struct LDKCVec_u8Z CResult_CVec_u8ZPeerHandleErrorZ_get_ok(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
6129 CHECK(owner->result_ok);
6130         return CVec_u8Z_clone(&*owner->contents.result);
6131 }
6132 int8_tArray  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_get_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_get_ok(uint32_t owner) {
6133         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
6134         LDKCVec_u8Z ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_ok(owner_conv);
6135         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
6136         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
6137         CVec_u8Z_free(ret_var);
6138         return ret_arr;
6139 }
6140
6141 static inline struct LDKPeerHandleError CResult_CVec_u8ZPeerHandleErrorZ_get_err(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
6142 CHECK(!owner->result_ok);
6143         return PeerHandleError_clone(&*owner->contents.err);
6144 }
6145 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_get_err"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_get_err(uint32_t owner) {
6146         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(owner & ~1);
6147         LDKPeerHandleError ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_err(owner_conv);
6148         uint32_t ret_ref = 0;
6149         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6150         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6151         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6152         ret_ref = (uintptr_t)ret_var.inner;
6153         if (ret_var.is_owned) {
6154                 ret_ref |= 1;
6155         }
6156         return ret_ref;
6157 }
6158
6159 static inline void CResult_NonePeerHandleErrorZ_get_ok(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
6160 CHECK(owner->result_ok);
6161         return *owner->contents.result;
6162 }
6163 void  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_get_ok"))) TS_CResult_NonePeerHandleErrorZ_get_ok(uint32_t owner) {
6164         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
6165         CResult_NonePeerHandleErrorZ_get_ok(owner_conv);
6166 }
6167
6168 static inline struct LDKPeerHandleError CResult_NonePeerHandleErrorZ_get_err(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
6169 CHECK(!owner->result_ok);
6170         return PeerHandleError_clone(&*owner->contents.err);
6171 }
6172 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_get_err"))) TS_CResult_NonePeerHandleErrorZ_get_err(uint32_t owner) {
6173         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)(owner & ~1);
6174         LDKPeerHandleError ret_var = CResult_NonePeerHandleErrorZ_get_err(owner_conv);
6175         uint32_t ret_ref = 0;
6176         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6177         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6178         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6179         ret_ref = (uintptr_t)ret_var.inner;
6180         if (ret_var.is_owned) {
6181                 ret_ref |= 1;
6182         }
6183         return ret_ref;
6184 }
6185
6186 static inline bool CResult_boolPeerHandleErrorZ_get_ok(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
6187 CHECK(owner->result_ok);
6188         return *owner->contents.result;
6189 }
6190 jboolean  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_get_ok"))) TS_CResult_boolPeerHandleErrorZ_get_ok(uint32_t owner) {
6191         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
6192         jboolean ret_conv = CResult_boolPeerHandleErrorZ_get_ok(owner_conv);
6193         return ret_conv;
6194 }
6195
6196 static inline struct LDKPeerHandleError CResult_boolPeerHandleErrorZ_get_err(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
6197 CHECK(!owner->result_ok);
6198         return PeerHandleError_clone(&*owner->contents.err);
6199 }
6200 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_get_err"))) TS_CResult_boolPeerHandleErrorZ_get_err(uint32_t owner) {
6201         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)(owner & ~1);
6202         LDKPeerHandleError ret_var = CResult_boolPeerHandleErrorZ_get_err(owner_conv);
6203         uint32_t ret_ref = 0;
6204         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6205         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6206         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6207         ret_ref = (uintptr_t)ret_var.inner;
6208         if (ret_var.is_owned) {
6209                 ret_ref |= 1;
6210         }
6211         return ret_ref;
6212 }
6213
6214 static inline struct LDKNodeId CResult_NodeIdDecodeErrorZ_get_ok(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
6215 CHECK(owner->result_ok);
6216         return NodeId_clone(&*owner->contents.result);
6217 }
6218 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_get_ok"))) TS_CResult_NodeIdDecodeErrorZ_get_ok(uint32_t owner) {
6219         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
6220         LDKNodeId ret_var = CResult_NodeIdDecodeErrorZ_get_ok(owner_conv);
6221         uint32_t ret_ref = 0;
6222         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6223         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6224         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6225         ret_ref = (uintptr_t)ret_var.inner;
6226         if (ret_var.is_owned) {
6227                 ret_ref |= 1;
6228         }
6229         return ret_ref;
6230 }
6231
6232 static inline struct LDKDecodeError CResult_NodeIdDecodeErrorZ_get_err(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
6233 CHECK(!owner->result_ok);
6234         return DecodeError_clone(&*owner->contents.err);
6235 }
6236 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_get_err"))) TS_CResult_NodeIdDecodeErrorZ_get_err(uint32_t owner) {
6237         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)(owner & ~1);
6238         LDKDecodeError ret_var = CResult_NodeIdDecodeErrorZ_get_err(owner_conv);
6239         uint32_t ret_ref = 0;
6240         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6241         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6242         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6243         ret_ref = (uintptr_t)ret_var.inner;
6244         if (ret_var.is_owned) {
6245                 ret_ref |= 1;
6246         }
6247         return ret_ref;
6248 }
6249
6250 static inline struct LDKCOption_NetworkUpdateZ CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
6251 CHECK(owner->result_ok);
6252         return COption_NetworkUpdateZ_clone(&*owner->contents.result);
6253 }
6254 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(uint32_t owner) {
6255         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
6256         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
6257         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(owner_conv);
6258         uint32_t ret_ref = (uintptr_t)ret_copy;
6259         return ret_ref;
6260 }
6261
6262 static inline struct LDKDecodeError CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
6263 CHECK(!owner->result_ok);
6264         return DecodeError_clone(&*owner->contents.err);
6265 }
6266 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_err"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(uint32_t owner) {
6267         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(owner & ~1);
6268         LDKDecodeError ret_var = CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(owner_conv);
6269         uint32_t ret_ref = 0;
6270         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6271         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6272         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6273         ret_ref = (uintptr_t)ret_var.inner;
6274         if (ret_var.is_owned) {
6275                 ret_ref |= 1;
6276         }
6277         return ret_ref;
6278 }
6279
6280 typedef struct LDKAccess_JCalls {
6281         atomic_size_t refcnt;
6282         uint32_t instance_ptr;
6283 } LDKAccess_JCalls;
6284 static void LDKAccess_JCalls_free(void* this_arg) {
6285         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6286         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6287                 FREE(j_calls);
6288         }
6289 }
6290 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
6291         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
6292         int8_tArray genesis_hash_arr = init_int8_tArray(32, __LINE__);
6293         memcpy(genesis_hash_arr->elems, *genesis_hash, 32);
6294         int64_t short_channel_id_conv = short_channel_id;
6295         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 31, (uint32_t)genesis_hash_arr, (uint32_t)short_channel_id_conv);
6296         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
6297         CHECK_ACCESS(ret_ptr);
6298         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
6299         FREE((void*)ret);
6300         return ret_conv;
6301 }
6302 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
6303         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
6304         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6305 }
6306 static inline LDKAccess LDKAccess_init (JSValue o) {
6307         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
6308         atomic_init(&calls->refcnt, 1);
6309         calls->instance_ptr = o;
6310
6311         LDKAccess ret = {
6312                 .this_arg = (void*) calls,
6313                 .get_utxo = get_utxo_LDKAccess_jcall,
6314                 .free = LDKAccess_JCalls_free,
6315         };
6316         return ret;
6317 }
6318 long  __attribute__((export_name("TS_LDKAccess_new"))) TS_LDKAccess_new(JSValue o) {
6319         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
6320         *res_ptr = LDKAccess_init(o);
6321         return (long)res_ptr;
6322 }
6323 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) {
6324         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
6325         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6326         LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
6327         unsigned char genesis_hash_arr[32];
6328         CHECK(genesis_hash->arr_len == 32);
6329         memcpy(genesis_hash_arr, genesis_hash->elems, 32); FREE(genesis_hash);
6330         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
6331         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
6332         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
6333         return (uint32_t)ret_conv;
6334 }
6335
6336 uint32_t __attribute__((export_name("TS_LDKCOption_AccessZ_ty_from_ptr"))) TS_LDKCOption_AccessZ_ty_from_ptr(uint32_t ptr) {
6337         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
6338         switch(obj->tag) {
6339                 case LDKCOption_AccessZ_Some: return 0;
6340                 case LDKCOption_AccessZ_None: return 1;
6341                 default: abort();
6342         }
6343 }
6344 uint32_t __attribute__((export_name("TS_LDKCOption_AccessZ_Some_get_some"))) TS_LDKCOption_AccessZ_Some_get_some(uint32_t ptr) {
6345         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
6346         assert(obj->tag == LDKCOption_AccessZ_Some);
6347                         LDKAccess* some_ret = MALLOC(sizeof(LDKAccess), "LDKAccess");
6348                         *some_ret = obj->some;
6349                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
6350                         if ((*some_ret).free == LDKAccess_JCalls_free) {
6351                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6352                                 LDKAccess_JCalls_cloned(&(*some_ret));
6353                         }
6354         return (uint32_t)some_ret;
6355 }
6356 static inline struct LDKChannelUpdateInfo CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
6357 CHECK(owner->result_ok);
6358         return ChannelUpdateInfo_clone(&*owner->contents.result);
6359 }
6360 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_ok"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(uint32_t owner) {
6361         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
6362         LDKChannelUpdateInfo ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(owner_conv);
6363         uint32_t ret_ref = 0;
6364         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6365         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6366         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6367         ret_ref = (uintptr_t)ret_var.inner;
6368         if (ret_var.is_owned) {
6369                 ret_ref |= 1;
6370         }
6371         return ret_ref;
6372 }
6373
6374 static inline struct LDKDecodeError CResult_ChannelUpdateInfoDecodeErrorZ_get_err(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
6375 CHECK(!owner->result_ok);
6376         return DecodeError_clone(&*owner->contents.err);
6377 }
6378 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_err"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_get_err(uint32_t owner) {
6379         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(owner & ~1);
6380         LDKDecodeError ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_err(owner_conv);
6381         uint32_t ret_ref = 0;
6382         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6383         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6384         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6385         ret_ref = (uintptr_t)ret_var.inner;
6386         if (ret_var.is_owned) {
6387                 ret_ref |= 1;
6388         }
6389         return ret_ref;
6390 }
6391
6392 static inline struct LDKChannelInfo CResult_ChannelInfoDecodeErrorZ_get_ok(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
6393 CHECK(owner->result_ok);
6394         return ChannelInfo_clone(&*owner->contents.result);
6395 }
6396 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_get_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_get_ok(uint32_t owner) {
6397         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
6398         LDKChannelInfo ret_var = CResult_ChannelInfoDecodeErrorZ_get_ok(owner_conv);
6399         uint32_t ret_ref = 0;
6400         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6401         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6402         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6403         ret_ref = (uintptr_t)ret_var.inner;
6404         if (ret_var.is_owned) {
6405                 ret_ref |= 1;
6406         }
6407         return ret_ref;
6408 }
6409
6410 static inline struct LDKDecodeError CResult_ChannelInfoDecodeErrorZ_get_err(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
6411 CHECK(!owner->result_ok);
6412         return DecodeError_clone(&*owner->contents.err);
6413 }
6414 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_get_err"))) TS_CResult_ChannelInfoDecodeErrorZ_get_err(uint32_t owner) {
6415         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(owner & ~1);
6416         LDKDecodeError ret_var = CResult_ChannelInfoDecodeErrorZ_get_err(owner_conv);
6417         uint32_t ret_ref = 0;
6418         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6419         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6420         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6421         ret_ref = (uintptr_t)ret_var.inner;
6422         if (ret_var.is_owned) {
6423                 ret_ref |= 1;
6424         }
6425         return ret_ref;
6426 }
6427
6428 static inline struct LDKRoutingFees CResult_RoutingFeesDecodeErrorZ_get_ok(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
6429 CHECK(owner->result_ok);
6430         return RoutingFees_clone(&*owner->contents.result);
6431 }
6432 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_get_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_get_ok(uint32_t owner) {
6433         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
6434         LDKRoutingFees ret_var = CResult_RoutingFeesDecodeErrorZ_get_ok(owner_conv);
6435         uint32_t ret_ref = 0;
6436         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6437         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6438         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6439         ret_ref = (uintptr_t)ret_var.inner;
6440         if (ret_var.is_owned) {
6441                 ret_ref |= 1;
6442         }
6443         return ret_ref;
6444 }
6445
6446 static inline struct LDKDecodeError CResult_RoutingFeesDecodeErrorZ_get_err(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
6447 CHECK(!owner->result_ok);
6448         return DecodeError_clone(&*owner->contents.err);
6449 }
6450 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_get_err"))) TS_CResult_RoutingFeesDecodeErrorZ_get_err(uint32_t owner) {
6451         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(owner & ~1);
6452         LDKDecodeError ret_var = CResult_RoutingFeesDecodeErrorZ_get_err(owner_conv);
6453         uint32_t ret_ref = 0;
6454         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6455         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6456         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6457         ret_ref = (uintptr_t)ret_var.inner;
6458         if (ret_var.is_owned) {
6459                 ret_ref |= 1;
6460         }
6461         return ret_ref;
6462 }
6463
6464 static inline struct LDKNodeAnnouncementInfo CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
6465 CHECK(owner->result_ok);
6466         return NodeAnnouncementInfo_clone(&*owner->contents.result);
6467 }
6468 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(uint32_t owner) {
6469         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
6470         LDKNodeAnnouncementInfo ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(owner_conv);
6471         uint32_t ret_ref = 0;
6472         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6473         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6474         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6475         ret_ref = (uintptr_t)ret_var.inner;
6476         if (ret_var.is_owned) {
6477                 ret_ref |= 1;
6478         }
6479         return ret_ref;
6480 }
6481
6482 static inline struct LDKDecodeError CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
6483 CHECK(!owner->result_ok);
6484         return DecodeError_clone(&*owner->contents.err);
6485 }
6486 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_err"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(uint32_t owner) {
6487         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(owner & ~1);
6488         LDKDecodeError ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(owner_conv);
6489         uint32_t ret_ref = 0;
6490         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6491         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6492         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6493         ret_ref = (uintptr_t)ret_var.inner;
6494         if (ret_var.is_owned) {
6495                 ret_ref |= 1;
6496         }
6497         return ret_ref;
6498 }
6499
6500 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
6501         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
6502         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
6503         return ret;
6504 }
6505 static inline struct LDKNodeInfo CResult_NodeInfoDecodeErrorZ_get_ok(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
6506 CHECK(owner->result_ok);
6507         return NodeInfo_clone(&*owner->contents.result);
6508 }
6509 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_get_ok"))) TS_CResult_NodeInfoDecodeErrorZ_get_ok(uint32_t owner) {
6510         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
6511         LDKNodeInfo ret_var = CResult_NodeInfoDecodeErrorZ_get_ok(owner_conv);
6512         uint32_t ret_ref = 0;
6513         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6514         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6515         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6516         ret_ref = (uintptr_t)ret_var.inner;
6517         if (ret_var.is_owned) {
6518                 ret_ref |= 1;
6519         }
6520         return ret_ref;
6521 }
6522
6523 static inline struct LDKDecodeError CResult_NodeInfoDecodeErrorZ_get_err(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
6524 CHECK(!owner->result_ok);
6525         return DecodeError_clone(&*owner->contents.err);
6526 }
6527 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_get_err"))) TS_CResult_NodeInfoDecodeErrorZ_get_err(uint32_t owner) {
6528         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(owner & ~1);
6529         LDKDecodeError ret_var = CResult_NodeInfoDecodeErrorZ_get_err(owner_conv);
6530         uint32_t ret_ref = 0;
6531         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6532         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6533         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6534         ret_ref = (uintptr_t)ret_var.inner;
6535         if (ret_var.is_owned) {
6536                 ret_ref |= 1;
6537         }
6538         return ret_ref;
6539 }
6540
6541 static inline struct LDKNetworkGraph CResult_NetworkGraphDecodeErrorZ_get_ok(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
6542 CHECK(owner->result_ok);
6543         return NetworkGraph_clone(&*owner->contents.result);
6544 }
6545 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_get_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_get_ok(uint32_t owner) {
6546         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
6547         LDKNetworkGraph ret_var = CResult_NetworkGraphDecodeErrorZ_get_ok(owner_conv);
6548         uint32_t ret_ref = 0;
6549         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6550         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6551         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6552         ret_ref = (uintptr_t)ret_var.inner;
6553         if (ret_var.is_owned) {
6554                 ret_ref |= 1;
6555         }
6556         return ret_ref;
6557 }
6558
6559 static inline struct LDKDecodeError CResult_NetworkGraphDecodeErrorZ_get_err(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
6560 CHECK(!owner->result_ok);
6561         return DecodeError_clone(&*owner->contents.err);
6562 }
6563 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_get_err"))) TS_CResult_NetworkGraphDecodeErrorZ_get_err(uint32_t owner) {
6564         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(owner & ~1);
6565         LDKDecodeError ret_var = CResult_NetworkGraphDecodeErrorZ_get_err(owner_conv);
6566         uint32_t ret_ref = 0;
6567         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6568         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6569         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6570         ret_ref = (uintptr_t)ret_var.inner;
6571         if (ret_var.is_owned) {
6572                 ret_ref |= 1;
6573         }
6574         return ret_ref;
6575 }
6576
6577 uint32_t __attribute__((export_name("TS_LDKCOption_CVec_NetAddressZZ_ty_from_ptr"))) TS_LDKCOption_CVec_NetAddressZZ_ty_from_ptr(uint32_t ptr) {
6578         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
6579         switch(obj->tag) {
6580                 case LDKCOption_CVec_NetAddressZZ_Some: return 0;
6581                 case LDKCOption_CVec_NetAddressZZ_None: return 1;
6582                 default: abort();
6583         }
6584 }
6585 uint32_tArray __attribute__((export_name("TS_LDKCOption_CVec_NetAddressZZ_Some_get_some"))) TS_LDKCOption_CVec_NetAddressZZ_Some_get_some(uint32_t ptr) {
6586         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
6587         assert(obj->tag == LDKCOption_CVec_NetAddressZZ_Some);
6588                         LDKCVec_NetAddressZ some_var = obj->some;
6589                         uint32_tArray some_arr = NULL;
6590                         some_arr = init_uint32_tArray(some_var.datalen, __LINE__);
6591                         uint32_t *some_arr_ptr = (uint32_t*)(((uint8_t*)some_arr) + 4);
6592                         for (size_t m = 0; m < some_var.datalen; m++) {
6593                                 uint32_t some_conv_12_ref = ((uintptr_t)&some_var.data[m]) | 1;
6594                                 some_arr_ptr[m] = some_conv_12_ref;
6595                         }
6596                         
6597         return some_arr;
6598 }
6599 static inline struct LDKNetAddress CResult_NetAddressDecodeErrorZ_get_ok(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
6600 CHECK(owner->result_ok);
6601         return NetAddress_clone(&*owner->contents.result);
6602 }
6603 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_get_ok"))) TS_CResult_NetAddressDecodeErrorZ_get_ok(uint32_t owner) {
6604         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
6605         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
6606         *ret_copy = CResult_NetAddressDecodeErrorZ_get_ok(owner_conv);
6607         uint32_t ret_ref = (uintptr_t)ret_copy;
6608         return ret_ref;
6609 }
6610
6611 static inline struct LDKDecodeError CResult_NetAddressDecodeErrorZ_get_err(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
6612 CHECK(!owner->result_ok);
6613         return DecodeError_clone(&*owner->contents.err);
6614 }
6615 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_get_err"))) TS_CResult_NetAddressDecodeErrorZ_get_err(uint32_t owner) {
6616         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)(owner & ~1);
6617         LDKDecodeError ret_var = CResult_NetAddressDecodeErrorZ_get_err(owner_conv);
6618         uint32_t ret_ref = 0;
6619         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6620         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6621         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6622         ret_ref = (uintptr_t)ret_var.inner;
6623         if (ret_var.is_owned) {
6624                 ret_ref |= 1;
6625         }
6626         return ret_ref;
6627 }
6628
6629 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
6630         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
6631         for (size_t i = 0; i < ret.datalen; i++) {
6632                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
6633         }
6634         return ret;
6635 }
6636 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
6637         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
6638         for (size_t i = 0; i < ret.datalen; i++) {
6639                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
6640         }
6641         return ret;
6642 }
6643 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
6644         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
6645         for (size_t i = 0; i < ret.datalen; i++) {
6646                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
6647         }
6648         return ret;
6649 }
6650 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
6651         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
6652         for (size_t i = 0; i < ret.datalen; i++) {
6653                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
6654         }
6655         return ret;
6656 }
6657 static inline struct LDKAcceptChannel CResult_AcceptChannelDecodeErrorZ_get_ok(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
6658 CHECK(owner->result_ok);
6659         return AcceptChannel_clone(&*owner->contents.result);
6660 }
6661 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_get_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_get_ok(uint32_t owner) {
6662         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
6663         LDKAcceptChannel ret_var = CResult_AcceptChannelDecodeErrorZ_get_ok(owner_conv);
6664         uint32_t ret_ref = 0;
6665         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6666         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6667         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6668         ret_ref = (uintptr_t)ret_var.inner;
6669         if (ret_var.is_owned) {
6670                 ret_ref |= 1;
6671         }
6672         return ret_ref;
6673 }
6674
6675 static inline struct LDKDecodeError CResult_AcceptChannelDecodeErrorZ_get_err(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
6676 CHECK(!owner->result_ok);
6677         return DecodeError_clone(&*owner->contents.err);
6678 }
6679 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_get_err"))) TS_CResult_AcceptChannelDecodeErrorZ_get_err(uint32_t owner) {
6680         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(owner & ~1);
6681         LDKDecodeError ret_var = CResult_AcceptChannelDecodeErrorZ_get_err(owner_conv);
6682         uint32_t ret_ref = 0;
6683         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6684         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6685         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6686         ret_ref = (uintptr_t)ret_var.inner;
6687         if (ret_var.is_owned) {
6688                 ret_ref |= 1;
6689         }
6690         return ret_ref;
6691 }
6692
6693 static inline struct LDKAnnouncementSignatures CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
6694 CHECK(owner->result_ok);
6695         return AnnouncementSignatures_clone(&*owner->contents.result);
6696 }
6697 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(uint32_t owner) {
6698         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
6699         LDKAnnouncementSignatures ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(owner_conv);
6700         uint32_t ret_ref = 0;
6701         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6702         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6703         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6704         ret_ref = (uintptr_t)ret_var.inner;
6705         if (ret_var.is_owned) {
6706                 ret_ref |= 1;
6707         }
6708         return ret_ref;
6709 }
6710
6711 static inline struct LDKDecodeError CResult_AnnouncementSignaturesDecodeErrorZ_get_err(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
6712 CHECK(!owner->result_ok);
6713         return DecodeError_clone(&*owner->contents.err);
6714 }
6715 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_err"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_get_err(uint32_t owner) {
6716         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(owner & ~1);
6717         LDKDecodeError ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_err(owner_conv);
6718         uint32_t ret_ref = 0;
6719         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6720         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6721         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6722         ret_ref = (uintptr_t)ret_var.inner;
6723         if (ret_var.is_owned) {
6724                 ret_ref |= 1;
6725         }
6726         return ret_ref;
6727 }
6728
6729 static inline struct LDKChannelReestablish CResult_ChannelReestablishDecodeErrorZ_get_ok(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
6730 CHECK(owner->result_ok);
6731         return ChannelReestablish_clone(&*owner->contents.result);
6732 }
6733 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_get_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_get_ok(uint32_t owner) {
6734         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
6735         LDKChannelReestablish ret_var = CResult_ChannelReestablishDecodeErrorZ_get_ok(owner_conv);
6736         uint32_t ret_ref = 0;
6737         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6738         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6739         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6740         ret_ref = (uintptr_t)ret_var.inner;
6741         if (ret_var.is_owned) {
6742                 ret_ref |= 1;
6743         }
6744         return ret_ref;
6745 }
6746
6747 static inline struct LDKDecodeError CResult_ChannelReestablishDecodeErrorZ_get_err(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
6748 CHECK(!owner->result_ok);
6749         return DecodeError_clone(&*owner->contents.err);
6750 }
6751 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_get_err"))) TS_CResult_ChannelReestablishDecodeErrorZ_get_err(uint32_t owner) {
6752         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(owner & ~1);
6753         LDKDecodeError ret_var = CResult_ChannelReestablishDecodeErrorZ_get_err(owner_conv);
6754         uint32_t ret_ref = 0;
6755         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6756         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6757         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6758         ret_ref = (uintptr_t)ret_var.inner;
6759         if (ret_var.is_owned) {
6760                 ret_ref |= 1;
6761         }
6762         return ret_ref;
6763 }
6764
6765 static inline struct LDKClosingSigned CResult_ClosingSignedDecodeErrorZ_get_ok(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
6766 CHECK(owner->result_ok);
6767         return ClosingSigned_clone(&*owner->contents.result);
6768 }
6769 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_get_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_get_ok(uint32_t owner) {
6770         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
6771         LDKClosingSigned ret_var = CResult_ClosingSignedDecodeErrorZ_get_ok(owner_conv);
6772         uint32_t ret_ref = 0;
6773         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6774         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6775         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6776         ret_ref = (uintptr_t)ret_var.inner;
6777         if (ret_var.is_owned) {
6778                 ret_ref |= 1;
6779         }
6780         return ret_ref;
6781 }
6782
6783 static inline struct LDKDecodeError CResult_ClosingSignedDecodeErrorZ_get_err(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
6784 CHECK(!owner->result_ok);
6785         return DecodeError_clone(&*owner->contents.err);
6786 }
6787 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_get_err"))) TS_CResult_ClosingSignedDecodeErrorZ_get_err(uint32_t owner) {
6788         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(owner & ~1);
6789         LDKDecodeError ret_var = CResult_ClosingSignedDecodeErrorZ_get_err(owner_conv);
6790         uint32_t ret_ref = 0;
6791         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6792         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6793         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6794         ret_ref = (uintptr_t)ret_var.inner;
6795         if (ret_var.is_owned) {
6796                 ret_ref |= 1;
6797         }
6798         return ret_ref;
6799 }
6800
6801 static inline struct LDKClosingSignedFeeRange CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
6802 CHECK(owner->result_ok);
6803         return ClosingSignedFeeRange_clone(&*owner->contents.result);
6804 }
6805 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(uint32_t owner) {
6806         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
6807         LDKClosingSignedFeeRange ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(owner_conv);
6808         uint32_t ret_ref = 0;
6809         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6810         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6811         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6812         ret_ref = (uintptr_t)ret_var.inner;
6813         if (ret_var.is_owned) {
6814                 ret_ref |= 1;
6815         }
6816         return ret_ref;
6817 }
6818
6819 static inline struct LDKDecodeError CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
6820 CHECK(!owner->result_ok);
6821         return DecodeError_clone(&*owner->contents.err);
6822 }
6823 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(uint32_t owner) {
6824         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(owner & ~1);
6825         LDKDecodeError ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(owner_conv);
6826         uint32_t ret_ref = 0;
6827         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6828         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6829         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6830         ret_ref = (uintptr_t)ret_var.inner;
6831         if (ret_var.is_owned) {
6832                 ret_ref |= 1;
6833         }
6834         return ret_ref;
6835 }
6836
6837 static inline struct LDKCommitmentSigned CResult_CommitmentSignedDecodeErrorZ_get_ok(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
6838 CHECK(owner->result_ok);
6839         return CommitmentSigned_clone(&*owner->contents.result);
6840 }
6841 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_get_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_get_ok(uint32_t owner) {
6842         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
6843         LDKCommitmentSigned ret_var = CResult_CommitmentSignedDecodeErrorZ_get_ok(owner_conv);
6844         uint32_t ret_ref = 0;
6845         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6846         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6847         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6848         ret_ref = (uintptr_t)ret_var.inner;
6849         if (ret_var.is_owned) {
6850                 ret_ref |= 1;
6851         }
6852         return ret_ref;
6853 }
6854
6855 static inline struct LDKDecodeError CResult_CommitmentSignedDecodeErrorZ_get_err(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
6856 CHECK(!owner->result_ok);
6857         return DecodeError_clone(&*owner->contents.err);
6858 }
6859 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_get_err"))) TS_CResult_CommitmentSignedDecodeErrorZ_get_err(uint32_t owner) {
6860         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(owner & ~1);
6861         LDKDecodeError ret_var = CResult_CommitmentSignedDecodeErrorZ_get_err(owner_conv);
6862         uint32_t ret_ref = 0;
6863         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6864         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6865         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6866         ret_ref = (uintptr_t)ret_var.inner;
6867         if (ret_var.is_owned) {
6868                 ret_ref |= 1;
6869         }
6870         return ret_ref;
6871 }
6872
6873 static inline struct LDKFundingCreated CResult_FundingCreatedDecodeErrorZ_get_ok(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
6874 CHECK(owner->result_ok);
6875         return FundingCreated_clone(&*owner->contents.result);
6876 }
6877 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_get_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_get_ok(uint32_t owner) {
6878         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
6879         LDKFundingCreated ret_var = CResult_FundingCreatedDecodeErrorZ_get_ok(owner_conv);
6880         uint32_t ret_ref = 0;
6881         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6882         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6883         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6884         ret_ref = (uintptr_t)ret_var.inner;
6885         if (ret_var.is_owned) {
6886                 ret_ref |= 1;
6887         }
6888         return ret_ref;
6889 }
6890
6891 static inline struct LDKDecodeError CResult_FundingCreatedDecodeErrorZ_get_err(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
6892 CHECK(!owner->result_ok);
6893         return DecodeError_clone(&*owner->contents.err);
6894 }
6895 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_get_err"))) TS_CResult_FundingCreatedDecodeErrorZ_get_err(uint32_t owner) {
6896         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(owner & ~1);
6897         LDKDecodeError ret_var = CResult_FundingCreatedDecodeErrorZ_get_err(owner_conv);
6898         uint32_t ret_ref = 0;
6899         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6900         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6901         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6902         ret_ref = (uintptr_t)ret_var.inner;
6903         if (ret_var.is_owned) {
6904                 ret_ref |= 1;
6905         }
6906         return ret_ref;
6907 }
6908
6909 static inline struct LDKFundingSigned CResult_FundingSignedDecodeErrorZ_get_ok(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
6910 CHECK(owner->result_ok);
6911         return FundingSigned_clone(&*owner->contents.result);
6912 }
6913 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_get_ok"))) TS_CResult_FundingSignedDecodeErrorZ_get_ok(uint32_t owner) {
6914         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
6915         LDKFundingSigned ret_var = CResult_FundingSignedDecodeErrorZ_get_ok(owner_conv);
6916         uint32_t ret_ref = 0;
6917         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6918         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6919         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6920         ret_ref = (uintptr_t)ret_var.inner;
6921         if (ret_var.is_owned) {
6922                 ret_ref |= 1;
6923         }
6924         return ret_ref;
6925 }
6926
6927 static inline struct LDKDecodeError CResult_FundingSignedDecodeErrorZ_get_err(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
6928 CHECK(!owner->result_ok);
6929         return DecodeError_clone(&*owner->contents.err);
6930 }
6931 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_get_err"))) TS_CResult_FundingSignedDecodeErrorZ_get_err(uint32_t owner) {
6932         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(owner & ~1);
6933         LDKDecodeError ret_var = CResult_FundingSignedDecodeErrorZ_get_err(owner_conv);
6934         uint32_t ret_ref = 0;
6935         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6936         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6937         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6938         ret_ref = (uintptr_t)ret_var.inner;
6939         if (ret_var.is_owned) {
6940                 ret_ref |= 1;
6941         }
6942         return ret_ref;
6943 }
6944
6945 static inline struct LDKFundingLocked CResult_FundingLockedDecodeErrorZ_get_ok(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR owner){
6946 CHECK(owner->result_ok);
6947         return FundingLocked_clone(&*owner->contents.result);
6948 }
6949 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_get_ok"))) TS_CResult_FundingLockedDecodeErrorZ_get_ok(uint32_t owner) {
6950         LDKCResult_FundingLockedDecodeErrorZ* owner_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(owner & ~1);
6951         LDKFundingLocked ret_var = CResult_FundingLockedDecodeErrorZ_get_ok(owner_conv);
6952         uint32_t ret_ref = 0;
6953         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6954         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6955         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6956         ret_ref = (uintptr_t)ret_var.inner;
6957         if (ret_var.is_owned) {
6958                 ret_ref |= 1;
6959         }
6960         return ret_ref;
6961 }
6962
6963 static inline struct LDKDecodeError CResult_FundingLockedDecodeErrorZ_get_err(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR owner){
6964 CHECK(!owner->result_ok);
6965         return DecodeError_clone(&*owner->contents.err);
6966 }
6967 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_get_err"))) TS_CResult_FundingLockedDecodeErrorZ_get_err(uint32_t owner) {
6968         LDKCResult_FundingLockedDecodeErrorZ* owner_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(owner & ~1);
6969         LDKDecodeError ret_var = CResult_FundingLockedDecodeErrorZ_get_err(owner_conv);
6970         uint32_t ret_ref = 0;
6971         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6972         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6973         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6974         ret_ref = (uintptr_t)ret_var.inner;
6975         if (ret_var.is_owned) {
6976                 ret_ref |= 1;
6977         }
6978         return ret_ref;
6979 }
6980
6981 static inline struct LDKInit CResult_InitDecodeErrorZ_get_ok(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
6982 CHECK(owner->result_ok);
6983         return Init_clone(&*owner->contents.result);
6984 }
6985 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_get_ok"))) TS_CResult_InitDecodeErrorZ_get_ok(uint32_t owner) {
6986         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
6987         LDKInit ret_var = CResult_InitDecodeErrorZ_get_ok(owner_conv);
6988         uint32_t ret_ref = 0;
6989         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6990         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6991         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6992         ret_ref = (uintptr_t)ret_var.inner;
6993         if (ret_var.is_owned) {
6994                 ret_ref |= 1;
6995         }
6996         return ret_ref;
6997 }
6998
6999 static inline struct LDKDecodeError CResult_InitDecodeErrorZ_get_err(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
7000 CHECK(!owner->result_ok);
7001         return DecodeError_clone(&*owner->contents.err);
7002 }
7003 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_get_err"))) TS_CResult_InitDecodeErrorZ_get_err(uint32_t owner) {
7004         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)(owner & ~1);
7005         LDKDecodeError ret_var = CResult_InitDecodeErrorZ_get_err(owner_conv);
7006         uint32_t ret_ref = 0;
7007         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7008         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7009         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7010         ret_ref = (uintptr_t)ret_var.inner;
7011         if (ret_var.is_owned) {
7012                 ret_ref |= 1;
7013         }
7014         return ret_ref;
7015 }
7016
7017 static inline struct LDKOpenChannel CResult_OpenChannelDecodeErrorZ_get_ok(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
7018 CHECK(owner->result_ok);
7019         return OpenChannel_clone(&*owner->contents.result);
7020 }
7021 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_get_ok"))) TS_CResult_OpenChannelDecodeErrorZ_get_ok(uint32_t owner) {
7022         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
7023         LDKOpenChannel ret_var = CResult_OpenChannelDecodeErrorZ_get_ok(owner_conv);
7024         uint32_t ret_ref = 0;
7025         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7026         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7027         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7028         ret_ref = (uintptr_t)ret_var.inner;
7029         if (ret_var.is_owned) {
7030                 ret_ref |= 1;
7031         }
7032         return ret_ref;
7033 }
7034
7035 static inline struct LDKDecodeError CResult_OpenChannelDecodeErrorZ_get_err(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
7036 CHECK(!owner->result_ok);
7037         return DecodeError_clone(&*owner->contents.err);
7038 }
7039 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_get_err"))) TS_CResult_OpenChannelDecodeErrorZ_get_err(uint32_t owner) {
7040         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(owner & ~1);
7041         LDKDecodeError ret_var = CResult_OpenChannelDecodeErrorZ_get_err(owner_conv);
7042         uint32_t ret_ref = 0;
7043         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7044         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7045         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7046         ret_ref = (uintptr_t)ret_var.inner;
7047         if (ret_var.is_owned) {
7048                 ret_ref |= 1;
7049         }
7050         return ret_ref;
7051 }
7052
7053 static inline struct LDKRevokeAndACK CResult_RevokeAndACKDecodeErrorZ_get_ok(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
7054 CHECK(owner->result_ok);
7055         return RevokeAndACK_clone(&*owner->contents.result);
7056 }
7057 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_get_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_get_ok(uint32_t owner) {
7058         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
7059         LDKRevokeAndACK ret_var = CResult_RevokeAndACKDecodeErrorZ_get_ok(owner_conv);
7060         uint32_t ret_ref = 0;
7061         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7062         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7063         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7064         ret_ref = (uintptr_t)ret_var.inner;
7065         if (ret_var.is_owned) {
7066                 ret_ref |= 1;
7067         }
7068         return ret_ref;
7069 }
7070
7071 static inline struct LDKDecodeError CResult_RevokeAndACKDecodeErrorZ_get_err(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
7072 CHECK(!owner->result_ok);
7073         return DecodeError_clone(&*owner->contents.err);
7074 }
7075 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_get_err"))) TS_CResult_RevokeAndACKDecodeErrorZ_get_err(uint32_t owner) {
7076         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(owner & ~1);
7077         LDKDecodeError ret_var = CResult_RevokeAndACKDecodeErrorZ_get_err(owner_conv);
7078         uint32_t ret_ref = 0;
7079         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7080         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7081         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7082         ret_ref = (uintptr_t)ret_var.inner;
7083         if (ret_var.is_owned) {
7084                 ret_ref |= 1;
7085         }
7086         return ret_ref;
7087 }
7088
7089 static inline struct LDKShutdown CResult_ShutdownDecodeErrorZ_get_ok(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
7090 CHECK(owner->result_ok);
7091         return Shutdown_clone(&*owner->contents.result);
7092 }
7093 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_get_ok"))) TS_CResult_ShutdownDecodeErrorZ_get_ok(uint32_t owner) {
7094         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
7095         LDKShutdown ret_var = CResult_ShutdownDecodeErrorZ_get_ok(owner_conv);
7096         uint32_t ret_ref = 0;
7097         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7098         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7099         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7100         ret_ref = (uintptr_t)ret_var.inner;
7101         if (ret_var.is_owned) {
7102                 ret_ref |= 1;
7103         }
7104         return ret_ref;
7105 }
7106
7107 static inline struct LDKDecodeError CResult_ShutdownDecodeErrorZ_get_err(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
7108 CHECK(!owner->result_ok);
7109         return DecodeError_clone(&*owner->contents.err);
7110 }
7111 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_get_err"))) TS_CResult_ShutdownDecodeErrorZ_get_err(uint32_t owner) {
7112         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)(owner & ~1);
7113         LDKDecodeError ret_var = CResult_ShutdownDecodeErrorZ_get_err(owner_conv);
7114         uint32_t ret_ref = 0;
7115         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7116         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7117         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7118         ret_ref = (uintptr_t)ret_var.inner;
7119         if (ret_var.is_owned) {
7120                 ret_ref |= 1;
7121         }
7122         return ret_ref;
7123 }
7124
7125 static inline struct LDKUpdateFailHTLC CResult_UpdateFailHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
7126 CHECK(owner->result_ok);
7127         return UpdateFailHTLC_clone(&*owner->contents.result);
7128 }
7129 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7130         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
7131         LDKUpdateFailHTLC ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_ok(owner_conv);
7132         uint32_t ret_ref = 0;
7133         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7134         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7135         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7136         ret_ref = (uintptr_t)ret_var.inner;
7137         if (ret_var.is_owned) {
7138                 ret_ref |= 1;
7139         }
7140         return ret_ref;
7141 }
7142
7143 static inline struct LDKDecodeError CResult_UpdateFailHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
7144 CHECK(!owner->result_ok);
7145         return DecodeError_clone(&*owner->contents.err);
7146 }
7147 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_get_err(uint32_t owner) {
7148         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(owner & ~1);
7149         LDKDecodeError ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_err(owner_conv);
7150         uint32_t ret_ref = 0;
7151         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7152         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7153         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7154         ret_ref = (uintptr_t)ret_var.inner;
7155         if (ret_var.is_owned) {
7156                 ret_ref |= 1;
7157         }
7158         return ret_ref;
7159 }
7160
7161 static inline struct LDKUpdateFailMalformedHTLC CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
7162 CHECK(owner->result_ok);
7163         return UpdateFailMalformedHTLC_clone(&*owner->contents.result);
7164 }
7165 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7166         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
7167         LDKUpdateFailMalformedHTLC ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(owner_conv);
7168         uint32_t ret_ref = 0;
7169         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7170         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7171         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7172         ret_ref = (uintptr_t)ret_var.inner;
7173         if (ret_var.is_owned) {
7174                 ret_ref |= 1;
7175         }
7176         return ret_ref;
7177 }
7178
7179 static inline struct LDKDecodeError CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
7180 CHECK(!owner->result_ok);
7181         return DecodeError_clone(&*owner->contents.err);
7182 }
7183 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(uint32_t owner) {
7184         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(owner & ~1);
7185         LDKDecodeError ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(owner_conv);
7186         uint32_t ret_ref = 0;
7187         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7188         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7189         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7190         ret_ref = (uintptr_t)ret_var.inner;
7191         if (ret_var.is_owned) {
7192                 ret_ref |= 1;
7193         }
7194         return ret_ref;
7195 }
7196
7197 static inline struct LDKUpdateFee CResult_UpdateFeeDecodeErrorZ_get_ok(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
7198 CHECK(owner->result_ok);
7199         return UpdateFee_clone(&*owner->contents.result);
7200 }
7201 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_get_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_get_ok(uint32_t owner) {
7202         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
7203         LDKUpdateFee ret_var = CResult_UpdateFeeDecodeErrorZ_get_ok(owner_conv);
7204         uint32_t ret_ref = 0;
7205         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7206         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7207         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7208         ret_ref = (uintptr_t)ret_var.inner;
7209         if (ret_var.is_owned) {
7210                 ret_ref |= 1;
7211         }
7212         return ret_ref;
7213 }
7214
7215 static inline struct LDKDecodeError CResult_UpdateFeeDecodeErrorZ_get_err(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
7216 CHECK(!owner->result_ok);
7217         return DecodeError_clone(&*owner->contents.err);
7218 }
7219 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_get_err"))) TS_CResult_UpdateFeeDecodeErrorZ_get_err(uint32_t owner) {
7220         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(owner & ~1);
7221         LDKDecodeError ret_var = CResult_UpdateFeeDecodeErrorZ_get_err(owner_conv);
7222         uint32_t ret_ref = 0;
7223         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7224         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7225         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7226         ret_ref = (uintptr_t)ret_var.inner;
7227         if (ret_var.is_owned) {
7228                 ret_ref |= 1;
7229         }
7230         return ret_ref;
7231 }
7232
7233 static inline struct LDKUpdateFulfillHTLC CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
7234 CHECK(owner->result_ok);
7235         return UpdateFulfillHTLC_clone(&*owner->contents.result);
7236 }
7237 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7238         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
7239         LDKUpdateFulfillHTLC ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(owner_conv);
7240         uint32_t ret_ref = 0;
7241         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7242         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7243         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7244         ret_ref = (uintptr_t)ret_var.inner;
7245         if (ret_var.is_owned) {
7246                 ret_ref |= 1;
7247         }
7248         return ret_ref;
7249 }
7250
7251 static inline struct LDKDecodeError CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
7252 CHECK(!owner->result_ok);
7253         return DecodeError_clone(&*owner->contents.err);
7254 }
7255 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(uint32_t owner) {
7256         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(owner & ~1);
7257         LDKDecodeError ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(owner_conv);
7258         uint32_t ret_ref = 0;
7259         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7260         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7261         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7262         ret_ref = (uintptr_t)ret_var.inner;
7263         if (ret_var.is_owned) {
7264                 ret_ref |= 1;
7265         }
7266         return ret_ref;
7267 }
7268
7269 static inline struct LDKUpdateAddHTLC CResult_UpdateAddHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
7270 CHECK(owner->result_ok);
7271         return UpdateAddHTLC_clone(&*owner->contents.result);
7272 }
7273 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_get_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_get_ok(uint32_t owner) {
7274         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
7275         LDKUpdateAddHTLC ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_ok(owner_conv);
7276         uint32_t ret_ref = 0;
7277         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7278         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7279         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7280         ret_ref = (uintptr_t)ret_var.inner;
7281         if (ret_var.is_owned) {
7282                 ret_ref |= 1;
7283         }
7284         return ret_ref;
7285 }
7286
7287 static inline struct LDKDecodeError CResult_UpdateAddHTLCDecodeErrorZ_get_err(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
7288 CHECK(!owner->result_ok);
7289         return DecodeError_clone(&*owner->contents.err);
7290 }
7291 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_get_err"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_get_err(uint32_t owner) {
7292         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(owner & ~1);
7293         LDKDecodeError ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_err(owner_conv);
7294         uint32_t ret_ref = 0;
7295         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7296         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7297         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7298         ret_ref = (uintptr_t)ret_var.inner;
7299         if (ret_var.is_owned) {
7300                 ret_ref |= 1;
7301         }
7302         return ret_ref;
7303 }
7304
7305 static inline struct LDKPing CResult_PingDecodeErrorZ_get_ok(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
7306 CHECK(owner->result_ok);
7307         return Ping_clone(&*owner->contents.result);
7308 }
7309 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_get_ok"))) TS_CResult_PingDecodeErrorZ_get_ok(uint32_t owner) {
7310         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
7311         LDKPing ret_var = CResult_PingDecodeErrorZ_get_ok(owner_conv);
7312         uint32_t ret_ref = 0;
7313         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7314         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7315         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7316         ret_ref = (uintptr_t)ret_var.inner;
7317         if (ret_var.is_owned) {
7318                 ret_ref |= 1;
7319         }
7320         return ret_ref;
7321 }
7322
7323 static inline struct LDKDecodeError CResult_PingDecodeErrorZ_get_err(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
7324 CHECK(!owner->result_ok);
7325         return DecodeError_clone(&*owner->contents.err);
7326 }
7327 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_get_err"))) TS_CResult_PingDecodeErrorZ_get_err(uint32_t owner) {
7328         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)(owner & ~1);
7329         LDKDecodeError ret_var = CResult_PingDecodeErrorZ_get_err(owner_conv);
7330         uint32_t ret_ref = 0;
7331         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7332         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7333         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7334         ret_ref = (uintptr_t)ret_var.inner;
7335         if (ret_var.is_owned) {
7336                 ret_ref |= 1;
7337         }
7338         return ret_ref;
7339 }
7340
7341 static inline struct LDKPong CResult_PongDecodeErrorZ_get_ok(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
7342 CHECK(owner->result_ok);
7343         return Pong_clone(&*owner->contents.result);
7344 }
7345 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_get_ok"))) TS_CResult_PongDecodeErrorZ_get_ok(uint32_t owner) {
7346         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
7347         LDKPong ret_var = CResult_PongDecodeErrorZ_get_ok(owner_conv);
7348         uint32_t ret_ref = 0;
7349         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7350         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7351         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7352         ret_ref = (uintptr_t)ret_var.inner;
7353         if (ret_var.is_owned) {
7354                 ret_ref |= 1;
7355         }
7356         return ret_ref;
7357 }
7358
7359 static inline struct LDKDecodeError CResult_PongDecodeErrorZ_get_err(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
7360 CHECK(!owner->result_ok);
7361         return DecodeError_clone(&*owner->contents.err);
7362 }
7363 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_get_err"))) TS_CResult_PongDecodeErrorZ_get_err(uint32_t owner) {
7364         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)(owner & ~1);
7365         LDKDecodeError ret_var = CResult_PongDecodeErrorZ_get_err(owner_conv);
7366         uint32_t ret_ref = 0;
7367         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7368         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7369         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7370         ret_ref = (uintptr_t)ret_var.inner;
7371         if (ret_var.is_owned) {
7372                 ret_ref |= 1;
7373         }
7374         return ret_ref;
7375 }
7376
7377 static inline struct LDKUnsignedChannelAnnouncement CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7378 CHECK(owner->result_ok);
7379         return UnsignedChannelAnnouncement_clone(&*owner->contents.result);
7380 }
7381 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7382         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7383         LDKUnsignedChannelAnnouncement ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
7384         uint32_t ret_ref = 0;
7385         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7386         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7387         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7388         ret_ref = (uintptr_t)ret_var.inner;
7389         if (ret_var.is_owned) {
7390                 ret_ref |= 1;
7391         }
7392         return ret_ref;
7393 }
7394
7395 static inline struct LDKDecodeError CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7396 CHECK(!owner->result_ok);
7397         return DecodeError_clone(&*owner->contents.err);
7398 }
7399 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7400         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7401         LDKDecodeError ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
7402         uint32_t ret_ref = 0;
7403         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7404         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7405         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7406         ret_ref = (uintptr_t)ret_var.inner;
7407         if (ret_var.is_owned) {
7408                 ret_ref |= 1;
7409         }
7410         return ret_ref;
7411 }
7412
7413 static inline struct LDKChannelAnnouncement CResult_ChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7414 CHECK(owner->result_ok);
7415         return ChannelAnnouncement_clone(&*owner->contents.result);
7416 }
7417 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7418         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7419         LDKChannelAnnouncement ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
7420         uint32_t ret_ref = 0;
7421         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7422         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7423         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7424         ret_ref = (uintptr_t)ret_var.inner;
7425         if (ret_var.is_owned) {
7426                 ret_ref |= 1;
7427         }
7428         return ret_ref;
7429 }
7430
7431 static inline struct LDKDecodeError CResult_ChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7432 CHECK(!owner->result_ok);
7433         return DecodeError_clone(&*owner->contents.err);
7434 }
7435 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_get_err"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7436         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(owner & ~1);
7437         LDKDecodeError ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
7438         uint32_t ret_ref = 0;
7439         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7440         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7441         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7442         ret_ref = (uintptr_t)ret_var.inner;
7443         if (ret_var.is_owned) {
7444                 ret_ref |= 1;
7445         }
7446         return ret_ref;
7447 }
7448
7449 static inline struct LDKUnsignedChannelUpdate CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7450 CHECK(owner->result_ok);
7451         return UnsignedChannelUpdate_clone(&*owner->contents.result);
7452 }
7453 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(uint32_t owner) {
7454         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
7455         LDKUnsignedChannelUpdate ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(owner_conv);
7456         uint32_t ret_ref = 0;
7457         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7458         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7459         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7460         ret_ref = (uintptr_t)ret_var.inner;
7461         if (ret_var.is_owned) {
7462                 ret_ref |= 1;
7463         }
7464         return ret_ref;
7465 }
7466
7467 static inline struct LDKDecodeError CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7468 CHECK(!owner->result_ok);
7469         return DecodeError_clone(&*owner->contents.err);
7470 }
7471 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_err"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(uint32_t owner) {
7472         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(owner & ~1);
7473         LDKDecodeError ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(owner_conv);
7474         uint32_t ret_ref = 0;
7475         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7476         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7477         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7478         ret_ref = (uintptr_t)ret_var.inner;
7479         if (ret_var.is_owned) {
7480                 ret_ref |= 1;
7481         }
7482         return ret_ref;
7483 }
7484
7485 static inline struct LDKChannelUpdate CResult_ChannelUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7486 CHECK(owner->result_ok);
7487         return ChannelUpdate_clone(&*owner->contents.result);
7488 }
7489 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_get_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_get_ok(uint32_t owner) {
7490         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
7491         LDKChannelUpdate ret_var = CResult_ChannelUpdateDecodeErrorZ_get_ok(owner_conv);
7492         uint32_t ret_ref = 0;
7493         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7494         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7495         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7496         ret_ref = (uintptr_t)ret_var.inner;
7497         if (ret_var.is_owned) {
7498                 ret_ref |= 1;
7499         }
7500         return ret_ref;
7501 }
7502
7503 static inline struct LDKDecodeError CResult_ChannelUpdateDecodeErrorZ_get_err(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
7504 CHECK(!owner->result_ok);
7505         return DecodeError_clone(&*owner->contents.err);
7506 }
7507 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_get_err"))) TS_CResult_ChannelUpdateDecodeErrorZ_get_err(uint32_t owner) {
7508         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(owner & ~1);
7509         LDKDecodeError ret_var = CResult_ChannelUpdateDecodeErrorZ_get_err(owner_conv);
7510         uint32_t ret_ref = 0;
7511         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7512         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7513         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7514         ret_ref = (uintptr_t)ret_var.inner;
7515         if (ret_var.is_owned) {
7516                 ret_ref |= 1;
7517         }
7518         return ret_ref;
7519 }
7520
7521 static inline struct LDKErrorMessage CResult_ErrorMessageDecodeErrorZ_get_ok(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
7522 CHECK(owner->result_ok);
7523         return ErrorMessage_clone(&*owner->contents.result);
7524 }
7525 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_get_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_get_ok(uint32_t owner) {
7526         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
7527         LDKErrorMessage ret_var = CResult_ErrorMessageDecodeErrorZ_get_ok(owner_conv);
7528         uint32_t ret_ref = 0;
7529         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7530         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7531         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7532         ret_ref = (uintptr_t)ret_var.inner;
7533         if (ret_var.is_owned) {
7534                 ret_ref |= 1;
7535         }
7536         return ret_ref;
7537 }
7538
7539 static inline struct LDKDecodeError CResult_ErrorMessageDecodeErrorZ_get_err(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
7540 CHECK(!owner->result_ok);
7541         return DecodeError_clone(&*owner->contents.err);
7542 }
7543 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_get_err"))) TS_CResult_ErrorMessageDecodeErrorZ_get_err(uint32_t owner) {
7544         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(owner & ~1);
7545         LDKDecodeError ret_var = CResult_ErrorMessageDecodeErrorZ_get_err(owner_conv);
7546         uint32_t ret_ref = 0;
7547         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7548         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7549         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7550         ret_ref = (uintptr_t)ret_var.inner;
7551         if (ret_var.is_owned) {
7552                 ret_ref |= 1;
7553         }
7554         return ret_ref;
7555 }
7556
7557 static inline struct LDKWarningMessage CResult_WarningMessageDecodeErrorZ_get_ok(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
7558 CHECK(owner->result_ok);
7559         return WarningMessage_clone(&*owner->contents.result);
7560 }
7561 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_get_ok"))) TS_CResult_WarningMessageDecodeErrorZ_get_ok(uint32_t owner) {
7562         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
7563         LDKWarningMessage ret_var = CResult_WarningMessageDecodeErrorZ_get_ok(owner_conv);
7564         uint32_t ret_ref = 0;
7565         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7566         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7567         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7568         ret_ref = (uintptr_t)ret_var.inner;
7569         if (ret_var.is_owned) {
7570                 ret_ref |= 1;
7571         }
7572         return ret_ref;
7573 }
7574
7575 static inline struct LDKDecodeError CResult_WarningMessageDecodeErrorZ_get_err(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
7576 CHECK(!owner->result_ok);
7577         return DecodeError_clone(&*owner->contents.err);
7578 }
7579 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_get_err"))) TS_CResult_WarningMessageDecodeErrorZ_get_err(uint32_t owner) {
7580         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(owner & ~1);
7581         LDKDecodeError ret_var = CResult_WarningMessageDecodeErrorZ_get_err(owner_conv);
7582         uint32_t ret_ref = 0;
7583         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7584         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7585         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7586         ret_ref = (uintptr_t)ret_var.inner;
7587         if (ret_var.is_owned) {
7588                 ret_ref |= 1;
7589         }
7590         return ret_ref;
7591 }
7592
7593 static inline struct LDKUnsignedNodeAnnouncement CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7594 CHECK(owner->result_ok);
7595         return UnsignedNodeAnnouncement_clone(&*owner->contents.result);
7596 }
7597 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7598         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
7599         LDKUnsignedNodeAnnouncement ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
7600         uint32_t ret_ref = 0;
7601         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7602         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7603         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7604         ret_ref = (uintptr_t)ret_var.inner;
7605         if (ret_var.is_owned) {
7606                 ret_ref |= 1;
7607         }
7608         return ret_ref;
7609 }
7610
7611 static inline struct LDKDecodeError CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7612 CHECK(!owner->result_ok);
7613         return DecodeError_clone(&*owner->contents.err);
7614 }
7615 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7616         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(owner & ~1);
7617         LDKDecodeError ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(owner_conv);
7618         uint32_t ret_ref = 0;
7619         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7620         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7621         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7622         ret_ref = (uintptr_t)ret_var.inner;
7623         if (ret_var.is_owned) {
7624                 ret_ref |= 1;
7625         }
7626         return ret_ref;
7627 }
7628
7629 static inline struct LDKNodeAnnouncement CResult_NodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7630 CHECK(owner->result_ok);
7631         return NodeAnnouncement_clone(&*owner->contents.result);
7632 }
7633 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_get_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_get_ok(uint32_t owner) {
7634         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
7635         LDKNodeAnnouncement ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
7636         uint32_t ret_ref = 0;
7637         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7638         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7639         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7640         ret_ref = (uintptr_t)ret_var.inner;
7641         if (ret_var.is_owned) {
7642                 ret_ref |= 1;
7643         }
7644         return ret_ref;
7645 }
7646
7647 static inline struct LDKDecodeError CResult_NodeAnnouncementDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
7648 CHECK(!owner->result_ok);
7649         return DecodeError_clone(&*owner->contents.err);
7650 }
7651 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_get_err"))) TS_CResult_NodeAnnouncementDecodeErrorZ_get_err(uint32_t owner) {
7652         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(owner & ~1);
7653         LDKDecodeError ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_err(owner_conv);
7654         uint32_t ret_ref = 0;
7655         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7656         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7657         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7658         ret_ref = (uintptr_t)ret_var.inner;
7659         if (ret_var.is_owned) {
7660                 ret_ref |= 1;
7661         }
7662         return ret_ref;
7663 }
7664
7665 static inline struct LDKQueryShortChannelIds CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
7666 CHECK(owner->result_ok);
7667         return QueryShortChannelIds_clone(&*owner->contents.result);
7668 }
7669 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(uint32_t owner) {
7670         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
7671         LDKQueryShortChannelIds ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(owner_conv);
7672         uint32_t ret_ref = 0;
7673         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7674         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7675         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7676         ret_ref = (uintptr_t)ret_var.inner;
7677         if (ret_var.is_owned) {
7678                 ret_ref |= 1;
7679         }
7680         return ret_ref;
7681 }
7682
7683 static inline struct LDKDecodeError CResult_QueryShortChannelIdsDecodeErrorZ_get_err(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
7684 CHECK(!owner->result_ok);
7685         return DecodeError_clone(&*owner->contents.err);
7686 }
7687 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_err"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_get_err(uint32_t owner) {
7688         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(owner & ~1);
7689         LDKDecodeError ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_err(owner_conv);
7690         uint32_t ret_ref = 0;
7691         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7692         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7693         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7694         ret_ref = (uintptr_t)ret_var.inner;
7695         if (ret_var.is_owned) {
7696                 ret_ref |= 1;
7697         }
7698         return ret_ref;
7699 }
7700
7701 static inline struct LDKReplyShortChannelIdsEnd CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
7702 CHECK(owner->result_ok);
7703         return ReplyShortChannelIdsEnd_clone(&*owner->contents.result);
7704 }
7705 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(uint32_t owner) {
7706         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
7707         LDKReplyShortChannelIdsEnd ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(owner_conv);
7708         uint32_t ret_ref = 0;
7709         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7710         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7711         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7712         ret_ref = (uintptr_t)ret_var.inner;
7713         if (ret_var.is_owned) {
7714                 ret_ref |= 1;
7715         }
7716         return ret_ref;
7717 }
7718
7719 static inline struct LDKDecodeError CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
7720 CHECK(!owner->result_ok);
7721         return DecodeError_clone(&*owner->contents.err);
7722 }
7723 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(uint32_t owner) {
7724         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(owner & ~1);
7725         LDKDecodeError ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(owner_conv);
7726         uint32_t ret_ref = 0;
7727         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7728         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7729         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7730         ret_ref = (uintptr_t)ret_var.inner;
7731         if (ret_var.is_owned) {
7732                 ret_ref |= 1;
7733         }
7734         return ret_ref;
7735 }
7736
7737 static inline struct LDKQueryChannelRange CResult_QueryChannelRangeDecodeErrorZ_get_ok(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
7738 CHECK(owner->result_ok);
7739         return QueryChannelRange_clone(&*owner->contents.result);
7740 }
7741 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_get_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_get_ok(uint32_t owner) {
7742         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
7743         LDKQueryChannelRange ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_ok(owner_conv);
7744         uint32_t ret_ref = 0;
7745         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7746         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7747         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7748         ret_ref = (uintptr_t)ret_var.inner;
7749         if (ret_var.is_owned) {
7750                 ret_ref |= 1;
7751         }
7752         return ret_ref;
7753 }
7754
7755 static inline struct LDKDecodeError CResult_QueryChannelRangeDecodeErrorZ_get_err(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
7756 CHECK(!owner->result_ok);
7757         return DecodeError_clone(&*owner->contents.err);
7758 }
7759 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_get_err"))) TS_CResult_QueryChannelRangeDecodeErrorZ_get_err(uint32_t owner) {
7760         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(owner & ~1);
7761         LDKDecodeError ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_err(owner_conv);
7762         uint32_t ret_ref = 0;
7763         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7764         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7765         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7766         ret_ref = (uintptr_t)ret_var.inner;
7767         if (ret_var.is_owned) {
7768                 ret_ref |= 1;
7769         }
7770         return ret_ref;
7771 }
7772
7773 static inline struct LDKReplyChannelRange CResult_ReplyChannelRangeDecodeErrorZ_get_ok(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
7774 CHECK(owner->result_ok);
7775         return ReplyChannelRange_clone(&*owner->contents.result);
7776 }
7777 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_get_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_get_ok(uint32_t owner) {
7778         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
7779         LDKReplyChannelRange ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_ok(owner_conv);
7780         uint32_t ret_ref = 0;
7781         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7782         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7783         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7784         ret_ref = (uintptr_t)ret_var.inner;
7785         if (ret_var.is_owned) {
7786                 ret_ref |= 1;
7787         }
7788         return ret_ref;
7789 }
7790
7791 static inline struct LDKDecodeError CResult_ReplyChannelRangeDecodeErrorZ_get_err(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
7792 CHECK(!owner->result_ok);
7793         return DecodeError_clone(&*owner->contents.err);
7794 }
7795 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_get_err"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_get_err(uint32_t owner) {
7796         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(owner & ~1);
7797         LDKDecodeError ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_err(owner_conv);
7798         uint32_t ret_ref = 0;
7799         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7800         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7801         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7802         ret_ref = (uintptr_t)ret_var.inner;
7803         if (ret_var.is_owned) {
7804                 ret_ref |= 1;
7805         }
7806         return ret_ref;
7807 }
7808
7809 static inline struct LDKGossipTimestampFilter CResult_GossipTimestampFilterDecodeErrorZ_get_ok(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
7810 CHECK(owner->result_ok);
7811         return GossipTimestampFilter_clone(&*owner->contents.result);
7812 }
7813 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_get_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_get_ok(uint32_t owner) {
7814         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
7815         LDKGossipTimestampFilter ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_ok(owner_conv);
7816         uint32_t ret_ref = 0;
7817         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7818         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7819         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7820         ret_ref = (uintptr_t)ret_var.inner;
7821         if (ret_var.is_owned) {
7822                 ret_ref |= 1;
7823         }
7824         return ret_ref;
7825 }
7826
7827 static inline struct LDKDecodeError CResult_GossipTimestampFilterDecodeErrorZ_get_err(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
7828 CHECK(!owner->result_ok);
7829         return DecodeError_clone(&*owner->contents.err);
7830 }
7831 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_get_err"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_get_err(uint32_t owner) {
7832         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(owner & ~1);
7833         LDKDecodeError ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_err(owner_conv);
7834         uint32_t ret_ref = 0;
7835         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7836         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7837         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7838         ret_ref = (uintptr_t)ret_var.inner;
7839         if (ret_var.is_owned) {
7840                 ret_ref |= 1;
7841         }
7842         return ret_ref;
7843 }
7844
7845 uint32_t __attribute__((export_name("TS_LDKSignOrCreationError_ty_from_ptr"))) TS_LDKSignOrCreationError_ty_from_ptr(uint32_t ptr) {
7846         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
7847         switch(obj->tag) {
7848                 case LDKSignOrCreationError_SignError: return 0;
7849                 case LDKSignOrCreationError_CreationError: return 1;
7850                 default: abort();
7851         }
7852 }
7853 uint32_t __attribute__((export_name("TS_LDKSignOrCreationError_CreationError_get_creation_error"))) TS_LDKSignOrCreationError_CreationError_get_creation_error(uint32_t ptr) {
7854         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
7855         assert(obj->tag == LDKSignOrCreationError_CreationError);
7856                         uint32_t creation_error_conv = LDKCreationError_to_js(obj->creation_error);
7857         return creation_error_conv;
7858 }
7859 static inline struct LDKInvoice CResult_InvoiceSignOrCreationErrorZ_get_ok(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
7860 CHECK(owner->result_ok);
7861         return Invoice_clone(&*owner->contents.result);
7862 }
7863 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_get_ok"))) TS_CResult_InvoiceSignOrCreationErrorZ_get_ok(uint32_t owner) {
7864         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
7865         LDKInvoice ret_var = CResult_InvoiceSignOrCreationErrorZ_get_ok(owner_conv);
7866         uint32_t ret_ref = 0;
7867         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7868         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7869         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7870         ret_ref = (uintptr_t)ret_var.inner;
7871         if (ret_var.is_owned) {
7872                 ret_ref |= 1;
7873         }
7874         return ret_ref;
7875 }
7876
7877 static inline struct LDKSignOrCreationError CResult_InvoiceSignOrCreationErrorZ_get_err(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
7878 CHECK(!owner->result_ok);
7879         return SignOrCreationError_clone(&*owner->contents.err);
7880 }
7881 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_get_err"))) TS_CResult_InvoiceSignOrCreationErrorZ_get_err(uint32_t owner) {
7882         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(owner & ~1);
7883         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
7884         *ret_copy = CResult_InvoiceSignOrCreationErrorZ_get_err(owner_conv);
7885         uint32_t ret_ref = (uintptr_t)ret_copy;
7886         return ret_ref;
7887 }
7888
7889 typedef struct LDKFilter_JCalls {
7890         atomic_size_t refcnt;
7891         uint32_t instance_ptr;
7892 } LDKFilter_JCalls;
7893 static void LDKFilter_JCalls_free(void* this_arg) {
7894         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7895         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7896                 FREE(j_calls);
7897         }
7898 }
7899 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
7900         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7901         int8_tArray txid_arr = init_int8_tArray(32, __LINE__);
7902         memcpy(txid_arr->elems, *txid, 32);
7903         LDKu8slice script_pubkey_var = script_pubkey;
7904         int8_tArray script_pubkey_arr = init_int8_tArray(script_pubkey_var.datalen, __LINE__);
7905         memcpy(script_pubkey_arr->elems, script_pubkey_var.data, script_pubkey_var.datalen);
7906         js_invoke_function_2(j_calls->instance_ptr, 32, (uint32_t)txid_arr, (uint32_t)script_pubkey_arr);
7907 }
7908 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
7909         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7910         LDKWatchedOutput output_var = output;
7911         uint32_t output_ref = 0;
7912         CHECK((((uintptr_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7913         CHECK((((uintptr_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7914         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
7915         output_ref = (uintptr_t)output_var.inner;
7916         if (output_var.is_owned) {
7917                 output_ref |= 1;
7918         }
7919         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 33, (uint32_t)output_ref);
7920         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
7921         CHECK_ACCESS(ret_ptr);
7922         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(ret_ptr);
7923         FREE((void*)ret);
7924         return ret_conv;
7925 }
7926 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
7927         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
7928         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7929 }
7930 static inline LDKFilter LDKFilter_init (JSValue o) {
7931         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
7932         atomic_init(&calls->refcnt, 1);
7933         calls->instance_ptr = o;
7934
7935         LDKFilter ret = {
7936                 .this_arg = (void*) calls,
7937                 .register_tx = register_tx_LDKFilter_jcall,
7938                 .register_output = register_output_LDKFilter_jcall,
7939                 .free = LDKFilter_JCalls_free,
7940         };
7941         return ret;
7942 }
7943 long  __attribute__((export_name("TS_LDKFilter_new"))) TS_LDKFilter_new(JSValue o) {
7944         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
7945         *res_ptr = LDKFilter_init(o);
7946         return (long)res_ptr;
7947 }
7948 void  __attribute__((export_name("TS_Filter_register_tx"))) TS_Filter_register_tx(uint32_t this_arg, int8_tArray txid, int8_tArray script_pubkey) {
7949         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7950         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7951         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
7952         unsigned char txid_arr[32];
7953         CHECK(txid->arr_len == 32);
7954         memcpy(txid_arr, txid->elems, 32); FREE(txid);
7955         unsigned char (*txid_ref)[32] = &txid_arr;
7956         LDKu8slice script_pubkey_ref;
7957         script_pubkey_ref.datalen = script_pubkey->arr_len;
7958         script_pubkey_ref.data = script_pubkey->elems /* XXX script_pubkey leaks */;
7959         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
7960 }
7961
7962 uint32_t  __attribute__((export_name("TS_Filter_register_output"))) TS_Filter_register_output(uint32_t this_arg, uint32_t output) {
7963         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
7964         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7965         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
7966         LDKWatchedOutput output_conv;
7967         output_conv.inner = (void*)(output & (~1));
7968         output_conv.is_owned = (output & 1) || (output == 0);
7969         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
7970         output_conv = WatchedOutput_clone(&output_conv);
7971         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
7972         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
7973         uint32_t ret_ref = (uintptr_t)ret_copy;
7974         return ret_ref;
7975 }
7976
7977 uint32_t __attribute__((export_name("TS_LDKCOption_FilterZ_ty_from_ptr"))) TS_LDKCOption_FilterZ_ty_from_ptr(uint32_t ptr) {
7978         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
7979         switch(obj->tag) {
7980                 case LDKCOption_FilterZ_Some: return 0;
7981                 case LDKCOption_FilterZ_None: return 1;
7982                 default: abort();
7983         }
7984 }
7985 uint32_t __attribute__((export_name("TS_LDKCOption_FilterZ_Some_get_some"))) TS_LDKCOption_FilterZ_Some_get_some(uint32_t ptr) {
7986         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
7987         assert(obj->tag == LDKCOption_FilterZ_Some);
7988                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
7989                         *some_ret = obj->some;
7990                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
7991                         if ((*some_ret).free == LDKFilter_JCalls_free) {
7992                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7993                                 LDKFilter_JCalls_cloned(&(*some_ret));
7994                         }
7995         return (uint32_t)some_ret;
7996 }
7997 static inline struct LDKLockedChannelMonitor *CResult_LockedChannelMonitorNoneZ_get_ok(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
7998 CHECK(owner->result_ok);
7999         return &*owner->contents.result;
8000 }
8001 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_get_ok"))) TS_CResult_LockedChannelMonitorNoneZ_get_ok(uint32_t owner) {
8002         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
8003         LDKLockedChannelMonitor ret_var = *CResult_LockedChannelMonitorNoneZ_get_ok(owner_conv);
8004         uint32_t ret_ref = 0;
8005         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8006         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8007         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8008         ret_ref = (uintptr_t)ret_var.inner & ~1;
8009         return ret_ref;
8010 }
8011
8012 static inline void CResult_LockedChannelMonitorNoneZ_get_err(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
8013 CHECK(!owner->result_ok);
8014         return *owner->contents.err;
8015 }
8016 void  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_get_err"))) TS_CResult_LockedChannelMonitorNoneZ_get_err(uint32_t owner) {
8017         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(owner & ~1);
8018         CResult_LockedChannelMonitorNoneZ_get_err(owner_conv);
8019 }
8020
8021 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
8022         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
8023         for (size_t i = 0; i < ret.datalen; i++) {
8024                 ret.data[i] = OutPoint_clone(&orig->data[i]);
8025         }
8026         return ret;
8027 }
8028 typedef struct LDKMessageSendEventsProvider_JCalls {
8029         atomic_size_t refcnt;
8030         uint32_t instance_ptr;
8031 } LDKMessageSendEventsProvider_JCalls;
8032 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
8033         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
8034         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8035                 FREE(j_calls);
8036         }
8037 }
8038 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
8039         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
8040         uint32_tArray ret = (uint32_tArray)js_invoke_function_0(j_calls->instance_ptr, 34);
8041         LDKCVec_MessageSendEventZ ret_constr;
8042         ret_constr.datalen = ret->arr_len;
8043         if (ret_constr.datalen > 0)
8044                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
8045         else
8046                 ret_constr.data = NULL;
8047         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
8048         for (size_t s = 0; s < ret_constr.datalen; s++) {
8049                 uint32_t ret_conv_18 = ret_vals[s];
8050                 void* ret_conv_18_ptr = (void*)(((uintptr_t)ret_conv_18) & ~1);
8051                 CHECK_ACCESS(ret_conv_18_ptr);
8052                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
8053                 FREE((void*)ret_conv_18);
8054                 ret_constr.data[s] = ret_conv_18_conv;
8055         }
8056         return ret_constr;
8057 }
8058 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
8059         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
8060         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8061 }
8062 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JSValue o) {
8063         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
8064         atomic_init(&calls->refcnt, 1);
8065         calls->instance_ptr = o;
8066
8067         LDKMessageSendEventsProvider ret = {
8068                 .this_arg = (void*) calls,
8069                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
8070                 .free = LDKMessageSendEventsProvider_JCalls_free,
8071         };
8072         return ret;
8073 }
8074 long  __attribute__((export_name("TS_LDKMessageSendEventsProvider_new"))) TS_LDKMessageSendEventsProvider_new(JSValue o) {
8075         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
8076         *res_ptr = LDKMessageSendEventsProvider_init(o);
8077         return (long)res_ptr;
8078 }
8079 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) {
8080         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8081         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8082         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
8083         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
8084         uint32_tArray ret_arr = NULL;
8085         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
8086         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
8087         for (size_t s = 0; s < ret_var.datalen; s++) {
8088                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
8089                 *ret_conv_18_copy = ret_var.data[s];
8090                 uint32_t ret_conv_18_ref = (uintptr_t)ret_conv_18_copy;
8091                 ret_arr_ptr[s] = ret_conv_18_ref;
8092         }
8093         
8094         FREE(ret_var.data);
8095         return ret_arr;
8096 }
8097
8098 typedef struct LDKEventHandler_JCalls {
8099         atomic_size_t refcnt;
8100         uint32_t instance_ptr;
8101 } LDKEventHandler_JCalls;
8102 static void LDKEventHandler_JCalls_free(void* this_arg) {
8103         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
8104         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8105                 FREE(j_calls);
8106         }
8107 }
8108 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
8109         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
8110         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
8111         *ret_event = Event_clone(event);
8112         js_invoke_function_1(j_calls->instance_ptr, 35, (uint32_t)(uint32_t)ret_event);
8113 }
8114 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
8115         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
8116         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8117 }
8118 static inline LDKEventHandler LDKEventHandler_init (JSValue o) {
8119         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
8120         atomic_init(&calls->refcnt, 1);
8121         calls->instance_ptr = o;
8122
8123         LDKEventHandler ret = {
8124                 .this_arg = (void*) calls,
8125                 .handle_event = handle_event_LDKEventHandler_jcall,
8126                 .free = LDKEventHandler_JCalls_free,
8127         };
8128         return ret;
8129 }
8130 long  __attribute__((export_name("TS_LDKEventHandler_new"))) TS_LDKEventHandler_new(JSValue o) {
8131         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
8132         *res_ptr = LDKEventHandler_init(o);
8133         return (long)res_ptr;
8134 }
8135 void  __attribute__((export_name("TS_EventHandler_handle_event"))) TS_EventHandler_handle_event(uint32_t this_arg, uint32_t event) {
8136         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8137         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8138         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
8139         LDKEvent* event_conv = (LDKEvent*)event;
8140         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
8141 }
8142
8143 typedef struct LDKEventsProvider_JCalls {
8144         atomic_size_t refcnt;
8145         uint32_t instance_ptr;
8146 } LDKEventsProvider_JCalls;
8147 static void LDKEventsProvider_JCalls_free(void* this_arg) {
8148         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
8149         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8150                 FREE(j_calls);
8151         }
8152 }
8153 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
8154         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
8155         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
8156         *handler_ret = handler;
8157         js_invoke_function_1(j_calls->instance_ptr, 36, (uint32_t)(uint32_t)handler_ret);
8158 }
8159 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
8160         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
8161         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8162 }
8163 static inline LDKEventsProvider LDKEventsProvider_init (JSValue o) {
8164         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
8165         atomic_init(&calls->refcnt, 1);
8166         calls->instance_ptr = o;
8167
8168         LDKEventsProvider ret = {
8169                 .this_arg = (void*) calls,
8170                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
8171                 .free = LDKEventsProvider_JCalls_free,
8172         };
8173         return ret;
8174 }
8175 long  __attribute__((export_name("TS_LDKEventsProvider_new"))) TS_LDKEventsProvider_new(JSValue o) {
8176         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
8177         *res_ptr = LDKEventsProvider_init(o);
8178         return (long)res_ptr;
8179 }
8180 void  __attribute__((export_name("TS_EventsProvider_process_pending_events"))) TS_EventsProvider_process_pending_events(uint32_t this_arg, uint32_t handler) {
8181         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8182         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8183         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
8184         void* handler_ptr = (void*)(((uintptr_t)handler) & ~1);
8185         CHECK_ACCESS(handler_ptr);
8186         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
8187         if (handler_conv.free == LDKEventHandler_JCalls_free) {
8188                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
8189                 LDKEventHandler_JCalls_cloned(&handler_conv);
8190         }
8191         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
8192 }
8193
8194 typedef struct LDKListen_JCalls {
8195         atomic_size_t refcnt;
8196         uint32_t instance_ptr;
8197 } LDKListen_JCalls;
8198 static void LDKListen_JCalls_free(void* this_arg) {
8199         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
8200         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8201                 FREE(j_calls);
8202         }
8203 }
8204 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
8205         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
8206         LDKu8slice block_var = block;
8207         int8_tArray block_arr = init_int8_tArray(block_var.datalen, __LINE__);
8208         memcpy(block_arr->elems, block_var.data, block_var.datalen);
8209         int32_t height_conv = height;
8210         js_invoke_function_2(j_calls->instance_ptr, 37, (uint32_t)block_arr, (uint32_t)height_conv);
8211 }
8212 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
8213         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
8214         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
8215         memcpy(header_arr->elems, *header, 80);
8216         int32_t height_conv = height;
8217         js_invoke_function_2(j_calls->instance_ptr, 38, (uint32_t)header_arr, (uint32_t)height_conv);
8218 }
8219 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
8220         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
8221         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8222 }
8223 static inline LDKListen LDKListen_init (JSValue o) {
8224         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
8225         atomic_init(&calls->refcnt, 1);
8226         calls->instance_ptr = o;
8227
8228         LDKListen ret = {
8229                 .this_arg = (void*) calls,
8230                 .block_connected = block_connected_LDKListen_jcall,
8231                 .block_disconnected = block_disconnected_LDKListen_jcall,
8232                 .free = LDKListen_JCalls_free,
8233         };
8234         return ret;
8235 }
8236 long  __attribute__((export_name("TS_LDKListen_new"))) TS_LDKListen_new(JSValue o) {
8237         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
8238         *res_ptr = LDKListen_init(o);
8239         return (long)res_ptr;
8240 }
8241 void  __attribute__((export_name("TS_Listen_block_connected"))) TS_Listen_block_connected(uint32_t this_arg, int8_tArray block, int32_t height) {
8242         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8243         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8244         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
8245         LDKu8slice block_ref;
8246         block_ref.datalen = block->arr_len;
8247         block_ref.data = block->elems /* XXX block leaks */;
8248         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
8249 }
8250
8251 void  __attribute__((export_name("TS_Listen_block_disconnected"))) TS_Listen_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t height) {
8252         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8253         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8254         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
8255         unsigned char header_arr[80];
8256         CHECK(header->arr_len == 80);
8257         memcpy(header_arr, header->elems, 80); FREE(header);
8258         unsigned char (*header_ref)[80] = &header_arr;
8259         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
8260 }
8261
8262 typedef struct LDKConfirm_JCalls {
8263         atomic_size_t refcnt;
8264         uint32_t instance_ptr;
8265 } LDKConfirm_JCalls;
8266 static void LDKConfirm_JCalls_free(void* this_arg) {
8267         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8268         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8269                 FREE(j_calls);
8270         }
8271 }
8272 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
8273         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8274         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
8275         memcpy(header_arr->elems, *header, 80);
8276         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
8277         uint32_tArray txdata_arr = NULL;
8278         txdata_arr = init_uint32_tArray(txdata_var.datalen, __LINE__);
8279         uint32_t *txdata_arr_ptr = (uint32_t*)(((uint8_t*)txdata_arr) + 4);
8280         for (size_t c = 0; c < txdata_var.datalen; c++) {
8281                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
8282                 *txdata_conv_28_conv = txdata_var.data[c];
8283                 txdata_arr_ptr[c] = ((uint32_t)txdata_conv_28_conv);
8284         }
8285         
8286         FREE(txdata_var.data);
8287         int32_t height_conv = height;
8288         js_invoke_function_3(j_calls->instance_ptr, 39, (uint32_t)header_arr, (uint32_t)txdata_arr, (uint32_t)height_conv);
8289 }
8290 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
8291         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8292         int8_tArray txid_arr = init_int8_tArray(32, __LINE__);
8293         memcpy(txid_arr->elems, *txid, 32);
8294         js_invoke_function_1(j_calls->instance_ptr, 40, (uint32_t)txid_arr);
8295 }
8296 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
8297         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8298         int8_tArray header_arr = init_int8_tArray(80, __LINE__);
8299         memcpy(header_arr->elems, *header, 80);
8300         int32_t height_conv = height;
8301         js_invoke_function_2(j_calls->instance_ptr, 41, (uint32_t)header_arr, (uint32_t)height_conv);
8302 }
8303 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
8304         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
8305         ptrArray ret = (ptrArray)js_invoke_function_0(j_calls->instance_ptr, 42);
8306         LDKCVec_TxidZ ret_constr;
8307         ret_constr.datalen = ret->arr_len;
8308         if (ret_constr.datalen > 0)
8309                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
8310         else
8311                 ret_constr.data = NULL;
8312         int8_tArray* ret_vals = (void*) ret->elems /* XXX ret leaks */;
8313         for (size_t m = 0; m < ret_constr.datalen; m++) {
8314                 int8_tArray ret_conv_12 = ret_vals[m];
8315                 LDKThirtyTwoBytes ret_conv_12_ref;
8316                 CHECK(ret_conv_12->arr_len == 32);
8317                 memcpy(ret_conv_12_ref.data, ret_conv_12->elems, 32); FREE(ret_conv_12);
8318                 ret_constr.data[m] = ret_conv_12_ref;
8319         }
8320         return ret_constr;
8321 }
8322 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
8323         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
8324         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8325 }
8326 static inline LDKConfirm LDKConfirm_init (JSValue o) {
8327         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
8328         atomic_init(&calls->refcnt, 1);
8329         calls->instance_ptr = o;
8330
8331         LDKConfirm ret = {
8332                 .this_arg = (void*) calls,
8333                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
8334                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
8335                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
8336                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
8337                 .free = LDKConfirm_JCalls_free,
8338         };
8339         return ret;
8340 }
8341 long  __attribute__((export_name("TS_LDKConfirm_new"))) TS_LDKConfirm_new(JSValue o) {
8342         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
8343         *res_ptr = LDKConfirm_init(o);
8344         return (long)res_ptr;
8345 }
8346 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) {
8347         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8348         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8349         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8350         unsigned char header_arr[80];
8351         CHECK(header->arr_len == 80);
8352         memcpy(header_arr, header->elems, 80); FREE(header);
8353         unsigned char (*header_ref)[80] = &header_arr;
8354         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
8355         txdata_constr.datalen = txdata->arr_len;
8356         if (txdata_constr.datalen > 0)
8357                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
8358         else
8359                 txdata_constr.data = NULL;
8360         uint32_t* txdata_vals = txdata->elems /* XXX txdata leaks */;
8361         for (size_t c = 0; c < txdata_constr.datalen; c++) {
8362                 uint32_t txdata_conv_28 = txdata_vals[c];
8363                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
8364                 CHECK_ACCESS(txdata_conv_28_ptr);
8365                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
8366                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
8367                 txdata_constr.data[c] = txdata_conv_28_conv;
8368         }
8369         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
8370 }
8371
8372 void  __attribute__((export_name("TS_Confirm_transaction_unconfirmed"))) TS_Confirm_transaction_unconfirmed(uint32_t this_arg, int8_tArray txid) {
8373         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8374         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8375         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8376         unsigned char txid_arr[32];
8377         CHECK(txid->arr_len == 32);
8378         memcpy(txid_arr, txid->elems, 32); FREE(txid);
8379         unsigned char (*txid_ref)[32] = &txid_arr;
8380         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
8381 }
8382
8383 void  __attribute__((export_name("TS_Confirm_best_block_updated"))) TS_Confirm_best_block_updated(uint32_t this_arg, int8_tArray header, int32_t height) {
8384         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8385         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8386         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8387         unsigned char header_arr[80];
8388         CHECK(header->arr_len == 80);
8389         memcpy(header_arr, header->elems, 80); FREE(header);
8390         unsigned char (*header_ref)[80] = &header_arr;
8391         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
8392 }
8393
8394 ptrArray  __attribute__((export_name("TS_Confirm_get_relevant_txids"))) TS_Confirm_get_relevant_txids(uint32_t this_arg) {
8395         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8396         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8397         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
8398         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
8399         ptrArray ret_arr = NULL;
8400         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
8401         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
8402         for (size_t m = 0; m < ret_var.datalen; m++) {
8403                 int8_tArray ret_conv_12_arr = init_int8_tArray(32, __LINE__);
8404                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].data, 32);
8405                 ret_arr_ptr[m] = ret_conv_12_arr;
8406         }
8407         
8408         FREE(ret_var.data);
8409         return ret_arr;
8410 }
8411
8412 typedef struct LDKPersist_JCalls {
8413         atomic_size_t refcnt;
8414         uint32_t instance_ptr;
8415 } LDKPersist_JCalls;
8416 static void LDKPersist_JCalls_free(void* this_arg) {
8417         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
8418         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8419                 FREE(j_calls);
8420         }
8421 }
8422 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
8423         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
8424         LDKOutPoint channel_id_var = channel_id;
8425         uint32_t channel_id_ref = 0;
8426         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8427         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8428         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
8429         channel_id_ref = (uintptr_t)channel_id_var.inner;
8430         if (channel_id_var.is_owned) {
8431                 channel_id_ref |= 1;
8432         }
8433         LDKChannelMonitor data_var = *data;
8434         uint32_t data_ref = 0;
8435         data_var = ChannelMonitor_clone(&data_var);
8436         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8437         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8438         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
8439         data_ref = (uintptr_t)data_var.inner;
8440         if (data_var.is_owned) {
8441                 data_ref |= 1;
8442         }
8443         LDKMonitorUpdateId update_id_var = update_id;
8444         uint32_t update_id_ref = 0;
8445         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8446         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8447         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
8448         update_id_ref = (uintptr_t)update_id_var.inner;
8449         if (update_id_var.is_owned) {
8450                 update_id_ref |= 1;
8451         }
8452         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);
8453         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8454         CHECK_ACCESS(ret_ptr);
8455         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
8456         FREE((void*)ret);
8457         return ret_conv;
8458 }
8459 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
8460         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
8461         LDKOutPoint channel_id_var = channel_id;
8462         uint32_t channel_id_ref = 0;
8463         CHECK((((uintptr_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8464         CHECK((((uintptr_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8465         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
8466         channel_id_ref = (uintptr_t)channel_id_var.inner;
8467         if (channel_id_var.is_owned) {
8468                 channel_id_ref |= 1;
8469         }
8470         LDKChannelMonitorUpdate update_var = *update;
8471         uint32_t update_ref = 0;
8472         if ((uintptr_t)update_var.inner > 4096) {
8473                 update_var = ChannelMonitorUpdate_clone(&update_var);
8474                 CHECK((((uintptr_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8475                 CHECK((((uintptr_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8476         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
8477                 update_ref = (uintptr_t)update_var.inner;
8478                 if (update_var.is_owned) {
8479                         update_ref |= 1;
8480                 }
8481         }
8482         LDKChannelMonitor data_var = *data;
8483         uint32_t data_ref = 0;
8484         data_var = ChannelMonitor_clone(&data_var);
8485         CHECK((((uintptr_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8486         CHECK((((uintptr_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8487         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
8488         data_ref = (uintptr_t)data_var.inner;
8489         if (data_var.is_owned) {
8490                 data_ref |= 1;
8491         }
8492         LDKMonitorUpdateId update_id_var = update_id;
8493         uint32_t update_id_ref = 0;
8494         CHECK((((uintptr_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8495         CHECK((((uintptr_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8496         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
8497         update_id_ref = (uintptr_t)update_id_var.inner;
8498         if (update_id_var.is_owned) {
8499                 update_id_ref |= 1;
8500         }
8501         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);
8502         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
8503         CHECK_ACCESS(ret_ptr);
8504         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
8505         FREE((void*)ret);
8506         return ret_conv;
8507 }
8508 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
8509         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
8510         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8511 }
8512 static inline LDKPersist LDKPersist_init (JSValue o) {
8513         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
8514         atomic_init(&calls->refcnt, 1);
8515         calls->instance_ptr = o;
8516
8517         LDKPersist ret = {
8518                 .this_arg = (void*) calls,
8519                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
8520                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
8521                 .free = LDKPersist_JCalls_free,
8522         };
8523         return ret;
8524 }
8525 long  __attribute__((export_name("TS_LDKPersist_new"))) TS_LDKPersist_new(JSValue o) {
8526         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
8527         *res_ptr = LDKPersist_init(o);
8528         return (long)res_ptr;
8529 }
8530 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) {
8531         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8532         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8533         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
8534         LDKOutPoint channel_id_conv;
8535         channel_id_conv.inner = (void*)(channel_id & (~1));
8536         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
8537         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
8538         channel_id_conv = OutPoint_clone(&channel_id_conv);
8539         LDKChannelMonitor data_conv;
8540         data_conv.inner = (void*)(data & (~1));
8541         data_conv.is_owned = false;
8542         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
8543         LDKMonitorUpdateId update_id_conv;
8544         update_id_conv.inner = (void*)(update_id & (~1));
8545         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
8546         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
8547         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
8548         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
8549         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv);
8550         return (uint32_t)ret_conv;
8551 }
8552
8553 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) {
8554         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8555         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8556         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
8557         LDKOutPoint channel_id_conv;
8558         channel_id_conv.inner = (void*)(channel_id & (~1));
8559         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
8560         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
8561         channel_id_conv = OutPoint_clone(&channel_id_conv);
8562         LDKChannelMonitorUpdate update_conv;
8563         update_conv.inner = (void*)(update & (~1));
8564         update_conv.is_owned = false;
8565         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
8566         LDKChannelMonitor data_conv;
8567         data_conv.inner = (void*)(data & (~1));
8568         data_conv.is_owned = false;
8569         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
8570         LDKMonitorUpdateId update_id_conv;
8571         update_id_conv.inner = (void*)(update_id & (~1));
8572         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
8573         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
8574         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
8575         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
8576         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv);
8577         return (uint32_t)ret_conv;
8578 }
8579
8580 typedef struct LDKChannelMessageHandler_JCalls {
8581         atomic_size_t refcnt;
8582         uint32_t instance_ptr;
8583         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
8584 } LDKChannelMessageHandler_JCalls;
8585 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
8586         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8587         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8588                 FREE(j_calls);
8589         }
8590 }
8591 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
8592         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8593         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8594         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8595         LDKInitFeatures their_features_var = their_features;
8596         uint32_t their_features_ref = 0;
8597         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8598         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8599         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
8600         their_features_ref = (uintptr_t)their_features_var.inner;
8601         if (their_features_var.is_owned) {
8602                 their_features_ref |= 1;
8603         }
8604         LDKOpenChannel msg_var = *msg;
8605         uint32_t msg_ref = 0;
8606         msg_var = OpenChannel_clone(&msg_var);
8607         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8608         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8609         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8610         msg_ref = (uintptr_t)msg_var.inner;
8611         if (msg_var.is_owned) {
8612                 msg_ref |= 1;
8613         }
8614         js_invoke_function_3(j_calls->instance_ptr, 45, (uint32_t)their_node_id_arr, (uint32_t)their_features_ref, (uint32_t)msg_ref);
8615 }
8616 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
8617         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8618         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8619         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8620         LDKInitFeatures their_features_var = their_features;
8621         uint32_t their_features_ref = 0;
8622         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8623         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8624         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
8625         their_features_ref = (uintptr_t)their_features_var.inner;
8626         if (their_features_var.is_owned) {
8627                 their_features_ref |= 1;
8628         }
8629         LDKAcceptChannel msg_var = *msg;
8630         uint32_t msg_ref = 0;
8631         msg_var = AcceptChannel_clone(&msg_var);
8632         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8633         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8634         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8635         msg_ref = (uintptr_t)msg_var.inner;
8636         if (msg_var.is_owned) {
8637                 msg_ref |= 1;
8638         }
8639         js_invoke_function_3(j_calls->instance_ptr, 46, (uint32_t)their_node_id_arr, (uint32_t)their_features_ref, (uint32_t)msg_ref);
8640 }
8641 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
8642         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8643         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8644         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8645         LDKFundingCreated msg_var = *msg;
8646         uint32_t msg_ref = 0;
8647         msg_var = FundingCreated_clone(&msg_var);
8648         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8649         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8650         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8651         msg_ref = (uintptr_t)msg_var.inner;
8652         if (msg_var.is_owned) {
8653                 msg_ref |= 1;
8654         }
8655         js_invoke_function_2(j_calls->instance_ptr, 47, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8656 }
8657 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
8658         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8659         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8660         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8661         LDKFundingSigned msg_var = *msg;
8662         uint32_t msg_ref = 0;
8663         msg_var = FundingSigned_clone(&msg_var);
8664         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8665         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8666         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8667         msg_ref = (uintptr_t)msg_var.inner;
8668         if (msg_var.is_owned) {
8669                 msg_ref |= 1;
8670         }
8671         js_invoke_function_2(j_calls->instance_ptr, 48, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8672 }
8673 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
8674         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8675         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8676         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8677         LDKFundingLocked msg_var = *msg;
8678         uint32_t msg_ref = 0;
8679         msg_var = FundingLocked_clone(&msg_var);
8680         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8681         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8682         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8683         msg_ref = (uintptr_t)msg_var.inner;
8684         if (msg_var.is_owned) {
8685                 msg_ref |= 1;
8686         }
8687         js_invoke_function_2(j_calls->instance_ptr, 49, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8688 }
8689 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
8690         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8691         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8692         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8693         LDKInitFeatures their_features_var = *their_features;
8694         uint32_t their_features_ref = 0;
8695         their_features_var = InitFeatures_clone(&their_features_var);
8696         CHECK((((uintptr_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8697         CHECK((((uintptr_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8698         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
8699         their_features_ref = (uintptr_t)their_features_var.inner;
8700         if (their_features_var.is_owned) {
8701                 their_features_ref |= 1;
8702         }
8703         LDKShutdown msg_var = *msg;
8704         uint32_t msg_ref = 0;
8705         msg_var = Shutdown_clone(&msg_var);
8706         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8707         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8708         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8709         msg_ref = (uintptr_t)msg_var.inner;
8710         if (msg_var.is_owned) {
8711                 msg_ref |= 1;
8712         }
8713         js_invoke_function_3(j_calls->instance_ptr, 50, (uint32_t)their_node_id_arr, (uint32_t)their_features_ref, (uint32_t)msg_ref);
8714 }
8715 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
8716         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8717         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8718         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8719         LDKClosingSigned msg_var = *msg;
8720         uint32_t msg_ref = 0;
8721         msg_var = ClosingSigned_clone(&msg_var);
8722         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8723         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8724         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8725         msg_ref = (uintptr_t)msg_var.inner;
8726         if (msg_var.is_owned) {
8727                 msg_ref |= 1;
8728         }
8729         js_invoke_function_2(j_calls->instance_ptr, 51, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8730 }
8731 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
8732         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8733         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8734         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8735         LDKUpdateAddHTLC msg_var = *msg;
8736         uint32_t msg_ref = 0;
8737         msg_var = UpdateAddHTLC_clone(&msg_var);
8738         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8739         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8740         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8741         msg_ref = (uintptr_t)msg_var.inner;
8742         if (msg_var.is_owned) {
8743                 msg_ref |= 1;
8744         }
8745         js_invoke_function_2(j_calls->instance_ptr, 52, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8746 }
8747 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
8748         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8749         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8750         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8751         LDKUpdateFulfillHTLC msg_var = *msg;
8752         uint32_t msg_ref = 0;
8753         msg_var = UpdateFulfillHTLC_clone(&msg_var);
8754         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8755         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8756         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8757         msg_ref = (uintptr_t)msg_var.inner;
8758         if (msg_var.is_owned) {
8759                 msg_ref |= 1;
8760         }
8761         js_invoke_function_2(j_calls->instance_ptr, 53, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8762 }
8763 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
8764         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8765         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8766         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8767         LDKUpdateFailHTLC msg_var = *msg;
8768         uint32_t msg_ref = 0;
8769         msg_var = UpdateFailHTLC_clone(&msg_var);
8770         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8771         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8772         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8773         msg_ref = (uintptr_t)msg_var.inner;
8774         if (msg_var.is_owned) {
8775                 msg_ref |= 1;
8776         }
8777         js_invoke_function_2(j_calls->instance_ptr, 54, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8778 }
8779 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
8780         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8781         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8782         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8783         LDKUpdateFailMalformedHTLC msg_var = *msg;
8784         uint32_t msg_ref = 0;
8785         msg_var = UpdateFailMalformedHTLC_clone(&msg_var);
8786         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8787         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8788         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8789         msg_ref = (uintptr_t)msg_var.inner;
8790         if (msg_var.is_owned) {
8791                 msg_ref |= 1;
8792         }
8793         js_invoke_function_2(j_calls->instance_ptr, 55, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8794 }
8795 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
8796         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8797         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8798         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8799         LDKCommitmentSigned msg_var = *msg;
8800         uint32_t msg_ref = 0;
8801         msg_var = CommitmentSigned_clone(&msg_var);
8802         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8803         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8804         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8805         msg_ref = (uintptr_t)msg_var.inner;
8806         if (msg_var.is_owned) {
8807                 msg_ref |= 1;
8808         }
8809         js_invoke_function_2(j_calls->instance_ptr, 56, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8810 }
8811 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
8812         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8813         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8814         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8815         LDKRevokeAndACK msg_var = *msg;
8816         uint32_t msg_ref = 0;
8817         msg_var = RevokeAndACK_clone(&msg_var);
8818         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8819         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8820         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8821         msg_ref = (uintptr_t)msg_var.inner;
8822         if (msg_var.is_owned) {
8823                 msg_ref |= 1;
8824         }
8825         js_invoke_function_2(j_calls->instance_ptr, 57, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8826 }
8827 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
8828         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8829         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8830         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8831         LDKUpdateFee msg_var = *msg;
8832         uint32_t msg_ref = 0;
8833         msg_var = UpdateFee_clone(&msg_var);
8834         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8835         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8836         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8837         msg_ref = (uintptr_t)msg_var.inner;
8838         if (msg_var.is_owned) {
8839                 msg_ref |= 1;
8840         }
8841         js_invoke_function_2(j_calls->instance_ptr, 58, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8842 }
8843 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
8844         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8845         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8846         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8847         LDKAnnouncementSignatures msg_var = *msg;
8848         uint32_t msg_ref = 0;
8849         msg_var = AnnouncementSignatures_clone(&msg_var);
8850         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8851         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8852         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8853         msg_ref = (uintptr_t)msg_var.inner;
8854         if (msg_var.is_owned) {
8855                 msg_ref |= 1;
8856         }
8857         js_invoke_function_2(j_calls->instance_ptr, 59, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8858 }
8859 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
8860         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8861         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8862         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8863         jboolean no_connection_possible_conv = no_connection_possible;
8864         js_invoke_function_2(j_calls->instance_ptr, 60, (uint32_t)their_node_id_arr, (uint32_t)no_connection_possible_conv);
8865 }
8866 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
8867         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8868         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8869         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8870         LDKInit msg_var = *msg;
8871         uint32_t msg_ref = 0;
8872         msg_var = Init_clone(&msg_var);
8873         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8874         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8875         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8876         msg_ref = (uintptr_t)msg_var.inner;
8877         if (msg_var.is_owned) {
8878                 msg_ref |= 1;
8879         }
8880         js_invoke_function_2(j_calls->instance_ptr, 61, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8881 }
8882 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
8883         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8884         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8885         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8886         LDKChannelReestablish msg_var = *msg;
8887         uint32_t msg_ref = 0;
8888         msg_var = ChannelReestablish_clone(&msg_var);
8889         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8890         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8891         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8892         msg_ref = (uintptr_t)msg_var.inner;
8893         if (msg_var.is_owned) {
8894                 msg_ref |= 1;
8895         }
8896         js_invoke_function_2(j_calls->instance_ptr, 62, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8897 }
8898 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
8899         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8900         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8901         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8902         LDKChannelUpdate msg_var = *msg;
8903         uint32_t msg_ref = 0;
8904         msg_var = ChannelUpdate_clone(&msg_var);
8905         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8906         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8907         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8908         msg_ref = (uintptr_t)msg_var.inner;
8909         if (msg_var.is_owned) {
8910                 msg_ref |= 1;
8911         }
8912         js_invoke_function_2(j_calls->instance_ptr, 63, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8913 }
8914 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
8915         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8916         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
8917         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
8918         LDKErrorMessage msg_var = *msg;
8919         uint32_t msg_ref = 0;
8920         msg_var = ErrorMessage_clone(&msg_var);
8921         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8922         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8923         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8924         msg_ref = (uintptr_t)msg_var.inner;
8925         if (msg_var.is_owned) {
8926                 msg_ref |= 1;
8927         }
8928         js_invoke_function_2(j_calls->instance_ptr, 64, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
8929 }
8930 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
8931         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
8932         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8933         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
8934 }
8935 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JSValue o, JSValue MessageSendEventsProvider) {
8936         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
8937         atomic_init(&calls->refcnt, 1);
8938         calls->instance_ptr = o;
8939
8940         LDKChannelMessageHandler ret = {
8941                 .this_arg = (void*) calls,
8942                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
8943                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
8944                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
8945                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
8946                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
8947                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
8948                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
8949                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
8950                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
8951                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
8952                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
8953                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
8954                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
8955                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
8956                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
8957                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
8958                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
8959                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
8960                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
8961                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
8962                 .free = LDKChannelMessageHandler_JCalls_free,
8963                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
8964         };
8965         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
8966         return ret;
8967 }
8968 long  __attribute__((export_name("TS_LDKChannelMessageHandler_new"))) TS_LDKChannelMessageHandler_new(JSValue o, JSValue MessageSendEventsProvider) {
8969         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
8970         *res_ptr = LDKChannelMessageHandler_init(o, MessageSendEventsProvider);
8971         return (long)res_ptr;
8972 }
8973 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) {
8974         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8975         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8976         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8977         LDKPublicKey their_node_id_ref;
8978         CHECK(their_node_id->arr_len == 33);
8979         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8980         LDKInitFeatures their_features_conv;
8981         their_features_conv.inner = (void*)(their_features & (~1));
8982         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
8983         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
8984         their_features_conv = InitFeatures_clone(&their_features_conv);
8985         LDKOpenChannel msg_conv;
8986         msg_conv.inner = (void*)(msg & (~1));
8987         msg_conv.is_owned = false;
8988         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8989         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
8990 }
8991
8992 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) {
8993         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
8994         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8995         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8996         LDKPublicKey their_node_id_ref;
8997         CHECK(their_node_id->arr_len == 33);
8998         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
8999         LDKInitFeatures their_features_conv;
9000         their_features_conv.inner = (void*)(their_features & (~1));
9001         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
9002         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
9003         their_features_conv = InitFeatures_clone(&their_features_conv);
9004         LDKAcceptChannel msg_conv;
9005         msg_conv.inner = (void*)(msg & (~1));
9006         msg_conv.is_owned = false;
9007         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9008         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
9009 }
9010
9011 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) {
9012         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9013         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9014         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9015         LDKPublicKey their_node_id_ref;
9016         CHECK(their_node_id->arr_len == 33);
9017         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9018         LDKFundingCreated msg_conv;
9019         msg_conv.inner = (void*)(msg & (~1));
9020         msg_conv.is_owned = false;
9021         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9022         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9023 }
9024
9025 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) {
9026         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9027         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9028         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9029         LDKPublicKey their_node_id_ref;
9030         CHECK(their_node_id->arr_len == 33);
9031         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9032         LDKFundingSigned msg_conv;
9033         msg_conv.inner = (void*)(msg & (~1));
9034         msg_conv.is_owned = false;
9035         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9036         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9037 }
9038
9039 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) {
9040         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9041         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9042         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9043         LDKPublicKey their_node_id_ref;
9044         CHECK(their_node_id->arr_len == 33);
9045         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9046         LDKFundingLocked msg_conv;
9047         msg_conv.inner = (void*)(msg & (~1));
9048         msg_conv.is_owned = false;
9049         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9050         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9051 }
9052
9053 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) {
9054         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9055         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9056         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9057         LDKPublicKey their_node_id_ref;
9058         CHECK(their_node_id->arr_len == 33);
9059         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9060         LDKInitFeatures their_features_conv;
9061         their_features_conv.inner = (void*)(their_features & (~1));
9062         their_features_conv.is_owned = false;
9063         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
9064         LDKShutdown msg_conv;
9065         msg_conv.inner = (void*)(msg & (~1));
9066         msg_conv.is_owned = false;
9067         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9068         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
9069 }
9070
9071 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) {
9072         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9073         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9074         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9075         LDKPublicKey their_node_id_ref;
9076         CHECK(their_node_id->arr_len == 33);
9077         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9078         LDKClosingSigned msg_conv;
9079         msg_conv.inner = (void*)(msg & (~1));
9080         msg_conv.is_owned = false;
9081         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9082         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9083 }
9084
9085 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) {
9086         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9087         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9088         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9089         LDKPublicKey their_node_id_ref;
9090         CHECK(their_node_id->arr_len == 33);
9091         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9092         LDKUpdateAddHTLC msg_conv;
9093         msg_conv.inner = (void*)(msg & (~1));
9094         msg_conv.is_owned = false;
9095         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9096         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9097 }
9098
9099 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) {
9100         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9101         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9102         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9103         LDKPublicKey their_node_id_ref;
9104         CHECK(their_node_id->arr_len == 33);
9105         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9106         LDKUpdateFulfillHTLC msg_conv;
9107         msg_conv.inner = (void*)(msg & (~1));
9108         msg_conv.is_owned = false;
9109         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9110         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9111 }
9112
9113 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) {
9114         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9115         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9116         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9117         LDKPublicKey their_node_id_ref;
9118         CHECK(their_node_id->arr_len == 33);
9119         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9120         LDKUpdateFailHTLC msg_conv;
9121         msg_conv.inner = (void*)(msg & (~1));
9122         msg_conv.is_owned = false;
9123         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9124         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9125 }
9126
9127 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) {
9128         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9129         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9130         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9131         LDKPublicKey their_node_id_ref;
9132         CHECK(their_node_id->arr_len == 33);
9133         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9134         LDKUpdateFailMalformedHTLC msg_conv;
9135         msg_conv.inner = (void*)(msg & (~1));
9136         msg_conv.is_owned = false;
9137         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9138         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9139 }
9140
9141 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) {
9142         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9143         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9144         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9145         LDKPublicKey their_node_id_ref;
9146         CHECK(their_node_id->arr_len == 33);
9147         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9148         LDKCommitmentSigned msg_conv;
9149         msg_conv.inner = (void*)(msg & (~1));
9150         msg_conv.is_owned = false;
9151         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9152         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9153 }
9154
9155 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) {
9156         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9157         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9158         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9159         LDKPublicKey their_node_id_ref;
9160         CHECK(their_node_id->arr_len == 33);
9161         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9162         LDKRevokeAndACK msg_conv;
9163         msg_conv.inner = (void*)(msg & (~1));
9164         msg_conv.is_owned = false;
9165         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9166         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9167 }
9168
9169 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) {
9170         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9171         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9172         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9173         LDKPublicKey their_node_id_ref;
9174         CHECK(their_node_id->arr_len == 33);
9175         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9176         LDKUpdateFee msg_conv;
9177         msg_conv.inner = (void*)(msg & (~1));
9178         msg_conv.is_owned = false;
9179         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9180         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9181 }
9182
9183 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) {
9184         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9185         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9186         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9187         LDKPublicKey their_node_id_ref;
9188         CHECK(their_node_id->arr_len == 33);
9189         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9190         LDKAnnouncementSignatures msg_conv;
9191         msg_conv.inner = (void*)(msg & (~1));
9192         msg_conv.is_owned = false;
9193         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9194         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9195 }
9196
9197 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) {
9198         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9199         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9200         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9201         LDKPublicKey their_node_id_ref;
9202         CHECK(their_node_id->arr_len == 33);
9203         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9204         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
9205 }
9206
9207 void  __attribute__((export_name("TS_ChannelMessageHandler_peer_connected"))) TS_ChannelMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
9208         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9209         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9210         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9211         LDKPublicKey their_node_id_ref;
9212         CHECK(their_node_id->arr_len == 33);
9213         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9214         LDKInit msg_conv;
9215         msg_conv.inner = (void*)(msg & (~1));
9216         msg_conv.is_owned = false;
9217         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9218         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9219 }
9220
9221 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) {
9222         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9223         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9224         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9225         LDKPublicKey their_node_id_ref;
9226         CHECK(their_node_id->arr_len == 33);
9227         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9228         LDKChannelReestablish msg_conv;
9229         msg_conv.inner = (void*)(msg & (~1));
9230         msg_conv.is_owned = false;
9231         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9232         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9233 }
9234
9235 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) {
9236         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9237         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9238         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9239         LDKPublicKey their_node_id_ref;
9240         CHECK(their_node_id->arr_len == 33);
9241         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9242         LDKChannelUpdate msg_conv;
9243         msg_conv.inner = (void*)(msg & (~1));
9244         msg_conv.is_owned = false;
9245         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9246         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9247 }
9248
9249 void  __attribute__((export_name("TS_ChannelMessageHandler_handle_error"))) TS_ChannelMessageHandler_handle_error(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
9250         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9251         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9252         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9253         LDKPublicKey their_node_id_ref;
9254         CHECK(their_node_id->arr_len == 33);
9255         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9256         LDKErrorMessage msg_conv;
9257         msg_conv.inner = (void*)(msg & (~1));
9258         msg_conv.is_owned = false;
9259         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9260         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9261 }
9262
9263 typedef struct LDKRoutingMessageHandler_JCalls {
9264         atomic_size_t refcnt;
9265         uint32_t instance_ptr;
9266         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
9267 } LDKRoutingMessageHandler_JCalls;
9268 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
9269         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9270         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9271                 FREE(j_calls);
9272         }
9273 }
9274 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
9275         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9276         LDKNodeAnnouncement msg_var = *msg;
9277         uint32_t msg_ref = 0;
9278         msg_var = NodeAnnouncement_clone(&msg_var);
9279         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9280         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9281         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9282         msg_ref = (uintptr_t)msg_var.inner;
9283         if (msg_var.is_owned) {
9284                 msg_ref |= 1;
9285         }
9286         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 65, (uint32_t)msg_ref);
9287         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9288         CHECK_ACCESS(ret_ptr);
9289         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9290         FREE((void*)ret);
9291         return ret_conv;
9292 }
9293 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
9294         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9295         LDKChannelAnnouncement msg_var = *msg;
9296         uint32_t msg_ref = 0;
9297         msg_var = ChannelAnnouncement_clone(&msg_var);
9298         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9299         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9300         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9301         msg_ref = (uintptr_t)msg_var.inner;
9302         if (msg_var.is_owned) {
9303                 msg_ref |= 1;
9304         }
9305         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 66, (uint32_t)msg_ref);
9306         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9307         CHECK_ACCESS(ret_ptr);
9308         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9309         FREE((void*)ret);
9310         return ret_conv;
9311 }
9312 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
9313         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9314         LDKChannelUpdate msg_var = *msg;
9315         uint32_t msg_ref = 0;
9316         msg_var = ChannelUpdate_clone(&msg_var);
9317         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9318         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9319         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9320         msg_ref = (uintptr_t)msg_var.inner;
9321         if (msg_var.is_owned) {
9322                 msg_ref |= 1;
9323         }
9324         uint32_t ret = js_invoke_function_1(j_calls->instance_ptr, 67, (uint32_t)msg_ref);
9325         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9326         CHECK_ACCESS(ret_ptr);
9327         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9328         FREE((void*)ret);
9329         return ret_conv;
9330 }
9331 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
9332         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9333         int64_t starting_point_conv = starting_point;
9334         int8_t batch_amount_conv = batch_amount;
9335         uint32_tArray ret = (uint32_tArray)js_invoke_function_2(j_calls->instance_ptr, 68, (uint32_t)starting_point_conv, (uint32_t)batch_amount_conv);
9336         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
9337         ret_constr.datalen = ret->arr_len;
9338         if (ret_constr.datalen > 0)
9339                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
9340         else
9341                 ret_constr.data = NULL;
9342         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
9343         for (size_t h = 0; h < ret_constr.datalen; h++) {
9344                 uint32_t ret_conv_59 = ret_vals[h];
9345                 void* ret_conv_59_ptr = (void*)(((uintptr_t)ret_conv_59) & ~1);
9346                 CHECK_ACCESS(ret_conv_59_ptr);
9347                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ret_conv_59_ptr);
9348                 FREE((void*)ret_conv_59);
9349                 ret_constr.data[h] = ret_conv_59_conv;
9350         }
9351         return ret_constr;
9352 }
9353 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
9354         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9355         int8_tArray starting_point_arr = init_int8_tArray(33, __LINE__);
9356         memcpy(starting_point_arr->elems, starting_point.compressed_form, 33);
9357         int8_t batch_amount_conv = batch_amount;
9358         uint32_tArray ret = (uint32_tArray)js_invoke_function_2(j_calls->instance_ptr, 69, (uint32_t)starting_point_arr, (uint32_t)batch_amount_conv);
9359         LDKCVec_NodeAnnouncementZ ret_constr;
9360         ret_constr.datalen = ret->arr_len;
9361         if (ret_constr.datalen > 0)
9362                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
9363         else
9364                 ret_constr.data = NULL;
9365         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
9366         for (size_t s = 0; s < ret_constr.datalen; s++) {
9367                 uint32_t ret_conv_18 = ret_vals[s];
9368                 LDKNodeAnnouncement ret_conv_18_conv;
9369                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
9370                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
9371                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_conv);
9372                 ret_constr.data[s] = ret_conv_18_conv;
9373         }
9374         return ret_constr;
9375 }
9376 void peer_connected_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
9377         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9378         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9379         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9380         LDKInit init_var = *init;
9381         uint32_t init_ref = 0;
9382         init_var = Init_clone(&init_var);
9383         CHECK((((uintptr_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9384         CHECK((((uintptr_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9385         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
9386         init_ref = (uintptr_t)init_var.inner;
9387         if (init_var.is_owned) {
9388                 init_ref |= 1;
9389         }
9390         js_invoke_function_2(j_calls->instance_ptr, 70, (uint32_t)their_node_id_arr, (uint32_t)init_ref);
9391 }
9392 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
9393         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9394         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9395         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9396         LDKReplyChannelRange msg_var = msg;
9397         uint32_t msg_ref = 0;
9398         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9399         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9400         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9401         msg_ref = (uintptr_t)msg_var.inner;
9402         if (msg_var.is_owned) {
9403                 msg_ref |= 1;
9404         }
9405         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 71, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9406         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9407         CHECK_ACCESS(ret_ptr);
9408         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9409         FREE((void*)ret);
9410         return ret_conv;
9411 }
9412 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
9413         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9414         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9415         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9416         LDKReplyShortChannelIdsEnd msg_var = msg;
9417         uint32_t msg_ref = 0;
9418         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9419         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9420         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9421         msg_ref = (uintptr_t)msg_var.inner;
9422         if (msg_var.is_owned) {
9423                 msg_ref |= 1;
9424         }
9425         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 72, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9426         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9427         CHECK_ACCESS(ret_ptr);
9428         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9429         FREE((void*)ret);
9430         return ret_conv;
9431 }
9432 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
9433         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9434         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9435         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9436         LDKQueryChannelRange msg_var = msg;
9437         uint32_t msg_ref = 0;
9438         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9439         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9440         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9441         msg_ref = (uintptr_t)msg_var.inner;
9442         if (msg_var.is_owned) {
9443                 msg_ref |= 1;
9444         }
9445         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 73, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9446         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9447         CHECK_ACCESS(ret_ptr);
9448         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9449         FREE((void*)ret);
9450         return ret_conv;
9451 }
9452 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
9453         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9454         int8_tArray their_node_id_arr = init_int8_tArray(33, __LINE__);
9455         memcpy(their_node_id_arr->elems, their_node_id.compressed_form, 33);
9456         LDKQueryShortChannelIds msg_var = msg;
9457         uint32_t msg_ref = 0;
9458         CHECK((((uintptr_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9459         CHECK((((uintptr_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9460         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9461         msg_ref = (uintptr_t)msg_var.inner;
9462         if (msg_var.is_owned) {
9463                 msg_ref |= 1;
9464         }
9465         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 74, (uint32_t)their_node_id_arr, (uint32_t)msg_ref);
9466         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9467         CHECK_ACCESS(ret_ptr);
9468         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9469         FREE((void*)ret);
9470         return ret_conv;
9471 }
9472 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
9473         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
9474         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9475         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
9476 }
9477 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JSValue o, JSValue MessageSendEventsProvider) {
9478         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
9479         atomic_init(&calls->refcnt, 1);
9480         calls->instance_ptr = o;
9481
9482         LDKRoutingMessageHandler ret = {
9483                 .this_arg = (void*) calls,
9484                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
9485                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
9486                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
9487                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
9488                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
9489                 .peer_connected = peer_connected_LDKRoutingMessageHandler_jcall,
9490                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
9491                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
9492                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
9493                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
9494                 .free = LDKRoutingMessageHandler_JCalls_free,
9495                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
9496         };
9497         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
9498         return ret;
9499 }
9500 long  __attribute__((export_name("TS_LDKRoutingMessageHandler_new"))) TS_LDKRoutingMessageHandler_new(JSValue o, JSValue MessageSendEventsProvider) {
9501         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
9502         *res_ptr = LDKRoutingMessageHandler_init(o, MessageSendEventsProvider);
9503         return (long)res_ptr;
9504 }
9505 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_node_announcement"))) TS_RoutingMessageHandler_handle_node_announcement(uint32_t this_arg, uint32_t msg) {
9506         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9507         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9508         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9509         LDKNodeAnnouncement msg_conv;
9510         msg_conv.inner = (void*)(msg & (~1));
9511         msg_conv.is_owned = false;
9512         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9513         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9514         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
9515         return (uint32_t)ret_conv;
9516 }
9517
9518 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_channel_announcement"))) TS_RoutingMessageHandler_handle_channel_announcement(uint32_t this_arg, uint32_t msg) {
9519         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9520         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9521         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9522         LDKChannelAnnouncement msg_conv;
9523         msg_conv.inner = (void*)(msg & (~1));
9524         msg_conv.is_owned = false;
9525         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9526         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9527         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
9528         return (uint32_t)ret_conv;
9529 }
9530
9531 uint32_t  __attribute__((export_name("TS_RoutingMessageHandler_handle_channel_update"))) TS_RoutingMessageHandler_handle_channel_update(uint32_t this_arg, uint32_t msg) {
9532         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9533         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9534         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9535         LDKChannelUpdate msg_conv;
9536         msg_conv.inner = (void*)(msg & (~1));
9537         msg_conv.is_owned = false;
9538         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9539         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9540         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
9541         return (uint32_t)ret_conv;
9542 }
9543
9544 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) {
9545         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9546         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9547         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9548         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
9549         uint32_tArray ret_arr = NULL;
9550         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
9551         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
9552         for (size_t h = 0; h < ret_var.datalen; h++) {
9553                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
9554                 *ret_conv_59_conv = ret_var.data[h];
9555                 ret_arr_ptr[h] = ((uint32_t)ret_conv_59_conv);
9556         }
9557         
9558         FREE(ret_var.data);
9559         return ret_arr;
9560 }
9561
9562 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) {
9563         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9564         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9565         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9566         LDKPublicKey starting_point_ref;
9567         CHECK(starting_point->arr_len == 33);
9568         memcpy(starting_point_ref.compressed_form, starting_point->elems, 33); FREE(starting_point);
9569         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
9570         uint32_tArray ret_arr = NULL;
9571         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
9572         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
9573         for (size_t s = 0; s < ret_var.datalen; s++) {
9574                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
9575                 uint32_t ret_conv_18_ref = 0;
9576                 CHECK((((uintptr_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9577                 CHECK((((uintptr_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9578                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_var);
9579                 ret_conv_18_ref = (uintptr_t)ret_conv_18_var.inner;
9580                 if (ret_conv_18_var.is_owned) {
9581                         ret_conv_18_ref |= 1;
9582                 }
9583                 ret_arr_ptr[s] = ret_conv_18_ref;
9584         }
9585         
9586         FREE(ret_var.data);
9587         return ret_arr;
9588 }
9589
9590 void  __attribute__((export_name("TS_RoutingMessageHandler_peer_connected"))) TS_RoutingMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t init) {
9591         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9592         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9593         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9594         LDKPublicKey their_node_id_ref;
9595         CHECK(their_node_id->arr_len == 33);
9596         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9597         LDKInit init_conv;
9598         init_conv.inner = (void*)(init & (~1));
9599         init_conv.is_owned = false;
9600         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
9601         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
9602 }
9603
9604 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) {
9605         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9606         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9607         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9608         LDKPublicKey their_node_id_ref;
9609         CHECK(their_node_id->arr_len == 33);
9610         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9611         LDKReplyChannelRange msg_conv;
9612         msg_conv.inner = (void*)(msg & (~1));
9613         msg_conv.is_owned = (msg & 1) || (msg == 0);
9614         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9615         msg_conv = ReplyChannelRange_clone(&msg_conv);
9616         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9617         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9618         return (uint32_t)ret_conv;
9619 }
9620
9621 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) {
9622         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9623         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9624         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9625         LDKPublicKey their_node_id_ref;
9626         CHECK(their_node_id->arr_len == 33);
9627         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9628         LDKReplyShortChannelIdsEnd msg_conv;
9629         msg_conv.inner = (void*)(msg & (~1));
9630         msg_conv.is_owned = (msg & 1) || (msg == 0);
9631         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9632         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
9633         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9634         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9635         return (uint32_t)ret_conv;
9636 }
9637
9638 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) {
9639         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9640         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9641         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9642         LDKPublicKey their_node_id_ref;
9643         CHECK(their_node_id->arr_len == 33);
9644         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9645         LDKQueryChannelRange msg_conv;
9646         msg_conv.inner = (void*)(msg & (~1));
9647         msg_conv.is_owned = (msg & 1) || (msg == 0);
9648         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9649         msg_conv = QueryChannelRange_clone(&msg_conv);
9650         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9651         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9652         return (uint32_t)ret_conv;
9653 }
9654
9655 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) {
9656         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9657         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9658         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9659         LDKPublicKey their_node_id_ref;
9660         CHECK(their_node_id->arr_len == 33);
9661         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
9662         LDKQueryShortChannelIds msg_conv;
9663         msg_conv.inner = (void*)(msg & (~1));
9664         msg_conv.is_owned = (msg & 1) || (msg == 0);
9665         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9666         msg_conv = QueryShortChannelIds_clone(&msg_conv);
9667         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9668         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9669         return (uint32_t)ret_conv;
9670 }
9671
9672 typedef struct LDKCustomMessageReader_JCalls {
9673         atomic_size_t refcnt;
9674         uint32_t instance_ptr;
9675 } LDKCustomMessageReader_JCalls;
9676 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
9677         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
9678         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9679                 FREE(j_calls);
9680         }
9681 }
9682 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
9683         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
9684         int16_t message_type_conv = message_type;
9685         LDKu8slice buffer_var = buffer;
9686         int8_tArray buffer_arr = init_int8_tArray(buffer_var.datalen, __LINE__);
9687         memcpy(buffer_arr->elems, buffer_var.data, buffer_var.datalen);
9688         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 75, (uint32_t)message_type_conv, (uint32_t)buffer_arr);
9689         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9690         CHECK_ACCESS(ret_ptr);
9691         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
9692         FREE((void*)ret);
9693         return ret_conv;
9694 }
9695 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
9696         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
9697         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9698 }
9699 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JSValue o) {
9700         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
9701         atomic_init(&calls->refcnt, 1);
9702         calls->instance_ptr = o;
9703
9704         LDKCustomMessageReader ret = {
9705                 .this_arg = (void*) calls,
9706                 .read = read_LDKCustomMessageReader_jcall,
9707                 .free = LDKCustomMessageReader_JCalls_free,
9708         };
9709         return ret;
9710 }
9711 long  __attribute__((export_name("TS_LDKCustomMessageReader_new"))) TS_LDKCustomMessageReader_new(JSValue o) {
9712         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
9713         *res_ptr = LDKCustomMessageReader_init(o);
9714         return (long)res_ptr;
9715 }
9716 uint32_t  __attribute__((export_name("TS_CustomMessageReader_read"))) TS_CustomMessageReader_read(uint32_t this_arg, int16_t message_type, int8_tArray buffer) {
9717         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9718         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9719         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
9720         LDKu8slice buffer_ref;
9721         buffer_ref.datalen = buffer->arr_len;
9722         buffer_ref.data = buffer->elems /* XXX buffer leaks */;
9723         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
9724         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
9725         return (uint32_t)ret_conv;
9726 }
9727
9728 typedef struct LDKCustomMessageHandler_JCalls {
9729         atomic_size_t refcnt;
9730         uint32_t instance_ptr;
9731         LDKCustomMessageReader_JCalls* CustomMessageReader;
9732 } LDKCustomMessageHandler_JCalls;
9733 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
9734         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
9735         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9736                 FREE(j_calls);
9737         }
9738 }
9739 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
9740         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
9741         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
9742         *msg_ret = msg;
9743         int8_tArray sender_node_id_arr = init_int8_tArray(33, __LINE__);
9744         memcpy(sender_node_id_arr->elems, sender_node_id.compressed_form, 33);
9745         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 76, (uint32_t)(uint32_t)msg_ret, (uint32_t)sender_node_id_arr);
9746         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
9747         CHECK_ACCESS(ret_ptr);
9748         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9749         FREE((void*)ret);
9750         return ret_conv;
9751 }
9752 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
9753         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
9754         uint32_tArray ret = (uint32_tArray)js_invoke_function_0(j_calls->instance_ptr, 77);
9755         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
9756         ret_constr.datalen = ret->arr_len;
9757         if (ret_constr.datalen > 0)
9758                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
9759         else
9760                 ret_constr.data = NULL;
9761         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
9762         for (size_t z = 0; z < ret_constr.datalen; z++) {
9763                 uint32_t ret_conv_25 = ret_vals[z];
9764                 void* ret_conv_25_ptr = (void*)(((uintptr_t)ret_conv_25) & ~1);
9765                 CHECK_ACCESS(ret_conv_25_ptr);
9766                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
9767                 FREE((void*)ret_conv_25);
9768                 ret_constr.data[z] = ret_conv_25_conv;
9769         }
9770         return ret_constr;
9771 }
9772 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
9773         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
9774         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9775         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
9776 }
9777 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JSValue o, JSValue CustomMessageReader) {
9778         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
9779         atomic_init(&calls->refcnt, 1);
9780         calls->instance_ptr = o;
9781
9782         LDKCustomMessageHandler ret = {
9783                 .this_arg = (void*) calls,
9784                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
9785                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
9786                 .free = LDKCustomMessageHandler_JCalls_free,
9787                 .CustomMessageReader = LDKCustomMessageReader_init(CustomMessageReader),
9788         };
9789         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
9790         return ret;
9791 }
9792 long  __attribute__((export_name("TS_LDKCustomMessageHandler_new"))) TS_LDKCustomMessageHandler_new(JSValue o, JSValue CustomMessageReader) {
9793         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
9794         *res_ptr = LDKCustomMessageHandler_init(o, CustomMessageReader);
9795         return (long)res_ptr;
9796 }
9797 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) {
9798         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9799         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9800         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
9801         void* msg_ptr = (void*)(((uintptr_t)msg) & ~1);
9802         CHECK_ACCESS(msg_ptr);
9803         LDKType msg_conv = *(LDKType*)(msg_ptr);
9804         if (msg_conv.free == LDKType_JCalls_free) {
9805                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
9806                 LDKType_JCalls_cloned(&msg_conv);
9807         }
9808         LDKPublicKey sender_node_id_ref;
9809         CHECK(sender_node_id->arr_len == 33);
9810         memcpy(sender_node_id_ref.compressed_form, sender_node_id->elems, 33); FREE(sender_node_id);
9811         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9812         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
9813         return (uint32_t)ret_conv;
9814 }
9815
9816 uint32_tArray  __attribute__((export_name("TS_CustomMessageHandler_get_and_clear_pending_msg"))) TS_CustomMessageHandler_get_and_clear_pending_msg(uint32_t this_arg) {
9817         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9818         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9819         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
9820         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
9821         uint32_tArray ret_arr = NULL;
9822         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
9823         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
9824         for (size_t z = 0; z < ret_var.datalen; z++) {
9825                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
9826                 *ret_conv_25_conv = ret_var.data[z];
9827                 ret_arr_ptr[z] = ((uint32_t)ret_conv_25_conv);
9828         }
9829         
9830         FREE(ret_var.data);
9831         return ret_arr;
9832 }
9833
9834 typedef struct LDKSocketDescriptor_JCalls {
9835         atomic_size_t refcnt;
9836         uint32_t instance_ptr;
9837 } LDKSocketDescriptor_JCalls;
9838 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
9839         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
9840         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9841                 FREE(j_calls);
9842         }
9843 }
9844 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
9845         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
9846         LDKu8slice data_var = data;
9847         int8_tArray data_arr = init_int8_tArray(data_var.datalen, __LINE__);
9848         memcpy(data_arr->elems, data_var.data, data_var.datalen);
9849         jboolean resume_read_conv = resume_read;
9850         return js_invoke_function_2(j_calls->instance_ptr, 78, (uint32_t)data_arr, (uint32_t)resume_read_conv);
9851 }
9852 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
9853         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
9854         js_invoke_function_0(j_calls->instance_ptr, 79);
9855 }
9856 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
9857         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
9858         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
9859         *other_arg_clone = SocketDescriptor_clone(other_arg);
9860         return js_invoke_function_1(j_calls->instance_ptr, 80, (uint32_t)(uint32_t)other_arg_clone);
9861 }
9862 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
9863         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
9864         return js_invoke_function_0(j_calls->instance_ptr, 81);
9865 }
9866 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
9867         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
9868         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9869 }
9870 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JSValue o) {
9871         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
9872         atomic_init(&calls->refcnt, 1);
9873         calls->instance_ptr = o;
9874
9875         LDKSocketDescriptor ret = {
9876                 .this_arg = (void*) calls,
9877                 .send_data = send_data_LDKSocketDescriptor_jcall,
9878                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
9879                 .eq = eq_LDKSocketDescriptor_jcall,
9880                 .hash = hash_LDKSocketDescriptor_jcall,
9881                 .cloned = LDKSocketDescriptor_JCalls_cloned,
9882                 .free = LDKSocketDescriptor_JCalls_free,
9883         };
9884         return ret;
9885 }
9886 long  __attribute__((export_name("TS_LDKSocketDescriptor_new"))) TS_LDKSocketDescriptor_new(JSValue o) {
9887         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
9888         *res_ptr = LDKSocketDescriptor_init(o);
9889         return (long)res_ptr;
9890 }
9891 uint32_t  __attribute__((export_name("TS_SocketDescriptor_send_data"))) TS_SocketDescriptor_send_data(uint32_t this_arg, int8_tArray data, jboolean resume_read) {
9892         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9893         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9894         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
9895         LDKu8slice data_ref;
9896         data_ref.datalen = data->arr_len;
9897         data_ref.data = data->elems /* XXX data leaks */;
9898         uint32_t ret_conv = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
9899         return ret_conv;
9900 }
9901
9902 void  __attribute__((export_name("TS_SocketDescriptor_disconnect_socket"))) TS_SocketDescriptor_disconnect_socket(uint32_t this_arg) {
9903         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9904         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9905         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
9906         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
9907 }
9908
9909 int64_t  __attribute__((export_name("TS_SocketDescriptor_hash"))) TS_SocketDescriptor_hash(uint32_t this_arg) {
9910         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
9911         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9912         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
9913         int64_t ret_conv = (this_arg_conv->hash)(this_arg_conv->this_arg);
9914         return ret_conv;
9915 }
9916
9917 uint32_t __attribute__((export_name("TS_LDKEffectiveCapacity_ty_from_ptr"))) TS_LDKEffectiveCapacity_ty_from_ptr(uint32_t ptr) {
9918         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
9919         switch(obj->tag) {
9920                 case LDKEffectiveCapacity_ExactLiquidity: return 0;
9921                 case LDKEffectiveCapacity_MaximumHTLC: return 1;
9922                 case LDKEffectiveCapacity_Total: return 2;
9923                 case LDKEffectiveCapacity_Infinite: return 3;
9924                 case LDKEffectiveCapacity_Unknown: return 4;
9925                 default: abort();
9926         }
9927 }
9928 int64_t __attribute__((export_name("TS_LDKEffectiveCapacity_ExactLiquidity_get_liquidity_msat"))) TS_LDKEffectiveCapacity_ExactLiquidity_get_liquidity_msat(uint32_t ptr) {
9929         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
9930         assert(obj->tag == LDKEffectiveCapacity_ExactLiquidity);
9931                         int64_t liquidity_msat_conv = obj->exact_liquidity.liquidity_msat;
9932         return liquidity_msat_conv;
9933 }
9934 int64_t __attribute__((export_name("TS_LDKEffectiveCapacity_MaximumHTLC_get_amount_msat"))) TS_LDKEffectiveCapacity_MaximumHTLC_get_amount_msat(uint32_t ptr) {
9935         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
9936         assert(obj->tag == LDKEffectiveCapacity_MaximumHTLC);
9937                         int64_t amount_msat_conv = obj->maximum_htlc.amount_msat;
9938         return amount_msat_conv;
9939 }
9940 int64_t __attribute__((export_name("TS_LDKEffectiveCapacity_Total_get_capacity_msat"))) TS_LDKEffectiveCapacity_Total_get_capacity_msat(uint32_t ptr) {
9941         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)(ptr & ~1);
9942         assert(obj->tag == LDKEffectiveCapacity_Total);
9943                         int64_t capacity_msat_conv = obj->total.capacity_msat;
9944         return capacity_msat_conv;
9945 }
9946 typedef struct LDKScore_JCalls {
9947         atomic_size_t refcnt;
9948         uint32_t instance_ptr;
9949 } LDKScore_JCalls;
9950 static void LDKScore_JCalls_free(void* this_arg) {
9951         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
9952         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9953                 FREE(j_calls);
9954         }
9955 }
9956 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) {
9957         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
9958         int64_t short_channel_id_conv = short_channel_id;
9959         int64_t send_amt_msat_conv = send_amt_msat;
9960         int64_t capacity_msat_conv = capacity_msat;
9961         LDKNodeId source_var = *source;
9962         uint32_t source_ref = 0;
9963         source_var = NodeId_clone(&source_var);
9964         CHECK((((uintptr_t)source_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9965         CHECK((((uintptr_t)&source_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9966         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
9967         source_ref = (uintptr_t)source_var.inner;
9968         if (source_var.is_owned) {
9969                 source_ref |= 1;
9970         }
9971         LDKNodeId target_var = *target;
9972         uint32_t target_ref = 0;
9973         target_var = NodeId_clone(&target_var);
9974         CHECK((((uintptr_t)target_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9975         CHECK((((uintptr_t)&target_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9976         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
9977         target_ref = (uintptr_t)target_var.inner;
9978         if (target_var.is_owned) {
9979                 target_ref |= 1;
9980         }
9981         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);
9982 }
9983 void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
9984         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
9985         LDKCVec_RouteHopZ path_var = path;
9986         uint32_tArray path_arr = NULL;
9987         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
9988         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
9989         for (size_t k = 0; k < path_var.datalen; k++) {
9990                 LDKRouteHop path_conv_10_var = path_var.data[k];
9991                 uint32_t path_conv_10_ref = 0;
9992                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9993                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9994                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
9995                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
9996                 if (path_conv_10_var.is_owned) {
9997                         path_conv_10_ref |= 1;
9998                 }
9999                 path_arr_ptr[k] = path_conv_10_ref;
10000         }
10001         
10002         FREE(path_var.data);
10003         int64_t short_channel_id_conv = short_channel_id;
10004         js_invoke_function_2(j_calls->instance_ptr, 83, (uint32_t)path_arr, (uint32_t)short_channel_id_conv);
10005 }
10006 void payment_path_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
10007         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10008         LDKCVec_RouteHopZ path_var = path;
10009         uint32_tArray path_arr = NULL;
10010         path_arr = init_uint32_tArray(path_var.datalen, __LINE__);
10011         uint32_t *path_arr_ptr = (uint32_t*)(((uint8_t*)path_arr) + 4);
10012         for (size_t k = 0; k < path_var.datalen; k++) {
10013                 LDKRouteHop path_conv_10_var = path_var.data[k];
10014                 uint32_t path_conv_10_ref = 0;
10015                 CHECK((((uintptr_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10016                 CHECK((((uintptr_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10017                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
10018                 path_conv_10_ref = (uintptr_t)path_conv_10_var.inner;
10019                 if (path_conv_10_var.is_owned) {
10020                         path_conv_10_ref |= 1;
10021                 }
10022                 path_arr_ptr[k] = path_conv_10_ref;
10023         }
10024         
10025         FREE(path_var.data);
10026         js_invoke_function_1(j_calls->instance_ptr, 84, (uint32_t)path_arr);
10027 }
10028 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
10029         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10030         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 85);
10031         LDKCVec_u8Z ret_ref;
10032         ret_ref.datalen = ret->arr_len;
10033         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
10034         memcpy(ret_ref.data, ret->elems, ret_ref.datalen); FREE(ret);
10035         return ret_ref;
10036 }
10037 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
10038         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
10039         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10040 }
10041 static inline LDKScore LDKScore_init (JSValue o) {
10042         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
10043         atomic_init(&calls->refcnt, 1);
10044         calls->instance_ptr = o;
10045
10046         LDKScore ret = {
10047                 .this_arg = (void*) calls,
10048                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
10049                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
10050                 .payment_path_successful = payment_path_successful_LDKScore_jcall,
10051                 .write = write_LDKScore_jcall,
10052                 .free = LDKScore_JCalls_free,
10053         };
10054         return ret;
10055 }
10056 long  __attribute__((export_name("TS_LDKScore_new"))) TS_LDKScore_new(JSValue o) {
10057         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
10058         *res_ptr = LDKScore_init(o);
10059         return (long)res_ptr;
10060 }
10061 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) {
10062         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10063         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10064         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10065         LDKNodeId source_conv;
10066         source_conv.inner = (void*)(source & (~1));
10067         source_conv.is_owned = false;
10068         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
10069         LDKNodeId target_conv;
10070         target_conv.inner = (void*)(target & (~1));
10071         target_conv.is_owned = false;
10072         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
10073         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);
10074         return ret_conv;
10075 }
10076
10077 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) {
10078         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10079         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10080         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10081         LDKCVec_RouteHopZ path_constr;
10082         path_constr.datalen = path->arr_len;
10083         if (path_constr.datalen > 0)
10084                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
10085         else
10086                 path_constr.data = NULL;
10087         uint32_t* path_vals = path->elems /* XXX path leaks */;
10088         for (size_t k = 0; k < path_constr.datalen; k++) {
10089                 uint32_t path_conv_10 = path_vals[k];
10090                 LDKRouteHop path_conv_10_conv;
10091                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
10092                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
10093                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
10094                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
10095                 path_constr.data[k] = path_conv_10_conv;
10096         }
10097         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
10098 }
10099
10100 void  __attribute__((export_name("TS_Score_payment_path_successful"))) TS_Score_payment_path_successful(uint32_t this_arg, uint32_tArray path) {
10101         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10102         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10103         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10104         LDKCVec_RouteHopZ path_constr;
10105         path_constr.datalen = path->arr_len;
10106         if (path_constr.datalen > 0)
10107                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
10108         else
10109                 path_constr.data = NULL;
10110         uint32_t* path_vals = path->elems /* XXX path leaks */;
10111         for (size_t k = 0; k < path_constr.datalen; k++) {
10112                 uint32_t path_conv_10 = path_vals[k];
10113                 LDKRouteHop path_conv_10_conv;
10114                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
10115                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
10116                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
10117                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
10118                 path_constr.data[k] = path_conv_10_conv;
10119         }
10120         (this_arg_conv->payment_path_successful)(this_arg_conv->this_arg, path_constr);
10121 }
10122
10123 int8_tArray  __attribute__((export_name("TS_Score_write"))) TS_Score_write(uint32_t this_arg) {
10124         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10125         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10126         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10127         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
10128         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
10129         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
10130         CVec_u8Z_free(ret_var);
10131         return ret_arr;
10132 }
10133
10134 typedef struct LDKLockableScore_JCalls {
10135         atomic_size_t refcnt;
10136         uint32_t instance_ptr;
10137 } LDKLockableScore_JCalls;
10138 static void LDKLockableScore_JCalls_free(void* this_arg) {
10139         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
10140         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10141                 FREE(j_calls);
10142         }
10143 }
10144 LDKScore lock_LDKLockableScore_jcall(const void* this_arg) {
10145         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
10146         uint32_t ret = js_invoke_function_0(j_calls->instance_ptr, 86);
10147         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10148         CHECK_ACCESS(ret_ptr);
10149         LDKScore ret_conv = *(LDKScore*)(ret_ptr);
10150         if (ret_conv.free == LDKScore_JCalls_free) {
10151                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10152                 LDKScore_JCalls_cloned(&ret_conv);
10153         }// WARNING: we may need a move here but no clone is available for LDKScore
10154         
10155         return ret_conv;
10156 }
10157 static void LDKLockableScore_JCalls_cloned(LDKLockableScore* new_obj) {
10158         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) new_obj->this_arg;
10159         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10160 }
10161 static inline LDKLockableScore LDKLockableScore_init (JSValue o) {
10162         LDKLockableScore_JCalls *calls = MALLOC(sizeof(LDKLockableScore_JCalls), "LDKLockableScore_JCalls");
10163         atomic_init(&calls->refcnt, 1);
10164         calls->instance_ptr = o;
10165
10166         LDKLockableScore ret = {
10167                 .this_arg = (void*) calls,
10168                 .lock = lock_LDKLockableScore_jcall,
10169                 .free = LDKLockableScore_JCalls_free,
10170         };
10171         return ret;
10172 }
10173 long  __attribute__((export_name("TS_LDKLockableScore_new"))) TS_LDKLockableScore_new(JSValue o) {
10174         LDKLockableScore *res_ptr = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
10175         *res_ptr = LDKLockableScore_init(o);
10176         return (long)res_ptr;
10177 }
10178 uint32_t  __attribute__((export_name("TS_LockableScore_lock"))) TS_LockableScore_lock(uint32_t this_arg) {
10179         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10180         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10181         LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
10182         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
10183         *ret_ret = (this_arg_conv->lock)(this_arg_conv->this_arg);
10184         return (uint32_t)ret_ret;
10185 }
10186
10187 uint32_t __attribute__((export_name("TS_LDKFallback_ty_from_ptr"))) TS_LDKFallback_ty_from_ptr(uint32_t ptr) {
10188         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10189         switch(obj->tag) {
10190                 case LDKFallback_SegWitProgram: return 0;
10191                 case LDKFallback_PubKeyHash: return 1;
10192                 case LDKFallback_ScriptHash: return 2;
10193                 default: abort();
10194         }
10195 }
10196 int8_t __attribute__((export_name("TS_LDKFallback_SegWitProgram_get_version"))) TS_LDKFallback_SegWitProgram_get_version(uint32_t ptr) {
10197         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10198         assert(obj->tag == LDKFallback_SegWitProgram);
10199                         uint8_t version_val = obj->seg_wit_program.version._0;
10200         return version_val;
10201 }
10202 int8_tArray __attribute__((export_name("TS_LDKFallback_SegWitProgram_get_program"))) TS_LDKFallback_SegWitProgram_get_program(uint32_t ptr) {
10203         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10204         assert(obj->tag == LDKFallback_SegWitProgram);
10205                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
10206                         int8_tArray program_arr = init_int8_tArray(program_var.datalen, __LINE__);
10207                         memcpy(program_arr->elems, program_var.data, program_var.datalen);
10208         return program_arr;
10209 }
10210 int8_tArray __attribute__((export_name("TS_LDKFallback_PubKeyHash_get_pub_key_hash"))) TS_LDKFallback_PubKeyHash_get_pub_key_hash(uint32_t ptr) {
10211         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10212         assert(obj->tag == LDKFallback_PubKeyHash);
10213                         int8_tArray pub_key_hash_arr = init_int8_tArray(20, __LINE__);
10214                         memcpy(pub_key_hash_arr->elems, obj->pub_key_hash.data, 20);
10215         return pub_key_hash_arr;
10216 }
10217 int8_tArray __attribute__((export_name("TS_LDKFallback_ScriptHash_get_script_hash"))) TS_LDKFallback_ScriptHash_get_script_hash(uint32_t ptr) {
10218         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10219         assert(obj->tag == LDKFallback_ScriptHash);
10220                         int8_tArray script_hash_arr = init_int8_tArray(20, __LINE__);
10221                         memcpy(script_hash_arr->elems, obj->script_hash.data, 20);
10222         return script_hash_arr;
10223 }
10224 typedef struct LDKPayer_JCalls {
10225         atomic_size_t refcnt;
10226         uint32_t instance_ptr;
10227 } LDKPayer_JCalls;
10228 static void LDKPayer_JCalls_free(void* this_arg) {
10229         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10230         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10231                 FREE(j_calls);
10232         }
10233 }
10234 LDKPublicKey node_id_LDKPayer_jcall(const void* this_arg) {
10235         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10236         int8_tArray ret = (int8_tArray)js_invoke_function_0(j_calls->instance_ptr, 87);
10237         LDKPublicKey ret_ref;
10238         CHECK(ret->arr_len == 33);
10239         memcpy(ret_ref.compressed_form, ret->elems, 33); FREE(ret);
10240         return ret_ref;
10241 }
10242 LDKCVec_ChannelDetailsZ first_hops_LDKPayer_jcall(const void* this_arg) {
10243         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10244         uint32_tArray ret = (uint32_tArray)js_invoke_function_0(j_calls->instance_ptr, 88);
10245         LDKCVec_ChannelDetailsZ ret_constr;
10246         ret_constr.datalen = ret->arr_len;
10247         if (ret_constr.datalen > 0)
10248                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
10249         else
10250                 ret_constr.data = NULL;
10251         uint32_t* ret_vals = ret->elems /* XXX ret leaks */;
10252         for (size_t q = 0; q < ret_constr.datalen; q++) {
10253                 uint32_t ret_conv_16 = ret_vals[q];
10254                 LDKChannelDetails ret_conv_16_conv;
10255                 ret_conv_16_conv.inner = (void*)(ret_conv_16 & (~1));
10256                 ret_conv_16_conv.is_owned = (ret_conv_16 & 1) || (ret_conv_16 == 0);
10257                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_conv);
10258                 ret_constr.data[q] = ret_conv_16_conv;
10259         }
10260         return ret_constr;
10261 }
10262 LDKCResult_PaymentIdPaymentSendFailureZ send_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret) {
10263         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10264         LDKRoute route_var = *route;
10265         uint32_t route_ref = 0;
10266         route_var = Route_clone(&route_var);
10267         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10268         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10269         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
10270         route_ref = (uintptr_t)route_var.inner;
10271         if (route_var.is_owned) {
10272                 route_ref |= 1;
10273         }
10274         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
10275         memcpy(payment_hash_arr->elems, payment_hash.data, 32);
10276         int8_tArray payment_secret_arr = init_int8_tArray(32, __LINE__);
10277         memcpy(payment_secret_arr->elems, payment_secret.data, 32);
10278         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);
10279         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10280         CHECK_ACCESS(ret_ptr);
10281         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
10282         FREE((void*)ret);
10283         return ret_conv;
10284 }
10285 LDKCResult_PaymentIdPaymentSendFailureZ send_spontaneous_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_preimage) {
10286         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10287         LDKRoute route_var = *route;
10288         uint32_t route_ref = 0;
10289         route_var = Route_clone(&route_var);
10290         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10291         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10292         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
10293         route_ref = (uintptr_t)route_var.inner;
10294         if (route_var.is_owned) {
10295                 route_ref |= 1;
10296         }
10297         int8_tArray payment_preimage_arr = init_int8_tArray(32, __LINE__);
10298         memcpy(payment_preimage_arr->elems, payment_preimage.data, 32);
10299         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 90, (uint32_t)route_ref, (uint32_t)payment_preimage_arr);
10300         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10301         CHECK_ACCESS(ret_ptr);
10302         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
10303         FREE((void*)ret);
10304         return ret_conv;
10305 }
10306 LDKCResult_NonePaymentSendFailureZ retry_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_id) {
10307         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10308         LDKRoute route_var = *route;
10309         uint32_t route_ref = 0;
10310         route_var = Route_clone(&route_var);
10311         CHECK((((uintptr_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10312         CHECK((((uintptr_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10313         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
10314         route_ref = (uintptr_t)route_var.inner;
10315         if (route_var.is_owned) {
10316                 route_ref |= 1;
10317         }
10318         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
10319         memcpy(payment_id_arr->elems, payment_id.data, 32);
10320         uint32_t ret = js_invoke_function_2(j_calls->instance_ptr, 91, (uint32_t)route_ref, (uint32_t)payment_id_arr);
10321         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10322         CHECK_ACCESS(ret_ptr);
10323         LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
10324         FREE((void*)ret);
10325         return ret_conv;
10326 }
10327 void abandon_payment_LDKPayer_jcall(const void* this_arg, LDKThirtyTwoBytes payment_id) {
10328         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10329         int8_tArray payment_id_arr = init_int8_tArray(32, __LINE__);
10330         memcpy(payment_id_arr->elems, payment_id.data, 32);
10331         js_invoke_function_1(j_calls->instance_ptr, 92, (uint32_t)payment_id_arr);
10332 }
10333 static void LDKPayer_JCalls_cloned(LDKPayer* new_obj) {
10334         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) new_obj->this_arg;
10335         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10336 }
10337 static inline LDKPayer LDKPayer_init (JSValue o) {
10338         LDKPayer_JCalls *calls = MALLOC(sizeof(LDKPayer_JCalls), "LDKPayer_JCalls");
10339         atomic_init(&calls->refcnt, 1);
10340         calls->instance_ptr = o;
10341
10342         LDKPayer ret = {
10343                 .this_arg = (void*) calls,
10344                 .node_id = node_id_LDKPayer_jcall,
10345                 .first_hops = first_hops_LDKPayer_jcall,
10346                 .send_payment = send_payment_LDKPayer_jcall,
10347                 .send_spontaneous_payment = send_spontaneous_payment_LDKPayer_jcall,
10348                 .retry_payment = retry_payment_LDKPayer_jcall,
10349                 .abandon_payment = abandon_payment_LDKPayer_jcall,
10350                 .free = LDKPayer_JCalls_free,
10351         };
10352         return ret;
10353 }
10354 long  __attribute__((export_name("TS_LDKPayer_new"))) TS_LDKPayer_new(JSValue o) {
10355         LDKPayer *res_ptr = MALLOC(sizeof(LDKPayer), "LDKPayer");
10356         *res_ptr = LDKPayer_init(o);
10357         return (long)res_ptr;
10358 }
10359 int8_tArray  __attribute__((export_name("TS_Payer_node_id"))) TS_Payer_node_id(uint32_t this_arg) {
10360         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10361         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10362         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10363         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
10364         memcpy(ret_arr->elems, (this_arg_conv->node_id)(this_arg_conv->this_arg).compressed_form, 33);
10365         return ret_arr;
10366 }
10367
10368 uint32_tArray  __attribute__((export_name("TS_Payer_first_hops"))) TS_Payer_first_hops(uint32_t this_arg) {
10369         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10370         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10371         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10372         LDKCVec_ChannelDetailsZ ret_var = (this_arg_conv->first_hops)(this_arg_conv->this_arg);
10373         uint32_tArray ret_arr = NULL;
10374         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
10375         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
10376         for (size_t q = 0; q < ret_var.datalen; q++) {
10377                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
10378                 uint32_t ret_conv_16_ref = 0;
10379                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10380                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10381                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
10382                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
10383                 if (ret_conv_16_var.is_owned) {
10384                         ret_conv_16_ref |= 1;
10385                 }
10386                 ret_arr_ptr[q] = ret_conv_16_ref;
10387         }
10388         
10389         FREE(ret_var.data);
10390         return ret_arr;
10391 }
10392
10393 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) {
10394         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10395         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10396         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10397         LDKRoute route_conv;
10398         route_conv.inner = (void*)(route & (~1));
10399         route_conv.is_owned = false;
10400         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
10401         LDKThirtyTwoBytes payment_hash_ref;
10402         CHECK(payment_hash->arr_len == 32);
10403         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
10404         LDKThirtyTwoBytes payment_secret_ref;
10405         CHECK(payment_secret->arr_len == 32);
10406         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
10407         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
10408         *ret_conv = (this_arg_conv->send_payment)(this_arg_conv->this_arg, &route_conv, payment_hash_ref, payment_secret_ref);
10409         return (uint32_t)ret_conv;
10410 }
10411
10412 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) {
10413         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10414         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10415         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10416         LDKRoute route_conv;
10417         route_conv.inner = (void*)(route & (~1));
10418         route_conv.is_owned = false;
10419         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
10420         LDKThirtyTwoBytes payment_preimage_ref;
10421         CHECK(payment_preimage->arr_len == 32);
10422         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
10423         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
10424         *ret_conv = (this_arg_conv->send_spontaneous_payment)(this_arg_conv->this_arg, &route_conv, payment_preimage_ref);
10425         return (uint32_t)ret_conv;
10426 }
10427
10428 uint32_t  __attribute__((export_name("TS_Payer_retry_payment"))) TS_Payer_retry_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_id) {
10429         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10430         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10431         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10432         LDKRoute route_conv;
10433         route_conv.inner = (void*)(route & (~1));
10434         route_conv.is_owned = false;
10435         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
10436         LDKThirtyTwoBytes payment_id_ref;
10437         CHECK(payment_id->arr_len == 32);
10438         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
10439         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10440         *ret_conv = (this_arg_conv->retry_payment)(this_arg_conv->this_arg, &route_conv, payment_id_ref);
10441         return (uint32_t)ret_conv;
10442 }
10443
10444 void  __attribute__((export_name("TS_Payer_abandon_payment"))) TS_Payer_abandon_payment(uint32_t this_arg, int8_tArray payment_id) {
10445         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10446         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10447         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10448         LDKThirtyTwoBytes payment_id_ref;
10449         CHECK(payment_id->arr_len == 32);
10450         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
10451         (this_arg_conv->abandon_payment)(this_arg_conv->this_arg, payment_id_ref);
10452 }
10453
10454 typedef struct LDKRouter_JCalls {
10455         atomic_size_t refcnt;
10456         uint32_t instance_ptr;
10457 } LDKRouter_JCalls;
10458 static void LDKRouter_JCalls_free(void* this_arg) {
10459         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
10460         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10461                 FREE(j_calls);
10462         }
10463 }
10464 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) {
10465         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
10466         int8_tArray payer_arr = init_int8_tArray(33, __LINE__);
10467         memcpy(payer_arr->elems, payer.compressed_form, 33);
10468         LDKRouteParameters route_params_var = *route_params;
10469         uint32_t route_params_ref = 0;
10470         route_params_var = RouteParameters_clone(&route_params_var);
10471         CHECK((((uintptr_t)route_params_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10472         CHECK((((uintptr_t)&route_params_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10473         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
10474         route_params_ref = (uintptr_t)route_params_var.inner;
10475         if (route_params_var.is_owned) {
10476                 route_params_ref |= 1;
10477         }
10478         int8_tArray payment_hash_arr = init_int8_tArray(32, __LINE__);
10479         memcpy(payment_hash_arr->elems, *payment_hash, 32);
10480         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
10481         uint32_tArray first_hops_arr = NULL;
10482         if (first_hops != NULL) {
10483                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
10484                 first_hops_arr = init_uint32_tArray(first_hops_var.datalen, __LINE__);
10485                 uint32_t *first_hops_arr_ptr = (uint32_t*)(((uint8_t*)first_hops_arr) + 4);
10486                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
10487                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
10488                         uint32_t first_hops_conv_16_ref = 0;
10489                         CHECK((((uintptr_t)first_hops_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10490                         CHECK((((uintptr_t)&first_hops_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10491                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
10492                         first_hops_conv_16_ref = (uintptr_t)first_hops_conv_16_var.inner;
10493                         if (first_hops_conv_16_var.is_owned) {
10494                                 first_hops_conv_16_ref |= 1;
10495                         }
10496                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
10497                 }
10498         
10499         }
10500         // WARNING: This object doesn't live past this scope, needs clone!
10501         uint32_t ret_scorer = ((uintptr_t)scorer) | 1;
10502         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);
10503         void* ret_ptr = (void*)(((uintptr_t)ret) & ~1);
10504         CHECK_ACCESS(ret_ptr);
10505         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
10506         FREE((void*)ret);
10507         return ret_conv;
10508 }
10509 static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
10510         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
10511         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10512 }
10513 static inline LDKRouter LDKRouter_init (JSValue o) {
10514         LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
10515         atomic_init(&calls->refcnt, 1);
10516         calls->instance_ptr = o;
10517
10518         LDKRouter ret = {
10519                 .this_arg = (void*) calls,
10520                 .find_route = find_route_LDKRouter_jcall,
10521                 .free = LDKRouter_JCalls_free,
10522         };
10523         return ret;
10524 }
10525 long  __attribute__((export_name("TS_LDKRouter_new"))) TS_LDKRouter_new(JSValue o) {
10526         LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
10527         *res_ptr = LDKRouter_init(o);
10528         return (long)res_ptr;
10529 }
10530 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) {
10531         void* this_arg_ptr = (void*)(((uintptr_t)this_arg) & ~1);
10532         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10533         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
10534         LDKPublicKey payer_ref;
10535         CHECK(payer->arr_len == 33);
10536         memcpy(payer_ref.compressed_form, payer->elems, 33); FREE(payer);
10537         LDKRouteParameters route_params_conv;
10538         route_params_conv.inner = (void*)(route_params & (~1));
10539         route_params_conv.is_owned = false;
10540         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
10541         unsigned char payment_hash_arr[32];
10542         CHECK(payment_hash->arr_len == 32);
10543         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
10544         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
10545         LDKCVec_ChannelDetailsZ first_hops_constr;
10546         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
10547         if (first_hops != 0) {
10548                 first_hops_constr.datalen = first_hops->arr_len;
10549                 if (first_hops_constr.datalen > 0)
10550                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
10551                 else
10552                         first_hops_constr.data = NULL;
10553                 uint32_t* first_hops_vals = first_hops->elems /* XXX first_hops leaks */;
10554                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
10555                         uint32_t first_hops_conv_16 = first_hops_vals[q];
10556                         LDKChannelDetails first_hops_conv_16_conv;
10557                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
10558                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
10559                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
10560                         first_hops_constr.data[q] = first_hops_conv_16_conv;
10561                 }
10562                 first_hops_ptr = &first_hops_constr;
10563         }
10564         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
10565         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
10566         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
10567         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
10568         *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);
10569         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
10570         return (uint32_t)ret_conv;
10571 }
10572
10573 jstring  __attribute__((export_name("TS__ldk_get_compiled_version"))) TS__ldk_get_compiled_version() {
10574         LDKStr ret_str = _ldk_get_compiled_version();
10575         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
10576         Str_free(ret_str);
10577         return ret_conv;
10578 }
10579
10580 jstring  __attribute__((export_name("TS__ldk_c_bindings_get_compiled_version"))) TS__ldk_c_bindings_get_compiled_version() {
10581         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
10582         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
10583         Str_free(ret_str);
10584         return ret_conv;
10585 }
10586
10587 static inline uintptr_t Bech32Error_clone_ptr(LDKBech32Error *NONNULL_PTR arg) {
10588         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
10589         *ret_copy = Bech32Error_clone(arg);
10590 uint32_t ret_ref = (uintptr_t)ret_copy;
10591         return ret_ref;
10592 }
10593 uint32_t  __attribute__((export_name("TS_Bech32Error_clone_ptr"))) TS_Bech32Error_clone_ptr(uint32_t arg) {
10594         LDKBech32Error* arg_conv = (LDKBech32Error*)arg;
10595         uint32_t ret_conv = Bech32Error_clone_ptr(arg_conv);
10596         return ret_conv;
10597 }
10598
10599 uint32_t  __attribute__((export_name("TS_Bech32Error_clone"))) TS_Bech32Error_clone(uint32_t orig) {
10600         LDKBech32Error* orig_conv = (LDKBech32Error*)orig;
10601         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
10602         *ret_copy = Bech32Error_clone(orig_conv);
10603         uint32_t ret_ref = (uintptr_t)ret_copy;
10604         return ret_ref;
10605 }
10606
10607 void  __attribute__((export_name("TS_Bech32Error_free"))) TS_Bech32Error_free(uint32_t o) {
10608         if ((o & 1) != 0) return;
10609         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
10610         CHECK_ACCESS(o_ptr);
10611         LDKBech32Error o_conv = *(LDKBech32Error*)(o_ptr);
10612         FREE((void*)o);
10613         Bech32Error_free(o_conv);
10614 }
10615
10616 void  __attribute__((export_name("TS_Transaction_free"))) TS_Transaction_free(int8_tArray _res) {
10617         LDKTransaction _res_ref;
10618         _res_ref.datalen = _res->arr_len;
10619         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
10620         memcpy(_res_ref.data, _res->elems, _res_ref.datalen); FREE(_res);
10621         _res_ref.data_is_owned = true;
10622         Transaction_free(_res_ref);
10623 }
10624
10625 uint32_t  __attribute__((export_name("TS_TxOut_new"))) TS_TxOut_new(int8_tArray script_pubkey, int64_t value) {
10626         LDKCVec_u8Z script_pubkey_ref;
10627         script_pubkey_ref.datalen = script_pubkey->arr_len;
10628         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
10629         memcpy(script_pubkey_ref.data, script_pubkey->elems, script_pubkey_ref.datalen); FREE(script_pubkey);
10630         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
10631         *ret_ref = TxOut_new(script_pubkey_ref, value);
10632         return (uint32_t)ret_ref;
10633 }
10634
10635 void  __attribute__((export_name("TS_TxOut_free"))) TS_TxOut_free(uint32_t _res) {
10636         if ((_res & 1) != 0) return;
10637         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10638         CHECK_ACCESS(_res_ptr);
10639         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
10640         FREE((void*)_res);
10641         TxOut_free(_res_conv);
10642 }
10643
10644 static inline uintptr_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
10645         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
10646         *ret_ref = TxOut_clone(arg);
10647         return (uint32_t)ret_ref;
10648 }
10649 uint32_t  __attribute__((export_name("TS_TxOut_clone_ptr"))) TS_TxOut_clone_ptr(uint32_t arg) {
10650         LDKTxOut* arg_conv = (LDKTxOut*)(arg & ~1);
10651         uint32_t ret_conv = TxOut_clone_ptr(arg_conv);
10652         return ret_conv;
10653 }
10654
10655 uint32_t  __attribute__((export_name("TS_TxOut_clone"))) TS_TxOut_clone(uint32_t orig) {
10656         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
10657         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
10658         *ret_ref = TxOut_clone(orig_conv);
10659         return (uint32_t)ret_ref;
10660 }
10661
10662 void  __attribute__((export_name("TS_Str_free"))) TS_Str_free(jstring _res) {
10663         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
10664         Str_free(dummy);
10665 }
10666
10667 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_ok"))) TS_CResult_NoneNoneZ_ok() {
10668         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10669         *ret_conv = CResult_NoneNoneZ_ok();
10670         return (uint32_t)ret_conv;
10671 }
10672
10673 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_err"))) TS_CResult_NoneNoneZ_err() {
10674         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10675         *ret_conv = CResult_NoneNoneZ_err();
10676         return (uint32_t)ret_conv;
10677 }
10678
10679 jboolean  __attribute__((export_name("TS_CResult_NoneNoneZ_is_ok"))) TS_CResult_NoneNoneZ_is_ok(uint32_t o) {
10680         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)(o & ~1);
10681         jboolean ret_conv = CResult_NoneNoneZ_is_ok(o_conv);
10682         return ret_conv;
10683 }
10684
10685 void  __attribute__((export_name("TS_CResult_NoneNoneZ_free"))) TS_CResult_NoneNoneZ_free(uint32_t _res) {
10686         if ((_res & 1) != 0) return;
10687         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10688         CHECK_ACCESS(_res_ptr);
10689         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
10690         FREE((void*)_res);
10691         CResult_NoneNoneZ_free(_res_conv);
10692 }
10693
10694 static inline uintptr_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
10695         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10696         *ret_conv = CResult_NoneNoneZ_clone(arg);
10697         return (uint32_t)ret_conv;
10698 }
10699 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_clone_ptr"))) TS_CResult_NoneNoneZ_clone_ptr(uint32_t arg) {
10700         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)(arg & ~1);
10701         uint32_t ret_conv = CResult_NoneNoneZ_clone_ptr(arg_conv);
10702         return ret_conv;
10703 }
10704
10705 uint32_t  __attribute__((export_name("TS_CResult_NoneNoneZ_clone"))) TS_CResult_NoneNoneZ_clone(uint32_t orig) {
10706         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1);
10707         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
10708         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
10709         return (uint32_t)ret_conv;
10710 }
10711
10712 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(uint32_t o) {
10713         LDKCounterpartyCommitmentSecrets o_conv;
10714         o_conv.inner = (void*)(o & (~1));
10715         o_conv.is_owned = (o & 1) || (o == 0);
10716         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10717         o_conv = CounterpartyCommitmentSecrets_clone(&o_conv);
10718         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
10719         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(o_conv);
10720         return (uint32_t)ret_conv;
10721 }
10722
10723 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(uint32_t e) {
10724         LDKDecodeError e_conv;
10725         e_conv.inner = (void*)(e & (~1));
10726         e_conv.is_owned = (e & 1) || (e == 0);
10727         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10728         e_conv = DecodeError_clone(&e_conv);
10729         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
10730         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e_conv);
10731         return (uint32_t)ret_conv;
10732 }
10733
10734 jboolean  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(uint32_t o) {
10735         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* o_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(o & ~1);
10736         jboolean ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(o_conv);
10737         return ret_conv;
10738 }
10739
10740 void  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(uint32_t _res) {
10741         if ((_res & 1) != 0) return;
10742         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10743         CHECK_ACCESS(_res_ptr);
10744         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(_res_ptr);
10745         FREE((void*)_res);
10746         CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(_res_conv);
10747 }
10748
10749 static inline uintptr_t CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR arg) {
10750         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
10751         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(arg);
10752         return (uint32_t)ret_conv;
10753 }
10754 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(uint32_t arg) {
10755         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(arg & ~1);
10756         uint32_t ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(arg_conv);
10757         return ret_conv;
10758 }
10759
10760 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone"))) TS_CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(uint32_t orig) {
10761         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(orig & ~1);
10762         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
10763         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(orig_conv);
10764         return (uint32_t)ret_conv;
10765 }
10766
10767 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_ok"))) TS_CResult_SecretKeyErrorZ_ok(int8_tArray o) {
10768         LDKSecretKey o_ref;
10769         CHECK(o->arr_len == 32);
10770         memcpy(o_ref.bytes, o->elems, 32); FREE(o);
10771         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
10772         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
10773         return (uint32_t)ret_conv;
10774 }
10775
10776 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_err"))) TS_CResult_SecretKeyErrorZ_err(uint32_t e) {
10777         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
10778         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
10779         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
10780         return (uint32_t)ret_conv;
10781 }
10782
10783 jboolean  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_is_ok"))) TS_CResult_SecretKeyErrorZ_is_ok(uint32_t o) {
10784         LDKCResult_SecretKeyErrorZ* o_conv = (LDKCResult_SecretKeyErrorZ*)(o & ~1);
10785         jboolean ret_conv = CResult_SecretKeyErrorZ_is_ok(o_conv);
10786         return ret_conv;
10787 }
10788
10789 void  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_free"))) TS_CResult_SecretKeyErrorZ_free(uint32_t _res) {
10790         if ((_res & 1) != 0) return;
10791         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10792         CHECK_ACCESS(_res_ptr);
10793         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
10794         FREE((void*)_res);
10795         CResult_SecretKeyErrorZ_free(_res_conv);
10796 }
10797
10798 static inline uintptr_t CResult_SecretKeyErrorZ_clone_ptr(LDKCResult_SecretKeyErrorZ *NONNULL_PTR arg) {
10799         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
10800         *ret_conv = CResult_SecretKeyErrorZ_clone(arg);
10801         return (uint32_t)ret_conv;
10802 }
10803 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_clone_ptr"))) TS_CResult_SecretKeyErrorZ_clone_ptr(uint32_t arg) {
10804         LDKCResult_SecretKeyErrorZ* arg_conv = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
10805         uint32_t ret_conv = CResult_SecretKeyErrorZ_clone_ptr(arg_conv);
10806         return ret_conv;
10807 }
10808
10809 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyErrorZ_clone"))) TS_CResult_SecretKeyErrorZ_clone(uint32_t orig) {
10810         LDKCResult_SecretKeyErrorZ* orig_conv = (LDKCResult_SecretKeyErrorZ*)(orig & ~1);
10811         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
10812         *ret_conv = CResult_SecretKeyErrorZ_clone(orig_conv);
10813         return (uint32_t)ret_conv;
10814 }
10815
10816 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_ok"))) TS_CResult_PublicKeyErrorZ_ok(int8_tArray o) {
10817         LDKPublicKey o_ref;
10818         CHECK(o->arr_len == 33);
10819         memcpy(o_ref.compressed_form, o->elems, 33); FREE(o);
10820         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
10821         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
10822         return (uint32_t)ret_conv;
10823 }
10824
10825 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_err"))) TS_CResult_PublicKeyErrorZ_err(uint32_t e) {
10826         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
10827         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
10828         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
10829         return (uint32_t)ret_conv;
10830 }
10831
10832 jboolean  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_is_ok"))) TS_CResult_PublicKeyErrorZ_is_ok(uint32_t o) {
10833         LDKCResult_PublicKeyErrorZ* o_conv = (LDKCResult_PublicKeyErrorZ*)(o & ~1);
10834         jboolean ret_conv = CResult_PublicKeyErrorZ_is_ok(o_conv);
10835         return ret_conv;
10836 }
10837
10838 void  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_free"))) TS_CResult_PublicKeyErrorZ_free(uint32_t _res) {
10839         if ((_res & 1) != 0) return;
10840         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10841         CHECK_ACCESS(_res_ptr);
10842         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
10843         FREE((void*)_res);
10844         CResult_PublicKeyErrorZ_free(_res_conv);
10845 }
10846
10847 static inline uintptr_t CResult_PublicKeyErrorZ_clone_ptr(LDKCResult_PublicKeyErrorZ *NONNULL_PTR arg) {
10848         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
10849         *ret_conv = CResult_PublicKeyErrorZ_clone(arg);
10850         return (uint32_t)ret_conv;
10851 }
10852 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_clone_ptr"))) TS_CResult_PublicKeyErrorZ_clone_ptr(uint32_t arg) {
10853         LDKCResult_PublicKeyErrorZ* arg_conv = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
10854         uint32_t ret_conv = CResult_PublicKeyErrorZ_clone_ptr(arg_conv);
10855         return ret_conv;
10856 }
10857
10858 uint32_t  __attribute__((export_name("TS_CResult_PublicKeyErrorZ_clone"))) TS_CResult_PublicKeyErrorZ_clone(uint32_t orig) {
10859         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
10860         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
10861         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
10862         return (uint32_t)ret_conv;
10863 }
10864
10865 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_ok(uint32_t o) {
10866         LDKTxCreationKeys o_conv;
10867         o_conv.inner = (void*)(o & (~1));
10868         o_conv.is_owned = (o & 1) || (o == 0);
10869         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10870         o_conv = TxCreationKeys_clone(&o_conv);
10871         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
10872         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
10873         return (uint32_t)ret_conv;
10874 }
10875
10876 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_err"))) TS_CResult_TxCreationKeysDecodeErrorZ_err(uint32_t e) {
10877         LDKDecodeError e_conv;
10878         e_conv.inner = (void*)(e & (~1));
10879         e_conv.is_owned = (e & 1) || (e == 0);
10880         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10881         e_conv = DecodeError_clone(&e_conv);
10882         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
10883         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
10884         return (uint32_t)ret_conv;
10885 }
10886
10887 jboolean  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_is_ok"))) TS_CResult_TxCreationKeysDecodeErrorZ_is_ok(uint32_t o) {
10888         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(o & ~1);
10889         jboolean ret_conv = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
10890         return ret_conv;
10891 }
10892
10893 void  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_free"))) TS_CResult_TxCreationKeysDecodeErrorZ_free(uint32_t _res) {
10894         if ((_res & 1) != 0) return;
10895         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10896         CHECK_ACCESS(_res_ptr);
10897         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
10898         FREE((void*)_res);
10899         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
10900 }
10901
10902 static inline uintptr_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
10903         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
10904         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
10905         return (uint32_t)ret_conv;
10906 }
10907 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_clone_ptr"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone_ptr(uint32_t arg) {
10908         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
10909         uint32_t ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
10910         return ret_conv;
10911 }
10912
10913 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysDecodeErrorZ_clone"))) TS_CResult_TxCreationKeysDecodeErrorZ_clone(uint32_t orig) {
10914         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
10915         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
10916         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
10917         return (uint32_t)ret_conv;
10918 }
10919
10920 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_ok(uint32_t o) {
10921         LDKChannelPublicKeys o_conv;
10922         o_conv.inner = (void*)(o & (~1));
10923         o_conv.is_owned = (o & 1) || (o == 0);
10924         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10925         o_conv = ChannelPublicKeys_clone(&o_conv);
10926         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
10927         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
10928         return (uint32_t)ret_conv;
10929 }
10930
10931 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_err"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_err(uint32_t e) {
10932         LDKDecodeError e_conv;
10933         e_conv.inner = (void*)(e & (~1));
10934         e_conv.is_owned = (e & 1) || (e == 0);
10935         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
10936         e_conv = DecodeError_clone(&e_conv);
10937         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
10938         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
10939         return (uint32_t)ret_conv;
10940 }
10941
10942 jboolean  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_is_ok"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_is_ok(uint32_t o) {
10943         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(o & ~1);
10944         jboolean ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
10945         return ret_conv;
10946 }
10947
10948 void  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_free"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_free(uint32_t _res) {
10949         if ((_res & 1) != 0) return;
10950         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
10951         CHECK_ACCESS(_res_ptr);
10952         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
10953         FREE((void*)_res);
10954         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
10955 }
10956
10957 static inline uintptr_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
10958         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
10959         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
10960         return (uint32_t)ret_conv;
10961 }
10962 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(uint32_t arg) {
10963         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
10964         uint32_t ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
10965         return ret_conv;
10966 }
10967
10968 uint32_t  __attribute__((export_name("TS_CResult_ChannelPublicKeysDecodeErrorZ_clone"))) TS_CResult_ChannelPublicKeysDecodeErrorZ_clone(uint32_t orig) {
10969         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
10970         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
10971         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
10972         return (uint32_t)ret_conv;
10973 }
10974
10975 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_ok"))) TS_CResult_TxCreationKeysErrorZ_ok(uint32_t o) {
10976         LDKTxCreationKeys o_conv;
10977         o_conv.inner = (void*)(o & (~1));
10978         o_conv.is_owned = (o & 1) || (o == 0);
10979         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
10980         o_conv = TxCreationKeys_clone(&o_conv);
10981         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
10982         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
10983         return (uint32_t)ret_conv;
10984 }
10985
10986 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_err"))) TS_CResult_TxCreationKeysErrorZ_err(uint32_t e) {
10987         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
10988         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
10989         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
10990         return (uint32_t)ret_conv;
10991 }
10992
10993 jboolean  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_is_ok"))) TS_CResult_TxCreationKeysErrorZ_is_ok(uint32_t o) {
10994         LDKCResult_TxCreationKeysErrorZ* o_conv = (LDKCResult_TxCreationKeysErrorZ*)(o & ~1);
10995         jboolean ret_conv = CResult_TxCreationKeysErrorZ_is_ok(o_conv);
10996         return ret_conv;
10997 }
10998
10999 void  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_free"))) TS_CResult_TxCreationKeysErrorZ_free(uint32_t _res) {
11000         if ((_res & 1) != 0) return;
11001         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11002         CHECK_ACCESS(_res_ptr);
11003         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
11004         FREE((void*)_res);
11005         CResult_TxCreationKeysErrorZ_free(_res_conv);
11006 }
11007
11008 static inline uintptr_t CResult_TxCreationKeysErrorZ_clone_ptr(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR arg) {
11009         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11010         *ret_conv = CResult_TxCreationKeysErrorZ_clone(arg);
11011         return (uint32_t)ret_conv;
11012 }
11013 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_clone_ptr"))) TS_CResult_TxCreationKeysErrorZ_clone_ptr(uint32_t arg) {
11014         LDKCResult_TxCreationKeysErrorZ* arg_conv = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
11015         uint32_t ret_conv = CResult_TxCreationKeysErrorZ_clone_ptr(arg_conv);
11016         return ret_conv;
11017 }
11018
11019 uint32_t  __attribute__((export_name("TS_CResult_TxCreationKeysErrorZ_clone"))) TS_CResult_TxCreationKeysErrorZ_clone(uint32_t orig) {
11020         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
11021         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11022         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
11023         return (uint32_t)ret_conv;
11024 }
11025
11026 uint32_t  __attribute__((export_name("TS_COption_u32Z_some"))) TS_COption_u32Z_some(int32_t o) {
11027         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11028         *ret_copy = COption_u32Z_some(o);
11029         uint32_t ret_ref = (uintptr_t)ret_copy;
11030         return ret_ref;
11031 }
11032
11033 uint32_t  __attribute__((export_name("TS_COption_u32Z_none"))) TS_COption_u32Z_none() {
11034         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11035         *ret_copy = COption_u32Z_none();
11036         uint32_t ret_ref = (uintptr_t)ret_copy;
11037         return ret_ref;
11038 }
11039
11040 void  __attribute__((export_name("TS_COption_u32Z_free"))) TS_COption_u32Z_free(uint32_t _res) {
11041         if ((_res & 1) != 0) return;
11042         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11043         CHECK_ACCESS(_res_ptr);
11044         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
11045         FREE((void*)_res);
11046         COption_u32Z_free(_res_conv);
11047 }
11048
11049 static inline uintptr_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
11050         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11051         *ret_copy = COption_u32Z_clone(arg);
11052 uint32_t ret_ref = (uintptr_t)ret_copy;
11053         return ret_ref;
11054 }
11055 uint32_t  __attribute__((export_name("TS_COption_u32Z_clone_ptr"))) TS_COption_u32Z_clone_ptr(uint32_t arg) {
11056         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)arg;
11057         uint32_t ret_conv = COption_u32Z_clone_ptr(arg_conv);
11058         return ret_conv;
11059 }
11060
11061 uint32_t  __attribute__((export_name("TS_COption_u32Z_clone"))) TS_COption_u32Z_clone(uint32_t orig) {
11062         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
11063         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11064         *ret_copy = COption_u32Z_clone(orig_conv);
11065         uint32_t ret_ref = (uintptr_t)ret_copy;
11066         return ret_ref;
11067 }
11068
11069 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(uint32_t o) {
11070         LDKHTLCOutputInCommitment o_conv;
11071         o_conv.inner = (void*)(o & (~1));
11072         o_conv.is_owned = (o & 1) || (o == 0);
11073         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11074         o_conv = HTLCOutputInCommitment_clone(&o_conv);
11075         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11076         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
11077         return (uint32_t)ret_conv;
11078 }
11079
11080 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_err(uint32_t e) {
11081         LDKDecodeError e_conv;
11082         e_conv.inner = (void*)(e & (~1));
11083         e_conv.is_owned = (e & 1) || (e == 0);
11084         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11085         e_conv = DecodeError_clone(&e_conv);
11086         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11087         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
11088         return (uint32_t)ret_conv;
11089 }
11090
11091 jboolean  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(uint32_t o) {
11092         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(o & ~1);
11093         jboolean ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
11094         return ret_conv;
11095 }
11096
11097 void  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_free(uint32_t _res) {
11098         if ((_res & 1) != 0) return;
11099         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11100         CHECK_ACCESS(_res_ptr);
11101         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
11102         FREE((void*)_res);
11103         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
11104 }
11105
11106 static inline uintptr_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
11107         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11108         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
11109         return (uint32_t)ret_conv;
11110 }
11111 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(uint32_t arg) {
11112         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
11113         uint32_t ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
11114         return ret_conv;
11115 }
11116
11117 uint32_t  __attribute__((export_name("TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone"))) TS_CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(uint32_t orig) {
11118         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
11119         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11120         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
11121         return (uint32_t)ret_conv;
11122 }
11123
11124 uint32_t  __attribute__((export_name("TS_COption_NoneZ_some"))) TS_COption_NoneZ_some() {
11125         uint32_t ret_conv = LDKCOption_NoneZ_to_js(COption_NoneZ_some());
11126         return ret_conv;
11127 }
11128
11129 uint32_t  __attribute__((export_name("TS_COption_NoneZ_none"))) TS_COption_NoneZ_none() {
11130         uint32_t ret_conv = LDKCOption_NoneZ_to_js(COption_NoneZ_none());
11131         return ret_conv;
11132 }
11133
11134 void  __attribute__((export_name("TS_COption_NoneZ_free"))) TS_COption_NoneZ_free(uint32_t _res) {
11135         LDKCOption_NoneZ _res_conv = LDKCOption_NoneZ_from_js(_res);
11136         COption_NoneZ_free(_res_conv);
11137 }
11138
11139 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
11140         LDKCounterpartyChannelTransactionParameters o_conv;
11141         o_conv.inner = (void*)(o & (~1));
11142         o_conv.is_owned = (o & 1) || (o == 0);
11143         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11144         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
11145         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11146         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
11147         return (uint32_t)ret_conv;
11148 }
11149
11150 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
11151         LDKDecodeError e_conv;
11152         e_conv.inner = (void*)(e & (~1));
11153         e_conv.is_owned = (e & 1) || (e == 0);
11154         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11155         e_conv = DecodeError_clone(&e_conv);
11156         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11157         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
11158         return (uint32_t)ret_conv;
11159 }
11160
11161 jboolean  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(uint32_t o) {
11162         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(o & ~1);
11163         jboolean ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
11164         return ret_conv;
11165 }
11166
11167 void  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
11168         if ((_res & 1) != 0) return;
11169         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11170         CHECK_ACCESS(_res_ptr);
11171         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
11172         FREE((void*)_res);
11173         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
11174 }
11175
11176 static inline uintptr_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
11177         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11178         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
11179         return (uint32_t)ret_conv;
11180 }
11181 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
11182         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
11183         uint32_t ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
11184         return ret_conv;
11185 }
11186
11187 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone"))) TS_CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
11188         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
11189         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11190         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
11191         return (uint32_t)ret_conv;
11192 }
11193
11194 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_ok(uint32_t o) {
11195         LDKChannelTransactionParameters o_conv;
11196         o_conv.inner = (void*)(o & (~1));
11197         o_conv.is_owned = (o & 1) || (o == 0);
11198         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11199         o_conv = ChannelTransactionParameters_clone(&o_conv);
11200         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11201         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
11202         return (uint32_t)ret_conv;
11203 }
11204
11205 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_err"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_err(uint32_t e) {
11206         LDKDecodeError e_conv;
11207         e_conv.inner = (void*)(e & (~1));
11208         e_conv.is_owned = (e & 1) || (e == 0);
11209         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11210         e_conv = DecodeError_clone(&e_conv);
11211         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11212         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
11213         return (uint32_t)ret_conv;
11214 }
11215
11216 jboolean  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_is_ok"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(uint32_t o) {
11217         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(o & ~1);
11218         jboolean ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
11219         return ret_conv;
11220 }
11221
11222 void  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_free"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_free(uint32_t _res) {
11223         if ((_res & 1) != 0) return;
11224         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11225         CHECK_ACCESS(_res_ptr);
11226         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
11227         FREE((void*)_res);
11228         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
11229 }
11230
11231 static inline uintptr_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
11232         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11233         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
11234         return (uint32_t)ret_conv;
11235 }
11236 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
11237         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
11238         uint32_t ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
11239         return ret_conv;
11240 }
11241
11242 uint32_t  __attribute__((export_name("TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone"))) TS_CResult_ChannelTransactionParametersDecodeErrorZ_clone(uint32_t orig) {
11243         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
11244         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11245         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
11246         return (uint32_t)ret_conv;
11247 }
11248
11249 void  __attribute__((export_name("TS_CVec_SignatureZ_free"))) TS_CVec_SignatureZ_free(ptrArray _res) {
11250         LDKCVec_SignatureZ _res_constr;
11251         _res_constr.datalen = _res->arr_len;
11252         if (_res_constr.datalen > 0)
11253                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
11254         else
11255                 _res_constr.data = NULL;
11256         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
11257         for (size_t m = 0; m < _res_constr.datalen; m++) {
11258                 int8_tArray _res_conv_12 = _res_vals[m];
11259                 LDKSignature _res_conv_12_ref;
11260                 CHECK(_res_conv_12->arr_len == 64);
11261                 memcpy(_res_conv_12_ref.compact_form, _res_conv_12->elems, 64); FREE(_res_conv_12);
11262                 _res_constr.data[m] = _res_conv_12_ref;
11263         }
11264         CVec_SignatureZ_free(_res_constr);
11265 }
11266
11267 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
11268         LDKHolderCommitmentTransaction o_conv;
11269         o_conv.inner = (void*)(o & (~1));
11270         o_conv.is_owned = (o & 1) || (o == 0);
11271         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11272         o_conv = HolderCommitmentTransaction_clone(&o_conv);
11273         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11274         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
11275         return (uint32_t)ret_conv;
11276 }
11277
11278 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
11279         LDKDecodeError e_conv;
11280         e_conv.inner = (void*)(e & (~1));
11281         e_conv.is_owned = (e & 1) || (e == 0);
11282         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11283         e_conv = DecodeError_clone(&e_conv);
11284         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11285         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
11286         return (uint32_t)ret_conv;
11287 }
11288
11289 jboolean  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
11290         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(o & ~1);
11291         jboolean ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
11292         return ret_conv;
11293 }
11294
11295 void  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
11296         if ((_res & 1) != 0) return;
11297         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11298         CHECK_ACCESS(_res_ptr);
11299         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
11300         FREE((void*)_res);
11301         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
11302 }
11303
11304 static inline uintptr_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
11305         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11306         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
11307         return (uint32_t)ret_conv;
11308 }
11309 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
11310         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
11311         uint32_t ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
11312         return ret_conv;
11313 }
11314
11315 uint32_t  __attribute__((export_name("TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_HolderCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
11316         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
11317         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11318         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
11319         return (uint32_t)ret_conv;
11320 }
11321
11322 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
11323         LDKBuiltCommitmentTransaction o_conv;
11324         o_conv.inner = (void*)(o & (~1));
11325         o_conv.is_owned = (o & 1) || (o == 0);
11326         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11327         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
11328         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11329         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
11330         return (uint32_t)ret_conv;
11331 }
11332
11333 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_err(uint32_t e) {
11334         LDKDecodeError e_conv;
11335         e_conv.inner = (void*)(e & (~1));
11336         e_conv.is_owned = (e & 1) || (e == 0);
11337         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11338         e_conv = DecodeError_clone(&e_conv);
11339         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11340         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
11341         return (uint32_t)ret_conv;
11342 }
11343
11344 jboolean  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
11345         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(o & ~1);
11346         jboolean ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
11347         return ret_conv;
11348 }
11349
11350 void  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
11351         if ((_res & 1) != 0) return;
11352         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11353         CHECK_ACCESS(_res_ptr);
11354         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
11355         FREE((void*)_res);
11356         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
11357 }
11358
11359 static inline uintptr_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
11360         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11361         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
11362         return (uint32_t)ret_conv;
11363 }
11364 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
11365         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
11366         uint32_t ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
11367         return ret_conv;
11368 }
11369
11370 uint32_t  __attribute__((export_name("TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
11371         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
11372         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11373         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
11374         return (uint32_t)ret_conv;
11375 }
11376
11377 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_ok(uint32_t o) {
11378         LDKTrustedClosingTransaction o_conv;
11379         o_conv.inner = (void*)(o & (~1));
11380         o_conv.is_owned = (o & 1) || (o == 0);
11381         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11382         // WARNING: we need a move here but no clone is available for LDKTrustedClosingTransaction
11383         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
11384         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
11385         return (uint32_t)ret_conv;
11386 }
11387
11388 uint32_t  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_err"))) TS_CResult_TrustedClosingTransactionNoneZ_err() {
11389         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
11390         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
11391         return (uint32_t)ret_conv;
11392 }
11393
11394 jboolean  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_is_ok"))) TS_CResult_TrustedClosingTransactionNoneZ_is_ok(uint32_t o) {
11395         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(o & ~1);
11396         jboolean ret_conv = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
11397         return ret_conv;
11398 }
11399
11400 void  __attribute__((export_name("TS_CResult_TrustedClosingTransactionNoneZ_free"))) TS_CResult_TrustedClosingTransactionNoneZ_free(uint32_t _res) {
11401         if ((_res & 1) != 0) return;
11402         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11403         CHECK_ACCESS(_res_ptr);
11404         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
11405         FREE((void*)_res);
11406         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
11407 }
11408
11409 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_ok(uint32_t o) {
11410         LDKCommitmentTransaction o_conv;
11411         o_conv.inner = (void*)(o & (~1));
11412         o_conv.is_owned = (o & 1) || (o == 0);
11413         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11414         o_conv = CommitmentTransaction_clone(&o_conv);
11415         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11416         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
11417         return (uint32_t)ret_conv;
11418 }
11419
11420 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_err"))) TS_CResult_CommitmentTransactionDecodeErrorZ_err(uint32_t e) {
11421         LDKDecodeError e_conv;
11422         e_conv.inner = (void*)(e & (~1));
11423         e_conv.is_owned = (e & 1) || (e == 0);
11424         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11425         e_conv = DecodeError_clone(&e_conv);
11426         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11427         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
11428         return (uint32_t)ret_conv;
11429 }
11430
11431 jboolean  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_is_ok"))) TS_CResult_CommitmentTransactionDecodeErrorZ_is_ok(uint32_t o) {
11432         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(o & ~1);
11433         jboolean ret_conv = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
11434         return ret_conv;
11435 }
11436
11437 void  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_free"))) TS_CResult_CommitmentTransactionDecodeErrorZ_free(uint32_t _res) {
11438         if ((_res & 1) != 0) return;
11439         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11440         CHECK_ACCESS(_res_ptr);
11441         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
11442         FREE((void*)_res);
11443         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
11444 }
11445
11446 static inline uintptr_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
11447         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11448         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
11449         return (uint32_t)ret_conv;
11450 }
11451 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_clone_ptr"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(uint32_t arg) {
11452         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
11453         uint32_t ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
11454         return ret_conv;
11455 }
11456
11457 uint32_t  __attribute__((export_name("TS_CResult_CommitmentTransactionDecodeErrorZ_clone"))) TS_CResult_CommitmentTransactionDecodeErrorZ_clone(uint32_t orig) {
11458         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
11459         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11460         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
11461         return (uint32_t)ret_conv;
11462 }
11463
11464 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_ok(uint32_t o) {
11465         LDKTrustedCommitmentTransaction o_conv;
11466         o_conv.inner = (void*)(o & (~1));
11467         o_conv.is_owned = (o & 1) || (o == 0);
11468         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11469         // WARNING: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
11470         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
11471         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
11472         return (uint32_t)ret_conv;
11473 }
11474
11475 uint32_t  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_err"))) TS_CResult_TrustedCommitmentTransactionNoneZ_err() {
11476         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
11477         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
11478         return (uint32_t)ret_conv;
11479 }
11480
11481 jboolean  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_is_ok"))) TS_CResult_TrustedCommitmentTransactionNoneZ_is_ok(uint32_t o) {
11482         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(o & ~1);
11483         jboolean ret_conv = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
11484         return ret_conv;
11485 }
11486
11487 void  __attribute__((export_name("TS_CResult_TrustedCommitmentTransactionNoneZ_free"))) TS_CResult_TrustedCommitmentTransactionNoneZ_free(uint32_t _res) {
11488         if ((_res & 1) != 0) return;
11489         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11490         CHECK_ACCESS(_res_ptr);
11491         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
11492         FREE((void*)_res);
11493         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
11494 }
11495
11496 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_ok"))) TS_CResult_CVec_SignatureZNoneZ_ok(ptrArray o) {
11497         LDKCVec_SignatureZ o_constr;
11498         o_constr.datalen = o->arr_len;
11499         if (o_constr.datalen > 0)
11500                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
11501         else
11502                 o_constr.data = NULL;
11503         int8_tArray* o_vals = (void*) o->elems /* XXX o leaks */;
11504         for (size_t m = 0; m < o_constr.datalen; m++) {
11505                 int8_tArray o_conv_12 = o_vals[m];
11506                 LDKSignature o_conv_12_ref;
11507                 CHECK(o_conv_12->arr_len == 64);
11508                 memcpy(o_conv_12_ref.compact_form, o_conv_12->elems, 64); FREE(o_conv_12);
11509                 o_constr.data[m] = o_conv_12_ref;
11510         }
11511         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11512         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
11513         return (uint32_t)ret_conv;
11514 }
11515
11516 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_err"))) TS_CResult_CVec_SignatureZNoneZ_err() {
11517         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11518         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
11519         return (uint32_t)ret_conv;
11520 }
11521
11522 jboolean  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_is_ok"))) TS_CResult_CVec_SignatureZNoneZ_is_ok(uint32_t o) {
11523         LDKCResult_CVec_SignatureZNoneZ* o_conv = (LDKCResult_CVec_SignatureZNoneZ*)(o & ~1);
11524         jboolean ret_conv = CResult_CVec_SignatureZNoneZ_is_ok(o_conv);
11525         return ret_conv;
11526 }
11527
11528 void  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_free"))) TS_CResult_CVec_SignatureZNoneZ_free(uint32_t _res) {
11529         if ((_res & 1) != 0) return;
11530         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11531         CHECK_ACCESS(_res_ptr);
11532         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
11533         FREE((void*)_res);
11534         CResult_CVec_SignatureZNoneZ_free(_res_conv);
11535 }
11536
11537 static inline uintptr_t CResult_CVec_SignatureZNoneZ_clone_ptr(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR arg) {
11538         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11539         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(arg);
11540         return (uint32_t)ret_conv;
11541 }
11542 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_clone_ptr"))) TS_CResult_CVec_SignatureZNoneZ_clone_ptr(uint32_t arg) {
11543         LDKCResult_CVec_SignatureZNoneZ* arg_conv = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
11544         uint32_t ret_conv = CResult_CVec_SignatureZNoneZ_clone_ptr(arg_conv);
11545         return ret_conv;
11546 }
11547
11548 uint32_t  __attribute__((export_name("TS_CResult_CVec_SignatureZNoneZ_clone"))) TS_CResult_CVec_SignatureZNoneZ_clone(uint32_t orig) {
11549         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
11550         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11551         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
11552         return (uint32_t)ret_conv;
11553 }
11554
11555 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_ok(uint32_t o) {
11556         LDKShutdownScript o_conv;
11557         o_conv.inner = (void*)(o & (~1));
11558         o_conv.is_owned = (o & 1) || (o == 0);
11559         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11560         o_conv = ShutdownScript_clone(&o_conv);
11561         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11562         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
11563         return (uint32_t)ret_conv;
11564 }
11565
11566 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_err"))) TS_CResult_ShutdownScriptDecodeErrorZ_err(uint32_t e) {
11567         LDKDecodeError e_conv;
11568         e_conv.inner = (void*)(e & (~1));
11569         e_conv.is_owned = (e & 1) || (e == 0);
11570         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11571         e_conv = DecodeError_clone(&e_conv);
11572         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11573         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
11574         return (uint32_t)ret_conv;
11575 }
11576
11577 jboolean  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_is_ok"))) TS_CResult_ShutdownScriptDecodeErrorZ_is_ok(uint32_t o) {
11578         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(o & ~1);
11579         jboolean ret_conv = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
11580         return ret_conv;
11581 }
11582
11583 void  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_free"))) TS_CResult_ShutdownScriptDecodeErrorZ_free(uint32_t _res) {
11584         if ((_res & 1) != 0) return;
11585         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11586         CHECK_ACCESS(_res_ptr);
11587         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
11588         FREE((void*)_res);
11589         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
11590 }
11591
11592 static inline uintptr_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
11593         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11594         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
11595         return (uint32_t)ret_conv;
11596 }
11597 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_clone_ptr"))) TS_CResult_ShutdownScriptDecodeErrorZ_clone_ptr(uint32_t arg) {
11598         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
11599         uint32_t ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
11600         return ret_conv;
11601 }
11602
11603 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptDecodeErrorZ_clone"))) TS_CResult_ShutdownScriptDecodeErrorZ_clone(uint32_t orig) {
11604         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1);
11605         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11606         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
11607         return (uint32_t)ret_conv;
11608 }
11609
11610 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_ok(uint32_t o) {
11611         LDKShutdownScript o_conv;
11612         o_conv.inner = (void*)(o & (~1));
11613         o_conv.is_owned = (o & 1) || (o == 0);
11614         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11615         o_conv = ShutdownScript_clone(&o_conv);
11616         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
11617         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
11618         return (uint32_t)ret_conv;
11619 }
11620
11621 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_err"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_err(uint32_t e) {
11622         LDKInvalidShutdownScript e_conv;
11623         e_conv.inner = (void*)(e & (~1));
11624         e_conv.is_owned = (e & 1) || (e == 0);
11625         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11626         e_conv = InvalidShutdownScript_clone(&e_conv);
11627         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
11628         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
11629         return (uint32_t)ret_conv;
11630 }
11631
11632 jboolean  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(uint32_t o) {
11633         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(o & ~1);
11634         jboolean ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
11635         return ret_conv;
11636 }
11637
11638 void  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_free"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_free(uint32_t _res) {
11639         if ((_res & 1) != 0) return;
11640         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11641         CHECK_ACCESS(_res_ptr);
11642         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
11643         FREE((void*)_res);
11644         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
11645 }
11646
11647 static inline uintptr_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
11648         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
11649         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
11650         return (uint32_t)ret_conv;
11651 }
11652 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(uint32_t arg) {
11653         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
11654         uint32_t ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
11655         return ret_conv;
11656 }
11657
11658 uint32_t  __attribute__((export_name("TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone"))) TS_CResult_ShutdownScriptInvalidShutdownScriptZ_clone(uint32_t orig) {
11659         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(orig & ~1);
11660         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
11661         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
11662         return (uint32_t)ret_conv;
11663 }
11664
11665 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_ok"))) TS_CResult_RouteHopDecodeErrorZ_ok(uint32_t o) {
11666         LDKRouteHop o_conv;
11667         o_conv.inner = (void*)(o & (~1));
11668         o_conv.is_owned = (o & 1) || (o == 0);
11669         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11670         o_conv = RouteHop_clone(&o_conv);
11671         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
11672         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
11673         return (uint32_t)ret_conv;
11674 }
11675
11676 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_err"))) TS_CResult_RouteHopDecodeErrorZ_err(uint32_t e) {
11677         LDKDecodeError e_conv;
11678         e_conv.inner = (void*)(e & (~1));
11679         e_conv.is_owned = (e & 1) || (e == 0);
11680         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11681         e_conv = DecodeError_clone(&e_conv);
11682         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
11683         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
11684         return (uint32_t)ret_conv;
11685 }
11686
11687 jboolean  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_is_ok"))) TS_CResult_RouteHopDecodeErrorZ_is_ok(uint32_t o) {
11688         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)(o & ~1);
11689         jboolean ret_conv = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
11690         return ret_conv;
11691 }
11692
11693 void  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_free"))) TS_CResult_RouteHopDecodeErrorZ_free(uint32_t _res) {
11694         if ((_res & 1) != 0) return;
11695         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11696         CHECK_ACCESS(_res_ptr);
11697         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
11698         FREE((void*)_res);
11699         CResult_RouteHopDecodeErrorZ_free(_res_conv);
11700 }
11701
11702 static inline uintptr_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
11703         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
11704         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
11705         return (uint32_t)ret_conv;
11706 }
11707 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHopDecodeErrorZ_clone_ptr(uint32_t arg) {
11708         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
11709         uint32_t ret_conv = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
11710         return ret_conv;
11711 }
11712
11713 uint32_t  __attribute__((export_name("TS_CResult_RouteHopDecodeErrorZ_clone"))) TS_CResult_RouteHopDecodeErrorZ_clone(uint32_t orig) {
11714         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
11715         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
11716         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
11717         return (uint32_t)ret_conv;
11718 }
11719
11720 void  __attribute__((export_name("TS_CVec_RouteHopZ_free"))) TS_CVec_RouteHopZ_free(uint32_tArray _res) {
11721         LDKCVec_RouteHopZ _res_constr;
11722         _res_constr.datalen = _res->arr_len;
11723         if (_res_constr.datalen > 0)
11724                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
11725         else
11726                 _res_constr.data = NULL;
11727         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
11728         for (size_t k = 0; k < _res_constr.datalen; k++) {
11729                 uint32_t _res_conv_10 = _res_vals[k];
11730                 LDKRouteHop _res_conv_10_conv;
11731                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
11732                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
11733                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
11734                 _res_constr.data[k] = _res_conv_10_conv;
11735         }
11736         CVec_RouteHopZ_free(_res_constr);
11737 }
11738
11739 void  __attribute__((export_name("TS_CVec_CVec_RouteHopZZ_free"))) TS_CVec_CVec_RouteHopZZ_free(ptrArray _res) {
11740         LDKCVec_CVec_RouteHopZZ _res_constr;
11741         _res_constr.datalen = _res->arr_len;
11742         if (_res_constr.datalen > 0)
11743                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
11744         else
11745                 _res_constr.data = NULL;
11746         uint32_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
11747         for (size_t m = 0; m < _res_constr.datalen; m++) {
11748                 uint32_tArray _res_conv_12 = _res_vals[m];
11749                 LDKCVec_RouteHopZ _res_conv_12_constr;
11750                 _res_conv_12_constr.datalen = _res_conv_12->arr_len;
11751                 if (_res_conv_12_constr.datalen > 0)
11752                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
11753                 else
11754                         _res_conv_12_constr.data = NULL;
11755                 uint32_t* _res_conv_12_vals = _res_conv_12->elems /* XXX _res_conv_12 leaks */;
11756                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
11757                         uint32_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
11758                         LDKRouteHop _res_conv_12_conv_10_conv;
11759                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
11760                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
11761                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv_10_conv);
11762                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
11763                 }
11764                 _res_constr.data[m] = _res_conv_12_constr;
11765         }
11766         CVec_CVec_RouteHopZZ_free(_res_constr);
11767 }
11768
11769 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_ok"))) TS_CResult_RouteDecodeErrorZ_ok(uint32_t o) {
11770         LDKRoute o_conv;
11771         o_conv.inner = (void*)(o & (~1));
11772         o_conv.is_owned = (o & 1) || (o == 0);
11773         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11774         o_conv = Route_clone(&o_conv);
11775         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
11776         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
11777         return (uint32_t)ret_conv;
11778 }
11779
11780 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_err"))) TS_CResult_RouteDecodeErrorZ_err(uint32_t e) {
11781         LDKDecodeError e_conv;
11782         e_conv.inner = (void*)(e & (~1));
11783         e_conv.is_owned = (e & 1) || (e == 0);
11784         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11785         e_conv = DecodeError_clone(&e_conv);
11786         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
11787         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
11788         return (uint32_t)ret_conv;
11789 }
11790
11791 jboolean  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_is_ok"))) TS_CResult_RouteDecodeErrorZ_is_ok(uint32_t o) {
11792         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)(o & ~1);
11793         jboolean ret_conv = CResult_RouteDecodeErrorZ_is_ok(o_conv);
11794         return ret_conv;
11795 }
11796
11797 void  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_free"))) TS_CResult_RouteDecodeErrorZ_free(uint32_t _res) {
11798         if ((_res & 1) != 0) return;
11799         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11800         CHECK_ACCESS(_res_ptr);
11801         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
11802         FREE((void*)_res);
11803         CResult_RouteDecodeErrorZ_free(_res_conv);
11804 }
11805
11806 static inline uintptr_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
11807         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
11808         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
11809         return (uint32_t)ret_conv;
11810 }
11811 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_clone_ptr"))) TS_CResult_RouteDecodeErrorZ_clone_ptr(uint32_t arg) {
11812         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
11813         uint32_t ret_conv = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
11814         return ret_conv;
11815 }
11816
11817 uint32_t  __attribute__((export_name("TS_CResult_RouteDecodeErrorZ_clone"))) TS_CResult_RouteDecodeErrorZ_clone(uint32_t orig) {
11818         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
11819         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
11820         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
11821         return (uint32_t)ret_conv;
11822 }
11823
11824 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_ok"))) TS_CResult_RouteParametersDecodeErrorZ_ok(uint32_t o) {
11825         LDKRouteParameters o_conv;
11826         o_conv.inner = (void*)(o & (~1));
11827         o_conv.is_owned = (o & 1) || (o == 0);
11828         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11829         o_conv = RouteParameters_clone(&o_conv);
11830         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
11831         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
11832         return (uint32_t)ret_conv;
11833 }
11834
11835 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_err"))) TS_CResult_RouteParametersDecodeErrorZ_err(uint32_t e) {
11836         LDKDecodeError e_conv;
11837         e_conv.inner = (void*)(e & (~1));
11838         e_conv.is_owned = (e & 1) || (e == 0);
11839         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11840         e_conv = DecodeError_clone(&e_conv);
11841         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
11842         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
11843         return (uint32_t)ret_conv;
11844 }
11845
11846 jboolean  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_is_ok"))) TS_CResult_RouteParametersDecodeErrorZ_is_ok(uint32_t o) {
11847         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(o & ~1);
11848         jboolean ret_conv = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
11849         return ret_conv;
11850 }
11851
11852 void  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_free"))) TS_CResult_RouteParametersDecodeErrorZ_free(uint32_t _res) {
11853         if ((_res & 1) != 0) return;
11854         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11855         CHECK_ACCESS(_res_ptr);
11856         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
11857         FREE((void*)_res);
11858         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
11859 }
11860
11861 static inline uintptr_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
11862         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
11863         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
11864         return (uint32_t)ret_conv;
11865 }
11866 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_clone_ptr"))) TS_CResult_RouteParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
11867         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
11868         uint32_t ret_conv = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
11869         return ret_conv;
11870 }
11871
11872 uint32_t  __attribute__((export_name("TS_CResult_RouteParametersDecodeErrorZ_clone"))) TS_CResult_RouteParametersDecodeErrorZ_clone(uint32_t orig) {
11873         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(orig & ~1);
11874         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
11875         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
11876         return (uint32_t)ret_conv;
11877 }
11878
11879 void  __attribute__((export_name("TS_CVec_RouteHintZ_free"))) TS_CVec_RouteHintZ_free(uint32_tArray _res) {
11880         LDKCVec_RouteHintZ _res_constr;
11881         _res_constr.datalen = _res->arr_len;
11882         if (_res_constr.datalen > 0)
11883                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
11884         else
11885                 _res_constr.data = NULL;
11886         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
11887         for (size_t l = 0; l < _res_constr.datalen; l++) {
11888                 uint32_t _res_conv_11 = _res_vals[l];
11889                 LDKRouteHint _res_conv_11_conv;
11890                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
11891                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
11892                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
11893                 _res_constr.data[l] = _res_conv_11_conv;
11894         }
11895         CVec_RouteHintZ_free(_res_constr);
11896 }
11897
11898 uint32_t  __attribute__((export_name("TS_COption_u64Z_some"))) TS_COption_u64Z_some(int64_t o) {
11899         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11900         *ret_copy = COption_u64Z_some(o);
11901         uint32_t ret_ref = (uintptr_t)ret_copy;
11902         return ret_ref;
11903 }
11904
11905 uint32_t  __attribute__((export_name("TS_COption_u64Z_none"))) TS_COption_u64Z_none() {
11906         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11907         *ret_copy = COption_u64Z_none();
11908         uint32_t ret_ref = (uintptr_t)ret_copy;
11909         return ret_ref;
11910 }
11911
11912 void  __attribute__((export_name("TS_COption_u64Z_free"))) TS_COption_u64Z_free(uint32_t _res) {
11913         if ((_res & 1) != 0) return;
11914         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11915         CHECK_ACCESS(_res_ptr);
11916         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
11917         FREE((void*)_res);
11918         COption_u64Z_free(_res_conv);
11919 }
11920
11921 static inline uintptr_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
11922         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11923         *ret_copy = COption_u64Z_clone(arg);
11924 uint32_t ret_ref = (uintptr_t)ret_copy;
11925         return ret_ref;
11926 }
11927 uint32_t  __attribute__((export_name("TS_COption_u64Z_clone_ptr"))) TS_COption_u64Z_clone_ptr(uint32_t arg) {
11928         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)arg;
11929         uint32_t ret_conv = COption_u64Z_clone_ptr(arg_conv);
11930         return ret_conv;
11931 }
11932
11933 uint32_t  __attribute__((export_name("TS_COption_u64Z_clone"))) TS_COption_u64Z_clone(uint32_t orig) {
11934         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
11935         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
11936         *ret_copy = COption_u64Z_clone(orig_conv);
11937         uint32_t ret_ref = (uintptr_t)ret_copy;
11938         return ret_ref;
11939 }
11940
11941 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_ok"))) TS_CResult_PaymentParametersDecodeErrorZ_ok(uint32_t o) {
11942         LDKPaymentParameters o_conv;
11943         o_conv.inner = (void*)(o & (~1));
11944         o_conv.is_owned = (o & 1) || (o == 0);
11945         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11946         o_conv = PaymentParameters_clone(&o_conv);
11947         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
11948         *ret_conv = CResult_PaymentParametersDecodeErrorZ_ok(o_conv);
11949         return (uint32_t)ret_conv;
11950 }
11951
11952 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_err"))) TS_CResult_PaymentParametersDecodeErrorZ_err(uint32_t e) {
11953         LDKDecodeError e_conv;
11954         e_conv.inner = (void*)(e & (~1));
11955         e_conv.is_owned = (e & 1) || (e == 0);
11956         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11957         e_conv = DecodeError_clone(&e_conv);
11958         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
11959         *ret_conv = CResult_PaymentParametersDecodeErrorZ_err(e_conv);
11960         return (uint32_t)ret_conv;
11961 }
11962
11963 jboolean  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_is_ok"))) TS_CResult_PaymentParametersDecodeErrorZ_is_ok(uint32_t o) {
11964         LDKCResult_PaymentParametersDecodeErrorZ* o_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(o & ~1);
11965         jboolean ret_conv = CResult_PaymentParametersDecodeErrorZ_is_ok(o_conv);
11966         return ret_conv;
11967 }
11968
11969 void  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_free"))) TS_CResult_PaymentParametersDecodeErrorZ_free(uint32_t _res) {
11970         if ((_res & 1) != 0) return;
11971         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
11972         CHECK_ACCESS(_res_ptr);
11973         LDKCResult_PaymentParametersDecodeErrorZ _res_conv = *(LDKCResult_PaymentParametersDecodeErrorZ*)(_res_ptr);
11974         FREE((void*)_res);
11975         CResult_PaymentParametersDecodeErrorZ_free(_res_conv);
11976 }
11977
11978 static inline uintptr_t CResult_PaymentParametersDecodeErrorZ_clone_ptr(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR arg) {
11979         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
11980         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(arg);
11981         return (uint32_t)ret_conv;
11982 }
11983 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_clone_ptr"))) TS_CResult_PaymentParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
11984         LDKCResult_PaymentParametersDecodeErrorZ* arg_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(arg & ~1);
11985         uint32_t ret_conv = CResult_PaymentParametersDecodeErrorZ_clone_ptr(arg_conv);
11986         return ret_conv;
11987 }
11988
11989 uint32_t  __attribute__((export_name("TS_CResult_PaymentParametersDecodeErrorZ_clone"))) TS_CResult_PaymentParametersDecodeErrorZ_clone(uint32_t orig) {
11990         LDKCResult_PaymentParametersDecodeErrorZ* orig_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)(orig & ~1);
11991         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
11992         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(orig_conv);
11993         return (uint32_t)ret_conv;
11994 }
11995
11996 void  __attribute__((export_name("TS_CVec_RouteHintHopZ_free"))) TS_CVec_RouteHintHopZ_free(uint32_tArray _res) {
11997         LDKCVec_RouteHintHopZ _res_constr;
11998         _res_constr.datalen = _res->arr_len;
11999         if (_res_constr.datalen > 0)
12000                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
12001         else
12002                 _res_constr.data = NULL;
12003         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12004         for (size_t o = 0; o < _res_constr.datalen; o++) {
12005                 uint32_t _res_conv_14 = _res_vals[o];
12006                 LDKRouteHintHop _res_conv_14_conv;
12007                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
12008                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
12009                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
12010                 _res_constr.data[o] = _res_conv_14_conv;
12011         }
12012         CVec_RouteHintHopZ_free(_res_constr);
12013 }
12014
12015 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_ok"))) TS_CResult_RouteHintDecodeErrorZ_ok(uint32_t o) {
12016         LDKRouteHint o_conv;
12017         o_conv.inner = (void*)(o & (~1));
12018         o_conv.is_owned = (o & 1) || (o == 0);
12019         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12020         o_conv = RouteHint_clone(&o_conv);
12021         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12022         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
12023         return (uint32_t)ret_conv;
12024 }
12025
12026 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_err"))) TS_CResult_RouteHintDecodeErrorZ_err(uint32_t e) {
12027         LDKDecodeError e_conv;
12028         e_conv.inner = (void*)(e & (~1));
12029         e_conv.is_owned = (e & 1) || (e == 0);
12030         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12031         e_conv = DecodeError_clone(&e_conv);
12032         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12033         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
12034         return (uint32_t)ret_conv;
12035 }
12036
12037 jboolean  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_is_ok"))) TS_CResult_RouteHintDecodeErrorZ_is_ok(uint32_t o) {
12038         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)(o & ~1);
12039         jboolean ret_conv = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
12040         return ret_conv;
12041 }
12042
12043 void  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_free"))) TS_CResult_RouteHintDecodeErrorZ_free(uint32_t _res) {
12044         if ((_res & 1) != 0) return;
12045         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12046         CHECK_ACCESS(_res_ptr);
12047         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
12048         FREE((void*)_res);
12049         CResult_RouteHintDecodeErrorZ_free(_res_conv);
12050 }
12051
12052 static inline uintptr_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
12053         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12054         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
12055         return (uint32_t)ret_conv;
12056 }
12057 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHintDecodeErrorZ_clone_ptr(uint32_t arg) {
12058         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
12059         uint32_t ret_conv = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
12060         return ret_conv;
12061 }
12062
12063 uint32_t  __attribute__((export_name("TS_CResult_RouteHintDecodeErrorZ_clone"))) TS_CResult_RouteHintDecodeErrorZ_clone(uint32_t orig) {
12064         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)(orig & ~1);
12065         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12066         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
12067         return (uint32_t)ret_conv;
12068 }
12069
12070 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_ok(uint32_t o) {
12071         LDKRouteHintHop o_conv;
12072         o_conv.inner = (void*)(o & (~1));
12073         o_conv.is_owned = (o & 1) || (o == 0);
12074         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12075         o_conv = RouteHintHop_clone(&o_conv);
12076         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12077         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
12078         return (uint32_t)ret_conv;
12079 }
12080
12081 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_err"))) TS_CResult_RouteHintHopDecodeErrorZ_err(uint32_t e) {
12082         LDKDecodeError e_conv;
12083         e_conv.inner = (void*)(e & (~1));
12084         e_conv.is_owned = (e & 1) || (e == 0);
12085         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12086         e_conv = DecodeError_clone(&e_conv);
12087         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12088         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
12089         return (uint32_t)ret_conv;
12090 }
12091
12092 jboolean  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_is_ok"))) TS_CResult_RouteHintHopDecodeErrorZ_is_ok(uint32_t o) {
12093         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(o & ~1);
12094         jboolean ret_conv = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
12095         return ret_conv;
12096 }
12097
12098 void  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_free"))) TS_CResult_RouteHintHopDecodeErrorZ_free(uint32_t _res) {
12099         if ((_res & 1) != 0) return;
12100         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12101         CHECK_ACCESS(_res_ptr);
12102         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
12103         FREE((void*)_res);
12104         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
12105 }
12106
12107 static inline uintptr_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
12108         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12109         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
12110         return (uint32_t)ret_conv;
12111 }
12112 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_clone_ptr"))) TS_CResult_RouteHintHopDecodeErrorZ_clone_ptr(uint32_t arg) {
12113         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
12114         uint32_t ret_conv = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
12115         return ret_conv;
12116 }
12117
12118 uint32_t  __attribute__((export_name("TS_CResult_RouteHintHopDecodeErrorZ_clone"))) TS_CResult_RouteHintHopDecodeErrorZ_clone(uint32_t orig) {
12119         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(orig & ~1);
12120         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12121         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
12122         return (uint32_t)ret_conv;
12123 }
12124
12125 void  __attribute__((export_name("TS_CVec_ChannelDetailsZ_free"))) TS_CVec_ChannelDetailsZ_free(uint32_tArray _res) {
12126         LDKCVec_ChannelDetailsZ _res_constr;
12127         _res_constr.datalen = _res->arr_len;
12128         if (_res_constr.datalen > 0)
12129                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
12130         else
12131                 _res_constr.data = NULL;
12132         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12133         for (size_t q = 0; q < _res_constr.datalen; q++) {
12134                 uint32_t _res_conv_16 = _res_vals[q];
12135                 LDKChannelDetails _res_conv_16_conv;
12136                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
12137                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
12138                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
12139                 _res_constr.data[q] = _res_conv_16_conv;
12140         }
12141         CVec_ChannelDetailsZ_free(_res_constr);
12142 }
12143
12144 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_ok"))) TS_CResult_RouteLightningErrorZ_ok(uint32_t o) {
12145         LDKRoute o_conv;
12146         o_conv.inner = (void*)(o & (~1));
12147         o_conv.is_owned = (o & 1) || (o == 0);
12148         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12149         o_conv = Route_clone(&o_conv);
12150         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12151         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
12152         return (uint32_t)ret_conv;
12153 }
12154
12155 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_err"))) TS_CResult_RouteLightningErrorZ_err(uint32_t e) {
12156         LDKLightningError e_conv;
12157         e_conv.inner = (void*)(e & (~1));
12158         e_conv.is_owned = (e & 1) || (e == 0);
12159         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12160         e_conv = LightningError_clone(&e_conv);
12161         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12162         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
12163         return (uint32_t)ret_conv;
12164 }
12165
12166 jboolean  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_is_ok"))) TS_CResult_RouteLightningErrorZ_is_ok(uint32_t o) {
12167         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)(o & ~1);
12168         jboolean ret_conv = CResult_RouteLightningErrorZ_is_ok(o_conv);
12169         return ret_conv;
12170 }
12171
12172 void  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_free"))) TS_CResult_RouteLightningErrorZ_free(uint32_t _res) {
12173         if ((_res & 1) != 0) return;
12174         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12175         CHECK_ACCESS(_res_ptr);
12176         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
12177         FREE((void*)_res);
12178         CResult_RouteLightningErrorZ_free(_res_conv);
12179 }
12180
12181 static inline uintptr_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
12182         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12183         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
12184         return (uint32_t)ret_conv;
12185 }
12186 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_clone_ptr"))) TS_CResult_RouteLightningErrorZ_clone_ptr(uint32_t arg) {
12187         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
12188         uint32_t ret_conv = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
12189         return ret_conv;
12190 }
12191
12192 uint32_t  __attribute__((export_name("TS_CResult_RouteLightningErrorZ_clone"))) TS_CResult_RouteLightningErrorZ_clone(uint32_t orig) {
12193         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
12194         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12195         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
12196         return (uint32_t)ret_conv;
12197 }
12198
12199 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_ok"))) TS_CResult_TxOutAccessErrorZ_ok(uint32_t o) {
12200         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12201         CHECK_ACCESS(o_ptr);
12202         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
12203         o_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)o) & ~1));
12204         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
12205         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
12206         return (uint32_t)ret_conv;
12207 }
12208
12209 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_err"))) TS_CResult_TxOutAccessErrorZ_err(uint32_t e) {
12210         LDKAccessError e_conv = LDKAccessError_from_js(e);
12211         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
12212         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
12213         return (uint32_t)ret_conv;
12214 }
12215
12216 jboolean  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_is_ok"))) TS_CResult_TxOutAccessErrorZ_is_ok(uint32_t o) {
12217         LDKCResult_TxOutAccessErrorZ* o_conv = (LDKCResult_TxOutAccessErrorZ*)(o & ~1);
12218         jboolean ret_conv = CResult_TxOutAccessErrorZ_is_ok(o_conv);
12219         return ret_conv;
12220 }
12221
12222 void  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_free"))) TS_CResult_TxOutAccessErrorZ_free(uint32_t _res) {
12223         if ((_res & 1) != 0) return;
12224         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12225         CHECK_ACCESS(_res_ptr);
12226         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
12227         FREE((void*)_res);
12228         CResult_TxOutAccessErrorZ_free(_res_conv);
12229 }
12230
12231 static inline uintptr_t CResult_TxOutAccessErrorZ_clone_ptr(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR arg) {
12232         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
12233         *ret_conv = CResult_TxOutAccessErrorZ_clone(arg);
12234         return (uint32_t)ret_conv;
12235 }
12236 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_clone_ptr"))) TS_CResult_TxOutAccessErrorZ_clone_ptr(uint32_t arg) {
12237         LDKCResult_TxOutAccessErrorZ* arg_conv = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
12238         uint32_t ret_conv = CResult_TxOutAccessErrorZ_clone_ptr(arg_conv);
12239         return ret_conv;
12240 }
12241
12242 uint32_t  __attribute__((export_name("TS_CResult_TxOutAccessErrorZ_clone"))) TS_CResult_TxOutAccessErrorZ_clone(uint32_t orig) {
12243         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
12244         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
12245         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
12246         return (uint32_t)ret_conv;
12247 }
12248
12249 static inline uintptr_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
12250         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
12251         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
12252         return ((uint32_t)ret_conv);
12253 }
12254 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_clone_ptr"))) TS_C2Tuple_usizeTransactionZ_clone_ptr(uint32_t arg) {
12255         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)(arg & ~1);
12256         uint32_t ret_conv = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
12257         return ret_conv;
12258 }
12259
12260 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_clone"))) TS_C2Tuple_usizeTransactionZ_clone(uint32_t orig) {
12261         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
12262         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
12263         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
12264         return ((uint32_t)ret_conv);
12265 }
12266
12267 uint32_t  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_new"))) TS_C2Tuple_usizeTransactionZ_new(uint32_t a, int8_tArray b) {
12268         LDKTransaction b_ref;
12269         b_ref.datalen = b->arr_len;
12270         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
12271         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
12272         b_ref.data_is_owned = true;
12273         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
12274         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
12275         return ((uint32_t)ret_conv);
12276 }
12277
12278 void  __attribute__((export_name("TS_C2Tuple_usizeTransactionZ_free"))) TS_C2Tuple_usizeTransactionZ_free(uint32_t _res) {
12279         if ((_res & 1) != 0) return;
12280         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12281         CHECK_ACCESS(_res_ptr);
12282         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
12283         FREE((void*)_res);
12284         C2Tuple_usizeTransactionZ_free(_res_conv);
12285 }
12286
12287 void  __attribute__((export_name("TS_CVec_C2Tuple_usizeTransactionZZ_free"))) TS_CVec_C2Tuple_usizeTransactionZZ_free(uint32_tArray _res) {
12288         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
12289         _res_constr.datalen = _res->arr_len;
12290         if (_res_constr.datalen > 0)
12291                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
12292         else
12293                 _res_constr.data = NULL;
12294         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12295         for (size_t c = 0; c < _res_constr.datalen; c++) {
12296                 uint32_t _res_conv_28 = _res_vals[c];
12297                 void* _res_conv_28_ptr = (void*)(((uintptr_t)_res_conv_28) & ~1);
12298                 CHECK_ACCESS(_res_conv_28_ptr);
12299                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
12300                 FREE((void*)_res_conv_28);
12301                 _res_constr.data[c] = _res_conv_28_conv;
12302         }
12303         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
12304 }
12305
12306 void  __attribute__((export_name("TS_CVec_TxidZ_free"))) TS_CVec_TxidZ_free(ptrArray _res) {
12307         LDKCVec_TxidZ _res_constr;
12308         _res_constr.datalen = _res->arr_len;
12309         if (_res_constr.datalen > 0)
12310                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
12311         else
12312                 _res_constr.data = NULL;
12313         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
12314         for (size_t m = 0; m < _res_constr.datalen; m++) {
12315                 int8_tArray _res_conv_12 = _res_vals[m];
12316                 LDKThirtyTwoBytes _res_conv_12_ref;
12317                 CHECK(_res_conv_12->arr_len == 32);
12318                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, 32); FREE(_res_conv_12);
12319                 _res_constr.data[m] = _res_conv_12_ref;
12320         }
12321         CVec_TxidZ_free(_res_constr);
12322 }
12323
12324 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_ok() {
12325         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
12326         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
12327         return (uint32_t)ret_conv;
12328 }
12329
12330 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_err"))) TS_CResult_NoneChannelMonitorUpdateErrZ_err(uint32_t e) {
12331         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_js(e);
12332         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
12333         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
12334         return (uint32_t)ret_conv;
12335 }
12336
12337 jboolean  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_is_ok"))) TS_CResult_NoneChannelMonitorUpdateErrZ_is_ok(uint32_t o) {
12338         LDKCResult_NoneChannelMonitorUpdateErrZ* o_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(o & ~1);
12339         jboolean ret_conv = CResult_NoneChannelMonitorUpdateErrZ_is_ok(o_conv);
12340         return ret_conv;
12341 }
12342
12343 void  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_free"))) TS_CResult_NoneChannelMonitorUpdateErrZ_free(uint32_t _res) {
12344         if ((_res & 1) != 0) return;
12345         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12346         CHECK_ACCESS(_res_ptr);
12347         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(_res_ptr);
12348         FREE((void*)_res);
12349         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
12350 }
12351
12352 static inline uintptr_t CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR arg) {
12353         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
12354         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(arg);
12355         return (uint32_t)ret_conv;
12356 }
12357 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_clone_ptr"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(uint32_t arg) {
12358         LDKCResult_NoneChannelMonitorUpdateErrZ* arg_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
12359         uint32_t ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(arg_conv);
12360         return ret_conv;
12361 }
12362
12363 uint32_t  __attribute__((export_name("TS_CResult_NoneChannelMonitorUpdateErrZ_clone"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone(uint32_t orig) {
12364         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
12365         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
12366         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
12367         return (uint32_t)ret_conv;
12368 }
12369
12370 void  __attribute__((export_name("TS_CVec_MonitorEventZ_free"))) TS_CVec_MonitorEventZ_free(uint32_tArray _res) {
12371         LDKCVec_MonitorEventZ _res_constr;
12372         _res_constr.datalen = _res->arr_len;
12373         if (_res_constr.datalen > 0)
12374                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
12375         else
12376                 _res_constr.data = NULL;
12377         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12378         for (size_t o = 0; o < _res_constr.datalen; o++) {
12379                 uint32_t _res_conv_14 = _res_vals[o];
12380                 void* _res_conv_14_ptr = (void*)(((uintptr_t)_res_conv_14) & ~1);
12381                 CHECK_ACCESS(_res_conv_14_ptr);
12382                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
12383                 FREE((void*)_res_conv_14);
12384                 _res_constr.data[o] = _res_conv_14_conv;
12385         }
12386         CVec_MonitorEventZ_free(_res_constr);
12387 }
12388
12389 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_some"))) TS_COption_C2Tuple_usizeTransactionZZ_some(uint32_t o) {
12390         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12391         CHECK_ACCESS(o_ptr);
12392         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(o_ptr);
12393         o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)o) & ~1));
12394         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
12395         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
12396         uint32_t ret_ref = (uintptr_t)ret_copy;
12397         return ret_ref;
12398 }
12399
12400 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_none"))) TS_COption_C2Tuple_usizeTransactionZZ_none() {
12401         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
12402         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
12403         uint32_t ret_ref = (uintptr_t)ret_copy;
12404         return ret_ref;
12405 }
12406
12407 void  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_free"))) TS_COption_C2Tuple_usizeTransactionZZ_free(uint32_t _res) {
12408         if ((_res & 1) != 0) return;
12409         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12410         CHECK_ACCESS(_res_ptr);
12411         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(_res_ptr);
12412         FREE((void*)_res);
12413         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
12414 }
12415
12416 static inline uintptr_t COption_C2Tuple_usizeTransactionZZ_clone_ptr(LDKCOption_C2Tuple_usizeTransactionZZ *NONNULL_PTR arg) {
12417         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
12418         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(arg);
12419 uint32_t ret_ref = (uintptr_t)ret_copy;
12420         return ret_ref;
12421 }
12422 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_clone_ptr"))) TS_COption_C2Tuple_usizeTransactionZZ_clone_ptr(uint32_t arg) {
12423         LDKCOption_C2Tuple_usizeTransactionZZ* arg_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)arg;
12424         uint32_t ret_conv = COption_C2Tuple_usizeTransactionZZ_clone_ptr(arg_conv);
12425         return ret_conv;
12426 }
12427
12428 uint32_t  __attribute__((export_name("TS_COption_C2Tuple_usizeTransactionZZ_clone"))) TS_COption_C2Tuple_usizeTransactionZZ_clone(uint32_t orig) {
12429         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
12430         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
12431         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
12432         uint32_t ret_ref = (uintptr_t)ret_copy;
12433         return ret_ref;
12434 }
12435
12436 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_some"))) TS_COption_ClosureReasonZ_some(uint32_t o) {
12437         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12438         CHECK_ACCESS(o_ptr);
12439         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
12440         o_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)o) & ~1));
12441         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12442         *ret_copy = COption_ClosureReasonZ_some(o_conv);
12443         uint32_t ret_ref = (uintptr_t)ret_copy;
12444         return ret_ref;
12445 }
12446
12447 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_none"))) TS_COption_ClosureReasonZ_none() {
12448         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12449         *ret_copy = COption_ClosureReasonZ_none();
12450         uint32_t ret_ref = (uintptr_t)ret_copy;
12451         return ret_ref;
12452 }
12453
12454 void  __attribute__((export_name("TS_COption_ClosureReasonZ_free"))) TS_COption_ClosureReasonZ_free(uint32_t _res) {
12455         if ((_res & 1) != 0) return;
12456         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12457         CHECK_ACCESS(_res_ptr);
12458         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
12459         FREE((void*)_res);
12460         COption_ClosureReasonZ_free(_res_conv);
12461 }
12462
12463 static inline uintptr_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
12464         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12465         *ret_copy = COption_ClosureReasonZ_clone(arg);
12466 uint32_t ret_ref = (uintptr_t)ret_copy;
12467         return ret_ref;
12468 }
12469 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_clone_ptr"))) TS_COption_ClosureReasonZ_clone_ptr(uint32_t arg) {
12470         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)arg;
12471         uint32_t ret_conv = COption_ClosureReasonZ_clone_ptr(arg_conv);
12472         return ret_conv;
12473 }
12474
12475 uint32_t  __attribute__((export_name("TS_COption_ClosureReasonZ_clone"))) TS_COption_ClosureReasonZ_clone(uint32_t orig) {
12476         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)orig;
12477         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12478         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
12479         uint32_t ret_ref = (uintptr_t)ret_copy;
12480         return ret_ref;
12481 }
12482
12483 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_ok(uint32_t o) {
12484         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12485         CHECK_ACCESS(o_ptr);
12486         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
12487         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)(((uintptr_t)o) & ~1));
12488         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12489         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
12490         return (uint32_t)ret_conv;
12491 }
12492
12493 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_err"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_err(uint32_t e) {
12494         LDKDecodeError e_conv;
12495         e_conv.inner = (void*)(e & (~1));
12496         e_conv.is_owned = (e & 1) || (e == 0);
12497         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12498         e_conv = DecodeError_clone(&e_conv);
12499         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12500         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
12501         return (uint32_t)ret_conv;
12502 }
12503
12504 jboolean  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_is_ok"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(uint32_t o) {
12505         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(o & ~1);
12506         jboolean ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
12507         return ret_conv;
12508 }
12509
12510 void  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_free"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_free(uint32_t _res) {
12511         if ((_res & 1) != 0) return;
12512         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12513         CHECK_ACCESS(_res_ptr);
12514         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
12515         FREE((void*)_res);
12516         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
12517 }
12518
12519 static inline uintptr_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
12520         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12521         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
12522         return (uint32_t)ret_conv;
12523 }
12524 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(uint32_t arg) {
12525         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(arg & ~1);
12526         uint32_t ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
12527         return ret_conv;
12528 }
12529
12530 uint32_t  __attribute__((export_name("TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone"))) TS_CResult_COption_ClosureReasonZDecodeErrorZ_clone(uint32_t orig) {
12531         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(orig & ~1);
12532         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12533         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
12534         return (uint32_t)ret_conv;
12535 }
12536
12537 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_some"))) TS_COption_NetworkUpdateZ_some(uint32_t o) {
12538         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12539         CHECK_ACCESS(o_ptr);
12540         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
12541         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uintptr_t)o) & ~1));
12542         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12543         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
12544         uint32_t ret_ref = (uintptr_t)ret_copy;
12545         return ret_ref;
12546 }
12547
12548 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_none"))) TS_COption_NetworkUpdateZ_none() {
12549         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12550         *ret_copy = COption_NetworkUpdateZ_none();
12551         uint32_t ret_ref = (uintptr_t)ret_copy;
12552         return ret_ref;
12553 }
12554
12555 void  __attribute__((export_name("TS_COption_NetworkUpdateZ_free"))) TS_COption_NetworkUpdateZ_free(uint32_t _res) {
12556         if ((_res & 1) != 0) return;
12557         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12558         CHECK_ACCESS(_res_ptr);
12559         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
12560         FREE((void*)_res);
12561         COption_NetworkUpdateZ_free(_res_conv);
12562 }
12563
12564 static inline uintptr_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
12565         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12566         *ret_copy = COption_NetworkUpdateZ_clone(arg);
12567 uint32_t ret_ref = (uintptr_t)ret_copy;
12568         return ret_ref;
12569 }
12570 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_clone_ptr"))) TS_COption_NetworkUpdateZ_clone_ptr(uint32_t arg) {
12571         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)arg;
12572         uint32_t ret_conv = COption_NetworkUpdateZ_clone_ptr(arg_conv);
12573         return ret_conv;
12574 }
12575
12576 uint32_t  __attribute__((export_name("TS_COption_NetworkUpdateZ_clone"))) TS_COption_NetworkUpdateZ_clone(uint32_t orig) {
12577         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig;
12578         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12579         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
12580         uint32_t ret_ref = (uintptr_t)ret_copy;
12581         return ret_ref;
12582 }
12583
12584 void  __attribute__((export_name("TS_CVec_SpendableOutputDescriptorZ_free"))) TS_CVec_SpendableOutputDescriptorZ_free(uint32_tArray _res) {
12585         LDKCVec_SpendableOutputDescriptorZ _res_constr;
12586         _res_constr.datalen = _res->arr_len;
12587         if (_res_constr.datalen > 0)
12588                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
12589         else
12590                 _res_constr.data = NULL;
12591         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12592         for (size_t b = 0; b < _res_constr.datalen; b++) {
12593                 uint32_t _res_conv_27 = _res_vals[b];
12594                 void* _res_conv_27_ptr = (void*)(((uintptr_t)_res_conv_27) & ~1);
12595                 CHECK_ACCESS(_res_conv_27_ptr);
12596                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
12597                 FREE((void*)_res_conv_27);
12598                 _res_constr.data[b] = _res_conv_27_conv;
12599         }
12600         CVec_SpendableOutputDescriptorZ_free(_res_constr);
12601 }
12602
12603 uint32_t  __attribute__((export_name("TS_COption_EventZ_some"))) TS_COption_EventZ_some(uint32_t o) {
12604         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12605         CHECK_ACCESS(o_ptr);
12606         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
12607         o_conv = Event_clone((LDKEvent*)(((uintptr_t)o) & ~1));
12608         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12609         *ret_copy = COption_EventZ_some(o_conv);
12610         uint32_t ret_ref = (uintptr_t)ret_copy;
12611         return ret_ref;
12612 }
12613
12614 uint32_t  __attribute__((export_name("TS_COption_EventZ_none"))) TS_COption_EventZ_none() {
12615         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12616         *ret_copy = COption_EventZ_none();
12617         uint32_t ret_ref = (uintptr_t)ret_copy;
12618         return ret_ref;
12619 }
12620
12621 void  __attribute__((export_name("TS_COption_EventZ_free"))) TS_COption_EventZ_free(uint32_t _res) {
12622         if ((_res & 1) != 0) return;
12623         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12624         CHECK_ACCESS(_res_ptr);
12625         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
12626         FREE((void*)_res);
12627         COption_EventZ_free(_res_conv);
12628 }
12629
12630 static inline uintptr_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
12631         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12632         *ret_copy = COption_EventZ_clone(arg);
12633 uint32_t ret_ref = (uintptr_t)ret_copy;
12634         return ret_ref;
12635 }
12636 uint32_t  __attribute__((export_name("TS_COption_EventZ_clone_ptr"))) TS_COption_EventZ_clone_ptr(uint32_t arg) {
12637         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)arg;
12638         uint32_t ret_conv = COption_EventZ_clone_ptr(arg_conv);
12639         return ret_conv;
12640 }
12641
12642 uint32_t  __attribute__((export_name("TS_COption_EventZ_clone"))) TS_COption_EventZ_clone(uint32_t orig) {
12643         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)orig;
12644         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12645         *ret_copy = COption_EventZ_clone(orig_conv);
12646         uint32_t ret_ref = (uintptr_t)ret_copy;
12647         return ret_ref;
12648 }
12649
12650 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_ok"))) TS_CResult_COption_EventZDecodeErrorZ_ok(uint32_t o) {
12651         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
12652         CHECK_ACCESS(o_ptr);
12653         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
12654         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)(((uintptr_t)o) & ~1));
12655         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12656         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
12657         return (uint32_t)ret_conv;
12658 }
12659
12660 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_err"))) TS_CResult_COption_EventZDecodeErrorZ_err(uint32_t e) {
12661         LDKDecodeError e_conv;
12662         e_conv.inner = (void*)(e & (~1));
12663         e_conv.is_owned = (e & 1) || (e == 0);
12664         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12665         e_conv = DecodeError_clone(&e_conv);
12666         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12667         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
12668         return (uint32_t)ret_conv;
12669 }
12670
12671 jboolean  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_is_ok"))) TS_CResult_COption_EventZDecodeErrorZ_is_ok(uint32_t o) {
12672         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(o & ~1);
12673         jboolean ret_conv = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
12674         return ret_conv;
12675 }
12676
12677 void  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_free"))) TS_CResult_COption_EventZDecodeErrorZ_free(uint32_t _res) {
12678         if ((_res & 1) != 0) return;
12679         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12680         CHECK_ACCESS(_res_ptr);
12681         LDKCResult_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
12682         FREE((void*)_res);
12683         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
12684 }
12685
12686 static inline uintptr_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
12687         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12688         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
12689         return (uint32_t)ret_conv;
12690 }
12691 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_EventZDecodeErrorZ_clone_ptr(uint32_t arg) {
12692         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(arg & ~1);
12693         uint32_t ret_conv = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
12694         return ret_conv;
12695 }
12696
12697 uint32_t  __attribute__((export_name("TS_CResult_COption_EventZDecodeErrorZ_clone"))) TS_CResult_COption_EventZDecodeErrorZ_clone(uint32_t orig) {
12698         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(orig & ~1);
12699         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12700         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
12701         return (uint32_t)ret_conv;
12702 }
12703
12704 void  __attribute__((export_name("TS_CVec_MessageSendEventZ_free"))) TS_CVec_MessageSendEventZ_free(uint32_tArray _res) {
12705         LDKCVec_MessageSendEventZ _res_constr;
12706         _res_constr.datalen = _res->arr_len;
12707         if (_res_constr.datalen > 0)
12708                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
12709         else
12710                 _res_constr.data = NULL;
12711         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
12712         for (size_t s = 0; s < _res_constr.datalen; s++) {
12713                 uint32_t _res_conv_18 = _res_vals[s];
12714                 void* _res_conv_18_ptr = (void*)(((uintptr_t)_res_conv_18) & ~1);
12715                 CHECK_ACCESS(_res_conv_18_ptr);
12716                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
12717                 FREE((void*)_res_conv_18);
12718                 _res_constr.data[s] = _res_conv_18_conv;
12719         }
12720         CVec_MessageSendEventZ_free(_res_constr);
12721 }
12722
12723 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_ok"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_ok(uint32_t o) {
12724         LDKFixedPenaltyScorer o_conv;
12725         o_conv.inner = (void*)(o & (~1));
12726         o_conv.is_owned = (o & 1) || (o == 0);
12727         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12728         o_conv = FixedPenaltyScorer_clone(&o_conv);
12729         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
12730         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_ok(o_conv);
12731         return (uint32_t)ret_conv;
12732 }
12733
12734 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_err"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_err(uint32_t e) {
12735         LDKDecodeError e_conv;
12736         e_conv.inner = (void*)(e & (~1));
12737         e_conv.is_owned = (e & 1) || (e == 0);
12738         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12739         e_conv = DecodeError_clone(&e_conv);
12740         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
12741         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_err(e_conv);
12742         return (uint32_t)ret_conv;
12743 }
12744
12745 jboolean  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_is_ok"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(uint32_t o) {
12746         LDKCResult_FixedPenaltyScorerDecodeErrorZ* o_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(o & ~1);
12747         jboolean ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(o_conv);
12748         return ret_conv;
12749 }
12750
12751 void  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_free"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_free(uint32_t _res) {
12752         if ((_res & 1) != 0) return;
12753         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12754         CHECK_ACCESS(_res_ptr);
12755         LDKCResult_FixedPenaltyScorerDecodeErrorZ _res_conv = *(LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(_res_ptr);
12756         FREE((void*)_res);
12757         CResult_FixedPenaltyScorerDecodeErrorZ_free(_res_conv);
12758 }
12759
12760 static inline uintptr_t CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR arg) {
12761         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
12762         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(arg);
12763         return (uint32_t)ret_conv;
12764 }
12765 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(uint32_t arg) {
12766         LDKCResult_FixedPenaltyScorerDecodeErrorZ* arg_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(arg & ~1);
12767         uint32_t ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(arg_conv);
12768         return ret_conv;
12769 }
12770
12771 uint32_t  __attribute__((export_name("TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone"))) TS_CResult_FixedPenaltyScorerDecodeErrorZ_clone(uint32_t orig) {
12772         LDKCResult_FixedPenaltyScorerDecodeErrorZ* orig_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(orig & ~1);
12773         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
12774         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig_conv);
12775         return (uint32_t)ret_conv;
12776 }
12777
12778 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_ok"))) TS_CResult_ScoringParametersDecodeErrorZ_ok(uint32_t o) {
12779         LDKScoringParameters o_conv;
12780         o_conv.inner = (void*)(o & (~1));
12781         o_conv.is_owned = (o & 1) || (o == 0);
12782         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12783         o_conv = ScoringParameters_clone(&o_conv);
12784         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
12785         *ret_conv = CResult_ScoringParametersDecodeErrorZ_ok(o_conv);
12786         return (uint32_t)ret_conv;
12787 }
12788
12789 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_err"))) TS_CResult_ScoringParametersDecodeErrorZ_err(uint32_t e) {
12790         LDKDecodeError e_conv;
12791         e_conv.inner = (void*)(e & (~1));
12792         e_conv.is_owned = (e & 1) || (e == 0);
12793         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12794         e_conv = DecodeError_clone(&e_conv);
12795         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
12796         *ret_conv = CResult_ScoringParametersDecodeErrorZ_err(e_conv);
12797         return (uint32_t)ret_conv;
12798 }
12799
12800 jboolean  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_is_ok"))) TS_CResult_ScoringParametersDecodeErrorZ_is_ok(uint32_t o) {
12801         LDKCResult_ScoringParametersDecodeErrorZ* o_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(o & ~1);
12802         jboolean ret_conv = CResult_ScoringParametersDecodeErrorZ_is_ok(o_conv);
12803         return ret_conv;
12804 }
12805
12806 void  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_free"))) TS_CResult_ScoringParametersDecodeErrorZ_free(uint32_t _res) {
12807         if ((_res & 1) != 0) return;
12808         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12809         CHECK_ACCESS(_res_ptr);
12810         LDKCResult_ScoringParametersDecodeErrorZ _res_conv = *(LDKCResult_ScoringParametersDecodeErrorZ*)(_res_ptr);
12811         FREE((void*)_res);
12812         CResult_ScoringParametersDecodeErrorZ_free(_res_conv);
12813 }
12814
12815 static inline uintptr_t CResult_ScoringParametersDecodeErrorZ_clone_ptr(LDKCResult_ScoringParametersDecodeErrorZ *NONNULL_PTR arg) {
12816         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
12817         *ret_conv = CResult_ScoringParametersDecodeErrorZ_clone(arg);
12818         return (uint32_t)ret_conv;
12819 }
12820 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_clone_ptr"))) TS_CResult_ScoringParametersDecodeErrorZ_clone_ptr(uint32_t arg) {
12821         LDKCResult_ScoringParametersDecodeErrorZ* arg_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(arg & ~1);
12822         uint32_t ret_conv = CResult_ScoringParametersDecodeErrorZ_clone_ptr(arg_conv);
12823         return ret_conv;
12824 }
12825
12826 uint32_t  __attribute__((export_name("TS_CResult_ScoringParametersDecodeErrorZ_clone"))) TS_CResult_ScoringParametersDecodeErrorZ_clone(uint32_t orig) {
12827         LDKCResult_ScoringParametersDecodeErrorZ* orig_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(orig & ~1);
12828         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
12829         *ret_conv = CResult_ScoringParametersDecodeErrorZ_clone(orig_conv);
12830         return (uint32_t)ret_conv;
12831 }
12832
12833 uint32_t  __attribute__((export_name("TS_CResult_ScorerDecodeErrorZ_ok"))) TS_CResult_ScorerDecodeErrorZ_ok(uint32_t o) {
12834         LDKScorer o_conv;
12835         o_conv.inner = (void*)(o & (~1));
12836         o_conv.is_owned = (o & 1) || (o == 0);
12837         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12838         // WARNING: we need a move here but no clone is available for LDKScorer
12839         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
12840         *ret_conv = CResult_ScorerDecodeErrorZ_ok(o_conv);
12841         return (uint32_t)ret_conv;
12842 }
12843
12844 uint32_t  __attribute__((export_name("TS_CResult_ScorerDecodeErrorZ_err"))) TS_CResult_ScorerDecodeErrorZ_err(uint32_t e) {
12845         LDKDecodeError e_conv;
12846         e_conv.inner = (void*)(e & (~1));
12847         e_conv.is_owned = (e & 1) || (e == 0);
12848         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12849         e_conv = DecodeError_clone(&e_conv);
12850         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
12851         *ret_conv = CResult_ScorerDecodeErrorZ_err(e_conv);
12852         return (uint32_t)ret_conv;
12853 }
12854
12855 jboolean  __attribute__((export_name("TS_CResult_ScorerDecodeErrorZ_is_ok"))) TS_CResult_ScorerDecodeErrorZ_is_ok(uint32_t o) {
12856         LDKCResult_ScorerDecodeErrorZ* o_conv = (LDKCResult_ScorerDecodeErrorZ*)(o & ~1);
12857         jboolean ret_conv = CResult_ScorerDecodeErrorZ_is_ok(o_conv);
12858         return ret_conv;
12859 }
12860
12861 void  __attribute__((export_name("TS_CResult_ScorerDecodeErrorZ_free"))) TS_CResult_ScorerDecodeErrorZ_free(uint32_t _res) {
12862         if ((_res & 1) != 0) return;
12863         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12864         CHECK_ACCESS(_res_ptr);
12865         LDKCResult_ScorerDecodeErrorZ _res_conv = *(LDKCResult_ScorerDecodeErrorZ*)(_res_ptr);
12866         FREE((void*)_res);
12867         CResult_ScorerDecodeErrorZ_free(_res_conv);
12868 }
12869
12870 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_ok"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_ok(uint32_t o) {
12871         LDKProbabilisticScorer o_conv;
12872         o_conv.inner = (void*)(o & (~1));
12873         o_conv.is_owned = (o & 1) || (o == 0);
12874         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12875         // WARNING: we need a move here but no clone is available for LDKProbabilisticScorer
12876         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
12877         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_ok(o_conv);
12878         return (uint32_t)ret_conv;
12879 }
12880
12881 uint32_t  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_err"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_err(uint32_t e) {
12882         LDKDecodeError e_conv;
12883         e_conv.inner = (void*)(e & (~1));
12884         e_conv.is_owned = (e & 1) || (e == 0);
12885         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12886         e_conv = DecodeError_clone(&e_conv);
12887         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
12888         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_err(e_conv);
12889         return (uint32_t)ret_conv;
12890 }
12891
12892 jboolean  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_is_ok"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_is_ok(uint32_t o) {
12893         LDKCResult_ProbabilisticScorerDecodeErrorZ* o_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)(o & ~1);
12894         jboolean ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_is_ok(o_conv);
12895         return ret_conv;
12896 }
12897
12898 void  __attribute__((export_name("TS_CResult_ProbabilisticScorerDecodeErrorZ_free"))) TS_CResult_ProbabilisticScorerDecodeErrorZ_free(uint32_t _res) {
12899         if ((_res & 1) != 0) return;
12900         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12901         CHECK_ACCESS(_res_ptr);
12902         LDKCResult_ProbabilisticScorerDecodeErrorZ _res_conv = *(LDKCResult_ProbabilisticScorerDecodeErrorZ*)(_res_ptr);
12903         FREE((void*)_res);
12904         CResult_ProbabilisticScorerDecodeErrorZ_free(_res_conv);
12905 }
12906
12907 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_ok(uint32_t o) {
12908         LDKInitFeatures o_conv;
12909         o_conv.inner = (void*)(o & (~1));
12910         o_conv.is_owned = (o & 1) || (o == 0);
12911         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12912         o_conv = InitFeatures_clone(&o_conv);
12913         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
12914         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
12915         return (uint32_t)ret_conv;
12916 }
12917
12918 uint32_t  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_err"))) TS_CResult_InitFeaturesDecodeErrorZ_err(uint32_t e) {
12919         LDKDecodeError e_conv;
12920         e_conv.inner = (void*)(e & (~1));
12921         e_conv.is_owned = (e & 1) || (e == 0);
12922         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12923         e_conv = DecodeError_clone(&e_conv);
12924         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
12925         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
12926         return (uint32_t)ret_conv;
12927 }
12928
12929 jboolean  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_is_ok"))) TS_CResult_InitFeaturesDecodeErrorZ_is_ok(uint32_t o) {
12930         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(o & ~1);
12931         jboolean ret_conv = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
12932         return ret_conv;
12933 }
12934
12935 void  __attribute__((export_name("TS_CResult_InitFeaturesDecodeErrorZ_free"))) TS_CResult_InitFeaturesDecodeErrorZ_free(uint32_t _res) {
12936         if ((_res & 1) != 0) return;
12937         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12938         CHECK_ACCESS(_res_ptr);
12939         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
12940         FREE((void*)_res);
12941         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
12942 }
12943
12944 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_ok(uint32_t o) {
12945         LDKChannelFeatures o_conv;
12946         o_conv.inner = (void*)(o & (~1));
12947         o_conv.is_owned = (o & 1) || (o == 0);
12948         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12949         o_conv = ChannelFeatures_clone(&o_conv);
12950         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
12951         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
12952         return (uint32_t)ret_conv;
12953 }
12954
12955 uint32_t  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_err"))) TS_CResult_ChannelFeaturesDecodeErrorZ_err(uint32_t e) {
12956         LDKDecodeError e_conv;
12957         e_conv.inner = (void*)(e & (~1));
12958         e_conv.is_owned = (e & 1) || (e == 0);
12959         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12960         e_conv = DecodeError_clone(&e_conv);
12961         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
12962         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
12963         return (uint32_t)ret_conv;
12964 }
12965
12966 jboolean  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_is_ok"))) TS_CResult_ChannelFeaturesDecodeErrorZ_is_ok(uint32_t o) {
12967         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(o & ~1);
12968         jboolean ret_conv = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
12969         return ret_conv;
12970 }
12971
12972 void  __attribute__((export_name("TS_CResult_ChannelFeaturesDecodeErrorZ_free"))) TS_CResult_ChannelFeaturesDecodeErrorZ_free(uint32_t _res) {
12973         if ((_res & 1) != 0) return;
12974         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
12975         CHECK_ACCESS(_res_ptr);
12976         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
12977         FREE((void*)_res);
12978         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
12979 }
12980
12981 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_ok(uint32_t o) {
12982         LDKNodeFeatures o_conv;
12983         o_conv.inner = (void*)(o & (~1));
12984         o_conv.is_owned = (o & 1) || (o == 0);
12985         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12986         o_conv = NodeFeatures_clone(&o_conv);
12987         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
12988         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
12989         return (uint32_t)ret_conv;
12990 }
12991
12992 uint32_t  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_err"))) TS_CResult_NodeFeaturesDecodeErrorZ_err(uint32_t e) {
12993         LDKDecodeError e_conv;
12994         e_conv.inner = (void*)(e & (~1));
12995         e_conv.is_owned = (e & 1) || (e == 0);
12996         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12997         e_conv = DecodeError_clone(&e_conv);
12998         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
12999         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
13000         return (uint32_t)ret_conv;
13001 }
13002
13003 jboolean  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_is_ok"))) TS_CResult_NodeFeaturesDecodeErrorZ_is_ok(uint32_t o) {
13004         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(o & ~1);
13005         jboolean ret_conv = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
13006         return ret_conv;
13007 }
13008
13009 void  __attribute__((export_name("TS_CResult_NodeFeaturesDecodeErrorZ_free"))) TS_CResult_NodeFeaturesDecodeErrorZ_free(uint32_t _res) {
13010         if ((_res & 1) != 0) return;
13011         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13012         CHECK_ACCESS(_res_ptr);
13013         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
13014         FREE((void*)_res);
13015         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
13016 }
13017
13018 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_ok(uint32_t o) {
13019         LDKInvoiceFeatures o_conv;
13020         o_conv.inner = (void*)(o & (~1));
13021         o_conv.is_owned = (o & 1) || (o == 0);
13022         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13023         o_conv = InvoiceFeatures_clone(&o_conv);
13024         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
13025         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
13026         return (uint32_t)ret_conv;
13027 }
13028
13029 uint32_t  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_err"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_err(uint32_t e) {
13030         LDKDecodeError e_conv;
13031         e_conv.inner = (void*)(e & (~1));
13032         e_conv.is_owned = (e & 1) || (e == 0);
13033         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13034         e_conv = DecodeError_clone(&e_conv);
13035         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
13036         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
13037         return (uint32_t)ret_conv;
13038 }
13039
13040 jboolean  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_is_ok"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_is_ok(uint32_t o) {
13041         LDKCResult_InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(o & ~1);
13042         jboolean ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
13043         return ret_conv;
13044 }
13045
13046 void  __attribute__((export_name("TS_CResult_InvoiceFeaturesDecodeErrorZ_free"))) TS_CResult_InvoiceFeaturesDecodeErrorZ_free(uint32_t _res) {
13047         if ((_res & 1) != 0) return;
13048         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13049         CHECK_ACCESS(_res_ptr);
13050         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
13051         FREE((void*)_res);
13052         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
13053 }
13054
13055 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_ok(uint32_t o) {
13056         LDKChannelTypeFeatures o_conv;
13057         o_conv.inner = (void*)(o & (~1));
13058         o_conv.is_owned = (o & 1) || (o == 0);
13059         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13060         o_conv = ChannelTypeFeatures_clone(&o_conv);
13061         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
13062         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o_conv);
13063         return (uint32_t)ret_conv;
13064 }
13065
13066 uint32_t  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_err"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_err(uint32_t e) {
13067         LDKDecodeError e_conv;
13068         e_conv.inner = (void*)(e & (~1));
13069         e_conv.is_owned = (e & 1) || (e == 0);
13070         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13071         e_conv = DecodeError_clone(&e_conv);
13072         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
13073         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_err(e_conv);
13074         return (uint32_t)ret_conv;
13075 }
13076
13077 jboolean  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(uint32_t o) {
13078         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(o & ~1);
13079         jboolean ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o_conv);
13080         return ret_conv;
13081 }
13082
13083 void  __attribute__((export_name("TS_CResult_ChannelTypeFeaturesDecodeErrorZ_free"))) TS_CResult_ChannelTypeFeaturesDecodeErrorZ_free(uint32_t _res) {
13084         if ((_res & 1) != 0) return;
13085         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13086         CHECK_ACCESS(_res_ptr);
13087         LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(_res_ptr);
13088         FREE((void*)_res);
13089         CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res_conv);
13090 }
13091
13092 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
13093         LDKDelayedPaymentOutputDescriptor o_conv;
13094         o_conv.inner = (void*)(o & (~1));
13095         o_conv.is_owned = (o & 1) || (o == 0);
13096         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13097         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
13098         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
13099         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
13100         return (uint32_t)ret_conv;
13101 }
13102
13103 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
13104         LDKDecodeError e_conv;
13105         e_conv.inner = (void*)(e & (~1));
13106         e_conv.is_owned = (e & 1) || (e == 0);
13107         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13108         e_conv = DecodeError_clone(&e_conv);
13109         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
13110         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
13111         return (uint32_t)ret_conv;
13112 }
13113
13114 jboolean  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
13115         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
13116         jboolean ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
13117         return ret_conv;
13118 }
13119
13120 void  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
13121         if ((_res & 1) != 0) return;
13122         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13123         CHECK_ACCESS(_res_ptr);
13124         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
13125         FREE((void*)_res);
13126         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
13127 }
13128
13129 static inline uintptr_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
13130         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
13131         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
13132         return (uint32_t)ret_conv;
13133 }
13134 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
13135         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
13136         uint32_t ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
13137         return ret_conv;
13138 }
13139
13140 uint32_t  __attribute__((export_name("TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
13141         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
13142         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
13143         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
13144         return (uint32_t)ret_conv;
13145 }
13146
13147 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
13148         LDKStaticPaymentOutputDescriptor o_conv;
13149         o_conv.inner = (void*)(o & (~1));
13150         o_conv.is_owned = (o & 1) || (o == 0);
13151         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13152         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
13153         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
13154         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
13155         return (uint32_t)ret_conv;
13156 }
13157
13158 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(uint32_t e) {
13159         LDKDecodeError e_conv;
13160         e_conv.inner = (void*)(e & (~1));
13161         e_conv.is_owned = (e & 1) || (e == 0);
13162         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13163         e_conv = DecodeError_clone(&e_conv);
13164         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
13165         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
13166         return (uint32_t)ret_conv;
13167 }
13168
13169 jboolean  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
13170         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
13171         jboolean ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
13172         return ret_conv;
13173 }
13174
13175 void  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
13176         if ((_res & 1) != 0) return;
13177         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13178         CHECK_ACCESS(_res_ptr);
13179         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
13180         FREE((void*)_res);
13181         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
13182 }
13183
13184 static inline uintptr_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
13185         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
13186         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
13187         return (uint32_t)ret_conv;
13188 }
13189 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
13190         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
13191         uint32_t ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
13192         return ret_conv;
13193 }
13194
13195 uint32_t  __attribute__((export_name("TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
13196         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
13197         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
13198         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
13199         return (uint32_t)ret_conv;
13200 }
13201
13202 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
13203         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13204         CHECK_ACCESS(o_ptr);
13205         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
13206         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)o) & ~1));
13207         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
13208         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
13209         return (uint32_t)ret_conv;
13210 }
13211
13212 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err(uint32_t e) {
13213         LDKDecodeError e_conv;
13214         e_conv.inner = (void*)(e & (~1));
13215         e_conv.is_owned = (e & 1) || (e == 0);
13216         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13217         e_conv = DecodeError_clone(&e_conv);
13218         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
13219         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
13220         return (uint32_t)ret_conv;
13221 }
13222
13223 jboolean  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(uint32_t o) {
13224         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(o & ~1);
13225         jboolean ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
13226         return ret_conv;
13227 }
13228
13229 void  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
13230         if ((_res & 1) != 0) return;
13231         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13232         CHECK_ACCESS(_res_ptr);
13233         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
13234         FREE((void*)_res);
13235         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
13236 }
13237
13238 static inline uintptr_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
13239         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
13240         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
13241         return (uint32_t)ret_conv;
13242 }
13243 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(uint32_t arg) {
13244         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
13245         uint32_t ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
13246         return ret_conv;
13247 }
13248
13249 uint32_t  __attribute__((export_name("TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
13250         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
13251         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
13252         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
13253         return (uint32_t)ret_conv;
13254 }
13255
13256 void  __attribute__((export_name("TS_CVec_PaymentPreimageZ_free"))) TS_CVec_PaymentPreimageZ_free(ptrArray _res) {
13257         LDKCVec_PaymentPreimageZ _res_constr;
13258         _res_constr.datalen = _res->arr_len;
13259         if (_res_constr.datalen > 0)
13260                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
13261         else
13262                 _res_constr.data = NULL;
13263         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
13264         for (size_t m = 0; m < _res_constr.datalen; m++) {
13265                 int8_tArray _res_conv_12 = _res_vals[m];
13266                 LDKThirtyTwoBytes _res_conv_12_ref;
13267                 CHECK(_res_conv_12->arr_len == 32);
13268                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, 32); FREE(_res_conv_12);
13269                 _res_constr.data[m] = _res_conv_12_ref;
13270         }
13271         CVec_PaymentPreimageZ_free(_res_constr);
13272 }
13273
13274 static inline uintptr_t C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR arg) {
13275         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
13276         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(arg);
13277         return ((uint32_t)ret_conv);
13278 }
13279 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_clone_ptr"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(uint32_t arg) {
13280         LDKC2Tuple_SignatureCVec_SignatureZZ* arg_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(arg & ~1);
13281         uint32_t ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(arg_conv);
13282         return ret_conv;
13283 }
13284
13285 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_clone"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone(uint32_t orig) {
13286         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
13287         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
13288         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
13289         return ((uint32_t)ret_conv);
13290 }
13291
13292 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_new"))) TS_C2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
13293         LDKSignature a_ref;
13294         CHECK(a->arr_len == 64);
13295         memcpy(a_ref.compact_form, a->elems, 64); FREE(a);
13296         LDKCVec_SignatureZ b_constr;
13297         b_constr.datalen = b->arr_len;
13298         if (b_constr.datalen > 0)
13299                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
13300         else
13301                 b_constr.data = NULL;
13302         int8_tArray* b_vals = (void*) b->elems /* XXX b leaks */;
13303         for (size_t m = 0; m < b_constr.datalen; m++) {
13304                 int8_tArray b_conv_12 = b_vals[m];
13305                 LDKSignature b_conv_12_ref;
13306                 CHECK(b_conv_12->arr_len == 64);
13307                 memcpy(b_conv_12_ref.compact_form, b_conv_12->elems, 64); FREE(b_conv_12);
13308                 b_constr.data[m] = b_conv_12_ref;
13309         }
13310         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
13311         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
13312         return ((uint32_t)ret_conv);
13313 }
13314
13315 void  __attribute__((export_name("TS_C2Tuple_SignatureCVec_SignatureZZ_free"))) TS_C2Tuple_SignatureCVec_SignatureZZ_free(uint32_t _res) {
13316         if ((_res & 1) != 0) return;
13317         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13318         CHECK_ACCESS(_res_ptr);
13319         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
13320         FREE((void*)_res);
13321         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
13322 }
13323
13324 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(uint32_t o) {
13325         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13326         CHECK_ACCESS(o_ptr);
13327         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
13328         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uintptr_t)o) & ~1));
13329         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
13330         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
13331         return (uint32_t)ret_conv;
13332 }
13333
13334 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() {
13335         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
13336         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
13337         return (uint32_t)ret_conv;
13338 }
13339
13340 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(uint32_t o) {
13341         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(o & ~1);
13342         jboolean ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o_conv);
13343         return ret_conv;
13344 }
13345
13346 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(uint32_t _res) {
13347         if ((_res & 1) != 0) return;
13348         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13349         CHECK_ACCESS(_res_ptr);
13350         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
13351         FREE((void*)_res);
13352         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
13353 }
13354
13355 static inline uintptr_t CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR arg) {
13356         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
13357         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(arg);
13358         return (uint32_t)ret_conv;
13359 }
13360 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(uint32_t arg) {
13361         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
13362         uint32_t ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(arg_conv);
13363         return ret_conv;
13364 }
13365
13366 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(uint32_t orig) {
13367         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
13368         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
13369         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
13370         return (uint32_t)ret_conv;
13371 }
13372
13373 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_ok"))) TS_CResult_SignatureNoneZ_ok(int8_tArray o) {
13374         LDKSignature o_ref;
13375         CHECK(o->arr_len == 64);
13376         memcpy(o_ref.compact_form, o->elems, 64); FREE(o);
13377         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
13378         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
13379         return (uint32_t)ret_conv;
13380 }
13381
13382 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_err"))) TS_CResult_SignatureNoneZ_err() {
13383         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
13384         *ret_conv = CResult_SignatureNoneZ_err();
13385         return (uint32_t)ret_conv;
13386 }
13387
13388 jboolean  __attribute__((export_name("TS_CResult_SignatureNoneZ_is_ok"))) TS_CResult_SignatureNoneZ_is_ok(uint32_t o) {
13389         LDKCResult_SignatureNoneZ* o_conv = (LDKCResult_SignatureNoneZ*)(o & ~1);
13390         jboolean ret_conv = CResult_SignatureNoneZ_is_ok(o_conv);
13391         return ret_conv;
13392 }
13393
13394 void  __attribute__((export_name("TS_CResult_SignatureNoneZ_free"))) TS_CResult_SignatureNoneZ_free(uint32_t _res) {
13395         if ((_res & 1) != 0) return;
13396         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13397         CHECK_ACCESS(_res_ptr);
13398         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
13399         FREE((void*)_res);
13400         CResult_SignatureNoneZ_free(_res_conv);
13401 }
13402
13403 static inline uintptr_t CResult_SignatureNoneZ_clone_ptr(LDKCResult_SignatureNoneZ *NONNULL_PTR arg) {
13404         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
13405         *ret_conv = CResult_SignatureNoneZ_clone(arg);
13406         return (uint32_t)ret_conv;
13407 }
13408 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_clone_ptr"))) TS_CResult_SignatureNoneZ_clone_ptr(uint32_t arg) {
13409         LDKCResult_SignatureNoneZ* arg_conv = (LDKCResult_SignatureNoneZ*)(arg & ~1);
13410         uint32_t ret_conv = CResult_SignatureNoneZ_clone_ptr(arg_conv);
13411         return ret_conv;
13412 }
13413
13414 uint32_t  __attribute__((export_name("TS_CResult_SignatureNoneZ_clone"))) TS_CResult_SignatureNoneZ_clone(uint32_t orig) {
13415         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
13416         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
13417         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
13418         return (uint32_t)ret_conv;
13419 }
13420
13421 static inline uintptr_t C2Tuple_SignatureSignatureZ_clone_ptr(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR arg) {
13422         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
13423         *ret_conv = C2Tuple_SignatureSignatureZ_clone(arg);
13424         return ((uint32_t)ret_conv);
13425 }
13426 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_clone_ptr"))) TS_C2Tuple_SignatureSignatureZ_clone_ptr(uint32_t arg) {
13427         LDKC2Tuple_SignatureSignatureZ* arg_conv = (LDKC2Tuple_SignatureSignatureZ*)(arg & ~1);
13428         uint32_t ret_conv = C2Tuple_SignatureSignatureZ_clone_ptr(arg_conv);
13429         return ret_conv;
13430 }
13431
13432 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_clone"))) TS_C2Tuple_SignatureSignatureZ_clone(uint32_t orig) {
13433         LDKC2Tuple_SignatureSignatureZ* orig_conv = (LDKC2Tuple_SignatureSignatureZ*)(orig & ~1);
13434         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
13435         *ret_conv = C2Tuple_SignatureSignatureZ_clone(orig_conv);
13436         return ((uint32_t)ret_conv);
13437 }
13438
13439 uint32_t  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_new"))) TS_C2Tuple_SignatureSignatureZ_new(int8_tArray a, int8_tArray b) {
13440         LDKSignature a_ref;
13441         CHECK(a->arr_len == 64);
13442         memcpy(a_ref.compact_form, a->elems, 64); FREE(a);
13443         LDKSignature b_ref;
13444         CHECK(b->arr_len == 64);
13445         memcpy(b_ref.compact_form, b->elems, 64); FREE(b);
13446         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
13447         *ret_conv = C2Tuple_SignatureSignatureZ_new(a_ref, b_ref);
13448         return ((uint32_t)ret_conv);
13449 }
13450
13451 void  __attribute__((export_name("TS_C2Tuple_SignatureSignatureZ_free"))) TS_C2Tuple_SignatureSignatureZ_free(uint32_t _res) {
13452         if ((_res & 1) != 0) return;
13453         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13454         CHECK_ACCESS(_res_ptr);
13455         LDKC2Tuple_SignatureSignatureZ _res_conv = *(LDKC2Tuple_SignatureSignatureZ*)(_res_ptr);
13456         FREE((void*)_res);
13457         C2Tuple_SignatureSignatureZ_free(_res_conv);
13458 }
13459
13460 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_ok"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_ok(uint32_t o) {
13461         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13462         CHECK_ACCESS(o_ptr);
13463         LDKC2Tuple_SignatureSignatureZ o_conv = *(LDKC2Tuple_SignatureSignatureZ*)(o_ptr);
13464         o_conv = C2Tuple_SignatureSignatureZ_clone((LDKC2Tuple_SignatureSignatureZ*)(((uintptr_t)o) & ~1));
13465         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
13466         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_ok(o_conv);
13467         return (uint32_t)ret_conv;
13468 }
13469
13470 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_err"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_err() {
13471         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
13472         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_err();
13473         return (uint32_t)ret_conv;
13474 }
13475
13476 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(uint32_t o) {
13477         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(o & ~1);
13478         jboolean ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(o_conv);
13479         return ret_conv;
13480 }
13481
13482 void  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_free"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_free(uint32_t _res) {
13483         if ((_res & 1) != 0) return;
13484         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13485         CHECK_ACCESS(_res_ptr);
13486         LDKCResult_C2Tuple_SignatureSignatureZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(_res_ptr);
13487         FREE((void*)_res);
13488         CResult_C2Tuple_SignatureSignatureZNoneZ_free(_res_conv);
13489 }
13490
13491 static inline uintptr_t CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR arg) {
13492         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
13493         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(arg);
13494         return (uint32_t)ret_conv;
13495 }
13496 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(uint32_t arg) {
13497         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(arg & ~1);
13498         uint32_t ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(arg_conv);
13499         return ret_conv;
13500 }
13501
13502 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone"))) TS_CResult_C2Tuple_SignatureSignatureZNoneZ_clone(uint32_t orig) {
13503         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(orig & ~1);
13504         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
13505         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(orig_conv);
13506         return (uint32_t)ret_conv;
13507 }
13508
13509 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_ok"))) TS_CResult_SecretKeyNoneZ_ok(int8_tArray o) {
13510         LDKSecretKey o_ref;
13511         CHECK(o->arr_len == 32);
13512         memcpy(o_ref.bytes, o->elems, 32); FREE(o);
13513         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
13514         *ret_conv = CResult_SecretKeyNoneZ_ok(o_ref);
13515         return (uint32_t)ret_conv;
13516 }
13517
13518 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_err"))) TS_CResult_SecretKeyNoneZ_err() {
13519         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
13520         *ret_conv = CResult_SecretKeyNoneZ_err();
13521         return (uint32_t)ret_conv;
13522 }
13523
13524 jboolean  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_is_ok"))) TS_CResult_SecretKeyNoneZ_is_ok(uint32_t o) {
13525         LDKCResult_SecretKeyNoneZ* o_conv = (LDKCResult_SecretKeyNoneZ*)(o & ~1);
13526         jboolean ret_conv = CResult_SecretKeyNoneZ_is_ok(o_conv);
13527         return ret_conv;
13528 }
13529
13530 void  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_free"))) TS_CResult_SecretKeyNoneZ_free(uint32_t _res) {
13531         if ((_res & 1) != 0) return;
13532         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13533         CHECK_ACCESS(_res_ptr);
13534         LDKCResult_SecretKeyNoneZ _res_conv = *(LDKCResult_SecretKeyNoneZ*)(_res_ptr);
13535         FREE((void*)_res);
13536         CResult_SecretKeyNoneZ_free(_res_conv);
13537 }
13538
13539 static inline uintptr_t CResult_SecretKeyNoneZ_clone_ptr(LDKCResult_SecretKeyNoneZ *NONNULL_PTR arg) {
13540         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
13541         *ret_conv = CResult_SecretKeyNoneZ_clone(arg);
13542         return (uint32_t)ret_conv;
13543 }
13544 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_clone_ptr"))) TS_CResult_SecretKeyNoneZ_clone_ptr(uint32_t arg) {
13545         LDKCResult_SecretKeyNoneZ* arg_conv = (LDKCResult_SecretKeyNoneZ*)(arg & ~1);
13546         uint32_t ret_conv = CResult_SecretKeyNoneZ_clone_ptr(arg_conv);
13547         return ret_conv;
13548 }
13549
13550 uint32_t  __attribute__((export_name("TS_CResult_SecretKeyNoneZ_clone"))) TS_CResult_SecretKeyNoneZ_clone(uint32_t orig) {
13551         LDKCResult_SecretKeyNoneZ* orig_conv = (LDKCResult_SecretKeyNoneZ*)(orig & ~1);
13552         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
13553         *ret_conv = CResult_SecretKeyNoneZ_clone(orig_conv);
13554         return (uint32_t)ret_conv;
13555 }
13556
13557 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_ok"))) TS_CResult_SignDecodeErrorZ_ok(uint32_t o) {
13558         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
13559         CHECK_ACCESS(o_ptr);
13560         LDKSign o_conv = *(LDKSign*)(o_ptr);
13561         if (o_conv.free == LDKSign_JCalls_free) {
13562                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13563                 LDKSign_JCalls_cloned(&o_conv);
13564         }
13565         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
13566         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
13567         return (uint32_t)ret_conv;
13568 }
13569
13570 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_err"))) TS_CResult_SignDecodeErrorZ_err(uint32_t e) {
13571         LDKDecodeError e_conv;
13572         e_conv.inner = (void*)(e & (~1));
13573         e_conv.is_owned = (e & 1) || (e == 0);
13574         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13575         e_conv = DecodeError_clone(&e_conv);
13576         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
13577         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
13578         return (uint32_t)ret_conv;
13579 }
13580
13581 jboolean  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_is_ok"))) TS_CResult_SignDecodeErrorZ_is_ok(uint32_t o) {
13582         LDKCResult_SignDecodeErrorZ* o_conv = (LDKCResult_SignDecodeErrorZ*)(o & ~1);
13583         jboolean ret_conv = CResult_SignDecodeErrorZ_is_ok(o_conv);
13584         return ret_conv;
13585 }
13586
13587 void  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_free"))) TS_CResult_SignDecodeErrorZ_free(uint32_t _res) {
13588         if ((_res & 1) != 0) return;
13589         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13590         CHECK_ACCESS(_res_ptr);
13591         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
13592         FREE((void*)_res);
13593         CResult_SignDecodeErrorZ_free(_res_conv);
13594 }
13595
13596 static inline uintptr_t CResult_SignDecodeErrorZ_clone_ptr(LDKCResult_SignDecodeErrorZ *NONNULL_PTR arg) {
13597         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
13598         *ret_conv = CResult_SignDecodeErrorZ_clone(arg);
13599         return (uint32_t)ret_conv;
13600 }
13601 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_clone_ptr"))) TS_CResult_SignDecodeErrorZ_clone_ptr(uint32_t arg) {
13602         LDKCResult_SignDecodeErrorZ* arg_conv = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
13603         uint32_t ret_conv = CResult_SignDecodeErrorZ_clone_ptr(arg_conv);
13604         return ret_conv;
13605 }
13606
13607 uint32_t  __attribute__((export_name("TS_CResult_SignDecodeErrorZ_clone"))) TS_CResult_SignDecodeErrorZ_clone(uint32_t orig) {
13608         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
13609         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
13610         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
13611         return (uint32_t)ret_conv;
13612 }
13613
13614 void  __attribute__((export_name("TS_CVec_u5Z_free"))) TS_CVec_u5Z_free(ptrArray _res) {
13615         LDKCVec_u5Z _res_constr;
13616         _res_constr.datalen = _res->arr_len;
13617         if (_res_constr.datalen > 0)
13618                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
13619         else
13620                 _res_constr.data = NULL;
13621         int8_t* _res_vals = (void*) _res->elems /* XXX _res leaks */;
13622         for (size_t h = 0; h < _res_constr.datalen; h++) {
13623                 int8_t _res_conv_7 = _res_vals[h];
13624                 
13625                 _res_constr.data[h] = (LDKu5){ ._0 = _res_conv_7 };
13626         }
13627         CVec_u5Z_free(_res_constr);
13628 }
13629
13630 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_ok"))) TS_CResult_RecoverableSignatureNoneZ_ok(int8_tArray o) {
13631         LDKRecoverableSignature o_ref;
13632         CHECK(o->arr_len == 68);
13633         memcpy(o_ref.serialized_form, o->elems, 68); FREE(o);
13634         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
13635         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(o_ref);
13636         return (uint32_t)ret_conv;
13637 }
13638
13639 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_err"))) TS_CResult_RecoverableSignatureNoneZ_err() {
13640         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
13641         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
13642         return (uint32_t)ret_conv;
13643 }
13644
13645 jboolean  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_is_ok"))) TS_CResult_RecoverableSignatureNoneZ_is_ok(uint32_t o) {
13646         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)(o & ~1);
13647         jboolean ret_conv = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
13648         return ret_conv;
13649 }
13650
13651 void  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_free"))) TS_CResult_RecoverableSignatureNoneZ_free(uint32_t _res) {
13652         if ((_res & 1) != 0) return;
13653         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13654         CHECK_ACCESS(_res_ptr);
13655         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
13656         FREE((void*)_res);
13657         CResult_RecoverableSignatureNoneZ_free(_res_conv);
13658 }
13659
13660 static inline uintptr_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
13661         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
13662         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
13663         return (uint32_t)ret_conv;
13664 }
13665 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_clone_ptr"))) TS_CResult_RecoverableSignatureNoneZ_clone_ptr(uint32_t arg) {
13666         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
13667         uint32_t ret_conv = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
13668         return ret_conv;
13669 }
13670
13671 uint32_t  __attribute__((export_name("TS_CResult_RecoverableSignatureNoneZ_clone"))) TS_CResult_RecoverableSignatureNoneZ_clone(uint32_t orig) {
13672         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
13673         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
13674         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
13675         return (uint32_t)ret_conv;
13676 }
13677
13678 void  __attribute__((export_name("TS_CVec_u8Z_free"))) TS_CVec_u8Z_free(int8_tArray _res) {
13679         LDKCVec_u8Z _res_ref;
13680         _res_ref.datalen = _res->arr_len;
13681         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
13682         memcpy(_res_ref.data, _res->elems, _res_ref.datalen); FREE(_res);
13683         CVec_u8Z_free(_res_ref);
13684 }
13685
13686 void  __attribute__((export_name("TS_CVec_CVec_u8ZZ_free"))) TS_CVec_CVec_u8ZZ_free(ptrArray _res) {
13687         LDKCVec_CVec_u8ZZ _res_constr;
13688         _res_constr.datalen = _res->arr_len;
13689         if (_res_constr.datalen > 0)
13690                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
13691         else
13692                 _res_constr.data = NULL;
13693         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
13694         for (size_t m = 0; m < _res_constr.datalen; m++) {
13695                 int8_tArray _res_conv_12 = _res_vals[m];
13696                 LDKCVec_u8Z _res_conv_12_ref;
13697                 _res_conv_12_ref.datalen = _res_conv_12->arr_len;
13698                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
13699                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, _res_conv_12_ref.datalen); FREE(_res_conv_12);
13700                 _res_constr.data[m] = _res_conv_12_ref;
13701         }
13702         CVec_CVec_u8ZZ_free(_res_constr);
13703 }
13704
13705 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_ok(ptrArray o) {
13706         LDKCVec_CVec_u8ZZ o_constr;
13707         o_constr.datalen = o->arr_len;
13708         if (o_constr.datalen > 0)
13709                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
13710         else
13711                 o_constr.data = NULL;
13712         int8_tArray* o_vals = (void*) o->elems /* XXX o leaks */;
13713         for (size_t m = 0; m < o_constr.datalen; m++) {
13714                 int8_tArray o_conv_12 = o_vals[m];
13715                 LDKCVec_u8Z o_conv_12_ref;
13716                 o_conv_12_ref.datalen = o_conv_12->arr_len;
13717                 o_conv_12_ref.data = MALLOC(o_conv_12_ref.datalen, "LDKCVec_u8Z Bytes");
13718                 memcpy(o_conv_12_ref.data, o_conv_12->elems, o_conv_12_ref.datalen); FREE(o_conv_12);
13719                 o_constr.data[m] = o_conv_12_ref;
13720         }
13721         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
13722         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
13723         return (uint32_t)ret_conv;
13724 }
13725
13726 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_err"))) TS_CResult_CVec_CVec_u8ZZNoneZ_err() {
13727         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
13728         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
13729         return (uint32_t)ret_conv;
13730 }
13731
13732 jboolean  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_is_ok"))) TS_CResult_CVec_CVec_u8ZZNoneZ_is_ok(uint32_t o) {
13733         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(o & ~1);
13734         jboolean ret_conv = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
13735         return ret_conv;
13736 }
13737
13738 void  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_free"))) TS_CResult_CVec_CVec_u8ZZNoneZ_free(uint32_t _res) {
13739         if ((_res & 1) != 0) return;
13740         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13741         CHECK_ACCESS(_res_ptr);
13742         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
13743         FREE((void*)_res);
13744         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
13745 }
13746
13747 static inline uintptr_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
13748         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
13749         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
13750         return (uint32_t)ret_conv;
13751 }
13752 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_clone_ptr"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(uint32_t arg) {
13753         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
13754         uint32_t ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
13755         return ret_conv;
13756 }
13757
13758 uint32_t  __attribute__((export_name("TS_CResult_CVec_CVec_u8ZZNoneZ_clone"))) TS_CResult_CVec_CVec_u8ZZNoneZ_clone(uint32_t orig) {
13759         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
13760         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
13761         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
13762         return (uint32_t)ret_conv;
13763 }
13764
13765 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_ok(uint32_t o) {
13766         LDKInMemorySigner o_conv;
13767         o_conv.inner = (void*)(o & (~1));
13768         o_conv.is_owned = (o & 1) || (o == 0);
13769         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13770         o_conv = InMemorySigner_clone(&o_conv);
13771         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
13772         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
13773         return (uint32_t)ret_conv;
13774 }
13775
13776 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_err"))) TS_CResult_InMemorySignerDecodeErrorZ_err(uint32_t e) {
13777         LDKDecodeError e_conv;
13778         e_conv.inner = (void*)(e & (~1));
13779         e_conv.is_owned = (e & 1) || (e == 0);
13780         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13781         e_conv = DecodeError_clone(&e_conv);
13782         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
13783         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
13784         return (uint32_t)ret_conv;
13785 }
13786
13787 jboolean  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_is_ok"))) TS_CResult_InMemorySignerDecodeErrorZ_is_ok(uint32_t o) {
13788         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(o & ~1);
13789         jboolean ret_conv = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
13790         return ret_conv;
13791 }
13792
13793 void  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_free"))) TS_CResult_InMemorySignerDecodeErrorZ_free(uint32_t _res) {
13794         if ((_res & 1) != 0) return;
13795         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13796         CHECK_ACCESS(_res_ptr);
13797         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
13798         FREE((void*)_res);
13799         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
13800 }
13801
13802 static inline uintptr_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
13803         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
13804         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
13805         return (uint32_t)ret_conv;
13806 }
13807 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_clone_ptr"))) TS_CResult_InMemorySignerDecodeErrorZ_clone_ptr(uint32_t arg) {
13808         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
13809         uint32_t ret_conv = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
13810         return ret_conv;
13811 }
13812
13813 uint32_t  __attribute__((export_name("TS_CResult_InMemorySignerDecodeErrorZ_clone"))) TS_CResult_InMemorySignerDecodeErrorZ_clone(uint32_t orig) {
13814         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
13815         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
13816         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
13817         return (uint32_t)ret_conv;
13818 }
13819
13820 void  __attribute__((export_name("TS_CVec_TxOutZ_free"))) TS_CVec_TxOutZ_free(uint32_tArray _res) {
13821         LDKCVec_TxOutZ _res_constr;
13822         _res_constr.datalen = _res->arr_len;
13823         if (_res_constr.datalen > 0)
13824                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
13825         else
13826                 _res_constr.data = NULL;
13827         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
13828         for (size_t h = 0; h < _res_constr.datalen; h++) {
13829                 uint32_t _res_conv_7 = _res_vals[h];
13830                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
13831                 CHECK_ACCESS(_res_conv_7_ptr);
13832                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
13833                 FREE((void*)_res_conv_7);
13834                 _res_constr.data[h] = _res_conv_7_conv;
13835         }
13836         CVec_TxOutZ_free(_res_constr);
13837 }
13838
13839 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_ok"))) TS_CResult_TransactionNoneZ_ok(int8_tArray o) {
13840         LDKTransaction o_ref;
13841         o_ref.datalen = o->arr_len;
13842         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
13843         memcpy(o_ref.data, o->elems, o_ref.datalen); FREE(o);
13844         o_ref.data_is_owned = true;
13845         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
13846         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
13847         return (uint32_t)ret_conv;
13848 }
13849
13850 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_err"))) TS_CResult_TransactionNoneZ_err() {
13851         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
13852         *ret_conv = CResult_TransactionNoneZ_err();
13853         return (uint32_t)ret_conv;
13854 }
13855
13856 jboolean  __attribute__((export_name("TS_CResult_TransactionNoneZ_is_ok"))) TS_CResult_TransactionNoneZ_is_ok(uint32_t o) {
13857         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)(o & ~1);
13858         jboolean ret_conv = CResult_TransactionNoneZ_is_ok(o_conv);
13859         return ret_conv;
13860 }
13861
13862 void  __attribute__((export_name("TS_CResult_TransactionNoneZ_free"))) TS_CResult_TransactionNoneZ_free(uint32_t _res) {
13863         if ((_res & 1) != 0) return;
13864         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13865         CHECK_ACCESS(_res_ptr);
13866         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
13867         FREE((void*)_res);
13868         CResult_TransactionNoneZ_free(_res_conv);
13869 }
13870
13871 static inline uintptr_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
13872         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
13873         *ret_conv = CResult_TransactionNoneZ_clone(arg);
13874         return (uint32_t)ret_conv;
13875 }
13876 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_clone_ptr"))) TS_CResult_TransactionNoneZ_clone_ptr(uint32_t arg) {
13877         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)(arg & ~1);
13878         uint32_t ret_conv = CResult_TransactionNoneZ_clone_ptr(arg_conv);
13879         return ret_conv;
13880 }
13881
13882 uint32_t  __attribute__((export_name("TS_CResult_TransactionNoneZ_clone"))) TS_CResult_TransactionNoneZ_clone(uint32_t orig) {
13883         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
13884         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
13885         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
13886         return (uint32_t)ret_conv;
13887 }
13888
13889 uint32_t  __attribute__((export_name("TS_COption_u16Z_some"))) TS_COption_u16Z_some(int16_t o) {
13890         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
13891         *ret_copy = COption_u16Z_some(o);
13892         uint32_t ret_ref = (uintptr_t)ret_copy;
13893         return ret_ref;
13894 }
13895
13896 uint32_t  __attribute__((export_name("TS_COption_u16Z_none"))) TS_COption_u16Z_none() {
13897         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
13898         *ret_copy = COption_u16Z_none();
13899         uint32_t ret_ref = (uintptr_t)ret_copy;
13900         return ret_ref;
13901 }
13902
13903 void  __attribute__((export_name("TS_COption_u16Z_free"))) TS_COption_u16Z_free(uint32_t _res) {
13904         if ((_res & 1) != 0) return;
13905         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13906         CHECK_ACCESS(_res_ptr);
13907         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
13908         FREE((void*)_res);
13909         COption_u16Z_free(_res_conv);
13910 }
13911
13912 static inline uintptr_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
13913         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
13914         *ret_copy = COption_u16Z_clone(arg);
13915 uint32_t ret_ref = (uintptr_t)ret_copy;
13916         return ret_ref;
13917 }
13918 uint32_t  __attribute__((export_name("TS_COption_u16Z_clone_ptr"))) TS_COption_u16Z_clone_ptr(uint32_t arg) {
13919         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)arg;
13920         uint32_t ret_conv = COption_u16Z_clone_ptr(arg_conv);
13921         return ret_conv;
13922 }
13923
13924 uint32_t  __attribute__((export_name("TS_COption_u16Z_clone"))) TS_COption_u16Z_clone(uint32_t orig) {
13925         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
13926         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
13927         *ret_copy = COption_u16Z_clone(orig_conv);
13928         uint32_t ret_ref = (uintptr_t)ret_copy;
13929         return ret_ref;
13930 }
13931
13932 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_ok"))) TS_CResult_NoneAPIErrorZ_ok() {
13933         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13934         *ret_conv = CResult_NoneAPIErrorZ_ok();
13935         return (uint32_t)ret_conv;
13936 }
13937
13938 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_err"))) TS_CResult_NoneAPIErrorZ_err(uint32_t e) {
13939         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
13940         CHECK_ACCESS(e_ptr);
13941         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
13942         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
13943         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13944         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
13945         return (uint32_t)ret_conv;
13946 }
13947
13948 jboolean  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_is_ok"))) TS_CResult_NoneAPIErrorZ_is_ok(uint32_t o) {
13949         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)(o & ~1);
13950         jboolean ret_conv = CResult_NoneAPIErrorZ_is_ok(o_conv);
13951         return ret_conv;
13952 }
13953
13954 void  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_free"))) TS_CResult_NoneAPIErrorZ_free(uint32_t _res) {
13955         if ((_res & 1) != 0) return;
13956         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
13957         CHECK_ACCESS(_res_ptr);
13958         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
13959         FREE((void*)_res);
13960         CResult_NoneAPIErrorZ_free(_res_conv);
13961 }
13962
13963 static inline uintptr_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
13964         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13965         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
13966         return (uint32_t)ret_conv;
13967 }
13968 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_clone_ptr"))) TS_CResult_NoneAPIErrorZ_clone_ptr(uint32_t arg) {
13969         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
13970         uint32_t ret_conv = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
13971         return ret_conv;
13972 }
13973
13974 uint32_t  __attribute__((export_name("TS_CResult_NoneAPIErrorZ_clone"))) TS_CResult_NoneAPIErrorZ_clone(uint32_t orig) {
13975         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
13976         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
13977         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
13978         return (uint32_t)ret_conv;
13979 }
13980
13981 void  __attribute__((export_name("TS_CVec_CResult_NoneAPIErrorZZ_free"))) TS_CVec_CResult_NoneAPIErrorZZ_free(uint32_tArray _res) {
13982         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
13983         _res_constr.datalen = _res->arr_len;
13984         if (_res_constr.datalen > 0)
13985                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
13986         else
13987                 _res_constr.data = NULL;
13988         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
13989         for (size_t w = 0; w < _res_constr.datalen; w++) {
13990                 uint32_t _res_conv_22 = _res_vals[w];
13991                 void* _res_conv_22_ptr = (void*)(((uintptr_t)_res_conv_22) & ~1);
13992                 CHECK_ACCESS(_res_conv_22_ptr);
13993                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
13994                 FREE((void*)_res_conv_22);
13995                 _res_constr.data[w] = _res_conv_22_conv;
13996         }
13997         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
13998 }
13999
14000 void  __attribute__((export_name("TS_CVec_APIErrorZ_free"))) TS_CVec_APIErrorZ_free(uint32_tArray _res) {
14001         LDKCVec_APIErrorZ _res_constr;
14002         _res_constr.datalen = _res->arr_len;
14003         if (_res_constr.datalen > 0)
14004                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
14005         else
14006                 _res_constr.data = NULL;
14007         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
14008         for (size_t k = 0; k < _res_constr.datalen; k++) {
14009                 uint32_t _res_conv_10 = _res_vals[k];
14010                 void* _res_conv_10_ptr = (void*)(((uintptr_t)_res_conv_10) & ~1);
14011                 CHECK_ACCESS(_res_conv_10_ptr);
14012                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
14013                 FREE((void*)_res_conv_10);
14014                 _res_constr.data[k] = _res_conv_10_conv;
14015         }
14016         CVec_APIErrorZ_free(_res_constr);
14017 }
14018
14019 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_ok"))) TS_CResult__u832APIErrorZ_ok(int8_tArray o) {
14020         LDKThirtyTwoBytes o_ref;
14021         CHECK(o->arr_len == 32);
14022         memcpy(o_ref.data, o->elems, 32); FREE(o);
14023         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
14024         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
14025         return (uint32_t)ret_conv;
14026 }
14027
14028 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_err"))) TS_CResult__u832APIErrorZ_err(uint32_t e) {
14029         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
14030         CHECK_ACCESS(e_ptr);
14031         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
14032         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
14033         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
14034         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
14035         return (uint32_t)ret_conv;
14036 }
14037
14038 jboolean  __attribute__((export_name("TS_CResult__u832APIErrorZ_is_ok"))) TS_CResult__u832APIErrorZ_is_ok(uint32_t o) {
14039         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)(o & ~1);
14040         jboolean ret_conv = CResult__u832APIErrorZ_is_ok(o_conv);
14041         return ret_conv;
14042 }
14043
14044 void  __attribute__((export_name("TS_CResult__u832APIErrorZ_free"))) TS_CResult__u832APIErrorZ_free(uint32_t _res) {
14045         if ((_res & 1) != 0) return;
14046         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14047         CHECK_ACCESS(_res_ptr);
14048         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
14049         FREE((void*)_res);
14050         CResult__u832APIErrorZ_free(_res_conv);
14051 }
14052
14053 static inline uintptr_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
14054         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
14055         *ret_conv = CResult__u832APIErrorZ_clone(arg);
14056         return (uint32_t)ret_conv;
14057 }
14058 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_clone_ptr"))) TS_CResult__u832APIErrorZ_clone_ptr(uint32_t arg) {
14059         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)(arg & ~1);
14060         uint32_t ret_conv = CResult__u832APIErrorZ_clone_ptr(arg_conv);
14061         return ret_conv;
14062 }
14063
14064 uint32_t  __attribute__((export_name("TS_CResult__u832APIErrorZ_clone"))) TS_CResult__u832APIErrorZ_clone(uint32_t orig) {
14065         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)(orig & ~1);
14066         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
14067         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
14068         return (uint32_t)ret_conv;
14069 }
14070
14071 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_ok(int8_tArray o) {
14072         LDKThirtyTwoBytes o_ref;
14073         CHECK(o->arr_len == 32);
14074         memcpy(o_ref.data, o->elems, 32); FREE(o);
14075         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14076         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_ref);
14077         return (uint32_t)ret_conv;
14078 }
14079
14080 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_err"))) TS_CResult_PaymentIdPaymentSendFailureZ_err(uint32_t e) {
14081         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
14082         CHECK_ACCESS(e_ptr);
14083         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
14084         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
14085         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14086         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
14087         return (uint32_t)ret_conv;
14088 }
14089
14090 jboolean  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_is_ok"))) TS_CResult_PaymentIdPaymentSendFailureZ_is_ok(uint32_t o) {
14091         LDKCResult_PaymentIdPaymentSendFailureZ* o_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(o & ~1);
14092         jboolean ret_conv = CResult_PaymentIdPaymentSendFailureZ_is_ok(o_conv);
14093         return ret_conv;
14094 }
14095
14096 void  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_free"))) TS_CResult_PaymentIdPaymentSendFailureZ_free(uint32_t _res) {
14097         if ((_res & 1) != 0) return;
14098         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14099         CHECK_ACCESS(_res_ptr);
14100         LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
14101         FREE((void*)_res);
14102         CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
14103 }
14104
14105 static inline uintptr_t CResult_PaymentIdPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR arg) {
14106         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14107         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(arg);
14108         return (uint32_t)ret_conv;
14109 }
14110 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_clone_ptr"))) TS_CResult_PaymentIdPaymentSendFailureZ_clone_ptr(uint32_t arg) {
14111         LDKCResult_PaymentIdPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
14112         uint32_t ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone_ptr(arg_conv);
14113         return ret_conv;
14114 }
14115
14116 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentSendFailureZ_clone"))) TS_CResult_PaymentIdPaymentSendFailureZ_clone(uint32_t orig) {
14117         LDKCResult_PaymentIdPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(orig & ~1);
14118         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14119         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(orig_conv);
14120         return (uint32_t)ret_conv;
14121 }
14122
14123 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_ok"))) TS_CResult_NonePaymentSendFailureZ_ok() {
14124         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
14125         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
14126         return (uint32_t)ret_conv;
14127 }
14128
14129 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_err"))) TS_CResult_NonePaymentSendFailureZ_err(uint32_t e) {
14130         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
14131         CHECK_ACCESS(e_ptr);
14132         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
14133         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
14134         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
14135         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
14136         return (uint32_t)ret_conv;
14137 }
14138
14139 jboolean  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_is_ok"))) TS_CResult_NonePaymentSendFailureZ_is_ok(uint32_t o) {
14140         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)(o & ~1);
14141         jboolean ret_conv = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
14142         return ret_conv;
14143 }
14144
14145 void  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_free"))) TS_CResult_NonePaymentSendFailureZ_free(uint32_t _res) {
14146         if ((_res & 1) != 0) return;
14147         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14148         CHECK_ACCESS(_res_ptr);
14149         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
14150         FREE((void*)_res);
14151         CResult_NonePaymentSendFailureZ_free(_res_conv);
14152 }
14153
14154 static inline uintptr_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
14155         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
14156         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
14157         return (uint32_t)ret_conv;
14158 }
14159 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_clone_ptr"))) TS_CResult_NonePaymentSendFailureZ_clone_ptr(uint32_t arg) {
14160         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
14161         uint32_t ret_conv = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
14162         return ret_conv;
14163 }
14164
14165 uint32_t  __attribute__((export_name("TS_CResult_NonePaymentSendFailureZ_clone"))) TS_CResult_NonePaymentSendFailureZ_clone(uint32_t orig) {
14166         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
14167         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
14168         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
14169         return (uint32_t)ret_conv;
14170 }
14171
14172 static inline uintptr_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
14173         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
14174         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
14175         return ((uint32_t)ret_conv);
14176 }
14177 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_clone_ptr"))) TS_C2Tuple_PaymentHashPaymentIdZ_clone_ptr(uint32_t arg) {
14178         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(arg & ~1);
14179         uint32_t ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
14180         return ret_conv;
14181 }
14182
14183 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_clone"))) TS_C2Tuple_PaymentHashPaymentIdZ_clone(uint32_t orig) {
14184         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(orig & ~1);
14185         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
14186         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
14187         return ((uint32_t)ret_conv);
14188 }
14189
14190 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_new"))) TS_C2Tuple_PaymentHashPaymentIdZ_new(int8_tArray a, int8_tArray b) {
14191         LDKThirtyTwoBytes a_ref;
14192         CHECK(a->arr_len == 32);
14193         memcpy(a_ref.data, a->elems, 32); FREE(a);
14194         LDKThirtyTwoBytes b_ref;
14195         CHECK(b->arr_len == 32);
14196         memcpy(b_ref.data, b->elems, 32); FREE(b);
14197         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
14198         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
14199         return ((uint32_t)ret_conv);
14200 }
14201
14202 void  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentIdZ_free"))) TS_C2Tuple_PaymentHashPaymentIdZ_free(uint32_t _res) {
14203         if ((_res & 1) != 0) return;
14204         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14205         CHECK_ACCESS(_res_ptr);
14206         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
14207         FREE((void*)_res);
14208         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
14209 }
14210
14211 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(uint32_t o) {
14212         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14213         CHECK_ACCESS(o_ptr);
14214         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
14215         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)(((uintptr_t)o) & ~1));
14216         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
14217         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
14218         return (uint32_t)ret_conv;
14219 }
14220
14221 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(uint32_t e) {
14222         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
14223         CHECK_ACCESS(e_ptr);
14224         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
14225         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)e) & ~1));
14226         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
14227         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
14228         return (uint32_t)ret_conv;
14229 }
14230
14231 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(uint32_t o) {
14232         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(o & ~1);
14233         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
14234         return ret_conv;
14235 }
14236
14237 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(uint32_t _res) {
14238         if ((_res & 1) != 0) return;
14239         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14240         CHECK_ACCESS(_res_ptr);
14241         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
14242         FREE((void*)_res);
14243         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
14244 }
14245
14246 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
14247         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
14248         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
14249         return (uint32_t)ret_conv;
14250 }
14251 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(uint32_t arg) {
14252         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
14253         uint32_t ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
14254         return ret_conv;
14255 }
14256
14257 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(uint32_t orig) {
14258         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(orig & ~1);
14259         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
14260         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
14261         return (uint32_t)ret_conv;
14262 }
14263
14264 void  __attribute__((export_name("TS_CVec_NetAddressZ_free"))) TS_CVec_NetAddressZ_free(uint32_tArray _res) {
14265         LDKCVec_NetAddressZ _res_constr;
14266         _res_constr.datalen = _res->arr_len;
14267         if (_res_constr.datalen > 0)
14268                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
14269         else
14270                 _res_constr.data = NULL;
14271         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
14272         for (size_t m = 0; m < _res_constr.datalen; m++) {
14273                 uint32_t _res_conv_12 = _res_vals[m];
14274                 void* _res_conv_12_ptr = (void*)(((uintptr_t)_res_conv_12) & ~1);
14275                 CHECK_ACCESS(_res_conv_12_ptr);
14276                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
14277                 FREE((void*)_res_conv_12);
14278                 _res_constr.data[m] = _res_conv_12_conv;
14279         }
14280         CVec_NetAddressZ_free(_res_constr);
14281 }
14282
14283 static inline uintptr_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
14284         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
14285         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
14286         return ((uint32_t)ret_conv);
14287 }
14288 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_clone_ptr"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(uint32_t arg) {
14289         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(arg & ~1);
14290         uint32_t ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
14291         return ret_conv;
14292 }
14293
14294 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_clone"))) TS_C2Tuple_PaymentHashPaymentSecretZ_clone(uint32_t orig) {
14295         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
14296         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
14297         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
14298         return ((uint32_t)ret_conv);
14299 }
14300
14301 uint32_t  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_new"))) TS_C2Tuple_PaymentHashPaymentSecretZ_new(int8_tArray a, int8_tArray b) {
14302         LDKThirtyTwoBytes a_ref;
14303         CHECK(a->arr_len == 32);
14304         memcpy(a_ref.data, a->elems, 32); FREE(a);
14305         LDKThirtyTwoBytes b_ref;
14306         CHECK(b->arr_len == 32);
14307         memcpy(b_ref.data, b->elems, 32); FREE(b);
14308         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
14309         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
14310         return ((uint32_t)ret_conv);
14311 }
14312
14313 void  __attribute__((export_name("TS_C2Tuple_PaymentHashPaymentSecretZ_free"))) TS_C2Tuple_PaymentHashPaymentSecretZ_free(uint32_t _res) {
14314         if ((_res & 1) != 0) return;
14315         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14316         CHECK_ACCESS(_res_ptr);
14317         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
14318         FREE((void*)_res);
14319         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
14320 }
14321
14322 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(uint32_t o) {
14323         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14324         CHECK_ACCESS(o_ptr);
14325         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
14326         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
14327         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
14328         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o_conv);
14329         return (uint32_t)ret_conv;
14330 }
14331
14332 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err() {
14333         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
14334         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err();
14335         return (uint32_t)ret_conv;
14336 }
14337
14338 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(uint32_t o) {
14339         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(o & ~1);
14340         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o_conv);
14341         return ret_conv;
14342 }
14343
14344 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(uint32_t _res) {
14345         if ((_res & 1) != 0) return;
14346         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14347         CHECK_ACCESS(_res_ptr);
14348         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(_res_ptr);
14349         FREE((void*)_res);
14350         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res_conv);
14351 }
14352
14353 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR arg) {
14354         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
14355         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(arg);
14356         return (uint32_t)ret_conv;
14357 }
14358 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(uint32_t arg) {
14359         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(arg & ~1);
14360         uint32_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(arg_conv);
14361         return ret_conv;
14362 }
14363
14364 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(uint32_t orig) {
14365         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(orig & ~1);
14366         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
14367         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig_conv);
14368         return (uint32_t)ret_conv;
14369 }
14370
14371 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(uint32_t o) {
14372         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14373         CHECK_ACCESS(o_ptr);
14374         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
14375         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)(((uintptr_t)o) & ~1));
14376         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
14377         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(o_conv);
14378         return (uint32_t)ret_conv;
14379 }
14380
14381 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(uint32_t e) {
14382         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
14383         CHECK_ACCESS(e_ptr);
14384         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
14385         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
14386         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
14387         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e_conv);
14388         return (uint32_t)ret_conv;
14389 }
14390
14391 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(uint32_t o) {
14392         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(o & ~1);
14393         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(o_conv);
14394         return ret_conv;
14395 }
14396
14397 void  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(uint32_t _res) {
14398         if ((_res & 1) != 0) return;
14399         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14400         CHECK_ACCESS(_res_ptr);
14401         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(_res_ptr);
14402         FREE((void*)_res);
14403         CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(_res_conv);
14404 }
14405
14406 static inline uintptr_t CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR arg) {
14407         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
14408         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(arg);
14409         return (uint32_t)ret_conv;
14410 }
14411 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(uint32_t arg) {
14412         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(arg & ~1);
14413         uint32_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(arg_conv);
14414         return ret_conv;
14415 }
14416
14417 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone"))) TS_CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(uint32_t orig) {
14418         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(orig & ~1);
14419         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
14420         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(orig_conv);
14421         return (uint32_t)ret_conv;
14422 }
14423
14424 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_ok"))) TS_CResult_PaymentSecretNoneZ_ok(int8_tArray o) {
14425         LDKThirtyTwoBytes o_ref;
14426         CHECK(o->arr_len == 32);
14427         memcpy(o_ref.data, o->elems, 32); FREE(o);
14428         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
14429         *ret_conv = CResult_PaymentSecretNoneZ_ok(o_ref);
14430         return (uint32_t)ret_conv;
14431 }
14432
14433 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_err"))) TS_CResult_PaymentSecretNoneZ_err() {
14434         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
14435         *ret_conv = CResult_PaymentSecretNoneZ_err();
14436         return (uint32_t)ret_conv;
14437 }
14438
14439 jboolean  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_is_ok"))) TS_CResult_PaymentSecretNoneZ_is_ok(uint32_t o) {
14440         LDKCResult_PaymentSecretNoneZ* o_conv = (LDKCResult_PaymentSecretNoneZ*)(o & ~1);
14441         jboolean ret_conv = CResult_PaymentSecretNoneZ_is_ok(o_conv);
14442         return ret_conv;
14443 }
14444
14445 void  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_free"))) TS_CResult_PaymentSecretNoneZ_free(uint32_t _res) {
14446         if ((_res & 1) != 0) return;
14447         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14448         CHECK_ACCESS(_res_ptr);
14449         LDKCResult_PaymentSecretNoneZ _res_conv = *(LDKCResult_PaymentSecretNoneZ*)(_res_ptr);
14450         FREE((void*)_res);
14451         CResult_PaymentSecretNoneZ_free(_res_conv);
14452 }
14453
14454 static inline uintptr_t CResult_PaymentSecretNoneZ_clone_ptr(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR arg) {
14455         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
14456         *ret_conv = CResult_PaymentSecretNoneZ_clone(arg);
14457         return (uint32_t)ret_conv;
14458 }
14459 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_clone_ptr"))) TS_CResult_PaymentSecretNoneZ_clone_ptr(uint32_t arg) {
14460         LDKCResult_PaymentSecretNoneZ* arg_conv = (LDKCResult_PaymentSecretNoneZ*)(arg & ~1);
14461         uint32_t ret_conv = CResult_PaymentSecretNoneZ_clone_ptr(arg_conv);
14462         return ret_conv;
14463 }
14464
14465 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretNoneZ_clone"))) TS_CResult_PaymentSecretNoneZ_clone(uint32_t orig) {
14466         LDKCResult_PaymentSecretNoneZ* orig_conv = (LDKCResult_PaymentSecretNoneZ*)(orig & ~1);
14467         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
14468         *ret_conv = CResult_PaymentSecretNoneZ_clone(orig_conv);
14469         return (uint32_t)ret_conv;
14470 }
14471
14472 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_ok"))) TS_CResult_PaymentSecretAPIErrorZ_ok(int8_tArray o) {
14473         LDKThirtyTwoBytes o_ref;
14474         CHECK(o->arr_len == 32);
14475         memcpy(o_ref.data, o->elems, 32); FREE(o);
14476         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
14477         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
14478         return (uint32_t)ret_conv;
14479 }
14480
14481 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_err"))) TS_CResult_PaymentSecretAPIErrorZ_err(uint32_t e) {
14482         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
14483         CHECK_ACCESS(e_ptr);
14484         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
14485         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
14486         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
14487         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
14488         return (uint32_t)ret_conv;
14489 }
14490
14491 jboolean  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_is_ok"))) TS_CResult_PaymentSecretAPIErrorZ_is_ok(uint32_t o) {
14492         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(o & ~1);
14493         jboolean ret_conv = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
14494         return ret_conv;
14495 }
14496
14497 void  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_free"))) TS_CResult_PaymentSecretAPIErrorZ_free(uint32_t _res) {
14498         if ((_res & 1) != 0) return;
14499         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14500         CHECK_ACCESS(_res_ptr);
14501         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
14502         FREE((void*)_res);
14503         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
14504 }
14505
14506 static inline uintptr_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
14507         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
14508         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
14509         return (uint32_t)ret_conv;
14510 }
14511 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_clone_ptr"))) TS_CResult_PaymentSecretAPIErrorZ_clone_ptr(uint32_t arg) {
14512         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
14513         uint32_t ret_conv = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
14514         return ret_conv;
14515 }
14516
14517 uint32_t  __attribute__((export_name("TS_CResult_PaymentSecretAPIErrorZ_clone"))) TS_CResult_PaymentSecretAPIErrorZ_clone(uint32_t orig) {
14518         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
14519         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
14520         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
14521         return (uint32_t)ret_conv;
14522 }
14523
14524 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_ok(int8_tArray o) {
14525         LDKThirtyTwoBytes o_ref;
14526         CHECK(o->arr_len == 32);
14527         memcpy(o_ref.data, o->elems, 32); FREE(o);
14528         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
14529         *ret_conv = CResult_PaymentPreimageAPIErrorZ_ok(o_ref);
14530         return (uint32_t)ret_conv;
14531 }
14532
14533 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_err"))) TS_CResult_PaymentPreimageAPIErrorZ_err(uint32_t e) {
14534         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
14535         CHECK_ACCESS(e_ptr);
14536         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
14537         e_conv = APIError_clone((LDKAPIError*)(((uintptr_t)e) & ~1));
14538         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
14539         *ret_conv = CResult_PaymentPreimageAPIErrorZ_err(e_conv);
14540         return (uint32_t)ret_conv;
14541 }
14542
14543 jboolean  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_is_ok"))) TS_CResult_PaymentPreimageAPIErrorZ_is_ok(uint32_t o) {
14544         LDKCResult_PaymentPreimageAPIErrorZ* o_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(o & ~1);
14545         jboolean ret_conv = CResult_PaymentPreimageAPIErrorZ_is_ok(o_conv);
14546         return ret_conv;
14547 }
14548
14549 void  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_free"))) TS_CResult_PaymentPreimageAPIErrorZ_free(uint32_t _res) {
14550         if ((_res & 1) != 0) return;
14551         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14552         CHECK_ACCESS(_res_ptr);
14553         LDKCResult_PaymentPreimageAPIErrorZ _res_conv = *(LDKCResult_PaymentPreimageAPIErrorZ*)(_res_ptr);
14554         FREE((void*)_res);
14555         CResult_PaymentPreimageAPIErrorZ_free(_res_conv);
14556 }
14557
14558 static inline uintptr_t CResult_PaymentPreimageAPIErrorZ_clone_ptr(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR arg) {
14559         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
14560         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(arg);
14561         return (uint32_t)ret_conv;
14562 }
14563 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_clone_ptr"))) TS_CResult_PaymentPreimageAPIErrorZ_clone_ptr(uint32_t arg) {
14564         LDKCResult_PaymentPreimageAPIErrorZ* arg_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(arg & ~1);
14565         uint32_t ret_conv = CResult_PaymentPreimageAPIErrorZ_clone_ptr(arg_conv);
14566         return ret_conv;
14567 }
14568
14569 uint32_t  __attribute__((export_name("TS_CResult_PaymentPreimageAPIErrorZ_clone"))) TS_CResult_PaymentPreimageAPIErrorZ_clone(uint32_t orig) {
14570         LDKCResult_PaymentPreimageAPIErrorZ* orig_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)(orig & ~1);
14571         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
14572         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(orig_conv);
14573         return (uint32_t)ret_conv;
14574 }
14575
14576 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_ok"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(uint32_t o) {
14577         LDKCounterpartyForwardingInfo o_conv;
14578         o_conv.inner = (void*)(o & (~1));
14579         o_conv.is_owned = (o & 1) || (o == 0);
14580         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14581         o_conv = CounterpartyForwardingInfo_clone(&o_conv);
14582         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
14583         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(o_conv);
14584         return (uint32_t)ret_conv;
14585 }
14586
14587 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_err"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_err(uint32_t e) {
14588         LDKDecodeError e_conv;
14589         e_conv.inner = (void*)(e & (~1));
14590         e_conv.is_owned = (e & 1) || (e == 0);
14591         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14592         e_conv = DecodeError_clone(&e_conv);
14593         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
14594         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e_conv);
14595         return (uint32_t)ret_conv;
14596 }
14597
14598 jboolean  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(uint32_t o) {
14599         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* o_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(o & ~1);
14600         jboolean ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(o_conv);
14601         return ret_conv;
14602 }
14603
14604 void  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_free"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_free(uint32_t _res) {
14605         if ((_res & 1) != 0) return;
14606         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14607         CHECK_ACCESS(_res_ptr);
14608         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(_res_ptr);
14609         FREE((void*)_res);
14610         CResult_CounterpartyForwardingInfoDecodeErrorZ_free(_res_conv);
14611 }
14612
14613 static inline uintptr_t CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR arg) {
14614         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
14615         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(arg);
14616         return (uint32_t)ret_conv;
14617 }
14618 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
14619         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(arg & ~1);
14620         uint32_t ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(arg_conv);
14621         return ret_conv;
14622 }
14623
14624 uint32_t  __attribute__((export_name("TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone"))) TS_CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(uint32_t orig) {
14625         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(orig & ~1);
14626         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
14627         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(orig_conv);
14628         return (uint32_t)ret_conv;
14629 }
14630
14631 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_ok"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_ok(uint32_t o) {
14632         LDKChannelCounterparty o_conv;
14633         o_conv.inner = (void*)(o & (~1));
14634         o_conv.is_owned = (o & 1) || (o == 0);
14635         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14636         o_conv = ChannelCounterparty_clone(&o_conv);
14637         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
14638         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_ok(o_conv);
14639         return (uint32_t)ret_conv;
14640 }
14641
14642 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_err"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_err(uint32_t e) {
14643         LDKDecodeError e_conv;
14644         e_conv.inner = (void*)(e & (~1));
14645         e_conv.is_owned = (e & 1) || (e == 0);
14646         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14647         e_conv = DecodeError_clone(&e_conv);
14648         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
14649         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_err(e_conv);
14650         return (uint32_t)ret_conv;
14651 }
14652
14653 jboolean  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_is_ok"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_is_ok(uint32_t o) {
14654         LDKCResult_ChannelCounterpartyDecodeErrorZ* o_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(o & ~1);
14655         jboolean ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_is_ok(o_conv);
14656         return ret_conv;
14657 }
14658
14659 void  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_free"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_free(uint32_t _res) {
14660         if ((_res & 1) != 0) return;
14661         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14662         CHECK_ACCESS(_res_ptr);
14663         LDKCResult_ChannelCounterpartyDecodeErrorZ _res_conv = *(LDKCResult_ChannelCounterpartyDecodeErrorZ*)(_res_ptr);
14664         FREE((void*)_res);
14665         CResult_ChannelCounterpartyDecodeErrorZ_free(_res_conv);
14666 }
14667
14668 static inline uintptr_t CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR arg) {
14669         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
14670         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(arg);
14671         return (uint32_t)ret_conv;
14672 }
14673 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(uint32_t arg) {
14674         LDKCResult_ChannelCounterpartyDecodeErrorZ* arg_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(arg & ~1);
14675         uint32_t ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(arg_conv);
14676         return ret_conv;
14677 }
14678
14679 uint32_t  __attribute__((export_name("TS_CResult_ChannelCounterpartyDecodeErrorZ_clone"))) TS_CResult_ChannelCounterpartyDecodeErrorZ_clone(uint32_t orig) {
14680         LDKCResult_ChannelCounterpartyDecodeErrorZ* orig_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)(orig & ~1);
14681         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
14682         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(orig_conv);
14683         return (uint32_t)ret_conv;
14684 }
14685
14686 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_ok"))) TS_CResult_ChannelDetailsDecodeErrorZ_ok(uint32_t o) {
14687         LDKChannelDetails o_conv;
14688         o_conv.inner = (void*)(o & (~1));
14689         o_conv.is_owned = (o & 1) || (o == 0);
14690         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14691         o_conv = ChannelDetails_clone(&o_conv);
14692         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
14693         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_ok(o_conv);
14694         return (uint32_t)ret_conv;
14695 }
14696
14697 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_err"))) TS_CResult_ChannelDetailsDecodeErrorZ_err(uint32_t e) {
14698         LDKDecodeError e_conv;
14699         e_conv.inner = (void*)(e & (~1));
14700         e_conv.is_owned = (e & 1) || (e == 0);
14701         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14702         e_conv = DecodeError_clone(&e_conv);
14703         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
14704         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_err(e_conv);
14705         return (uint32_t)ret_conv;
14706 }
14707
14708 jboolean  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_is_ok"))) TS_CResult_ChannelDetailsDecodeErrorZ_is_ok(uint32_t o) {
14709         LDKCResult_ChannelDetailsDecodeErrorZ* o_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(o & ~1);
14710         jboolean ret_conv = CResult_ChannelDetailsDecodeErrorZ_is_ok(o_conv);
14711         return ret_conv;
14712 }
14713
14714 void  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_free"))) TS_CResult_ChannelDetailsDecodeErrorZ_free(uint32_t _res) {
14715         if ((_res & 1) != 0) return;
14716         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14717         CHECK_ACCESS(_res_ptr);
14718         LDKCResult_ChannelDetailsDecodeErrorZ _res_conv = *(LDKCResult_ChannelDetailsDecodeErrorZ*)(_res_ptr);
14719         FREE((void*)_res);
14720         CResult_ChannelDetailsDecodeErrorZ_free(_res_conv);
14721 }
14722
14723 static inline uintptr_t CResult_ChannelDetailsDecodeErrorZ_clone_ptr(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR arg) {
14724         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
14725         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(arg);
14726         return (uint32_t)ret_conv;
14727 }
14728 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelDetailsDecodeErrorZ_clone_ptr(uint32_t arg) {
14729         LDKCResult_ChannelDetailsDecodeErrorZ* arg_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(arg & ~1);
14730         uint32_t ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone_ptr(arg_conv);
14731         return ret_conv;
14732 }
14733
14734 uint32_t  __attribute__((export_name("TS_CResult_ChannelDetailsDecodeErrorZ_clone"))) TS_CResult_ChannelDetailsDecodeErrorZ_clone(uint32_t orig) {
14735         LDKCResult_ChannelDetailsDecodeErrorZ* orig_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)(orig & ~1);
14736         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
14737         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(orig_conv);
14738         return (uint32_t)ret_conv;
14739 }
14740
14741 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_ok"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_ok(uint32_t o) {
14742         LDKPhantomRouteHints o_conv;
14743         o_conv.inner = (void*)(o & (~1));
14744         o_conv.is_owned = (o & 1) || (o == 0);
14745         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14746         o_conv = PhantomRouteHints_clone(&o_conv);
14747         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
14748         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_ok(o_conv);
14749         return (uint32_t)ret_conv;
14750 }
14751
14752 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_err"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_err(uint32_t e) {
14753         LDKDecodeError e_conv;
14754         e_conv.inner = (void*)(e & (~1));
14755         e_conv.is_owned = (e & 1) || (e == 0);
14756         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14757         e_conv = DecodeError_clone(&e_conv);
14758         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
14759         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_err(e_conv);
14760         return (uint32_t)ret_conv;
14761 }
14762
14763 jboolean  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_is_ok"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_is_ok(uint32_t o) {
14764         LDKCResult_PhantomRouteHintsDecodeErrorZ* o_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(o & ~1);
14765         jboolean ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_is_ok(o_conv);
14766         return ret_conv;
14767 }
14768
14769 void  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_free"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_free(uint32_t _res) {
14770         if ((_res & 1) != 0) return;
14771         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14772         CHECK_ACCESS(_res_ptr);
14773         LDKCResult_PhantomRouteHintsDecodeErrorZ _res_conv = *(LDKCResult_PhantomRouteHintsDecodeErrorZ*)(_res_ptr);
14774         FREE((void*)_res);
14775         CResult_PhantomRouteHintsDecodeErrorZ_free(_res_conv);
14776 }
14777
14778 static inline uintptr_t CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR arg) {
14779         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
14780         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(arg);
14781         return (uint32_t)ret_conv;
14782 }
14783 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(uint32_t arg) {
14784         LDKCResult_PhantomRouteHintsDecodeErrorZ* arg_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(arg & ~1);
14785         uint32_t ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(arg_conv);
14786         return ret_conv;
14787 }
14788
14789 uint32_t  __attribute__((export_name("TS_CResult_PhantomRouteHintsDecodeErrorZ_clone"))) TS_CResult_PhantomRouteHintsDecodeErrorZ_clone(uint32_t orig) {
14790         LDKCResult_PhantomRouteHintsDecodeErrorZ* orig_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)(orig & ~1);
14791         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
14792         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(orig_conv);
14793         return (uint32_t)ret_conv;
14794 }
14795
14796 void  __attribute__((export_name("TS_CVec_ChannelMonitorZ_free"))) TS_CVec_ChannelMonitorZ_free(uint32_tArray _res) {
14797         LDKCVec_ChannelMonitorZ _res_constr;
14798         _res_constr.datalen = _res->arr_len;
14799         if (_res_constr.datalen > 0)
14800                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
14801         else
14802                 _res_constr.data = NULL;
14803         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
14804         for (size_t q = 0; q < _res_constr.datalen; q++) {
14805                 uint32_t _res_conv_16 = _res_vals[q];
14806                 LDKChannelMonitor _res_conv_16_conv;
14807                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
14808                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
14809                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
14810                 _res_constr.data[q] = _res_conv_16_conv;
14811         }
14812         CVec_ChannelMonitorZ_free(_res_constr);
14813 }
14814
14815 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_new"))) TS_C2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
14816         LDKThirtyTwoBytes a_ref;
14817         CHECK(a->arr_len == 32);
14818         memcpy(a_ref.data, a->elems, 32); FREE(a);
14819         LDKChannelManager b_conv;
14820         b_conv.inner = (void*)(b & (~1));
14821         b_conv.is_owned = (b & 1) || (b == 0);
14822         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
14823         // WARNING: we need a move here but no clone is available for LDKChannelManager
14824         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
14825         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
14826         return ((uint32_t)ret_conv);
14827 }
14828
14829 void  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_free"))) TS_C2Tuple_BlockHashChannelManagerZ_free(uint32_t _res) {
14830         if ((_res & 1) != 0) return;
14831         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14832         CHECK_ACCESS(_res_ptr);
14833         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
14834         FREE((void*)_res);
14835         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
14836 }
14837
14838 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(uint32_t o) {
14839         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14840         CHECK_ACCESS(o_ptr);
14841         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
14842         // WARNING: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
14843         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
14844         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
14845         return (uint32_t)ret_conv;
14846 }
14847
14848 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(uint32_t e) {
14849         LDKDecodeError e_conv;
14850         e_conv.inner = (void*)(e & (~1));
14851         e_conv.is_owned = (e & 1) || (e == 0);
14852         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14853         e_conv = DecodeError_clone(&e_conv);
14854         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
14855         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
14856         return (uint32_t)ret_conv;
14857 }
14858
14859 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(uint32_t o) {
14860         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(o & ~1);
14861         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
14862         return ret_conv;
14863 }
14864
14865 void  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(uint32_t _res) {
14866         if ((_res & 1) != 0) return;
14867         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14868         CHECK_ACCESS(_res_ptr);
14869         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
14870         FREE((void*)_res);
14871         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
14872 }
14873
14874 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_ok(uint32_t o) {
14875         LDKChannelConfig o_conv;
14876         o_conv.inner = (void*)(o & (~1));
14877         o_conv.is_owned = (o & 1) || (o == 0);
14878         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14879         o_conv = ChannelConfig_clone(&o_conv);
14880         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
14881         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
14882         return (uint32_t)ret_conv;
14883 }
14884
14885 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_err"))) TS_CResult_ChannelConfigDecodeErrorZ_err(uint32_t e) {
14886         LDKDecodeError e_conv;
14887         e_conv.inner = (void*)(e & (~1));
14888         e_conv.is_owned = (e & 1) || (e == 0);
14889         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14890         e_conv = DecodeError_clone(&e_conv);
14891         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
14892         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
14893         return (uint32_t)ret_conv;
14894 }
14895
14896 jboolean  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_is_ok"))) TS_CResult_ChannelConfigDecodeErrorZ_is_ok(uint32_t o) {
14897         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(o & ~1);
14898         jboolean ret_conv = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
14899         return ret_conv;
14900 }
14901
14902 void  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_free"))) TS_CResult_ChannelConfigDecodeErrorZ_free(uint32_t _res) {
14903         if ((_res & 1) != 0) return;
14904         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14905         CHECK_ACCESS(_res_ptr);
14906         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
14907         FREE((void*)_res);
14908         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
14909 }
14910
14911 static inline uintptr_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
14912         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
14913         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
14914         return (uint32_t)ret_conv;
14915 }
14916 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelConfigDecodeErrorZ_clone_ptr(uint32_t arg) {
14917         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
14918         uint32_t ret_conv = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
14919         return ret_conv;
14920 }
14921
14922 uint32_t  __attribute__((export_name("TS_CResult_ChannelConfigDecodeErrorZ_clone"))) TS_CResult_ChannelConfigDecodeErrorZ_clone(uint32_t orig) {
14923         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
14924         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
14925         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
14926         return (uint32_t)ret_conv;
14927 }
14928
14929 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_ok"))) TS_CResult_OutPointDecodeErrorZ_ok(uint32_t o) {
14930         LDKOutPoint o_conv;
14931         o_conv.inner = (void*)(o & (~1));
14932         o_conv.is_owned = (o & 1) || (o == 0);
14933         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14934         o_conv = OutPoint_clone(&o_conv);
14935         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14936         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
14937         return (uint32_t)ret_conv;
14938 }
14939
14940 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_err"))) TS_CResult_OutPointDecodeErrorZ_err(uint32_t e) {
14941         LDKDecodeError e_conv;
14942         e_conv.inner = (void*)(e & (~1));
14943         e_conv.is_owned = (e & 1) || (e == 0);
14944         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14945         e_conv = DecodeError_clone(&e_conv);
14946         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14947         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
14948         return (uint32_t)ret_conv;
14949 }
14950
14951 jboolean  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_is_ok"))) TS_CResult_OutPointDecodeErrorZ_is_ok(uint32_t o) {
14952         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)(o & ~1);
14953         jboolean ret_conv = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
14954         return ret_conv;
14955 }
14956
14957 void  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_free"))) TS_CResult_OutPointDecodeErrorZ_free(uint32_t _res) {
14958         if ((_res & 1) != 0) return;
14959         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
14960         CHECK_ACCESS(_res_ptr);
14961         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
14962         FREE((void*)_res);
14963         CResult_OutPointDecodeErrorZ_free(_res_conv);
14964 }
14965
14966 static inline uintptr_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
14967         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14968         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
14969         return (uint32_t)ret_conv;
14970 }
14971 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_clone_ptr"))) TS_CResult_OutPointDecodeErrorZ_clone_ptr(uint32_t arg) {
14972         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
14973         uint32_t ret_conv = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
14974         return ret_conv;
14975 }
14976
14977 uint32_t  __attribute__((export_name("TS_CResult_OutPointDecodeErrorZ_clone"))) TS_CResult_OutPointDecodeErrorZ_clone(uint32_t orig) {
14978         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
14979         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14980         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
14981         return (uint32_t)ret_conv;
14982 }
14983
14984 uint32_t  __attribute__((export_name("TS_COption_TypeZ_some"))) TS_COption_TypeZ_some(uint32_t o) {
14985         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
14986         CHECK_ACCESS(o_ptr);
14987         LDKType o_conv = *(LDKType*)(o_ptr);
14988         if (o_conv.free == LDKType_JCalls_free) {
14989                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14990                 LDKType_JCalls_cloned(&o_conv);
14991         }
14992         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
14993         *ret_copy = COption_TypeZ_some(o_conv);
14994         uint32_t ret_ref = (uintptr_t)ret_copy;
14995         return ret_ref;
14996 }
14997
14998 uint32_t  __attribute__((export_name("TS_COption_TypeZ_none"))) TS_COption_TypeZ_none() {
14999         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
15000         *ret_copy = COption_TypeZ_none();
15001         uint32_t ret_ref = (uintptr_t)ret_copy;
15002         return ret_ref;
15003 }
15004
15005 void  __attribute__((export_name("TS_COption_TypeZ_free"))) TS_COption_TypeZ_free(uint32_t _res) {
15006         if ((_res & 1) != 0) return;
15007         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15008         CHECK_ACCESS(_res_ptr);
15009         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
15010         FREE((void*)_res);
15011         COption_TypeZ_free(_res_conv);
15012 }
15013
15014 static inline uintptr_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
15015         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
15016         *ret_copy = COption_TypeZ_clone(arg);
15017 uint32_t ret_ref = (uintptr_t)ret_copy;
15018         return ret_ref;
15019 }
15020 uint32_t  __attribute__((export_name("TS_COption_TypeZ_clone_ptr"))) TS_COption_TypeZ_clone_ptr(uint32_t arg) {
15021         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)arg;
15022         uint32_t ret_conv = COption_TypeZ_clone_ptr(arg_conv);
15023         return ret_conv;
15024 }
15025
15026 uint32_t  __attribute__((export_name("TS_COption_TypeZ_clone"))) TS_COption_TypeZ_clone(uint32_t orig) {
15027         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig;
15028         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
15029         *ret_copy = COption_TypeZ_clone(orig_conv);
15030         uint32_t ret_ref = (uintptr_t)ret_copy;
15031         return ret_ref;
15032 }
15033
15034 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_ok(uint32_t o) {
15035         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15036         CHECK_ACCESS(o_ptr);
15037         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
15038         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uintptr_t)o) & ~1));
15039         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
15040         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
15041         return (uint32_t)ret_conv;
15042 }
15043
15044 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_err"))) TS_CResult_COption_TypeZDecodeErrorZ_err(uint32_t e) {
15045         LDKDecodeError e_conv;
15046         e_conv.inner = (void*)(e & (~1));
15047         e_conv.is_owned = (e & 1) || (e == 0);
15048         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15049         e_conv = DecodeError_clone(&e_conv);
15050         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
15051         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
15052         return (uint32_t)ret_conv;
15053 }
15054
15055 jboolean  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_is_ok"))) TS_CResult_COption_TypeZDecodeErrorZ_is_ok(uint32_t o) {
15056         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(o & ~1);
15057         jboolean ret_conv = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
15058         return ret_conv;
15059 }
15060
15061 void  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_free"))) TS_CResult_COption_TypeZDecodeErrorZ_free(uint32_t _res) {
15062         if ((_res & 1) != 0) return;
15063         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15064         CHECK_ACCESS(_res_ptr);
15065         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
15066         FREE((void*)_res);
15067         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
15068 }
15069
15070 static inline uintptr_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
15071         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
15072         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
15073         return (uint32_t)ret_conv;
15074 }
15075 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_TypeZDecodeErrorZ_clone_ptr(uint32_t arg) {
15076         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
15077         uint32_t ret_conv = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
15078         return ret_conv;
15079 }
15080
15081 uint32_t  __attribute__((export_name("TS_CResult_COption_TypeZDecodeErrorZ_clone"))) TS_CResult_COption_TypeZDecodeErrorZ_clone(uint32_t orig) {
15082         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1);
15083         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
15084         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
15085         return (uint32_t)ret_conv;
15086 }
15087
15088 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_ok"))) TS_CResult_PaymentIdPaymentErrorZ_ok(int8_tArray o) {
15089         LDKThirtyTwoBytes o_ref;
15090         CHECK(o->arr_len == 32);
15091         memcpy(o_ref.data, o->elems, 32); FREE(o);
15092         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
15093         *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
15094         return (uint32_t)ret_conv;
15095 }
15096
15097 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_err"))) TS_CResult_PaymentIdPaymentErrorZ_err(uint32_t e) {
15098         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15099         CHECK_ACCESS(e_ptr);
15100         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
15101         e_conv = PaymentError_clone((LDKPaymentError*)(((uintptr_t)e) & ~1));
15102         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
15103         *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
15104         return (uint32_t)ret_conv;
15105 }
15106
15107 jboolean  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_is_ok"))) TS_CResult_PaymentIdPaymentErrorZ_is_ok(uint32_t o) {
15108         LDKCResult_PaymentIdPaymentErrorZ* o_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(o & ~1);
15109         jboolean ret_conv = CResult_PaymentIdPaymentErrorZ_is_ok(o_conv);
15110         return ret_conv;
15111 }
15112
15113 void  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_free"))) TS_CResult_PaymentIdPaymentErrorZ_free(uint32_t _res) {
15114         if ((_res & 1) != 0) return;
15115         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15116         CHECK_ACCESS(_res_ptr);
15117         LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
15118         FREE((void*)_res);
15119         CResult_PaymentIdPaymentErrorZ_free(_res_conv);
15120 }
15121
15122 static inline uintptr_t CResult_PaymentIdPaymentErrorZ_clone_ptr(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR arg) {
15123         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
15124         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(arg);
15125         return (uint32_t)ret_conv;
15126 }
15127 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_clone_ptr"))) TS_CResult_PaymentIdPaymentErrorZ_clone_ptr(uint32_t arg) {
15128         LDKCResult_PaymentIdPaymentErrorZ* arg_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
15129         uint32_t ret_conv = CResult_PaymentIdPaymentErrorZ_clone_ptr(arg_conv);
15130         return ret_conv;
15131 }
15132
15133 uint32_t  __attribute__((export_name("TS_CResult_PaymentIdPaymentErrorZ_clone"))) TS_CResult_PaymentIdPaymentErrorZ_clone(uint32_t orig) {
15134         LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(orig & ~1);
15135         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
15136         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(orig_conv);
15137         return (uint32_t)ret_conv;
15138 }
15139
15140 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_ok"))) TS_CResult_SiPrefixParseErrorZ_ok(uint32_t o) {
15141         LDKSiPrefix o_conv = LDKSiPrefix_from_js(o);
15142         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
15143         *ret_conv = CResult_SiPrefixParseErrorZ_ok(o_conv);
15144         return (uint32_t)ret_conv;
15145 }
15146
15147 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_err"))) TS_CResult_SiPrefixParseErrorZ_err(uint32_t e) {
15148         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15149         CHECK_ACCESS(e_ptr);
15150         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
15151         e_conv = ParseError_clone((LDKParseError*)(((uintptr_t)e) & ~1));
15152         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
15153         *ret_conv = CResult_SiPrefixParseErrorZ_err(e_conv);
15154         return (uint32_t)ret_conv;
15155 }
15156
15157 jboolean  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_is_ok"))) TS_CResult_SiPrefixParseErrorZ_is_ok(uint32_t o) {
15158         LDKCResult_SiPrefixParseErrorZ* o_conv = (LDKCResult_SiPrefixParseErrorZ*)(o & ~1);
15159         jboolean ret_conv = CResult_SiPrefixParseErrorZ_is_ok(o_conv);
15160         return ret_conv;
15161 }
15162
15163 void  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_free"))) TS_CResult_SiPrefixParseErrorZ_free(uint32_t _res) {
15164         if ((_res & 1) != 0) return;
15165         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15166         CHECK_ACCESS(_res_ptr);
15167         LDKCResult_SiPrefixParseErrorZ _res_conv = *(LDKCResult_SiPrefixParseErrorZ*)(_res_ptr);
15168         FREE((void*)_res);
15169         CResult_SiPrefixParseErrorZ_free(_res_conv);
15170 }
15171
15172 static inline uintptr_t CResult_SiPrefixParseErrorZ_clone_ptr(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR arg) {
15173         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
15174         *ret_conv = CResult_SiPrefixParseErrorZ_clone(arg);
15175         return (uint32_t)ret_conv;
15176 }
15177 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_clone_ptr"))) TS_CResult_SiPrefixParseErrorZ_clone_ptr(uint32_t arg) {
15178         LDKCResult_SiPrefixParseErrorZ* arg_conv = (LDKCResult_SiPrefixParseErrorZ*)(arg & ~1);
15179         uint32_t ret_conv = CResult_SiPrefixParseErrorZ_clone_ptr(arg_conv);
15180         return ret_conv;
15181 }
15182
15183 uint32_t  __attribute__((export_name("TS_CResult_SiPrefixParseErrorZ_clone"))) TS_CResult_SiPrefixParseErrorZ_clone(uint32_t orig) {
15184         LDKCResult_SiPrefixParseErrorZ* orig_conv = (LDKCResult_SiPrefixParseErrorZ*)(orig & ~1);
15185         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
15186         *ret_conv = CResult_SiPrefixParseErrorZ_clone(orig_conv);
15187         return (uint32_t)ret_conv;
15188 }
15189
15190 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_ok"))) TS_CResult_InvoiceParseOrSemanticErrorZ_ok(uint32_t o) {
15191         LDKInvoice o_conv;
15192         o_conv.inner = (void*)(o & (~1));
15193         o_conv.is_owned = (o & 1) || (o == 0);
15194         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15195         o_conv = Invoice_clone(&o_conv);
15196         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
15197         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_ok(o_conv);
15198         return (uint32_t)ret_conv;
15199 }
15200
15201 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_err"))) TS_CResult_InvoiceParseOrSemanticErrorZ_err(uint32_t e) {
15202         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15203         CHECK_ACCESS(e_ptr);
15204         LDKParseOrSemanticError e_conv = *(LDKParseOrSemanticError*)(e_ptr);
15205         e_conv = ParseOrSemanticError_clone((LDKParseOrSemanticError*)(((uintptr_t)e) & ~1));
15206         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
15207         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_err(e_conv);
15208         return (uint32_t)ret_conv;
15209 }
15210
15211 jboolean  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_is_ok"))) TS_CResult_InvoiceParseOrSemanticErrorZ_is_ok(uint32_t o) {
15212         LDKCResult_InvoiceParseOrSemanticErrorZ* o_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(o & ~1);
15213         jboolean ret_conv = CResult_InvoiceParseOrSemanticErrorZ_is_ok(o_conv);
15214         return ret_conv;
15215 }
15216
15217 void  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_free"))) TS_CResult_InvoiceParseOrSemanticErrorZ_free(uint32_t _res) {
15218         if ((_res & 1) != 0) return;
15219         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15220         CHECK_ACCESS(_res_ptr);
15221         LDKCResult_InvoiceParseOrSemanticErrorZ _res_conv = *(LDKCResult_InvoiceParseOrSemanticErrorZ*)(_res_ptr);
15222         FREE((void*)_res);
15223         CResult_InvoiceParseOrSemanticErrorZ_free(_res_conv);
15224 }
15225
15226 static inline uintptr_t CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR arg) {
15227         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
15228         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(arg);
15229         return (uint32_t)ret_conv;
15230 }
15231 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_clone_ptr"))) TS_CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(uint32_t arg) {
15232         LDKCResult_InvoiceParseOrSemanticErrorZ* arg_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(arg & ~1);
15233         uint32_t ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(arg_conv);
15234         return ret_conv;
15235 }
15236
15237 uint32_t  __attribute__((export_name("TS_CResult_InvoiceParseOrSemanticErrorZ_clone"))) TS_CResult_InvoiceParseOrSemanticErrorZ_clone(uint32_t orig) {
15238         LDKCResult_InvoiceParseOrSemanticErrorZ* orig_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)(orig & ~1);
15239         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
15240         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(orig_conv);
15241         return (uint32_t)ret_conv;
15242 }
15243
15244 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_ok"))) TS_CResult_SignedRawInvoiceParseErrorZ_ok(uint32_t o) {
15245         LDKSignedRawInvoice o_conv;
15246         o_conv.inner = (void*)(o & (~1));
15247         o_conv.is_owned = (o & 1) || (o == 0);
15248         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15249         o_conv = SignedRawInvoice_clone(&o_conv);
15250         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
15251         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_ok(o_conv);
15252         return (uint32_t)ret_conv;
15253 }
15254
15255 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_err"))) TS_CResult_SignedRawInvoiceParseErrorZ_err(uint32_t e) {
15256         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
15257         CHECK_ACCESS(e_ptr);
15258         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
15259         e_conv = ParseError_clone((LDKParseError*)(((uintptr_t)e) & ~1));
15260         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
15261         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_err(e_conv);
15262         return (uint32_t)ret_conv;
15263 }
15264
15265 jboolean  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_is_ok"))) TS_CResult_SignedRawInvoiceParseErrorZ_is_ok(uint32_t o) {
15266         LDKCResult_SignedRawInvoiceParseErrorZ* o_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(o & ~1);
15267         jboolean ret_conv = CResult_SignedRawInvoiceParseErrorZ_is_ok(o_conv);
15268         return ret_conv;
15269 }
15270
15271 void  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_free"))) TS_CResult_SignedRawInvoiceParseErrorZ_free(uint32_t _res) {
15272         if ((_res & 1) != 0) return;
15273         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15274         CHECK_ACCESS(_res_ptr);
15275         LDKCResult_SignedRawInvoiceParseErrorZ _res_conv = *(LDKCResult_SignedRawInvoiceParseErrorZ*)(_res_ptr);
15276         FREE((void*)_res);
15277         CResult_SignedRawInvoiceParseErrorZ_free(_res_conv);
15278 }
15279
15280 static inline uintptr_t CResult_SignedRawInvoiceParseErrorZ_clone_ptr(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR arg) {
15281         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
15282         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(arg);
15283         return (uint32_t)ret_conv;
15284 }
15285 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_clone_ptr"))) TS_CResult_SignedRawInvoiceParseErrorZ_clone_ptr(uint32_t arg) {
15286         LDKCResult_SignedRawInvoiceParseErrorZ* arg_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(arg & ~1);
15287         uint32_t ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone_ptr(arg_conv);
15288         return ret_conv;
15289 }
15290
15291 uint32_t  __attribute__((export_name("TS_CResult_SignedRawInvoiceParseErrorZ_clone"))) TS_CResult_SignedRawInvoiceParseErrorZ_clone(uint32_t orig) {
15292         LDKCResult_SignedRawInvoiceParseErrorZ* orig_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)(orig & ~1);
15293         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
15294         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(orig_conv);
15295         return (uint32_t)ret_conv;
15296 }
15297
15298 static inline uintptr_t C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR arg) {
15299         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
15300         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(arg);
15301         return ((uint32_t)ret_conv);
15302 }
15303 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(uint32_t arg) {
15304         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* arg_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(arg & ~1);
15305         uint32_t ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(arg_conv);
15306         return ret_conv;
15307 }
15308
15309 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(uint32_t orig) {
15310         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
15311         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
15312         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
15313         return ((uint32_t)ret_conv);
15314 }
15315
15316 uint32_t  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_new"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(uint32_t a, int8_tArray b, uint32_t c) {
15317         LDKRawInvoice a_conv;
15318         a_conv.inner = (void*)(a & (~1));
15319         a_conv.is_owned = (a & 1) || (a == 0);
15320         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
15321         a_conv = RawInvoice_clone(&a_conv);
15322         LDKThirtyTwoBytes b_ref;
15323         CHECK(b->arr_len == 32);
15324         memcpy(b_ref.data, b->elems, 32); FREE(b);
15325         LDKInvoiceSignature c_conv;
15326         c_conv.inner = (void*)(c & (~1));
15327         c_conv.is_owned = (c & 1) || (c == 0);
15328         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
15329         c_conv = InvoiceSignature_clone(&c_conv);
15330         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
15331         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
15332         return ((uint32_t)ret_conv);
15333 }
15334
15335 void  __attribute__((export_name("TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_free"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(uint32_t _res) {
15336         if ((_res & 1) != 0) return;
15337         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15338         CHECK_ACCESS(_res_ptr);
15339         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
15340         FREE((void*)_res);
15341         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
15342 }
15343
15344 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_ok"))) TS_CResult_PayeePubKeyErrorZ_ok(uint32_t o) {
15345         LDKPayeePubKey o_conv;
15346         o_conv.inner = (void*)(o & (~1));
15347         o_conv.is_owned = (o & 1) || (o == 0);
15348         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15349         o_conv = PayeePubKey_clone(&o_conv);
15350         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
15351         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
15352         return (uint32_t)ret_conv;
15353 }
15354
15355 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_err"))) TS_CResult_PayeePubKeyErrorZ_err(uint32_t e) {
15356         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
15357         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
15358         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
15359         return (uint32_t)ret_conv;
15360 }
15361
15362 jboolean  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_is_ok"))) TS_CResult_PayeePubKeyErrorZ_is_ok(uint32_t o) {
15363         LDKCResult_PayeePubKeyErrorZ* o_conv = (LDKCResult_PayeePubKeyErrorZ*)(o & ~1);
15364         jboolean ret_conv = CResult_PayeePubKeyErrorZ_is_ok(o_conv);
15365         return ret_conv;
15366 }
15367
15368 void  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_free"))) TS_CResult_PayeePubKeyErrorZ_free(uint32_t _res) {
15369         if ((_res & 1) != 0) return;
15370         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15371         CHECK_ACCESS(_res_ptr);
15372         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
15373         FREE((void*)_res);
15374         CResult_PayeePubKeyErrorZ_free(_res_conv);
15375 }
15376
15377 static inline uintptr_t CResult_PayeePubKeyErrorZ_clone_ptr(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR arg) {
15378         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
15379         *ret_conv = CResult_PayeePubKeyErrorZ_clone(arg);
15380         return (uint32_t)ret_conv;
15381 }
15382 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_clone_ptr"))) TS_CResult_PayeePubKeyErrorZ_clone_ptr(uint32_t arg) {
15383         LDKCResult_PayeePubKeyErrorZ* arg_conv = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
15384         uint32_t ret_conv = CResult_PayeePubKeyErrorZ_clone_ptr(arg_conv);
15385         return ret_conv;
15386 }
15387
15388 uint32_t  __attribute__((export_name("TS_CResult_PayeePubKeyErrorZ_clone"))) TS_CResult_PayeePubKeyErrorZ_clone(uint32_t orig) {
15389         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
15390         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
15391         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
15392         return (uint32_t)ret_conv;
15393 }
15394
15395 void  __attribute__((export_name("TS_CVec_PrivateRouteZ_free"))) TS_CVec_PrivateRouteZ_free(uint32_tArray _res) {
15396         LDKCVec_PrivateRouteZ _res_constr;
15397         _res_constr.datalen = _res->arr_len;
15398         if (_res_constr.datalen > 0)
15399                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
15400         else
15401                 _res_constr.data = NULL;
15402         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
15403         for (size_t o = 0; o < _res_constr.datalen; o++) {
15404                 uint32_t _res_conv_14 = _res_vals[o];
15405                 LDKPrivateRoute _res_conv_14_conv;
15406                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
15407                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
15408                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
15409                 _res_constr.data[o] = _res_conv_14_conv;
15410         }
15411         CVec_PrivateRouteZ_free(_res_constr);
15412 }
15413
15414 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_ok"))) TS_CResult_PositiveTimestampCreationErrorZ_ok(uint32_t o) {
15415         LDKPositiveTimestamp o_conv;
15416         o_conv.inner = (void*)(o & (~1));
15417         o_conv.is_owned = (o & 1) || (o == 0);
15418         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15419         o_conv = PositiveTimestamp_clone(&o_conv);
15420         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
15421         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
15422         return (uint32_t)ret_conv;
15423 }
15424
15425 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_err"))) TS_CResult_PositiveTimestampCreationErrorZ_err(uint32_t e) {
15426         LDKCreationError e_conv = LDKCreationError_from_js(e);
15427         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
15428         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
15429         return (uint32_t)ret_conv;
15430 }
15431
15432 jboolean  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_is_ok"))) TS_CResult_PositiveTimestampCreationErrorZ_is_ok(uint32_t o) {
15433         LDKCResult_PositiveTimestampCreationErrorZ* o_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(o & ~1);
15434         jboolean ret_conv = CResult_PositiveTimestampCreationErrorZ_is_ok(o_conv);
15435         return ret_conv;
15436 }
15437
15438 void  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_free"))) TS_CResult_PositiveTimestampCreationErrorZ_free(uint32_t _res) {
15439         if ((_res & 1) != 0) return;
15440         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15441         CHECK_ACCESS(_res_ptr);
15442         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
15443         FREE((void*)_res);
15444         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
15445 }
15446
15447 static inline uintptr_t CResult_PositiveTimestampCreationErrorZ_clone_ptr(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR arg) {
15448         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
15449         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(arg);
15450         return (uint32_t)ret_conv;
15451 }
15452 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_clone_ptr"))) TS_CResult_PositiveTimestampCreationErrorZ_clone_ptr(uint32_t arg) {
15453         LDKCResult_PositiveTimestampCreationErrorZ* arg_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
15454         uint32_t ret_conv = CResult_PositiveTimestampCreationErrorZ_clone_ptr(arg_conv);
15455         return ret_conv;
15456 }
15457
15458 uint32_t  __attribute__((export_name("TS_CResult_PositiveTimestampCreationErrorZ_clone"))) TS_CResult_PositiveTimestampCreationErrorZ_clone(uint32_t orig) {
15459         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
15460         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
15461         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
15462         return (uint32_t)ret_conv;
15463 }
15464
15465 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_ok"))) TS_CResult_NoneSemanticErrorZ_ok() {
15466         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
15467         *ret_conv = CResult_NoneSemanticErrorZ_ok();
15468         return (uint32_t)ret_conv;
15469 }
15470
15471 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_err"))) TS_CResult_NoneSemanticErrorZ_err(uint32_t e) {
15472         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
15473         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
15474         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
15475         return (uint32_t)ret_conv;
15476 }
15477
15478 jboolean  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_is_ok"))) TS_CResult_NoneSemanticErrorZ_is_ok(uint32_t o) {
15479         LDKCResult_NoneSemanticErrorZ* o_conv = (LDKCResult_NoneSemanticErrorZ*)(o & ~1);
15480         jboolean ret_conv = CResult_NoneSemanticErrorZ_is_ok(o_conv);
15481         return ret_conv;
15482 }
15483
15484 void  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_free"))) TS_CResult_NoneSemanticErrorZ_free(uint32_t _res) {
15485         if ((_res & 1) != 0) return;
15486         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15487         CHECK_ACCESS(_res_ptr);
15488         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
15489         FREE((void*)_res);
15490         CResult_NoneSemanticErrorZ_free(_res_conv);
15491 }
15492
15493 static inline uintptr_t CResult_NoneSemanticErrorZ_clone_ptr(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR arg) {
15494         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
15495         *ret_conv = CResult_NoneSemanticErrorZ_clone(arg);
15496         return (uint32_t)ret_conv;
15497 }
15498 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_clone_ptr"))) TS_CResult_NoneSemanticErrorZ_clone_ptr(uint32_t arg) {
15499         LDKCResult_NoneSemanticErrorZ* arg_conv = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
15500         uint32_t ret_conv = CResult_NoneSemanticErrorZ_clone_ptr(arg_conv);
15501         return ret_conv;
15502 }
15503
15504 uint32_t  __attribute__((export_name("TS_CResult_NoneSemanticErrorZ_clone"))) TS_CResult_NoneSemanticErrorZ_clone(uint32_t orig) {
15505         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
15506         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
15507         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
15508         return (uint32_t)ret_conv;
15509 }
15510
15511 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_ok"))) TS_CResult_InvoiceSemanticErrorZ_ok(uint32_t o) {
15512         LDKInvoice o_conv;
15513         o_conv.inner = (void*)(o & (~1));
15514         o_conv.is_owned = (o & 1) || (o == 0);
15515         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15516         o_conv = Invoice_clone(&o_conv);
15517         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
15518         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
15519         return (uint32_t)ret_conv;
15520 }
15521
15522 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_err"))) TS_CResult_InvoiceSemanticErrorZ_err(uint32_t e) {
15523         LDKSemanticError e_conv = LDKSemanticError_from_js(e);
15524         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
15525         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
15526         return (uint32_t)ret_conv;
15527 }
15528
15529 jboolean  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_is_ok"))) TS_CResult_InvoiceSemanticErrorZ_is_ok(uint32_t o) {
15530         LDKCResult_InvoiceSemanticErrorZ* o_conv = (LDKCResult_InvoiceSemanticErrorZ*)(o & ~1);
15531         jboolean ret_conv = CResult_InvoiceSemanticErrorZ_is_ok(o_conv);
15532         return ret_conv;
15533 }
15534
15535 void  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_free"))) TS_CResult_InvoiceSemanticErrorZ_free(uint32_t _res) {
15536         if ((_res & 1) != 0) return;
15537         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15538         CHECK_ACCESS(_res_ptr);
15539         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
15540         FREE((void*)_res);
15541         CResult_InvoiceSemanticErrorZ_free(_res_conv);
15542 }
15543
15544 static inline uintptr_t CResult_InvoiceSemanticErrorZ_clone_ptr(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR arg) {
15545         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
15546         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(arg);
15547         return (uint32_t)ret_conv;
15548 }
15549 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_clone_ptr"))) TS_CResult_InvoiceSemanticErrorZ_clone_ptr(uint32_t arg) {
15550         LDKCResult_InvoiceSemanticErrorZ* arg_conv = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
15551         uint32_t ret_conv = CResult_InvoiceSemanticErrorZ_clone_ptr(arg_conv);
15552         return ret_conv;
15553 }
15554
15555 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSemanticErrorZ_clone"))) TS_CResult_InvoiceSemanticErrorZ_clone(uint32_t orig) {
15556         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
15557         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
15558         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
15559         return (uint32_t)ret_conv;
15560 }
15561
15562 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_ok"))) TS_CResult_DescriptionCreationErrorZ_ok(uint32_t o) {
15563         LDKDescription o_conv;
15564         o_conv.inner = (void*)(o & (~1));
15565         o_conv.is_owned = (o & 1) || (o == 0);
15566         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15567         o_conv = Description_clone(&o_conv);
15568         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
15569         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
15570         return (uint32_t)ret_conv;
15571 }
15572
15573 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_err"))) TS_CResult_DescriptionCreationErrorZ_err(uint32_t e) {
15574         LDKCreationError e_conv = LDKCreationError_from_js(e);
15575         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
15576         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
15577         return (uint32_t)ret_conv;
15578 }
15579
15580 jboolean  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_is_ok"))) TS_CResult_DescriptionCreationErrorZ_is_ok(uint32_t o) {
15581         LDKCResult_DescriptionCreationErrorZ* o_conv = (LDKCResult_DescriptionCreationErrorZ*)(o & ~1);
15582         jboolean ret_conv = CResult_DescriptionCreationErrorZ_is_ok(o_conv);
15583         return ret_conv;
15584 }
15585
15586 void  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_free"))) TS_CResult_DescriptionCreationErrorZ_free(uint32_t _res) {
15587         if ((_res & 1) != 0) return;
15588         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15589         CHECK_ACCESS(_res_ptr);
15590         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
15591         FREE((void*)_res);
15592         CResult_DescriptionCreationErrorZ_free(_res_conv);
15593 }
15594
15595 static inline uintptr_t CResult_DescriptionCreationErrorZ_clone_ptr(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR arg) {
15596         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
15597         *ret_conv = CResult_DescriptionCreationErrorZ_clone(arg);
15598         return (uint32_t)ret_conv;
15599 }
15600 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_clone_ptr"))) TS_CResult_DescriptionCreationErrorZ_clone_ptr(uint32_t arg) {
15601         LDKCResult_DescriptionCreationErrorZ* arg_conv = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
15602         uint32_t ret_conv = CResult_DescriptionCreationErrorZ_clone_ptr(arg_conv);
15603         return ret_conv;
15604 }
15605
15606 uint32_t  __attribute__((export_name("TS_CResult_DescriptionCreationErrorZ_clone"))) TS_CResult_DescriptionCreationErrorZ_clone(uint32_t orig) {
15607         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
15608         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
15609         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
15610         return (uint32_t)ret_conv;
15611 }
15612
15613 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_ok"))) TS_CResult_PrivateRouteCreationErrorZ_ok(uint32_t o) {
15614         LDKPrivateRoute o_conv;
15615         o_conv.inner = (void*)(o & (~1));
15616         o_conv.is_owned = (o & 1) || (o == 0);
15617         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15618         o_conv = PrivateRoute_clone(&o_conv);
15619         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
15620         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
15621         return (uint32_t)ret_conv;
15622 }
15623
15624 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_err"))) TS_CResult_PrivateRouteCreationErrorZ_err(uint32_t e) {
15625         LDKCreationError e_conv = LDKCreationError_from_js(e);
15626         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
15627         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
15628         return (uint32_t)ret_conv;
15629 }
15630
15631 jboolean  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_is_ok"))) TS_CResult_PrivateRouteCreationErrorZ_is_ok(uint32_t o) {
15632         LDKCResult_PrivateRouteCreationErrorZ* o_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(o & ~1);
15633         jboolean ret_conv = CResult_PrivateRouteCreationErrorZ_is_ok(o_conv);
15634         return ret_conv;
15635 }
15636
15637 void  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_free"))) TS_CResult_PrivateRouteCreationErrorZ_free(uint32_t _res) {
15638         if ((_res & 1) != 0) return;
15639         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15640         CHECK_ACCESS(_res_ptr);
15641         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
15642         FREE((void*)_res);
15643         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
15644 }
15645
15646 static inline uintptr_t CResult_PrivateRouteCreationErrorZ_clone_ptr(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR arg) {
15647         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
15648         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(arg);
15649         return (uint32_t)ret_conv;
15650 }
15651 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_clone_ptr"))) TS_CResult_PrivateRouteCreationErrorZ_clone_ptr(uint32_t arg) {
15652         LDKCResult_PrivateRouteCreationErrorZ* arg_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
15653         uint32_t ret_conv = CResult_PrivateRouteCreationErrorZ_clone_ptr(arg_conv);
15654         return ret_conv;
15655 }
15656
15657 uint32_t  __attribute__((export_name("TS_CResult_PrivateRouteCreationErrorZ_clone"))) TS_CResult_PrivateRouteCreationErrorZ_clone(uint32_t orig) {
15658         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
15659         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
15660         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
15661         return (uint32_t)ret_conv;
15662 }
15663
15664 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_ok"))) TS_CResult_StringErrorZ_ok(jstring o) {
15665         LDKStr o_conv = str_ref_to_owned_c(o);
15666         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
15667         *ret_conv = CResult_StringErrorZ_ok(o_conv);
15668         return (uint32_t)ret_conv;
15669 }
15670
15671 uint32_t  __attribute__((export_name("TS_CResult_StringErrorZ_err"))) TS_CResult_StringErrorZ_err(uint32_t e) {
15672         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
15673         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
15674         *ret_conv = CResult_StringErrorZ_err(e_conv);
15675         return (uint32_t)ret_conv;
15676 }
15677
15678 jboolean  __attribute__((export_name("TS_CResult_StringErrorZ_is_ok"))) TS_CResult_StringErrorZ_is_ok(uint32_t o) {
15679         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)(o & ~1);
15680         jboolean ret_conv = CResult_StringErrorZ_is_ok(o_conv);
15681         return ret_conv;
15682 }
15683
15684 void  __attribute__((export_name("TS_CResult_StringErrorZ_free"))) TS_CResult_StringErrorZ_free(uint32_t _res) {
15685         if ((_res & 1) != 0) return;
15686         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15687         CHECK_ACCESS(_res_ptr);
15688         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
15689         FREE((void*)_res);
15690         CResult_StringErrorZ_free(_res_conv);
15691 }
15692
15693 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok(uint32_t o) {
15694         LDKChannelMonitorUpdate o_conv;
15695         o_conv.inner = (void*)(o & (~1));
15696         o_conv.is_owned = (o & 1) || (o == 0);
15697         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15698         o_conv = ChannelMonitorUpdate_clone(&o_conv);
15699         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
15700         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
15701         return (uint32_t)ret_conv;
15702 }
15703
15704 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err(uint32_t e) {
15705         LDKDecodeError e_conv;
15706         e_conv.inner = (void*)(e & (~1));
15707         e_conv.is_owned = (e & 1) || (e == 0);
15708         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15709         e_conv = DecodeError_clone(&e_conv);
15710         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
15711         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
15712         return (uint32_t)ret_conv;
15713 }
15714
15715 jboolean  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(uint32_t o) {
15716         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(o & ~1);
15717         jboolean ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
15718         return ret_conv;
15719 }
15720
15721 void  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free(uint32_t _res) {
15722         if ((_res & 1) != 0) return;
15723         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15724         CHECK_ACCESS(_res_ptr);
15725         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
15726         FREE((void*)_res);
15727         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
15728 }
15729
15730 static inline uintptr_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
15731         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
15732         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
15733         return (uint32_t)ret_conv;
15734 }
15735 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
15736         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
15737         uint32_t ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
15738         return ret_conv;
15739 }
15740
15741 uint32_t  __attribute__((export_name("TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_clone(uint32_t orig) {
15742         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
15743         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
15744         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
15745         return (uint32_t)ret_conv;
15746 }
15747
15748 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_some"))) TS_COption_MonitorEventZ_some(uint32_t o) {
15749         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15750         CHECK_ACCESS(o_ptr);
15751         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
15752         o_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uintptr_t)o) & ~1));
15753         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
15754         *ret_copy = COption_MonitorEventZ_some(o_conv);
15755         uint32_t ret_ref = (uintptr_t)ret_copy;
15756         return ret_ref;
15757 }
15758
15759 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_none"))) TS_COption_MonitorEventZ_none() {
15760         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
15761         *ret_copy = COption_MonitorEventZ_none();
15762         uint32_t ret_ref = (uintptr_t)ret_copy;
15763         return ret_ref;
15764 }
15765
15766 void  __attribute__((export_name("TS_COption_MonitorEventZ_free"))) TS_COption_MonitorEventZ_free(uint32_t _res) {
15767         if ((_res & 1) != 0) return;
15768         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15769         CHECK_ACCESS(_res_ptr);
15770         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
15771         FREE((void*)_res);
15772         COption_MonitorEventZ_free(_res_conv);
15773 }
15774
15775 static inline uintptr_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
15776         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
15777         *ret_copy = COption_MonitorEventZ_clone(arg);
15778 uint32_t ret_ref = (uintptr_t)ret_copy;
15779         return ret_ref;
15780 }
15781 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_clone_ptr"))) TS_COption_MonitorEventZ_clone_ptr(uint32_t arg) {
15782         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)arg;
15783         uint32_t ret_conv = COption_MonitorEventZ_clone_ptr(arg_conv);
15784         return ret_conv;
15785 }
15786
15787 uint32_t  __attribute__((export_name("TS_COption_MonitorEventZ_clone"))) TS_COption_MonitorEventZ_clone(uint32_t orig) {
15788         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)orig;
15789         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
15790         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
15791         uint32_t ret_ref = (uintptr_t)ret_copy;
15792         return ret_ref;
15793 }
15794
15795 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_ok(uint32_t o) {
15796         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
15797         CHECK_ACCESS(o_ptr);
15798         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
15799         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)(((uintptr_t)o) & ~1));
15800         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
15801         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
15802         return (uint32_t)ret_conv;
15803 }
15804
15805 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_err"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_err(uint32_t e) {
15806         LDKDecodeError e_conv;
15807         e_conv.inner = (void*)(e & (~1));
15808         e_conv.is_owned = (e & 1) || (e == 0);
15809         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15810         e_conv = DecodeError_clone(&e_conv);
15811         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
15812         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
15813         return (uint32_t)ret_conv;
15814 }
15815
15816 jboolean  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_is_ok"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_is_ok(uint32_t o) {
15817         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(o & ~1);
15818         jboolean ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
15819         return ret_conv;
15820 }
15821
15822 void  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_free"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_free(uint32_t _res) {
15823         if ((_res & 1) != 0) return;
15824         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15825         CHECK_ACCESS(_res_ptr);
15826         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
15827         FREE((void*)_res);
15828         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
15829 }
15830
15831 static inline uintptr_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
15832         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
15833         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
15834         return (uint32_t)ret_conv;
15835 }
15836 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(uint32_t arg) {
15837         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(arg & ~1);
15838         uint32_t ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
15839         return ret_conv;
15840 }
15841
15842 uint32_t  __attribute__((export_name("TS_CResult_COption_MonitorEventZDecodeErrorZ_clone"))) TS_CResult_COption_MonitorEventZDecodeErrorZ_clone(uint32_t orig) {
15843         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(orig & ~1);
15844         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
15845         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
15846         return (uint32_t)ret_conv;
15847 }
15848
15849 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_ok(uint32_t o) {
15850         LDKHTLCUpdate o_conv;
15851         o_conv.inner = (void*)(o & (~1));
15852         o_conv.is_owned = (o & 1) || (o == 0);
15853         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15854         o_conv = HTLCUpdate_clone(&o_conv);
15855         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
15856         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
15857         return (uint32_t)ret_conv;
15858 }
15859
15860 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_err"))) TS_CResult_HTLCUpdateDecodeErrorZ_err(uint32_t e) {
15861         LDKDecodeError e_conv;
15862         e_conv.inner = (void*)(e & (~1));
15863         e_conv.is_owned = (e & 1) || (e == 0);
15864         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15865         e_conv = DecodeError_clone(&e_conv);
15866         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
15867         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
15868         return (uint32_t)ret_conv;
15869 }
15870
15871 jboolean  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_is_ok"))) TS_CResult_HTLCUpdateDecodeErrorZ_is_ok(uint32_t o) {
15872         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(o & ~1);
15873         jboolean ret_conv = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
15874         return ret_conv;
15875 }
15876
15877 void  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_free"))) TS_CResult_HTLCUpdateDecodeErrorZ_free(uint32_t _res) {
15878         if ((_res & 1) != 0) return;
15879         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15880         CHECK_ACCESS(_res_ptr);
15881         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
15882         FREE((void*)_res);
15883         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
15884 }
15885
15886 static inline uintptr_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
15887         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
15888         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
15889         return (uint32_t)ret_conv;
15890 }
15891 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
15892         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
15893         uint32_t ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
15894         return ret_conv;
15895 }
15896
15897 uint32_t  __attribute__((export_name("TS_CResult_HTLCUpdateDecodeErrorZ_clone"))) TS_CResult_HTLCUpdateDecodeErrorZ_clone(uint32_t orig) {
15898         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
15899         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
15900         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
15901         return (uint32_t)ret_conv;
15902 }
15903
15904 static inline uintptr_t C2Tuple_OutPointScriptZ_clone_ptr(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR arg) {
15905         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
15906         *ret_conv = C2Tuple_OutPointScriptZ_clone(arg);
15907         return ((uint32_t)ret_conv);
15908 }
15909 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_clone_ptr"))) TS_C2Tuple_OutPointScriptZ_clone_ptr(uint32_t arg) {
15910         LDKC2Tuple_OutPointScriptZ* arg_conv = (LDKC2Tuple_OutPointScriptZ*)(arg & ~1);
15911         uint32_t ret_conv = C2Tuple_OutPointScriptZ_clone_ptr(arg_conv);
15912         return ret_conv;
15913 }
15914
15915 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_clone"))) TS_C2Tuple_OutPointScriptZ_clone(uint32_t orig) {
15916         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
15917         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
15918         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
15919         return ((uint32_t)ret_conv);
15920 }
15921
15922 uint32_t  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_new"))) TS_C2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
15923         LDKOutPoint a_conv;
15924         a_conv.inner = (void*)(a & (~1));
15925         a_conv.is_owned = (a & 1) || (a == 0);
15926         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
15927         a_conv = OutPoint_clone(&a_conv);
15928         LDKCVec_u8Z b_ref;
15929         b_ref.datalen = b->arr_len;
15930         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
15931         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
15932         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
15933         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
15934         return ((uint32_t)ret_conv);
15935 }
15936
15937 void  __attribute__((export_name("TS_C2Tuple_OutPointScriptZ_free"))) TS_C2Tuple_OutPointScriptZ_free(uint32_t _res) {
15938         if ((_res & 1) != 0) return;
15939         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15940         CHECK_ACCESS(_res_ptr);
15941         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
15942         FREE((void*)_res);
15943         C2Tuple_OutPointScriptZ_free(_res_conv);
15944 }
15945
15946 static inline uintptr_t C2Tuple_u32ScriptZ_clone_ptr(LDKC2Tuple_u32ScriptZ *NONNULL_PTR arg) {
15947         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
15948         *ret_conv = C2Tuple_u32ScriptZ_clone(arg);
15949         return ((uint32_t)ret_conv);
15950 }
15951 uint32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_clone_ptr"))) TS_C2Tuple_u32ScriptZ_clone_ptr(uint32_t arg) {
15952         LDKC2Tuple_u32ScriptZ* arg_conv = (LDKC2Tuple_u32ScriptZ*)(arg & ~1);
15953         uint32_t ret_conv = C2Tuple_u32ScriptZ_clone_ptr(arg_conv);
15954         return ret_conv;
15955 }
15956
15957 uint32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_clone"))) TS_C2Tuple_u32ScriptZ_clone(uint32_t orig) {
15958         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
15959         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
15960         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
15961         return ((uint32_t)ret_conv);
15962 }
15963
15964 uint32_t  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_new"))) TS_C2Tuple_u32ScriptZ_new(int32_t a, int8_tArray b) {
15965         LDKCVec_u8Z b_ref;
15966         b_ref.datalen = b->arr_len;
15967         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
15968         memcpy(b_ref.data, b->elems, b_ref.datalen); FREE(b);
15969         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
15970         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
15971         return ((uint32_t)ret_conv);
15972 }
15973
15974 void  __attribute__((export_name("TS_C2Tuple_u32ScriptZ_free"))) TS_C2Tuple_u32ScriptZ_free(uint32_t _res) {
15975         if ((_res & 1) != 0) return;
15976         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
15977         CHECK_ACCESS(_res_ptr);
15978         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
15979         FREE((void*)_res);
15980         C2Tuple_u32ScriptZ_free(_res_conv);
15981 }
15982
15983 void  __attribute__((export_name("TS_CVec_C2Tuple_u32ScriptZZ_free"))) TS_CVec_C2Tuple_u32ScriptZZ_free(uint32_tArray _res) {
15984         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
15985         _res_constr.datalen = _res->arr_len;
15986         if (_res_constr.datalen > 0)
15987                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
15988         else
15989                 _res_constr.data = NULL;
15990         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
15991         for (size_t v = 0; v < _res_constr.datalen; v++) {
15992                 uint32_t _res_conv_21 = _res_vals[v];
15993                 void* _res_conv_21_ptr = (void*)(((uintptr_t)_res_conv_21) & ~1);
15994                 CHECK_ACCESS(_res_conv_21_ptr);
15995                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
15996                 FREE((void*)_res_conv_21);
15997                 _res_constr.data[v] = _res_conv_21_conv;
15998         }
15999         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
16000 }
16001
16002 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR arg) {
16003         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
16004         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(arg);
16005         return ((uint32_t)ret_conv);
16006 }
16007 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(uint32_t arg) {
16008         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(arg & ~1);
16009         uint32_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(arg_conv);
16010         return ret_conv;
16011 }
16012
16013 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(uint32_t orig) {
16014         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
16015         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
16016         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
16017         return ((uint32_t)ret_conv);
16018 }
16019
16020 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(int8_tArray a, uint32_tArray b) {
16021         LDKThirtyTwoBytes a_ref;
16022         CHECK(a->arr_len == 32);
16023         memcpy(a_ref.data, a->elems, 32); FREE(a);
16024         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
16025         b_constr.datalen = b->arr_len;
16026         if (b_constr.datalen > 0)
16027                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
16028         else
16029                 b_constr.data = NULL;
16030         uint32_t* b_vals = b->elems /* XXX b leaks */;
16031         for (size_t v = 0; v < b_constr.datalen; v++) {
16032                 uint32_t b_conv_21 = b_vals[v];
16033                 void* b_conv_21_ptr = (void*)(((uintptr_t)b_conv_21) & ~1);
16034                 CHECK_ACCESS(b_conv_21_ptr);
16035                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
16036                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uintptr_t)b_conv_21) & ~1));
16037                 b_constr.data[v] = b_conv_21_conv;
16038         }
16039         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
16040         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
16041         return ((uint32_t)ret_conv);
16042 }
16043
16044 void  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(uint32_t _res) {
16045         if ((_res & 1) != 0) return;
16046         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16047         CHECK_ACCESS(_res_ptr);
16048         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
16049         FREE((void*)_res);
16050         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
16051 }
16052
16053 void  __attribute__((export_name("TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(uint32_tArray _res) {
16054         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
16055         _res_constr.datalen = _res->arr_len;
16056         if (_res_constr.datalen > 0)
16057                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
16058         else
16059                 _res_constr.data = NULL;
16060         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16061         for (size_t o = 0; o < _res_constr.datalen; o++) {
16062                 uint32_t _res_conv_40 = _res_vals[o];
16063                 void* _res_conv_40_ptr = (void*)(((uintptr_t)_res_conv_40) & ~1);
16064                 CHECK_ACCESS(_res_conv_40_ptr);
16065                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
16066                 FREE((void*)_res_conv_40);
16067                 _res_constr.data[o] = _res_conv_40_conv;
16068         }
16069         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
16070 }
16071
16072 void  __attribute__((export_name("TS_CVec_EventZ_free"))) TS_CVec_EventZ_free(uint32_tArray _res) {
16073         LDKCVec_EventZ _res_constr;
16074         _res_constr.datalen = _res->arr_len;
16075         if (_res_constr.datalen > 0)
16076                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
16077         else
16078                 _res_constr.data = NULL;
16079         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16080         for (size_t h = 0; h < _res_constr.datalen; h++) {
16081                 uint32_t _res_conv_7 = _res_vals[h];
16082                 void* _res_conv_7_ptr = (void*)(((uintptr_t)_res_conv_7) & ~1);
16083                 CHECK_ACCESS(_res_conv_7_ptr);
16084                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
16085                 FREE((void*)_res_conv_7);
16086                 _res_constr.data[h] = _res_conv_7_conv;
16087         }
16088         CVec_EventZ_free(_res_constr);
16089 }
16090
16091 void  __attribute__((export_name("TS_CVec_TransactionZ_free"))) TS_CVec_TransactionZ_free(ptrArray _res) {
16092         LDKCVec_TransactionZ _res_constr;
16093         _res_constr.datalen = _res->arr_len;
16094         if (_res_constr.datalen > 0)
16095                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
16096         else
16097                 _res_constr.data = NULL;
16098         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
16099         for (size_t m = 0; m < _res_constr.datalen; m++) {
16100                 int8_tArray _res_conv_12 = _res_vals[m];
16101                 LDKTransaction _res_conv_12_ref;
16102                 _res_conv_12_ref.datalen = _res_conv_12->arr_len;
16103                 _res_conv_12_ref.data = MALLOC(_res_conv_12_ref.datalen, "LDKTransaction Bytes");
16104                 memcpy(_res_conv_12_ref.data, _res_conv_12->elems, _res_conv_12_ref.datalen); FREE(_res_conv_12);
16105                 _res_conv_12_ref.data_is_owned = true;
16106                 _res_constr.data[m] = _res_conv_12_ref;
16107         }
16108         CVec_TransactionZ_free(_res_constr);
16109 }
16110
16111 static inline uintptr_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
16112         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
16113         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
16114         return ((uint32_t)ret_conv);
16115 }
16116 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_clone_ptr"))) TS_C2Tuple_u32TxOutZ_clone_ptr(uint32_t arg) {
16117         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)(arg & ~1);
16118         uint32_t ret_conv = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
16119         return ret_conv;
16120 }
16121
16122 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_clone"))) TS_C2Tuple_u32TxOutZ_clone(uint32_t orig) {
16123         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
16124         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
16125         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
16126         return ((uint32_t)ret_conv);
16127 }
16128
16129 uint32_t  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_new"))) TS_C2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
16130         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
16131         CHECK_ACCESS(b_ptr);
16132         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
16133         b_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)b) & ~1));
16134         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
16135         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
16136         return ((uint32_t)ret_conv);
16137 }
16138
16139 void  __attribute__((export_name("TS_C2Tuple_u32TxOutZ_free"))) TS_C2Tuple_u32TxOutZ_free(uint32_t _res) {
16140         if ((_res & 1) != 0) return;
16141         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16142         CHECK_ACCESS(_res_ptr);
16143         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
16144         FREE((void*)_res);
16145         C2Tuple_u32TxOutZ_free(_res_conv);
16146 }
16147
16148 void  __attribute__((export_name("TS_CVec_C2Tuple_u32TxOutZZ_free"))) TS_CVec_C2Tuple_u32TxOutZZ_free(uint32_tArray _res) {
16149         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
16150         _res_constr.datalen = _res->arr_len;
16151         if (_res_constr.datalen > 0)
16152                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
16153         else
16154                 _res_constr.data = NULL;
16155         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16156         for (size_t u = 0; u < _res_constr.datalen; u++) {
16157                 uint32_t _res_conv_20 = _res_vals[u];
16158                 void* _res_conv_20_ptr = (void*)(((uintptr_t)_res_conv_20) & ~1);
16159                 CHECK_ACCESS(_res_conv_20_ptr);
16160                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
16161                 FREE((void*)_res_conv_20);
16162                 _res_constr.data[u] = _res_conv_20_conv;
16163         }
16164         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
16165 }
16166
16167 static inline uintptr_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
16168         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
16169         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
16170         return ((uint32_t)ret_conv);
16171 }
16172 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(uint32_t arg) {
16173         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(arg & ~1);
16174         uint32_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
16175         return ret_conv;
16176 }
16177
16178 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(uint32_t orig) {
16179         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
16180         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
16181         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
16182         return ((uint32_t)ret_conv);
16183 }
16184
16185 uint32_t  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
16186         LDKThirtyTwoBytes a_ref;
16187         CHECK(a->arr_len == 32);
16188         memcpy(a_ref.data, a->elems, 32); FREE(a);
16189         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
16190         b_constr.datalen = b->arr_len;
16191         if (b_constr.datalen > 0)
16192                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
16193         else
16194                 b_constr.data = NULL;
16195         uint32_t* b_vals = b->elems /* XXX b leaks */;
16196         for (size_t u = 0; u < b_constr.datalen; u++) {
16197                 uint32_t b_conv_20 = b_vals[u];
16198                 void* b_conv_20_ptr = (void*)(((uintptr_t)b_conv_20) & ~1);
16199                 CHECK_ACCESS(b_conv_20_ptr);
16200                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
16201                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uintptr_t)b_conv_20) & ~1));
16202                 b_constr.data[u] = b_conv_20_conv;
16203         }
16204         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
16205         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
16206         return ((uint32_t)ret_conv);
16207 }
16208
16209 void  __attribute__((export_name("TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(uint32_t _res) {
16210         if ((_res & 1) != 0) return;
16211         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16212         CHECK_ACCESS(_res_ptr);
16213         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
16214         FREE((void*)_res);
16215         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
16216 }
16217
16218 void  __attribute__((export_name("TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(uint32_tArray _res) {
16219         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
16220         _res_constr.datalen = _res->arr_len;
16221         if (_res_constr.datalen > 0)
16222                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
16223         else
16224                 _res_constr.data = NULL;
16225         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16226         for (size_t n = 0; n < _res_constr.datalen; n++) {
16227                 uint32_t _res_conv_39 = _res_vals[n];
16228                 void* _res_conv_39_ptr = (void*)(((uintptr_t)_res_conv_39) & ~1);
16229                 CHECK_ACCESS(_res_conv_39_ptr);
16230                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
16231                 FREE((void*)_res_conv_39);
16232                 _res_constr.data[n] = _res_conv_39_conv;
16233         }
16234         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
16235 }
16236
16237 void  __attribute__((export_name("TS_CVec_BalanceZ_free"))) TS_CVec_BalanceZ_free(uint32_tArray _res) {
16238         LDKCVec_BalanceZ _res_constr;
16239         _res_constr.datalen = _res->arr_len;
16240         if (_res_constr.datalen > 0)
16241                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
16242         else
16243                 _res_constr.data = NULL;
16244         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16245         for (size_t j = 0; j < _res_constr.datalen; j++) {
16246                 uint32_t _res_conv_9 = _res_vals[j];
16247                 void* _res_conv_9_ptr = (void*)(((uintptr_t)_res_conv_9) & ~1);
16248                 CHECK_ACCESS(_res_conv_9_ptr);
16249                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
16250                 FREE((void*)_res_conv_9);
16251                 _res_constr.data[j] = _res_conv_9_conv;
16252         }
16253         CVec_BalanceZ_free(_res_constr);
16254 }
16255
16256 static inline uintptr_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
16257         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
16258         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
16259         return ((uint32_t)ret_conv);
16260 }
16261 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_clone_ptr"))) TS_C2Tuple_BlockHashChannelMonitorZ_clone_ptr(uint32_t arg) {
16262         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(arg & ~1);
16263         uint32_t ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
16264         return ret_conv;
16265 }
16266
16267 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_clone"))) TS_C2Tuple_BlockHashChannelMonitorZ_clone(uint32_t orig) {
16268         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(orig & ~1);
16269         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
16270         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
16271         return ((uint32_t)ret_conv);
16272 }
16273
16274 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_new"))) TS_C2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
16275         LDKThirtyTwoBytes a_ref;
16276         CHECK(a->arr_len == 32);
16277         memcpy(a_ref.data, a->elems, 32); FREE(a);
16278         LDKChannelMonitor b_conv;
16279         b_conv.inner = (void*)(b & (~1));
16280         b_conv.is_owned = (b & 1) || (b == 0);
16281         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
16282         b_conv = ChannelMonitor_clone(&b_conv);
16283         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
16284         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
16285         return ((uint32_t)ret_conv);
16286 }
16287
16288 void  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_free"))) TS_C2Tuple_BlockHashChannelMonitorZ_free(uint32_t _res) {
16289         if ((_res & 1) != 0) return;
16290         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16291         CHECK_ACCESS(_res_ptr);
16292         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
16293         FREE((void*)_res);
16294         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
16295 }
16296
16297 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(uint32_t o) {
16298         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16299         CHECK_ACCESS(o_ptr);
16300         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
16301         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uintptr_t)o) & ~1));
16302         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
16303         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
16304         return (uint32_t)ret_conv;
16305 }
16306
16307 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(uint32_t e) {
16308         LDKDecodeError e_conv;
16309         e_conv.inner = (void*)(e & (~1));
16310         e_conv.is_owned = (e & 1) || (e == 0);
16311         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16312         e_conv = DecodeError_clone(&e_conv);
16313         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
16314         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
16315         return (uint32_t)ret_conv;
16316 }
16317
16318 jboolean  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(uint32_t o) {
16319         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(o & ~1);
16320         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
16321         return ret_conv;
16322 }
16323
16324 void  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(uint32_t _res) {
16325         if ((_res & 1) != 0) return;
16326         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16327         CHECK_ACCESS(_res_ptr);
16328         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
16329         FREE((void*)_res);
16330         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
16331 }
16332
16333 static inline uintptr_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
16334         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
16335         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
16336         return (uint32_t)ret_conv;
16337 }
16338 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(uint32_t arg) {
16339         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
16340         uint32_t ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
16341         return ret_conv;
16342 }
16343
16344 uint32_t  __attribute__((export_name("TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(uint32_t orig) {
16345         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(orig & ~1);
16346         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
16347         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
16348         return (uint32_t)ret_conv;
16349 }
16350
16351 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_ok"))) TS_CResult_NoneLightningErrorZ_ok() {
16352         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
16353         *ret_conv = CResult_NoneLightningErrorZ_ok();
16354         return (uint32_t)ret_conv;
16355 }
16356
16357 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_err"))) TS_CResult_NoneLightningErrorZ_err(uint32_t e) {
16358         LDKLightningError e_conv;
16359         e_conv.inner = (void*)(e & (~1));
16360         e_conv.is_owned = (e & 1) || (e == 0);
16361         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16362         e_conv = LightningError_clone(&e_conv);
16363         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
16364         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
16365         return (uint32_t)ret_conv;
16366 }
16367
16368 jboolean  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_is_ok"))) TS_CResult_NoneLightningErrorZ_is_ok(uint32_t o) {
16369         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)(o & ~1);
16370         jboolean ret_conv = CResult_NoneLightningErrorZ_is_ok(o_conv);
16371         return ret_conv;
16372 }
16373
16374 void  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_free"))) TS_CResult_NoneLightningErrorZ_free(uint32_t _res) {
16375         if ((_res & 1) != 0) return;
16376         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16377         CHECK_ACCESS(_res_ptr);
16378         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
16379         FREE((void*)_res);
16380         CResult_NoneLightningErrorZ_free(_res_conv);
16381 }
16382
16383 static inline uintptr_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
16384         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
16385         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
16386         return (uint32_t)ret_conv;
16387 }
16388 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_clone_ptr"))) TS_CResult_NoneLightningErrorZ_clone_ptr(uint32_t arg) {
16389         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
16390         uint32_t ret_conv = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
16391         return ret_conv;
16392 }
16393
16394 uint32_t  __attribute__((export_name("TS_CResult_NoneLightningErrorZ_clone"))) TS_CResult_NoneLightningErrorZ_clone(uint32_t orig) {
16395         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
16396         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
16397         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
16398         return (uint32_t)ret_conv;
16399 }
16400
16401 static inline uintptr_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
16402         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
16403         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
16404         return ((uint32_t)ret_conv);
16405 }
16406 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_clone_ptr"))) TS_C2Tuple_PublicKeyTypeZ_clone_ptr(uint32_t arg) {
16407         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)(arg & ~1);
16408         uint32_t ret_conv = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
16409         return ret_conv;
16410 }
16411
16412 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_clone"))) TS_C2Tuple_PublicKeyTypeZ_clone(uint32_t orig) {
16413         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1);
16414         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
16415         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
16416         return ((uint32_t)ret_conv);
16417 }
16418
16419 uint32_t  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_new"))) TS_C2Tuple_PublicKeyTypeZ_new(int8_tArray a, uint32_t b) {
16420         LDKPublicKey a_ref;
16421         CHECK(a->arr_len == 33);
16422         memcpy(a_ref.compressed_form, a->elems, 33); FREE(a);
16423         void* b_ptr = (void*)(((uintptr_t)b) & ~1);
16424         CHECK_ACCESS(b_ptr);
16425         LDKType b_conv = *(LDKType*)(b_ptr);
16426         if (b_conv.free == LDKType_JCalls_free) {
16427                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16428                 LDKType_JCalls_cloned(&b_conv);
16429         }
16430         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
16431         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
16432         return ((uint32_t)ret_conv);
16433 }
16434
16435 void  __attribute__((export_name("TS_C2Tuple_PublicKeyTypeZ_free"))) TS_C2Tuple_PublicKeyTypeZ_free(uint32_t _res) {
16436         if ((_res & 1) != 0) return;
16437         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16438         CHECK_ACCESS(_res_ptr);
16439         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
16440         FREE((void*)_res);
16441         C2Tuple_PublicKeyTypeZ_free(_res_conv);
16442 }
16443
16444 void  __attribute__((export_name("TS_CVec_C2Tuple_PublicKeyTypeZZ_free"))) TS_CVec_C2Tuple_PublicKeyTypeZZ_free(uint32_tArray _res) {
16445         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
16446         _res_constr.datalen = _res->arr_len;
16447         if (_res_constr.datalen > 0)
16448                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
16449         else
16450                 _res_constr.data = NULL;
16451         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16452         for (size_t z = 0; z < _res_constr.datalen; z++) {
16453                 uint32_t _res_conv_25 = _res_vals[z];
16454                 void* _res_conv_25_ptr = (void*)(((uintptr_t)_res_conv_25) & ~1);
16455                 CHECK_ACCESS(_res_conv_25_ptr);
16456                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
16457                 FREE((void*)_res_conv_25);
16458                 _res_constr.data[z] = _res_conv_25_conv;
16459         }
16460         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
16461 }
16462
16463 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_ok"))) TS_CResult_boolLightningErrorZ_ok(jboolean o) {
16464         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
16465         *ret_conv = CResult_boolLightningErrorZ_ok(o);
16466         return (uint32_t)ret_conv;
16467 }
16468
16469 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_err"))) TS_CResult_boolLightningErrorZ_err(uint32_t e) {
16470         LDKLightningError e_conv;
16471         e_conv.inner = (void*)(e & (~1));
16472         e_conv.is_owned = (e & 1) || (e == 0);
16473         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16474         e_conv = LightningError_clone(&e_conv);
16475         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
16476         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
16477         return (uint32_t)ret_conv;
16478 }
16479
16480 jboolean  __attribute__((export_name("TS_CResult_boolLightningErrorZ_is_ok"))) TS_CResult_boolLightningErrorZ_is_ok(uint32_t o) {
16481         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)(o & ~1);
16482         jboolean ret_conv = CResult_boolLightningErrorZ_is_ok(o_conv);
16483         return ret_conv;
16484 }
16485
16486 void  __attribute__((export_name("TS_CResult_boolLightningErrorZ_free"))) TS_CResult_boolLightningErrorZ_free(uint32_t _res) {
16487         if ((_res & 1) != 0) return;
16488         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16489         CHECK_ACCESS(_res_ptr);
16490         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
16491         FREE((void*)_res);
16492         CResult_boolLightningErrorZ_free(_res_conv);
16493 }
16494
16495 static inline uintptr_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
16496         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
16497         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
16498         return (uint32_t)ret_conv;
16499 }
16500 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_clone_ptr"))) TS_CResult_boolLightningErrorZ_clone_ptr(uint32_t arg) {
16501         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
16502         uint32_t ret_conv = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
16503         return ret_conv;
16504 }
16505
16506 uint32_t  __attribute__((export_name("TS_CResult_boolLightningErrorZ_clone"))) TS_CResult_boolLightningErrorZ_clone(uint32_t orig) {
16507         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
16508         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
16509         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
16510         return (uint32_t)ret_conv;
16511 }
16512
16513 static inline uintptr_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
16514         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
16515         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
16516         return ((uint32_t)ret_conv);
16517 }
16518 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(uint32_t arg) {
16519         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(arg & ~1);
16520         uint32_t ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
16521         return ret_conv;
16522 }
16523
16524 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(uint32_t orig) {
16525         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
16526         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
16527         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
16528         return ((uint32_t)ret_conv);
16529 }
16530
16531 uint32_t  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
16532         LDKChannelAnnouncement a_conv;
16533         a_conv.inner = (void*)(a & (~1));
16534         a_conv.is_owned = (a & 1) || (a == 0);
16535         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
16536         a_conv = ChannelAnnouncement_clone(&a_conv);
16537         LDKChannelUpdate b_conv;
16538         b_conv.inner = (void*)(b & (~1));
16539         b_conv.is_owned = (b & 1) || (b == 0);
16540         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
16541         b_conv = ChannelUpdate_clone(&b_conv);
16542         LDKChannelUpdate c_conv;
16543         c_conv.inner = (void*)(c & (~1));
16544         c_conv.is_owned = (c & 1) || (c == 0);
16545         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
16546         c_conv = ChannelUpdate_clone(&c_conv);
16547         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
16548         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
16549         return ((uint32_t)ret_conv);
16550 }
16551
16552 void  __attribute__((export_name("TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(uint32_t _res) {
16553         if ((_res & 1) != 0) return;
16554         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16555         CHECK_ACCESS(_res_ptr);
16556         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
16557         FREE((void*)_res);
16558         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
16559 }
16560
16561 void  __attribute__((export_name("TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free"))) TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(uint32_tArray _res) {
16562         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
16563         _res_constr.datalen = _res->arr_len;
16564         if (_res_constr.datalen > 0)
16565                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
16566         else
16567                 _res_constr.data = NULL;
16568         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16569         for (size_t h = 0; h < _res_constr.datalen; h++) {
16570                 uint32_t _res_conv_59 = _res_vals[h];
16571                 void* _res_conv_59_ptr = (void*)(((uintptr_t)_res_conv_59) & ~1);
16572                 CHECK_ACCESS(_res_conv_59_ptr);
16573                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_conv_59_ptr);
16574                 FREE((void*)_res_conv_59);
16575                 _res_constr.data[h] = _res_conv_59_conv;
16576         }
16577         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
16578 }
16579
16580 void  __attribute__((export_name("TS_CVec_NodeAnnouncementZ_free"))) TS_CVec_NodeAnnouncementZ_free(uint32_tArray _res) {
16581         LDKCVec_NodeAnnouncementZ _res_constr;
16582         _res_constr.datalen = _res->arr_len;
16583         if (_res_constr.datalen > 0)
16584                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
16585         else
16586                 _res_constr.data = NULL;
16587         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
16588         for (size_t s = 0; s < _res_constr.datalen; s++) {
16589                 uint32_t _res_conv_18 = _res_vals[s];
16590                 LDKNodeAnnouncement _res_conv_18_conv;
16591                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
16592                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
16593                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_18_conv);
16594                 _res_constr.data[s] = _res_conv_18_conv;
16595         }
16596         CVec_NodeAnnouncementZ_free(_res_constr);
16597 }
16598
16599 void  __attribute__((export_name("TS_CVec_PublicKeyZ_free"))) TS_CVec_PublicKeyZ_free(ptrArray _res) {
16600         LDKCVec_PublicKeyZ _res_constr;
16601         _res_constr.datalen = _res->arr_len;
16602         if (_res_constr.datalen > 0)
16603                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
16604         else
16605                 _res_constr.data = NULL;
16606         int8_tArray* _res_vals = (void*) _res->elems /* XXX _res leaks */;
16607         for (size_t m = 0; m < _res_constr.datalen; m++) {
16608                 int8_tArray _res_conv_12 = _res_vals[m];
16609                 LDKPublicKey _res_conv_12_ref;
16610                 CHECK(_res_conv_12->arr_len == 33);
16611                 memcpy(_res_conv_12_ref.compressed_form, _res_conv_12->elems, 33); FREE(_res_conv_12);
16612                 _res_constr.data[m] = _res_conv_12_ref;
16613         }
16614         CVec_PublicKeyZ_free(_res_constr);
16615 }
16616
16617 uint32_t  __attribute__((export_name("TS_COption_NetAddressZ_some"))) TS_COption_NetAddressZ_some(uint32_t o) {
16618         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16619         CHECK_ACCESS(o_ptr);
16620         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
16621         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
16622         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
16623         *ret_copy = COption_NetAddressZ_some(o_conv);
16624         uint32_t ret_ref = (uintptr_t)ret_copy;
16625         return ret_ref;
16626 }
16627
16628 uint32_t  __attribute__((export_name("TS_COption_NetAddressZ_none"))) TS_COption_NetAddressZ_none() {
16629         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
16630         *ret_copy = COption_NetAddressZ_none();
16631         uint32_t ret_ref = (uintptr_t)ret_copy;
16632         return ret_ref;
16633 }
16634
16635 void  __attribute__((export_name("TS_COption_NetAddressZ_free"))) TS_COption_NetAddressZ_free(uint32_t _res) {
16636         if ((_res & 1) != 0) return;
16637         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16638         CHECK_ACCESS(_res_ptr);
16639         LDKCOption_NetAddressZ _res_conv = *(LDKCOption_NetAddressZ*)(_res_ptr);
16640         FREE((void*)_res);
16641         COption_NetAddressZ_free(_res_conv);
16642 }
16643
16644 static inline uintptr_t COption_NetAddressZ_clone_ptr(LDKCOption_NetAddressZ *NONNULL_PTR arg) {
16645         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
16646         *ret_copy = COption_NetAddressZ_clone(arg);
16647 uint32_t ret_ref = (uintptr_t)ret_copy;
16648         return ret_ref;
16649 }
16650 uint32_t  __attribute__((export_name("TS_COption_NetAddressZ_clone_ptr"))) TS_COption_NetAddressZ_clone_ptr(uint32_t arg) {
16651         LDKCOption_NetAddressZ* arg_conv = (LDKCOption_NetAddressZ*)arg;
16652         uint32_t ret_conv = COption_NetAddressZ_clone_ptr(arg_conv);
16653         return ret_conv;
16654 }
16655
16656 uint32_t  __attribute__((export_name("TS_COption_NetAddressZ_clone"))) TS_COption_NetAddressZ_clone(uint32_t orig) {
16657         LDKCOption_NetAddressZ* orig_conv = (LDKCOption_NetAddressZ*)orig;
16658         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
16659         *ret_copy = COption_NetAddressZ_clone(orig_conv);
16660         uint32_t ret_ref = (uintptr_t)ret_copy;
16661         return ret_ref;
16662 }
16663
16664 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_ok(int8_tArray o) {
16665         LDKCVec_u8Z o_ref;
16666         o_ref.datalen = o->arr_len;
16667         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
16668         memcpy(o_ref.data, o->elems, o_ref.datalen); FREE(o);
16669         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
16670         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
16671         return (uint32_t)ret_conv;
16672 }
16673
16674 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_err"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_err(uint32_t e) {
16675         LDKPeerHandleError e_conv;
16676         e_conv.inner = (void*)(e & (~1));
16677         e_conv.is_owned = (e & 1) || (e == 0);
16678         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16679         e_conv = PeerHandleError_clone(&e_conv);
16680         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
16681         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
16682         return (uint32_t)ret_conv;
16683 }
16684
16685 jboolean  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_is_ok"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_is_ok(uint32_t o) {
16686         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(o & ~1);
16687         jboolean ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
16688         return ret_conv;
16689 }
16690
16691 void  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_free"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_free(uint32_t _res) {
16692         if ((_res & 1) != 0) return;
16693         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16694         CHECK_ACCESS(_res_ptr);
16695         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
16696         FREE((void*)_res);
16697         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
16698 }
16699
16700 static inline uintptr_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
16701         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
16702         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
16703         return (uint32_t)ret_conv;
16704 }
16705 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(uint32_t arg) {
16706         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
16707         uint32_t ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
16708         return ret_conv;
16709 }
16710
16711 uint32_t  __attribute__((export_name("TS_CResult_CVec_u8ZPeerHandleErrorZ_clone"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone(uint32_t orig) {
16712         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
16713         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
16714         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
16715         return (uint32_t)ret_conv;
16716 }
16717
16718 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_ok"))) TS_CResult_NonePeerHandleErrorZ_ok() {
16719         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
16720         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
16721         return (uint32_t)ret_conv;
16722 }
16723
16724 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_err"))) TS_CResult_NonePeerHandleErrorZ_err(uint32_t e) {
16725         LDKPeerHandleError e_conv;
16726         e_conv.inner = (void*)(e & (~1));
16727         e_conv.is_owned = (e & 1) || (e == 0);
16728         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16729         e_conv = PeerHandleError_clone(&e_conv);
16730         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
16731         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
16732         return (uint32_t)ret_conv;
16733 }
16734
16735 jboolean  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_is_ok"))) TS_CResult_NonePeerHandleErrorZ_is_ok(uint32_t o) {
16736         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)(o & ~1);
16737         jboolean ret_conv = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
16738         return ret_conv;
16739 }
16740
16741 void  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_free"))) TS_CResult_NonePeerHandleErrorZ_free(uint32_t _res) {
16742         if ((_res & 1) != 0) return;
16743         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16744         CHECK_ACCESS(_res_ptr);
16745         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
16746         FREE((void*)_res);
16747         CResult_NonePeerHandleErrorZ_free(_res_conv);
16748 }
16749
16750 static inline uintptr_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
16751         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
16752         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
16753         return (uint32_t)ret_conv;
16754 }
16755 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_clone_ptr"))) TS_CResult_NonePeerHandleErrorZ_clone_ptr(uint32_t arg) {
16756         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
16757         uint32_t ret_conv = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
16758         return ret_conv;
16759 }
16760
16761 uint32_t  __attribute__((export_name("TS_CResult_NonePeerHandleErrorZ_clone"))) TS_CResult_NonePeerHandleErrorZ_clone(uint32_t orig) {
16762         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
16763         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
16764         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
16765         return (uint32_t)ret_conv;
16766 }
16767
16768 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_ok"))) TS_CResult_boolPeerHandleErrorZ_ok(jboolean o) {
16769         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
16770         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
16771         return (uint32_t)ret_conv;
16772 }
16773
16774 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_err"))) TS_CResult_boolPeerHandleErrorZ_err(uint32_t e) {
16775         LDKPeerHandleError e_conv;
16776         e_conv.inner = (void*)(e & (~1));
16777         e_conv.is_owned = (e & 1) || (e == 0);
16778         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16779         e_conv = PeerHandleError_clone(&e_conv);
16780         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
16781         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
16782         return (uint32_t)ret_conv;
16783 }
16784
16785 jboolean  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_is_ok"))) TS_CResult_boolPeerHandleErrorZ_is_ok(uint32_t o) {
16786         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)(o & ~1);
16787         jboolean ret_conv = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
16788         return ret_conv;
16789 }
16790
16791 void  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_free"))) TS_CResult_boolPeerHandleErrorZ_free(uint32_t _res) {
16792         if ((_res & 1) != 0) return;
16793         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16794         CHECK_ACCESS(_res_ptr);
16795         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
16796         FREE((void*)_res);
16797         CResult_boolPeerHandleErrorZ_free(_res_conv);
16798 }
16799
16800 static inline uintptr_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
16801         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
16802         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
16803         return (uint32_t)ret_conv;
16804 }
16805 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_clone_ptr"))) TS_CResult_boolPeerHandleErrorZ_clone_ptr(uint32_t arg) {
16806         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
16807         uint32_t ret_conv = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
16808         return ret_conv;
16809 }
16810
16811 uint32_t  __attribute__((export_name("TS_CResult_boolPeerHandleErrorZ_clone"))) TS_CResult_boolPeerHandleErrorZ_clone(uint32_t orig) {
16812         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
16813         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
16814         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
16815         return (uint32_t)ret_conv;
16816 }
16817
16818 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_ok"))) TS_CResult_NodeIdDecodeErrorZ_ok(uint32_t o) {
16819         LDKNodeId o_conv;
16820         o_conv.inner = (void*)(o & (~1));
16821         o_conv.is_owned = (o & 1) || (o == 0);
16822         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16823         o_conv = NodeId_clone(&o_conv);
16824         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
16825         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
16826         return (uint32_t)ret_conv;
16827 }
16828
16829 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_err"))) TS_CResult_NodeIdDecodeErrorZ_err(uint32_t e) {
16830         LDKDecodeError e_conv;
16831         e_conv.inner = (void*)(e & (~1));
16832         e_conv.is_owned = (e & 1) || (e == 0);
16833         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16834         e_conv = DecodeError_clone(&e_conv);
16835         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
16836         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
16837         return (uint32_t)ret_conv;
16838 }
16839
16840 jboolean  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_is_ok"))) TS_CResult_NodeIdDecodeErrorZ_is_ok(uint32_t o) {
16841         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)(o & ~1);
16842         jboolean ret_conv = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
16843         return ret_conv;
16844 }
16845
16846 void  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_free"))) TS_CResult_NodeIdDecodeErrorZ_free(uint32_t _res) {
16847         if ((_res & 1) != 0) return;
16848         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16849         CHECK_ACCESS(_res_ptr);
16850         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
16851         FREE((void*)_res);
16852         CResult_NodeIdDecodeErrorZ_free(_res_conv);
16853 }
16854
16855 static inline uintptr_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
16856         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
16857         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
16858         return (uint32_t)ret_conv;
16859 }
16860 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_clone_ptr"))) TS_CResult_NodeIdDecodeErrorZ_clone_ptr(uint32_t arg) {
16861         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
16862         uint32_t ret_conv = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
16863         return ret_conv;
16864 }
16865
16866 uint32_t  __attribute__((export_name("TS_CResult_NodeIdDecodeErrorZ_clone"))) TS_CResult_NodeIdDecodeErrorZ_clone(uint32_t orig) {
16867         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)(orig & ~1);
16868         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
16869         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
16870         return (uint32_t)ret_conv;
16871 }
16872
16873 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_ok(uint32_t o) {
16874         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16875         CHECK_ACCESS(o_ptr);
16876         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
16877         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)o) & ~1));
16878         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
16879         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
16880         return (uint32_t)ret_conv;
16881 }
16882
16883 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_err"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_err(uint32_t e) {
16884         LDKDecodeError e_conv;
16885         e_conv.inner = (void*)(e & (~1));
16886         e_conv.is_owned = (e & 1) || (e == 0);
16887         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16888         e_conv = DecodeError_clone(&e_conv);
16889         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
16890         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
16891         return (uint32_t)ret_conv;
16892 }
16893
16894 jboolean  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(uint32_t o) {
16895         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(o & ~1);
16896         jboolean ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
16897         return ret_conv;
16898 }
16899
16900 void  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_free"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_free(uint32_t _res) {
16901         if ((_res & 1) != 0) return;
16902         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16903         CHECK_ACCESS(_res_ptr);
16904         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
16905         FREE((void*)_res);
16906         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
16907 }
16908
16909 static inline uintptr_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
16910         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
16911         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
16912         return (uint32_t)ret_conv;
16913 }
16914 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(uint32_t arg) {
16915         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(arg & ~1);
16916         uint32_t ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
16917         return ret_conv;
16918 }
16919
16920 uint32_t  __attribute__((export_name("TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone"))) TS_CResult_COption_NetworkUpdateZDecodeErrorZ_clone(uint32_t orig) {
16921         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(orig & ~1);
16922         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
16923         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
16924         return (uint32_t)ret_conv;
16925 }
16926
16927 uint32_t  __attribute__((export_name("TS_COption_AccessZ_some"))) TS_COption_AccessZ_some(uint32_t o) {
16928         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
16929         CHECK_ACCESS(o_ptr);
16930         LDKAccess o_conv = *(LDKAccess*)(o_ptr);
16931         if (o_conv.free == LDKAccess_JCalls_free) {
16932                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16933                 LDKAccess_JCalls_cloned(&o_conv);
16934         }
16935         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
16936         *ret_copy = COption_AccessZ_some(o_conv);
16937         uint32_t ret_ref = (uintptr_t)ret_copy;
16938         return ret_ref;
16939 }
16940
16941 uint32_t  __attribute__((export_name("TS_COption_AccessZ_none"))) TS_COption_AccessZ_none() {
16942         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
16943         *ret_copy = COption_AccessZ_none();
16944         uint32_t ret_ref = (uintptr_t)ret_copy;
16945         return ret_ref;
16946 }
16947
16948 void  __attribute__((export_name("TS_COption_AccessZ_free"))) TS_COption_AccessZ_free(uint32_t _res) {
16949         if ((_res & 1) != 0) return;
16950         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16951         CHECK_ACCESS(_res_ptr);
16952         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
16953         FREE((void*)_res);
16954         COption_AccessZ_free(_res_conv);
16955 }
16956
16957 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_ok"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_ok(uint32_t o) {
16958         LDKChannelUpdateInfo o_conv;
16959         o_conv.inner = (void*)(o & (~1));
16960         o_conv.is_owned = (o & 1) || (o == 0);
16961         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16962         o_conv = ChannelUpdateInfo_clone(&o_conv);
16963         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
16964         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_ok(o_conv);
16965         return (uint32_t)ret_conv;
16966 }
16967
16968 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_err"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_err(uint32_t e) {
16969         LDKDecodeError e_conv;
16970         e_conv.inner = (void*)(e & (~1));
16971         e_conv.is_owned = (e & 1) || (e == 0);
16972         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16973         e_conv = DecodeError_clone(&e_conv);
16974         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
16975         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_err(e_conv);
16976         return (uint32_t)ret_conv;
16977 }
16978
16979 jboolean  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_is_ok"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(uint32_t o) {
16980         LDKCResult_ChannelUpdateInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(o & ~1);
16981         jboolean ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(o_conv);
16982         return ret_conv;
16983 }
16984
16985 void  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_free"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_free(uint32_t _res) {
16986         if ((_res & 1) != 0) return;
16987         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
16988         CHECK_ACCESS(_res_ptr);
16989         LDKCResult_ChannelUpdateInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(_res_ptr);
16990         FREE((void*)_res);
16991         CResult_ChannelUpdateInfoDecodeErrorZ_free(_res_conv);
16992 }
16993
16994 static inline uintptr_t CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR arg) {
16995         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
16996         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(arg);
16997         return (uint32_t)ret_conv;
16998 }
16999 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
17000         LDKCResult_ChannelUpdateInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(arg & ~1);
17001         uint32_t ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(arg_conv);
17002         return ret_conv;
17003 }
17004
17005 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone"))) TS_CResult_ChannelUpdateInfoDecodeErrorZ_clone(uint32_t orig) {
17006         LDKCResult_ChannelUpdateInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(orig & ~1);
17007         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
17008         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(orig_conv);
17009         return (uint32_t)ret_conv;
17010 }
17011
17012 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_ok(uint32_t o) {
17013         LDKChannelInfo o_conv;
17014         o_conv.inner = (void*)(o & (~1));
17015         o_conv.is_owned = (o & 1) || (o == 0);
17016         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17017         o_conv = ChannelInfo_clone(&o_conv);
17018         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
17019         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
17020         return (uint32_t)ret_conv;
17021 }
17022
17023 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_err"))) TS_CResult_ChannelInfoDecodeErrorZ_err(uint32_t e) {
17024         LDKDecodeError e_conv;
17025         e_conv.inner = (void*)(e & (~1));
17026         e_conv.is_owned = (e & 1) || (e == 0);
17027         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17028         e_conv = DecodeError_clone(&e_conv);
17029         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
17030         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
17031         return (uint32_t)ret_conv;
17032 }
17033
17034 jboolean  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_is_ok"))) TS_CResult_ChannelInfoDecodeErrorZ_is_ok(uint32_t o) {
17035         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(o & ~1);
17036         jboolean ret_conv = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
17037         return ret_conv;
17038 }
17039
17040 void  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_free"))) TS_CResult_ChannelInfoDecodeErrorZ_free(uint32_t _res) {
17041         if ((_res & 1) != 0) return;
17042         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17043         CHECK_ACCESS(_res_ptr);
17044         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
17045         FREE((void*)_res);
17046         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
17047 }
17048
17049 static inline uintptr_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
17050         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
17051         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
17052         return (uint32_t)ret_conv;
17053 }
17054 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
17055         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
17056         uint32_t ret_conv = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
17057         return ret_conv;
17058 }
17059
17060 uint32_t  __attribute__((export_name("TS_CResult_ChannelInfoDecodeErrorZ_clone"))) TS_CResult_ChannelInfoDecodeErrorZ_clone(uint32_t orig) {
17061         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
17062         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
17063         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
17064         return (uint32_t)ret_conv;
17065 }
17066
17067 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_ok(uint32_t o) {
17068         LDKRoutingFees o_conv;
17069         o_conv.inner = (void*)(o & (~1));
17070         o_conv.is_owned = (o & 1) || (o == 0);
17071         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17072         o_conv = RoutingFees_clone(&o_conv);
17073         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
17074         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
17075         return (uint32_t)ret_conv;
17076 }
17077
17078 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_err"))) TS_CResult_RoutingFeesDecodeErrorZ_err(uint32_t e) {
17079         LDKDecodeError e_conv;
17080         e_conv.inner = (void*)(e & (~1));
17081         e_conv.is_owned = (e & 1) || (e == 0);
17082         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17083         e_conv = DecodeError_clone(&e_conv);
17084         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
17085         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
17086         return (uint32_t)ret_conv;
17087 }
17088
17089 jboolean  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_is_ok"))) TS_CResult_RoutingFeesDecodeErrorZ_is_ok(uint32_t o) {
17090         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(o & ~1);
17091         jboolean ret_conv = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
17092         return ret_conv;
17093 }
17094
17095 void  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_free"))) TS_CResult_RoutingFeesDecodeErrorZ_free(uint32_t _res) {
17096         if ((_res & 1) != 0) return;
17097         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17098         CHECK_ACCESS(_res_ptr);
17099         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
17100         FREE((void*)_res);
17101         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
17102 }
17103
17104 static inline uintptr_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
17105         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
17106         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
17107         return (uint32_t)ret_conv;
17108 }
17109 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_clone_ptr"))) TS_CResult_RoutingFeesDecodeErrorZ_clone_ptr(uint32_t arg) {
17110         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
17111         uint32_t ret_conv = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
17112         return ret_conv;
17113 }
17114
17115 uint32_t  __attribute__((export_name("TS_CResult_RoutingFeesDecodeErrorZ_clone"))) TS_CResult_RoutingFeesDecodeErrorZ_clone(uint32_t orig) {
17116         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
17117         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
17118         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
17119         return (uint32_t)ret_conv;
17120 }
17121
17122 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok(uint32_t o) {
17123         LDKNodeAnnouncementInfo o_conv;
17124         o_conv.inner = (void*)(o & (~1));
17125         o_conv.is_owned = (o & 1) || (o == 0);
17126         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17127         o_conv = NodeAnnouncementInfo_clone(&o_conv);
17128         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
17129         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
17130         return (uint32_t)ret_conv;
17131 }
17132
17133 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err(uint32_t e) {
17134         LDKDecodeError e_conv;
17135         e_conv.inner = (void*)(e & (~1));
17136         e_conv.is_owned = (e & 1) || (e == 0);
17137         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17138         e_conv = DecodeError_clone(&e_conv);
17139         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
17140         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
17141         return (uint32_t)ret_conv;
17142 }
17143
17144 jboolean  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(uint32_t o) {
17145         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(o & ~1);
17146         jboolean ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
17147         return ret_conv;
17148 }
17149
17150 void  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free(uint32_t _res) {
17151         if ((_res & 1) != 0) return;
17152         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17153         CHECK_ACCESS(_res_ptr);
17154         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
17155         FREE((void*)_res);
17156         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
17157 }
17158
17159 static inline uintptr_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
17160         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
17161         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
17162         return (uint32_t)ret_conv;
17163 }
17164 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
17165         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
17166         uint32_t ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
17167         return ret_conv;
17168 }
17169
17170 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone(uint32_t orig) {
17171         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
17172         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
17173         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
17174         return (uint32_t)ret_conv;
17175 }
17176
17177 void  __attribute__((export_name("TS_CVec_u64Z_free"))) TS_CVec_u64Z_free(int64_tArray _res) {
17178         LDKCVec_u64Z _res_constr;
17179         _res_constr.datalen = _res->arr_len;
17180         if (_res_constr.datalen > 0)
17181                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
17182         else
17183                 _res_constr.data = NULL;
17184         int64_t* _res_vals = _res->elems /* XXX _res leaks */;
17185         for (size_t i = 0; i < _res_constr.datalen; i++) {
17186                 int64_t _res_conv_8 = _res_vals[i];
17187                 _res_constr.data[i] = _res_conv_8;
17188         }
17189         CVec_u64Z_free(_res_constr);
17190 }
17191
17192 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_ok"))) TS_CResult_NodeInfoDecodeErrorZ_ok(uint32_t o) {
17193         LDKNodeInfo o_conv;
17194         o_conv.inner = (void*)(o & (~1));
17195         o_conv.is_owned = (o & 1) || (o == 0);
17196         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17197         o_conv = NodeInfo_clone(&o_conv);
17198         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
17199         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
17200         return (uint32_t)ret_conv;
17201 }
17202
17203 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_err"))) TS_CResult_NodeInfoDecodeErrorZ_err(uint32_t e) {
17204         LDKDecodeError e_conv;
17205         e_conv.inner = (void*)(e & (~1));
17206         e_conv.is_owned = (e & 1) || (e == 0);
17207         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17208         e_conv = DecodeError_clone(&e_conv);
17209         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
17210         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
17211         return (uint32_t)ret_conv;
17212 }
17213
17214 jboolean  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_is_ok"))) TS_CResult_NodeInfoDecodeErrorZ_is_ok(uint32_t o) {
17215         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(o & ~1);
17216         jboolean ret_conv = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
17217         return ret_conv;
17218 }
17219
17220 void  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_free"))) TS_CResult_NodeInfoDecodeErrorZ_free(uint32_t _res) {
17221         if ((_res & 1) != 0) return;
17222         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17223         CHECK_ACCESS(_res_ptr);
17224         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
17225         FREE((void*)_res);
17226         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
17227 }
17228
17229 static inline uintptr_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
17230         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
17231         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
17232         return (uint32_t)ret_conv;
17233 }
17234 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_clone_ptr"))) TS_CResult_NodeInfoDecodeErrorZ_clone_ptr(uint32_t arg) {
17235         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
17236         uint32_t ret_conv = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
17237         return ret_conv;
17238 }
17239
17240 uint32_t  __attribute__((export_name("TS_CResult_NodeInfoDecodeErrorZ_clone"))) TS_CResult_NodeInfoDecodeErrorZ_clone(uint32_t orig) {
17241         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
17242         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
17243         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
17244         return (uint32_t)ret_conv;
17245 }
17246
17247 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_ok(uint32_t o) {
17248         LDKNetworkGraph o_conv;
17249         o_conv.inner = (void*)(o & (~1));
17250         o_conv.is_owned = (o & 1) || (o == 0);
17251         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17252         o_conv = NetworkGraph_clone(&o_conv);
17253         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
17254         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
17255         return (uint32_t)ret_conv;
17256 }
17257
17258 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_err"))) TS_CResult_NetworkGraphDecodeErrorZ_err(uint32_t e) {
17259         LDKDecodeError e_conv;
17260         e_conv.inner = (void*)(e & (~1));
17261         e_conv.is_owned = (e & 1) || (e == 0);
17262         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17263         e_conv = DecodeError_clone(&e_conv);
17264         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
17265         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
17266         return (uint32_t)ret_conv;
17267 }
17268
17269 jboolean  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_is_ok"))) TS_CResult_NetworkGraphDecodeErrorZ_is_ok(uint32_t o) {
17270         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(o & ~1);
17271         jboolean ret_conv = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
17272         return ret_conv;
17273 }
17274
17275 void  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_free"))) TS_CResult_NetworkGraphDecodeErrorZ_free(uint32_t _res) {
17276         if ((_res & 1) != 0) return;
17277         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17278         CHECK_ACCESS(_res_ptr);
17279         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
17280         FREE((void*)_res);
17281         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
17282 }
17283
17284 static inline uintptr_t CResult_NetworkGraphDecodeErrorZ_clone_ptr(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR arg) {
17285         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
17286         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(arg);
17287         return (uint32_t)ret_conv;
17288 }
17289 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_clone_ptr"))) TS_CResult_NetworkGraphDecodeErrorZ_clone_ptr(uint32_t arg) {
17290         LDKCResult_NetworkGraphDecodeErrorZ* arg_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
17291         uint32_t ret_conv = CResult_NetworkGraphDecodeErrorZ_clone_ptr(arg_conv);
17292         return ret_conv;
17293 }
17294
17295 uint32_t  __attribute__((export_name("TS_CResult_NetworkGraphDecodeErrorZ_clone"))) TS_CResult_NetworkGraphDecodeErrorZ_clone(uint32_t orig) {
17296         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
17297         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
17298         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
17299         return (uint32_t)ret_conv;
17300 }
17301
17302 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_some"))) TS_COption_CVec_NetAddressZZ_some(uint32_tArray o) {
17303         LDKCVec_NetAddressZ o_constr;
17304         o_constr.datalen = o->arr_len;
17305         if (o_constr.datalen > 0)
17306                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
17307         else
17308                 o_constr.data = NULL;
17309         uint32_t* o_vals = o->elems /* XXX o leaks */;
17310         for (size_t m = 0; m < o_constr.datalen; m++) {
17311                 uint32_t o_conv_12 = o_vals[m];
17312                 void* o_conv_12_ptr = (void*)(((uintptr_t)o_conv_12) & ~1);
17313                 CHECK_ACCESS(o_conv_12_ptr);
17314                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
17315                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o_conv_12) & ~1));
17316                 o_constr.data[m] = o_conv_12_conv;
17317         }
17318         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17319         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
17320         uint32_t ret_ref = (uintptr_t)ret_copy;
17321         return ret_ref;
17322 }
17323
17324 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_none"))) TS_COption_CVec_NetAddressZZ_none() {
17325         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17326         *ret_copy = COption_CVec_NetAddressZZ_none();
17327         uint32_t ret_ref = (uintptr_t)ret_copy;
17328         return ret_ref;
17329 }
17330
17331 void  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_free"))) TS_COption_CVec_NetAddressZZ_free(uint32_t _res) {
17332         if ((_res & 1) != 0) return;
17333         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17334         CHECK_ACCESS(_res_ptr);
17335         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
17336         FREE((void*)_res);
17337         COption_CVec_NetAddressZZ_free(_res_conv);
17338 }
17339
17340 static inline uintptr_t COption_CVec_NetAddressZZ_clone_ptr(LDKCOption_CVec_NetAddressZZ *NONNULL_PTR arg) {
17341         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17342         *ret_copy = COption_CVec_NetAddressZZ_clone(arg);
17343 uint32_t ret_ref = (uintptr_t)ret_copy;
17344         return ret_ref;
17345 }
17346 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_clone_ptr"))) TS_COption_CVec_NetAddressZZ_clone_ptr(uint32_t arg) {
17347         LDKCOption_CVec_NetAddressZZ* arg_conv = (LDKCOption_CVec_NetAddressZZ*)arg;
17348         uint32_t ret_conv = COption_CVec_NetAddressZZ_clone_ptr(arg_conv);
17349         return ret_conv;
17350 }
17351
17352 uint32_t  __attribute__((export_name("TS_COption_CVec_NetAddressZZ_clone"))) TS_COption_CVec_NetAddressZZ_clone(uint32_t orig) {
17353         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)orig;
17354         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17355         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
17356         uint32_t ret_ref = (uintptr_t)ret_copy;
17357         return ret_ref;
17358 }
17359
17360 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_ok"))) TS_CResult_NetAddressDecodeErrorZ_ok(uint32_t o) {
17361         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
17362         CHECK_ACCESS(o_ptr);
17363         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
17364         o_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)o) & ~1));
17365         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17366         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
17367         return (uint32_t)ret_conv;
17368 }
17369
17370 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_err"))) TS_CResult_NetAddressDecodeErrorZ_err(uint32_t e) {
17371         LDKDecodeError e_conv;
17372         e_conv.inner = (void*)(e & (~1));
17373         e_conv.is_owned = (e & 1) || (e == 0);
17374         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17375         e_conv = DecodeError_clone(&e_conv);
17376         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17377         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
17378         return (uint32_t)ret_conv;
17379 }
17380
17381 jboolean  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_is_ok"))) TS_CResult_NetAddressDecodeErrorZ_is_ok(uint32_t o) {
17382         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)(o & ~1);
17383         jboolean ret_conv = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
17384         return ret_conv;
17385 }
17386
17387 void  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_free"))) TS_CResult_NetAddressDecodeErrorZ_free(uint32_t _res) {
17388         if ((_res & 1) != 0) return;
17389         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17390         CHECK_ACCESS(_res_ptr);
17391         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
17392         FREE((void*)_res);
17393         CResult_NetAddressDecodeErrorZ_free(_res_conv);
17394 }
17395
17396 static inline uintptr_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
17397         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17398         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
17399         return (uint32_t)ret_conv;
17400 }
17401 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_clone_ptr"))) TS_CResult_NetAddressDecodeErrorZ_clone_ptr(uint32_t arg) {
17402         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
17403         uint32_t ret_conv = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
17404         return ret_conv;
17405 }
17406
17407 uint32_t  __attribute__((export_name("TS_CResult_NetAddressDecodeErrorZ_clone"))) TS_CResult_NetAddressDecodeErrorZ_clone(uint32_t orig) {
17408         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
17409         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17410         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
17411         return (uint32_t)ret_conv;
17412 }
17413
17414 void  __attribute__((export_name("TS_CVec_UpdateAddHTLCZ_free"))) TS_CVec_UpdateAddHTLCZ_free(uint32_tArray _res) {
17415         LDKCVec_UpdateAddHTLCZ _res_constr;
17416         _res_constr.datalen = _res->arr_len;
17417         if (_res_constr.datalen > 0)
17418                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
17419         else
17420                 _res_constr.data = NULL;
17421         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
17422         for (size_t p = 0; p < _res_constr.datalen; p++) {
17423                 uint32_t _res_conv_15 = _res_vals[p];
17424                 LDKUpdateAddHTLC _res_conv_15_conv;
17425                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
17426                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
17427                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
17428                 _res_constr.data[p] = _res_conv_15_conv;
17429         }
17430         CVec_UpdateAddHTLCZ_free(_res_constr);
17431 }
17432
17433 void  __attribute__((export_name("TS_CVec_UpdateFulfillHTLCZ_free"))) TS_CVec_UpdateFulfillHTLCZ_free(uint32_tArray _res) {
17434         LDKCVec_UpdateFulfillHTLCZ _res_constr;
17435         _res_constr.datalen = _res->arr_len;
17436         if (_res_constr.datalen > 0)
17437                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
17438         else
17439                 _res_constr.data = NULL;
17440         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
17441         for (size_t t = 0; t < _res_constr.datalen; t++) {
17442                 uint32_t _res_conv_19 = _res_vals[t];
17443                 LDKUpdateFulfillHTLC _res_conv_19_conv;
17444                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
17445                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
17446                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
17447                 _res_constr.data[t] = _res_conv_19_conv;
17448         }
17449         CVec_UpdateFulfillHTLCZ_free(_res_constr);
17450 }
17451
17452 void  __attribute__((export_name("TS_CVec_UpdateFailHTLCZ_free"))) TS_CVec_UpdateFailHTLCZ_free(uint32_tArray _res) {
17453         LDKCVec_UpdateFailHTLCZ _res_constr;
17454         _res_constr.datalen = _res->arr_len;
17455         if (_res_constr.datalen > 0)
17456                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
17457         else
17458                 _res_constr.data = NULL;
17459         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
17460         for (size_t q = 0; q < _res_constr.datalen; q++) {
17461                 uint32_t _res_conv_16 = _res_vals[q];
17462                 LDKUpdateFailHTLC _res_conv_16_conv;
17463                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
17464                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
17465                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
17466                 _res_constr.data[q] = _res_conv_16_conv;
17467         }
17468         CVec_UpdateFailHTLCZ_free(_res_constr);
17469 }
17470
17471 void  __attribute__((export_name("TS_CVec_UpdateFailMalformedHTLCZ_free"))) TS_CVec_UpdateFailMalformedHTLCZ_free(uint32_tArray _res) {
17472         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
17473         _res_constr.datalen = _res->arr_len;
17474         if (_res_constr.datalen > 0)
17475                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
17476         else
17477                 _res_constr.data = NULL;
17478         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
17479         for (size_t z = 0; z < _res_constr.datalen; z++) {
17480                 uint32_t _res_conv_25 = _res_vals[z];
17481                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
17482                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
17483                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
17484                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
17485                 _res_constr.data[z] = _res_conv_25_conv;
17486         }
17487         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
17488 }
17489
17490 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_ok(uint32_t o) {
17491         LDKAcceptChannel o_conv;
17492         o_conv.inner = (void*)(o & (~1));
17493         o_conv.is_owned = (o & 1) || (o == 0);
17494         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17495         o_conv = AcceptChannel_clone(&o_conv);
17496         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
17497         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
17498         return (uint32_t)ret_conv;
17499 }
17500
17501 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_err"))) TS_CResult_AcceptChannelDecodeErrorZ_err(uint32_t e) {
17502         LDKDecodeError e_conv;
17503         e_conv.inner = (void*)(e & (~1));
17504         e_conv.is_owned = (e & 1) || (e == 0);
17505         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17506         e_conv = DecodeError_clone(&e_conv);
17507         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
17508         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
17509         return (uint32_t)ret_conv;
17510 }
17511
17512 jboolean  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_is_ok"))) TS_CResult_AcceptChannelDecodeErrorZ_is_ok(uint32_t o) {
17513         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(o & ~1);
17514         jboolean ret_conv = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
17515         return ret_conv;
17516 }
17517
17518 void  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_free"))) TS_CResult_AcceptChannelDecodeErrorZ_free(uint32_t _res) {
17519         if ((_res & 1) != 0) return;
17520         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17521         CHECK_ACCESS(_res_ptr);
17522         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
17523         FREE((void*)_res);
17524         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
17525 }
17526
17527 static inline uintptr_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
17528         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
17529         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
17530         return (uint32_t)ret_conv;
17531 }
17532 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_clone_ptr"))) TS_CResult_AcceptChannelDecodeErrorZ_clone_ptr(uint32_t arg) {
17533         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
17534         uint32_t ret_conv = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
17535         return ret_conv;
17536 }
17537
17538 uint32_t  __attribute__((export_name("TS_CResult_AcceptChannelDecodeErrorZ_clone"))) TS_CResult_AcceptChannelDecodeErrorZ_clone(uint32_t orig) {
17539         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
17540         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
17541         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
17542         return (uint32_t)ret_conv;
17543 }
17544
17545 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_ok(uint32_t o) {
17546         LDKAnnouncementSignatures o_conv;
17547         o_conv.inner = (void*)(o & (~1));
17548         o_conv.is_owned = (o & 1) || (o == 0);
17549         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17550         o_conv = AnnouncementSignatures_clone(&o_conv);
17551         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
17552         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
17553         return (uint32_t)ret_conv;
17554 }
17555
17556 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_err"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_err(uint32_t e) {
17557         LDKDecodeError e_conv;
17558         e_conv.inner = (void*)(e & (~1));
17559         e_conv.is_owned = (e & 1) || (e == 0);
17560         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17561         e_conv = DecodeError_clone(&e_conv);
17562         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
17563         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
17564         return (uint32_t)ret_conv;
17565 }
17566
17567 jboolean  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_is_ok"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(uint32_t o) {
17568         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(o & ~1);
17569         jboolean ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
17570         return ret_conv;
17571 }
17572
17573 void  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_free"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_free(uint32_t _res) {
17574         if ((_res & 1) != 0) return;
17575         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17576         CHECK_ACCESS(_res_ptr);
17577         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
17578         FREE((void*)_res);
17579         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
17580 }
17581
17582 static inline uintptr_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
17583         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
17584         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
17585         return (uint32_t)ret_conv;
17586 }
17587 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(uint32_t arg) {
17588         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
17589         uint32_t ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
17590         return ret_conv;
17591 }
17592
17593 uint32_t  __attribute__((export_name("TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone"))) TS_CResult_AnnouncementSignaturesDecodeErrorZ_clone(uint32_t orig) {
17594         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
17595         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
17596         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
17597         return (uint32_t)ret_conv;
17598 }
17599
17600 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_ok(uint32_t o) {
17601         LDKChannelReestablish o_conv;
17602         o_conv.inner = (void*)(o & (~1));
17603         o_conv.is_owned = (o & 1) || (o == 0);
17604         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17605         o_conv = ChannelReestablish_clone(&o_conv);
17606         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
17607         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
17608         return (uint32_t)ret_conv;
17609 }
17610
17611 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_err"))) TS_CResult_ChannelReestablishDecodeErrorZ_err(uint32_t e) {
17612         LDKDecodeError e_conv;
17613         e_conv.inner = (void*)(e & (~1));
17614         e_conv.is_owned = (e & 1) || (e == 0);
17615         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17616         e_conv = DecodeError_clone(&e_conv);
17617         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
17618         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
17619         return (uint32_t)ret_conv;
17620 }
17621
17622 jboolean  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_is_ok"))) TS_CResult_ChannelReestablishDecodeErrorZ_is_ok(uint32_t o) {
17623         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(o & ~1);
17624         jboolean ret_conv = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
17625         return ret_conv;
17626 }
17627
17628 void  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_free"))) TS_CResult_ChannelReestablishDecodeErrorZ_free(uint32_t _res) {
17629         if ((_res & 1) != 0) return;
17630         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17631         CHECK_ACCESS(_res_ptr);
17632         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
17633         FREE((void*)_res);
17634         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
17635 }
17636
17637 static inline uintptr_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
17638         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
17639         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
17640         return (uint32_t)ret_conv;
17641 }
17642 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone_ptr(uint32_t arg) {
17643         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
17644         uint32_t ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
17645         return ret_conv;
17646 }
17647
17648 uint32_t  __attribute__((export_name("TS_CResult_ChannelReestablishDecodeErrorZ_clone"))) TS_CResult_ChannelReestablishDecodeErrorZ_clone(uint32_t orig) {
17649         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
17650         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
17651         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
17652         return (uint32_t)ret_conv;
17653 }
17654
17655 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_ok(uint32_t o) {
17656         LDKClosingSigned o_conv;
17657         o_conv.inner = (void*)(o & (~1));
17658         o_conv.is_owned = (o & 1) || (o == 0);
17659         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17660         o_conv = ClosingSigned_clone(&o_conv);
17661         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
17662         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
17663         return (uint32_t)ret_conv;
17664 }
17665
17666 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_err"))) TS_CResult_ClosingSignedDecodeErrorZ_err(uint32_t e) {
17667         LDKDecodeError e_conv;
17668         e_conv.inner = (void*)(e & (~1));
17669         e_conv.is_owned = (e & 1) || (e == 0);
17670         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17671         e_conv = DecodeError_clone(&e_conv);
17672         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
17673         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
17674         return (uint32_t)ret_conv;
17675 }
17676
17677 jboolean  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_is_ok"))) TS_CResult_ClosingSignedDecodeErrorZ_is_ok(uint32_t o) {
17678         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(o & ~1);
17679         jboolean ret_conv = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
17680         return ret_conv;
17681 }
17682
17683 void  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_free"))) TS_CResult_ClosingSignedDecodeErrorZ_free(uint32_t _res) {
17684         if ((_res & 1) != 0) return;
17685         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17686         CHECK_ACCESS(_res_ptr);
17687         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
17688         FREE((void*)_res);
17689         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
17690 }
17691
17692 static inline uintptr_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
17693         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
17694         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
17695         return (uint32_t)ret_conv;
17696 }
17697 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_clone_ptr"))) TS_CResult_ClosingSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
17698         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
17699         uint32_t ret_conv = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
17700         return ret_conv;
17701 }
17702
17703 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedDecodeErrorZ_clone"))) TS_CResult_ClosingSignedDecodeErrorZ_clone(uint32_t orig) {
17704         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
17705         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
17706         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
17707         return (uint32_t)ret_conv;
17708 }
17709
17710 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(uint32_t o) {
17711         LDKClosingSignedFeeRange o_conv;
17712         o_conv.inner = (void*)(o & (~1));
17713         o_conv.is_owned = (o & 1) || (o == 0);
17714         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17715         o_conv = ClosingSignedFeeRange_clone(&o_conv);
17716         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
17717         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
17718         return (uint32_t)ret_conv;
17719 }
17720
17721 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_err"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_err(uint32_t e) {
17722         LDKDecodeError e_conv;
17723         e_conv.inner = (void*)(e & (~1));
17724         e_conv.is_owned = (e & 1) || (e == 0);
17725         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17726         e_conv = DecodeError_clone(&e_conv);
17727         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
17728         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
17729         return (uint32_t)ret_conv;
17730 }
17731
17732 jboolean  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(uint32_t o) {
17733         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(o & ~1);
17734         jboolean ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
17735         return ret_conv;
17736 }
17737
17738 void  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_free"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_free(uint32_t _res) {
17739         if ((_res & 1) != 0) return;
17740         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17741         CHECK_ACCESS(_res_ptr);
17742         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
17743         FREE((void*)_res);
17744         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
17745 }
17746
17747 static inline uintptr_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
17748         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
17749         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
17750         return (uint32_t)ret_conv;
17751 }
17752 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
17753         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
17754         uint32_t ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
17755         return ret_conv;
17756 }
17757
17758 uint32_t  __attribute__((export_name("TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone"))) TS_CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(uint32_t orig) {
17759         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1);
17760         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
17761         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
17762         return (uint32_t)ret_conv;
17763 }
17764
17765 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_ok(uint32_t o) {
17766         LDKCommitmentSigned o_conv;
17767         o_conv.inner = (void*)(o & (~1));
17768         o_conv.is_owned = (o & 1) || (o == 0);
17769         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17770         o_conv = CommitmentSigned_clone(&o_conv);
17771         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
17772         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
17773         return (uint32_t)ret_conv;
17774 }
17775
17776 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_err"))) TS_CResult_CommitmentSignedDecodeErrorZ_err(uint32_t e) {
17777         LDKDecodeError e_conv;
17778         e_conv.inner = (void*)(e & (~1));
17779         e_conv.is_owned = (e & 1) || (e == 0);
17780         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17781         e_conv = DecodeError_clone(&e_conv);
17782         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
17783         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
17784         return (uint32_t)ret_conv;
17785 }
17786
17787 jboolean  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_is_ok"))) TS_CResult_CommitmentSignedDecodeErrorZ_is_ok(uint32_t o) {
17788         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(o & ~1);
17789         jboolean ret_conv = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
17790         return ret_conv;
17791 }
17792
17793 void  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_free"))) TS_CResult_CommitmentSignedDecodeErrorZ_free(uint32_t _res) {
17794         if ((_res & 1) != 0) return;
17795         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17796         CHECK_ACCESS(_res_ptr);
17797         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
17798         FREE((void*)_res);
17799         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
17800 }
17801
17802 static inline uintptr_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
17803         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
17804         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
17805         return (uint32_t)ret_conv;
17806 }
17807 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_clone_ptr"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
17808         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
17809         uint32_t ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
17810         return ret_conv;
17811 }
17812
17813 uint32_t  __attribute__((export_name("TS_CResult_CommitmentSignedDecodeErrorZ_clone"))) TS_CResult_CommitmentSignedDecodeErrorZ_clone(uint32_t orig) {
17814         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
17815         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
17816         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
17817         return (uint32_t)ret_conv;
17818 }
17819
17820 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_ok(uint32_t o) {
17821         LDKFundingCreated o_conv;
17822         o_conv.inner = (void*)(o & (~1));
17823         o_conv.is_owned = (o & 1) || (o == 0);
17824         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17825         o_conv = FundingCreated_clone(&o_conv);
17826         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
17827         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
17828         return (uint32_t)ret_conv;
17829 }
17830
17831 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_err"))) TS_CResult_FundingCreatedDecodeErrorZ_err(uint32_t e) {
17832         LDKDecodeError e_conv;
17833         e_conv.inner = (void*)(e & (~1));
17834         e_conv.is_owned = (e & 1) || (e == 0);
17835         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17836         e_conv = DecodeError_clone(&e_conv);
17837         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
17838         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
17839         return (uint32_t)ret_conv;
17840 }
17841
17842 jboolean  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_is_ok"))) TS_CResult_FundingCreatedDecodeErrorZ_is_ok(uint32_t o) {
17843         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(o & ~1);
17844         jboolean ret_conv = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
17845         return ret_conv;
17846 }
17847
17848 void  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_free"))) TS_CResult_FundingCreatedDecodeErrorZ_free(uint32_t _res) {
17849         if ((_res & 1) != 0) return;
17850         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17851         CHECK_ACCESS(_res_ptr);
17852         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
17853         FREE((void*)_res);
17854         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
17855 }
17856
17857 static inline uintptr_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
17858         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
17859         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
17860         return (uint32_t)ret_conv;
17861 }
17862 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_clone_ptr"))) TS_CResult_FundingCreatedDecodeErrorZ_clone_ptr(uint32_t arg) {
17863         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
17864         uint32_t ret_conv = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
17865         return ret_conv;
17866 }
17867
17868 uint32_t  __attribute__((export_name("TS_CResult_FundingCreatedDecodeErrorZ_clone"))) TS_CResult_FundingCreatedDecodeErrorZ_clone(uint32_t orig) {
17869         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
17870         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
17871         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
17872         return (uint32_t)ret_conv;
17873 }
17874
17875 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_ok"))) TS_CResult_FundingSignedDecodeErrorZ_ok(uint32_t o) {
17876         LDKFundingSigned o_conv;
17877         o_conv.inner = (void*)(o & (~1));
17878         o_conv.is_owned = (o & 1) || (o == 0);
17879         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17880         o_conv = FundingSigned_clone(&o_conv);
17881         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
17882         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
17883         return (uint32_t)ret_conv;
17884 }
17885
17886 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_err"))) TS_CResult_FundingSignedDecodeErrorZ_err(uint32_t e) {
17887         LDKDecodeError e_conv;
17888         e_conv.inner = (void*)(e & (~1));
17889         e_conv.is_owned = (e & 1) || (e == 0);
17890         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17891         e_conv = DecodeError_clone(&e_conv);
17892         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
17893         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
17894         return (uint32_t)ret_conv;
17895 }
17896
17897 jboolean  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_is_ok"))) TS_CResult_FundingSignedDecodeErrorZ_is_ok(uint32_t o) {
17898         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(o & ~1);
17899         jboolean ret_conv = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
17900         return ret_conv;
17901 }
17902
17903 void  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_free"))) TS_CResult_FundingSignedDecodeErrorZ_free(uint32_t _res) {
17904         if ((_res & 1) != 0) return;
17905         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17906         CHECK_ACCESS(_res_ptr);
17907         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
17908         FREE((void*)_res);
17909         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
17910 }
17911
17912 static inline uintptr_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
17913         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
17914         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
17915         return (uint32_t)ret_conv;
17916 }
17917 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_clone_ptr"))) TS_CResult_FundingSignedDecodeErrorZ_clone_ptr(uint32_t arg) {
17918         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
17919         uint32_t ret_conv = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
17920         return ret_conv;
17921 }
17922
17923 uint32_t  __attribute__((export_name("TS_CResult_FundingSignedDecodeErrorZ_clone"))) TS_CResult_FundingSignedDecodeErrorZ_clone(uint32_t orig) {
17924         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
17925         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
17926         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
17927         return (uint32_t)ret_conv;
17928 }
17929
17930 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_ok"))) TS_CResult_FundingLockedDecodeErrorZ_ok(uint32_t o) {
17931         LDKFundingLocked o_conv;
17932         o_conv.inner = (void*)(o & (~1));
17933         o_conv.is_owned = (o & 1) || (o == 0);
17934         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17935         o_conv = FundingLocked_clone(&o_conv);
17936         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
17937         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
17938         return (uint32_t)ret_conv;
17939 }
17940
17941 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_err"))) TS_CResult_FundingLockedDecodeErrorZ_err(uint32_t e) {
17942         LDKDecodeError e_conv;
17943         e_conv.inner = (void*)(e & (~1));
17944         e_conv.is_owned = (e & 1) || (e == 0);
17945         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17946         e_conv = DecodeError_clone(&e_conv);
17947         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
17948         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
17949         return (uint32_t)ret_conv;
17950 }
17951
17952 jboolean  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_is_ok"))) TS_CResult_FundingLockedDecodeErrorZ_is_ok(uint32_t o) {
17953         LDKCResult_FundingLockedDecodeErrorZ* o_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(o & ~1);
17954         jboolean ret_conv = CResult_FundingLockedDecodeErrorZ_is_ok(o_conv);
17955         return ret_conv;
17956 }
17957
17958 void  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_free"))) TS_CResult_FundingLockedDecodeErrorZ_free(uint32_t _res) {
17959         if ((_res & 1) != 0) return;
17960         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
17961         CHECK_ACCESS(_res_ptr);
17962         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(_res_ptr);
17963         FREE((void*)_res);
17964         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
17965 }
17966
17967 static inline uintptr_t CResult_FundingLockedDecodeErrorZ_clone_ptr(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR arg) {
17968         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
17969         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(arg);
17970         return (uint32_t)ret_conv;
17971 }
17972 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_clone_ptr"))) TS_CResult_FundingLockedDecodeErrorZ_clone_ptr(uint32_t arg) {
17973         LDKCResult_FundingLockedDecodeErrorZ* arg_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
17974         uint32_t ret_conv = CResult_FundingLockedDecodeErrorZ_clone_ptr(arg_conv);
17975         return ret_conv;
17976 }
17977
17978 uint32_t  __attribute__((export_name("TS_CResult_FundingLockedDecodeErrorZ_clone"))) TS_CResult_FundingLockedDecodeErrorZ_clone(uint32_t orig) {
17979         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
17980         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
17981         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
17982         return (uint32_t)ret_conv;
17983 }
17984
17985 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_ok"))) TS_CResult_InitDecodeErrorZ_ok(uint32_t o) {
17986         LDKInit o_conv;
17987         o_conv.inner = (void*)(o & (~1));
17988         o_conv.is_owned = (o & 1) || (o == 0);
17989         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17990         o_conv = Init_clone(&o_conv);
17991         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
17992         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
17993         return (uint32_t)ret_conv;
17994 }
17995
17996 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_err"))) TS_CResult_InitDecodeErrorZ_err(uint32_t e) {
17997         LDKDecodeError e_conv;
17998         e_conv.inner = (void*)(e & (~1));
17999         e_conv.is_owned = (e & 1) || (e == 0);
18000         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18001         e_conv = DecodeError_clone(&e_conv);
18002         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
18003         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
18004         return (uint32_t)ret_conv;
18005 }
18006
18007 jboolean  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_is_ok"))) TS_CResult_InitDecodeErrorZ_is_ok(uint32_t o) {
18008         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)(o & ~1);
18009         jboolean ret_conv = CResult_InitDecodeErrorZ_is_ok(o_conv);
18010         return ret_conv;
18011 }
18012
18013 void  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_free"))) TS_CResult_InitDecodeErrorZ_free(uint32_t _res) {
18014         if ((_res & 1) != 0) return;
18015         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18016         CHECK_ACCESS(_res_ptr);
18017         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
18018         FREE((void*)_res);
18019         CResult_InitDecodeErrorZ_free(_res_conv);
18020 }
18021
18022 static inline uintptr_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
18023         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
18024         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
18025         return (uint32_t)ret_conv;
18026 }
18027 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_clone_ptr"))) TS_CResult_InitDecodeErrorZ_clone_ptr(uint32_t arg) {
18028         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
18029         uint32_t ret_conv = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
18030         return ret_conv;
18031 }
18032
18033 uint32_t  __attribute__((export_name("TS_CResult_InitDecodeErrorZ_clone"))) TS_CResult_InitDecodeErrorZ_clone(uint32_t orig) {
18034         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
18035         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
18036         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
18037         return (uint32_t)ret_conv;
18038 }
18039
18040 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_ok"))) TS_CResult_OpenChannelDecodeErrorZ_ok(uint32_t o) {
18041         LDKOpenChannel o_conv;
18042         o_conv.inner = (void*)(o & (~1));
18043         o_conv.is_owned = (o & 1) || (o == 0);
18044         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18045         o_conv = OpenChannel_clone(&o_conv);
18046         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
18047         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
18048         return (uint32_t)ret_conv;
18049 }
18050
18051 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_err"))) TS_CResult_OpenChannelDecodeErrorZ_err(uint32_t e) {
18052         LDKDecodeError e_conv;
18053         e_conv.inner = (void*)(e & (~1));
18054         e_conv.is_owned = (e & 1) || (e == 0);
18055         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18056         e_conv = DecodeError_clone(&e_conv);
18057         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
18058         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
18059         return (uint32_t)ret_conv;
18060 }
18061
18062 jboolean  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_is_ok"))) TS_CResult_OpenChannelDecodeErrorZ_is_ok(uint32_t o) {
18063         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(o & ~1);
18064         jboolean ret_conv = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
18065         return ret_conv;
18066 }
18067
18068 void  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_free"))) TS_CResult_OpenChannelDecodeErrorZ_free(uint32_t _res) {
18069         if ((_res & 1) != 0) return;
18070         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18071         CHECK_ACCESS(_res_ptr);
18072         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
18073         FREE((void*)_res);
18074         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
18075 }
18076
18077 static inline uintptr_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
18078         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
18079         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
18080         return (uint32_t)ret_conv;
18081 }
18082 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_clone_ptr"))) TS_CResult_OpenChannelDecodeErrorZ_clone_ptr(uint32_t arg) {
18083         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
18084         uint32_t ret_conv = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
18085         return ret_conv;
18086 }
18087
18088 uint32_t  __attribute__((export_name("TS_CResult_OpenChannelDecodeErrorZ_clone"))) TS_CResult_OpenChannelDecodeErrorZ_clone(uint32_t orig) {
18089         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
18090         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
18091         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
18092         return (uint32_t)ret_conv;
18093 }
18094
18095 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_ok(uint32_t o) {
18096         LDKRevokeAndACK o_conv;
18097         o_conv.inner = (void*)(o & (~1));
18098         o_conv.is_owned = (o & 1) || (o == 0);
18099         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18100         o_conv = RevokeAndACK_clone(&o_conv);
18101         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
18102         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
18103         return (uint32_t)ret_conv;
18104 }
18105
18106 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_err"))) TS_CResult_RevokeAndACKDecodeErrorZ_err(uint32_t e) {
18107         LDKDecodeError e_conv;
18108         e_conv.inner = (void*)(e & (~1));
18109         e_conv.is_owned = (e & 1) || (e == 0);
18110         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18111         e_conv = DecodeError_clone(&e_conv);
18112         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
18113         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
18114         return (uint32_t)ret_conv;
18115 }
18116
18117 jboolean  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_is_ok"))) TS_CResult_RevokeAndACKDecodeErrorZ_is_ok(uint32_t o) {
18118         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(o & ~1);
18119         jboolean ret_conv = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
18120         return ret_conv;
18121 }
18122
18123 void  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_free"))) TS_CResult_RevokeAndACKDecodeErrorZ_free(uint32_t _res) {
18124         if ((_res & 1) != 0) return;
18125         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18126         CHECK_ACCESS(_res_ptr);
18127         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
18128         FREE((void*)_res);
18129         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
18130 }
18131
18132 static inline uintptr_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
18133         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
18134         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
18135         return (uint32_t)ret_conv;
18136 }
18137 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_clone_ptr"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone_ptr(uint32_t arg) {
18138         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
18139         uint32_t ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
18140         return ret_conv;
18141 }
18142
18143 uint32_t  __attribute__((export_name("TS_CResult_RevokeAndACKDecodeErrorZ_clone"))) TS_CResult_RevokeAndACKDecodeErrorZ_clone(uint32_t orig) {
18144         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
18145         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
18146         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
18147         return (uint32_t)ret_conv;
18148 }
18149
18150 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_ok"))) TS_CResult_ShutdownDecodeErrorZ_ok(uint32_t o) {
18151         LDKShutdown o_conv;
18152         o_conv.inner = (void*)(o & (~1));
18153         o_conv.is_owned = (o & 1) || (o == 0);
18154         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18155         o_conv = Shutdown_clone(&o_conv);
18156         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
18157         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
18158         return (uint32_t)ret_conv;
18159 }
18160
18161 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_err"))) TS_CResult_ShutdownDecodeErrorZ_err(uint32_t e) {
18162         LDKDecodeError e_conv;
18163         e_conv.inner = (void*)(e & (~1));
18164         e_conv.is_owned = (e & 1) || (e == 0);
18165         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18166         e_conv = DecodeError_clone(&e_conv);
18167         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
18168         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
18169         return (uint32_t)ret_conv;
18170 }
18171
18172 jboolean  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_is_ok"))) TS_CResult_ShutdownDecodeErrorZ_is_ok(uint32_t o) {
18173         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)(o & ~1);
18174         jboolean ret_conv = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
18175         return ret_conv;
18176 }
18177
18178 void  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_free"))) TS_CResult_ShutdownDecodeErrorZ_free(uint32_t _res) {
18179         if ((_res & 1) != 0) return;
18180         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18181         CHECK_ACCESS(_res_ptr);
18182         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
18183         FREE((void*)_res);
18184         CResult_ShutdownDecodeErrorZ_free(_res_conv);
18185 }
18186
18187 static inline uintptr_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
18188         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
18189         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
18190         return (uint32_t)ret_conv;
18191 }
18192 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_clone_ptr"))) TS_CResult_ShutdownDecodeErrorZ_clone_ptr(uint32_t arg) {
18193         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
18194         uint32_t ret_conv = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
18195         return ret_conv;
18196 }
18197
18198 uint32_t  __attribute__((export_name("TS_CResult_ShutdownDecodeErrorZ_clone"))) TS_CResult_ShutdownDecodeErrorZ_clone(uint32_t orig) {
18199         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
18200         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
18201         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
18202         return (uint32_t)ret_conv;
18203 }
18204
18205 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_ok(uint32_t o) {
18206         LDKUpdateFailHTLC o_conv;
18207         o_conv.inner = (void*)(o & (~1));
18208         o_conv.is_owned = (o & 1) || (o == 0);
18209         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18210         o_conv = UpdateFailHTLC_clone(&o_conv);
18211         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
18212         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
18213         return (uint32_t)ret_conv;
18214 }
18215
18216 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_err(uint32_t e) {
18217         LDKDecodeError e_conv;
18218         e_conv.inner = (void*)(e & (~1));
18219         e_conv.is_owned = (e & 1) || (e == 0);
18220         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18221         e_conv = DecodeError_clone(&e_conv);
18222         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
18223         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
18224         return (uint32_t)ret_conv;
18225 }
18226
18227 jboolean  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_is_ok(uint32_t o) {
18228         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(o & ~1);
18229         jboolean ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
18230         return ret_conv;
18231 }
18232
18233 void  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_free(uint32_t _res) {
18234         if ((_res & 1) != 0) return;
18235         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18236         CHECK_ACCESS(_res_ptr);
18237         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
18238         FREE((void*)_res);
18239         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
18240 }
18241
18242 static inline uintptr_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
18243         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
18244         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
18245         return (uint32_t)ret_conv;
18246 }
18247 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
18248         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
18249         uint32_t ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
18250         return ret_conv;
18251 }
18252
18253 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFailHTLCDecodeErrorZ_clone(uint32_t orig) {
18254         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
18255         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
18256         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
18257         return (uint32_t)ret_conv;
18258 }
18259
18260 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(uint32_t o) {
18261         LDKUpdateFailMalformedHTLC o_conv;
18262         o_conv.inner = (void*)(o & (~1));
18263         o_conv.is_owned = (o & 1) || (o == 0);
18264         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18265         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
18266         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
18267         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
18268         return (uint32_t)ret_conv;
18269 }
18270
18271 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(uint32_t e) {
18272         LDKDecodeError e_conv;
18273         e_conv.inner = (void*)(e & (~1));
18274         e_conv.is_owned = (e & 1) || (e == 0);
18275         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18276         e_conv = DecodeError_clone(&e_conv);
18277         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
18278         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
18279         return (uint32_t)ret_conv;
18280 }
18281
18282 jboolean  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(uint32_t o) {
18283         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(o & ~1);
18284         jboolean ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
18285         return ret_conv;
18286 }
18287
18288 void  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(uint32_t _res) {
18289         if ((_res & 1) != 0) return;
18290         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18291         CHECK_ACCESS(_res_ptr);
18292         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
18293         FREE((void*)_res);
18294         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
18295 }
18296
18297 static inline uintptr_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
18298         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
18299         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
18300         return (uint32_t)ret_conv;
18301 }
18302 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
18303         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
18304         uint32_t ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
18305         return ret_conv;
18306 }
18307
18308 uint32_t  __attribute__((export_name("TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(uint32_t orig) {
18309         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
18310         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
18311         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
18312         return (uint32_t)ret_conv;
18313 }
18314
18315 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_ok(uint32_t o) {
18316         LDKUpdateFee o_conv;
18317         o_conv.inner = (void*)(o & (~1));
18318         o_conv.is_owned = (o & 1) || (o == 0);
18319         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18320         o_conv = UpdateFee_clone(&o_conv);
18321         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18322         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
18323         return (uint32_t)ret_conv;
18324 }
18325
18326 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_err"))) TS_CResult_UpdateFeeDecodeErrorZ_err(uint32_t e) {
18327         LDKDecodeError e_conv;
18328         e_conv.inner = (void*)(e & (~1));
18329         e_conv.is_owned = (e & 1) || (e == 0);
18330         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18331         e_conv = DecodeError_clone(&e_conv);
18332         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18333         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
18334         return (uint32_t)ret_conv;
18335 }
18336
18337 jboolean  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_is_ok"))) TS_CResult_UpdateFeeDecodeErrorZ_is_ok(uint32_t o) {
18338         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(o & ~1);
18339         jboolean ret_conv = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
18340         return ret_conv;
18341 }
18342
18343 void  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_free"))) TS_CResult_UpdateFeeDecodeErrorZ_free(uint32_t _res) {
18344         if ((_res & 1) != 0) return;
18345         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18346         CHECK_ACCESS(_res_ptr);
18347         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
18348         FREE((void*)_res);
18349         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
18350 }
18351
18352 static inline uintptr_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
18353         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18354         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
18355         return (uint32_t)ret_conv;
18356 }
18357 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFeeDecodeErrorZ_clone_ptr(uint32_t arg) {
18358         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
18359         uint32_t ret_conv = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
18360         return ret_conv;
18361 }
18362
18363 uint32_t  __attribute__((export_name("TS_CResult_UpdateFeeDecodeErrorZ_clone"))) TS_CResult_UpdateFeeDecodeErrorZ_clone(uint32_t orig) {
18364         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
18365         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18366         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
18367         return (uint32_t)ret_conv;
18368 }
18369
18370 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_ok(uint32_t o) {
18371         LDKUpdateFulfillHTLC o_conv;
18372         o_conv.inner = (void*)(o & (~1));
18373         o_conv.is_owned = (o & 1) || (o == 0);
18374         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18375         o_conv = UpdateFulfillHTLC_clone(&o_conv);
18376         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18377         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
18378         return (uint32_t)ret_conv;
18379 }
18380
18381 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_err(uint32_t e) {
18382         LDKDecodeError e_conv;
18383         e_conv.inner = (void*)(e & (~1));
18384         e_conv.is_owned = (e & 1) || (e == 0);
18385         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18386         e_conv = DecodeError_clone(&e_conv);
18387         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18388         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
18389         return (uint32_t)ret_conv;
18390 }
18391
18392 jboolean  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(uint32_t o) {
18393         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(o & ~1);
18394         jboolean ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
18395         return ret_conv;
18396 }
18397
18398 void  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_free(uint32_t _res) {
18399         if ((_res & 1) != 0) return;
18400         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18401         CHECK_ACCESS(_res_ptr);
18402         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
18403         FREE((void*)_res);
18404         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
18405 }
18406
18407 static inline uintptr_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
18408         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18409         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
18410         return (uint32_t)ret_conv;
18411 }
18412 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
18413         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
18414         uint32_t ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
18415         return ret_conv;
18416 }
18417
18418 uint32_t  __attribute__((export_name("TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateFulfillHTLCDecodeErrorZ_clone(uint32_t orig) {
18419         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
18420         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18421         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
18422         return (uint32_t)ret_conv;
18423 }
18424
18425 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_ok(uint32_t o) {
18426         LDKUpdateAddHTLC o_conv;
18427         o_conv.inner = (void*)(o & (~1));
18428         o_conv.is_owned = (o & 1) || (o == 0);
18429         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18430         o_conv = UpdateAddHTLC_clone(&o_conv);
18431         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18432         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
18433         return (uint32_t)ret_conv;
18434 }
18435
18436 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_err"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_err(uint32_t e) {
18437         LDKDecodeError e_conv;
18438         e_conv.inner = (void*)(e & (~1));
18439         e_conv.is_owned = (e & 1) || (e == 0);
18440         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18441         e_conv = DecodeError_clone(&e_conv);
18442         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18443         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
18444         return (uint32_t)ret_conv;
18445 }
18446
18447 jboolean  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_is_ok"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_is_ok(uint32_t o) {
18448         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(o & ~1);
18449         jboolean ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
18450         return ret_conv;
18451 }
18452
18453 void  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_free"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_free(uint32_t _res) {
18454         if ((_res & 1) != 0) return;
18455         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18456         CHECK_ACCESS(_res_ptr);
18457         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
18458         FREE((void*)_res);
18459         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
18460 }
18461
18462 static inline uintptr_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
18463         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18464         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
18465         return (uint32_t)ret_conv;
18466 }
18467 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(uint32_t arg) {
18468         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
18469         uint32_t ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
18470         return ret_conv;
18471 }
18472
18473 uint32_t  __attribute__((export_name("TS_CResult_UpdateAddHTLCDecodeErrorZ_clone"))) TS_CResult_UpdateAddHTLCDecodeErrorZ_clone(uint32_t orig) {
18474         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
18475         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18476         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
18477         return (uint32_t)ret_conv;
18478 }
18479
18480 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_ok"))) TS_CResult_PingDecodeErrorZ_ok(uint32_t o) {
18481         LDKPing o_conv;
18482         o_conv.inner = (void*)(o & (~1));
18483         o_conv.is_owned = (o & 1) || (o == 0);
18484         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18485         o_conv = Ping_clone(&o_conv);
18486         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
18487         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
18488         return (uint32_t)ret_conv;
18489 }
18490
18491 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_err"))) TS_CResult_PingDecodeErrorZ_err(uint32_t e) {
18492         LDKDecodeError e_conv;
18493         e_conv.inner = (void*)(e & (~1));
18494         e_conv.is_owned = (e & 1) || (e == 0);
18495         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18496         e_conv = DecodeError_clone(&e_conv);
18497         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
18498         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
18499         return (uint32_t)ret_conv;
18500 }
18501
18502 jboolean  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_is_ok"))) TS_CResult_PingDecodeErrorZ_is_ok(uint32_t o) {
18503         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)(o & ~1);
18504         jboolean ret_conv = CResult_PingDecodeErrorZ_is_ok(o_conv);
18505         return ret_conv;
18506 }
18507
18508 void  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_free"))) TS_CResult_PingDecodeErrorZ_free(uint32_t _res) {
18509         if ((_res & 1) != 0) return;
18510         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18511         CHECK_ACCESS(_res_ptr);
18512         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
18513         FREE((void*)_res);
18514         CResult_PingDecodeErrorZ_free(_res_conv);
18515 }
18516
18517 static inline uintptr_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
18518         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
18519         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
18520         return (uint32_t)ret_conv;
18521 }
18522 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_clone_ptr"))) TS_CResult_PingDecodeErrorZ_clone_ptr(uint32_t arg) {
18523         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
18524         uint32_t ret_conv = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
18525         return ret_conv;
18526 }
18527
18528 uint32_t  __attribute__((export_name("TS_CResult_PingDecodeErrorZ_clone"))) TS_CResult_PingDecodeErrorZ_clone(uint32_t orig) {
18529         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
18530         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
18531         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
18532         return (uint32_t)ret_conv;
18533 }
18534
18535 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_ok"))) TS_CResult_PongDecodeErrorZ_ok(uint32_t o) {
18536         LDKPong o_conv;
18537         o_conv.inner = (void*)(o & (~1));
18538         o_conv.is_owned = (o & 1) || (o == 0);
18539         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18540         o_conv = Pong_clone(&o_conv);
18541         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
18542         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
18543         return (uint32_t)ret_conv;
18544 }
18545
18546 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_err"))) TS_CResult_PongDecodeErrorZ_err(uint32_t e) {
18547         LDKDecodeError e_conv;
18548         e_conv.inner = (void*)(e & (~1));
18549         e_conv.is_owned = (e & 1) || (e == 0);
18550         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18551         e_conv = DecodeError_clone(&e_conv);
18552         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
18553         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
18554         return (uint32_t)ret_conv;
18555 }
18556
18557 jboolean  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_is_ok"))) TS_CResult_PongDecodeErrorZ_is_ok(uint32_t o) {
18558         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)(o & ~1);
18559         jboolean ret_conv = CResult_PongDecodeErrorZ_is_ok(o_conv);
18560         return ret_conv;
18561 }
18562
18563 void  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_free"))) TS_CResult_PongDecodeErrorZ_free(uint32_t _res) {
18564         if ((_res & 1) != 0) return;
18565         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18566         CHECK_ACCESS(_res_ptr);
18567         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
18568         FREE((void*)_res);
18569         CResult_PongDecodeErrorZ_free(_res_conv);
18570 }
18571
18572 static inline uintptr_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
18573         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
18574         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
18575         return (uint32_t)ret_conv;
18576 }
18577 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_clone_ptr"))) TS_CResult_PongDecodeErrorZ_clone_ptr(uint32_t arg) {
18578         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
18579         uint32_t ret_conv = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
18580         return ret_conv;
18581 }
18582
18583 uint32_t  __attribute__((export_name("TS_CResult_PongDecodeErrorZ_clone"))) TS_CResult_PongDecodeErrorZ_clone(uint32_t orig) {
18584         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
18585         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
18586         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
18587         return (uint32_t)ret_conv;
18588 }
18589
18590 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
18591         LDKUnsignedChannelAnnouncement o_conv;
18592         o_conv.inner = (void*)(o & (~1));
18593         o_conv.is_owned = (o & 1) || (o == 0);
18594         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18595         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
18596         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
18597         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
18598         return (uint32_t)ret_conv;
18599 }
18600
18601 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
18602         LDKDecodeError e_conv;
18603         e_conv.inner = (void*)(e & (~1));
18604         e_conv.is_owned = (e & 1) || (e == 0);
18605         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18606         e_conv = DecodeError_clone(&e_conv);
18607         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
18608         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
18609         return (uint32_t)ret_conv;
18610 }
18611
18612 jboolean  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
18613         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(o & ~1);
18614         jboolean ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
18615         return ret_conv;
18616 }
18617
18618 void  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
18619         if ((_res & 1) != 0) return;
18620         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18621         CHECK_ACCESS(_res_ptr);
18622         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
18623         FREE((void*)_res);
18624         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
18625 }
18626
18627 static inline uintptr_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
18628         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
18629         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
18630         return (uint32_t)ret_conv;
18631 }
18632 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
18633         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
18634         uint32_t ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
18635         return ret_conv;
18636 }
18637
18638 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
18639         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
18640         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
18641         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
18642         return (uint32_t)ret_conv;
18643 }
18644
18645 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
18646         LDKChannelAnnouncement o_conv;
18647         o_conv.inner = (void*)(o & (~1));
18648         o_conv.is_owned = (o & 1) || (o == 0);
18649         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18650         o_conv = ChannelAnnouncement_clone(&o_conv);
18651         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
18652         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
18653         return (uint32_t)ret_conv;
18654 }
18655
18656 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_err"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
18657         LDKDecodeError e_conv;
18658         e_conv.inner = (void*)(e & (~1));
18659         e_conv.is_owned = (e & 1) || (e == 0);
18660         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18661         e_conv = DecodeError_clone(&e_conv);
18662         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
18663         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
18664         return (uint32_t)ret_conv;
18665 }
18666
18667 jboolean  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
18668         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(o & ~1);
18669         jboolean ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
18670         return ret_conv;
18671 }
18672
18673 void  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_free"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
18674         if ((_res & 1) != 0) return;
18675         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18676         CHECK_ACCESS(_res_ptr);
18677         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
18678         FREE((void*)_res);
18679         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
18680 }
18681
18682 static inline uintptr_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
18683         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
18684         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
18685         return (uint32_t)ret_conv;
18686 }
18687 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
18688         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
18689         uint32_t ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
18690         return ret_conv;
18691 }
18692
18693 uint32_t  __attribute__((export_name("TS_CResult_ChannelAnnouncementDecodeErrorZ_clone"))) TS_CResult_ChannelAnnouncementDecodeErrorZ_clone(uint32_t orig) {
18694         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
18695         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
18696         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
18697         return (uint32_t)ret_conv;
18698 }
18699
18700 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok(uint32_t o) {
18701         LDKUnsignedChannelUpdate o_conv;
18702         o_conv.inner = (void*)(o & (~1));
18703         o_conv.is_owned = (o & 1) || (o == 0);
18704         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18705         o_conv = UnsignedChannelUpdate_clone(&o_conv);
18706         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
18707         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
18708         return (uint32_t)ret_conv;
18709 }
18710
18711 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err(uint32_t e) {
18712         LDKDecodeError e_conv;
18713         e_conv.inner = (void*)(e & (~1));
18714         e_conv.is_owned = (e & 1) || (e == 0);
18715         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18716         e_conv = DecodeError_clone(&e_conv);
18717         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
18718         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
18719         return (uint32_t)ret_conv;
18720 }
18721
18722 jboolean  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(uint32_t o) {
18723         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(o & ~1);
18724         jboolean ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
18725         return ret_conv;
18726 }
18727
18728 void  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free(uint32_t _res) {
18729         if ((_res & 1) != 0) return;
18730         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18731         CHECK_ACCESS(_res_ptr);
18732         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
18733         FREE((void*)_res);
18734         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
18735 }
18736
18737 static inline uintptr_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
18738         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
18739         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
18740         return (uint32_t)ret_conv;
18741 }
18742 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
18743         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
18744         uint32_t ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
18745         return ret_conv;
18746 }
18747
18748 uint32_t  __attribute__((export_name("TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
18749         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
18750         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
18751         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
18752         return (uint32_t)ret_conv;
18753 }
18754
18755 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_ok(uint32_t o) {
18756         LDKChannelUpdate o_conv;
18757         o_conv.inner = (void*)(o & (~1));
18758         o_conv.is_owned = (o & 1) || (o == 0);
18759         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18760         o_conv = ChannelUpdate_clone(&o_conv);
18761         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
18762         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
18763         return (uint32_t)ret_conv;
18764 }
18765
18766 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_err"))) TS_CResult_ChannelUpdateDecodeErrorZ_err(uint32_t e) {
18767         LDKDecodeError e_conv;
18768         e_conv.inner = (void*)(e & (~1));
18769         e_conv.is_owned = (e & 1) || (e == 0);
18770         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18771         e_conv = DecodeError_clone(&e_conv);
18772         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
18773         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
18774         return (uint32_t)ret_conv;
18775 }
18776
18777 jboolean  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_is_ok"))) TS_CResult_ChannelUpdateDecodeErrorZ_is_ok(uint32_t o) {
18778         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(o & ~1);
18779         jboolean ret_conv = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
18780         return ret_conv;
18781 }
18782
18783 void  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_free"))) TS_CResult_ChannelUpdateDecodeErrorZ_free(uint32_t _res) {
18784         if ((_res & 1) != 0) return;
18785         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18786         CHECK_ACCESS(_res_ptr);
18787         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
18788         FREE((void*)_res);
18789         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
18790 }
18791
18792 static inline uintptr_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
18793         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
18794         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
18795         return (uint32_t)ret_conv;
18796 }
18797 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_clone_ptr"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone_ptr(uint32_t arg) {
18798         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
18799         uint32_t ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
18800         return ret_conv;
18801 }
18802
18803 uint32_t  __attribute__((export_name("TS_CResult_ChannelUpdateDecodeErrorZ_clone"))) TS_CResult_ChannelUpdateDecodeErrorZ_clone(uint32_t orig) {
18804         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
18805         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
18806         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
18807         return (uint32_t)ret_conv;
18808 }
18809
18810 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_ok(uint32_t o) {
18811         LDKErrorMessage o_conv;
18812         o_conv.inner = (void*)(o & (~1));
18813         o_conv.is_owned = (o & 1) || (o == 0);
18814         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18815         o_conv = ErrorMessage_clone(&o_conv);
18816         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
18817         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
18818         return (uint32_t)ret_conv;
18819 }
18820
18821 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_err"))) TS_CResult_ErrorMessageDecodeErrorZ_err(uint32_t e) {
18822         LDKDecodeError e_conv;
18823         e_conv.inner = (void*)(e & (~1));
18824         e_conv.is_owned = (e & 1) || (e == 0);
18825         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18826         e_conv = DecodeError_clone(&e_conv);
18827         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
18828         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
18829         return (uint32_t)ret_conv;
18830 }
18831
18832 jboolean  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_is_ok"))) TS_CResult_ErrorMessageDecodeErrorZ_is_ok(uint32_t o) {
18833         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(o & ~1);
18834         jboolean ret_conv = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
18835         return ret_conv;
18836 }
18837
18838 void  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_free"))) TS_CResult_ErrorMessageDecodeErrorZ_free(uint32_t _res) {
18839         if ((_res & 1) != 0) return;
18840         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18841         CHECK_ACCESS(_res_ptr);
18842         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
18843         FREE((void*)_res);
18844         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
18845 }
18846
18847 static inline uintptr_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
18848         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
18849         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
18850         return (uint32_t)ret_conv;
18851 }
18852 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_clone_ptr"))) TS_CResult_ErrorMessageDecodeErrorZ_clone_ptr(uint32_t arg) {
18853         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
18854         uint32_t ret_conv = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
18855         return ret_conv;
18856 }
18857
18858 uint32_t  __attribute__((export_name("TS_CResult_ErrorMessageDecodeErrorZ_clone"))) TS_CResult_ErrorMessageDecodeErrorZ_clone(uint32_t orig) {
18859         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
18860         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
18861         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
18862         return (uint32_t)ret_conv;
18863 }
18864
18865 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_ok"))) TS_CResult_WarningMessageDecodeErrorZ_ok(uint32_t o) {
18866         LDKWarningMessage o_conv;
18867         o_conv.inner = (void*)(o & (~1));
18868         o_conv.is_owned = (o & 1) || (o == 0);
18869         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18870         o_conv = WarningMessage_clone(&o_conv);
18871         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
18872         *ret_conv = CResult_WarningMessageDecodeErrorZ_ok(o_conv);
18873         return (uint32_t)ret_conv;
18874 }
18875
18876 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_err"))) TS_CResult_WarningMessageDecodeErrorZ_err(uint32_t e) {
18877         LDKDecodeError e_conv;
18878         e_conv.inner = (void*)(e & (~1));
18879         e_conv.is_owned = (e & 1) || (e == 0);
18880         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18881         e_conv = DecodeError_clone(&e_conv);
18882         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
18883         *ret_conv = CResult_WarningMessageDecodeErrorZ_err(e_conv);
18884         return (uint32_t)ret_conv;
18885 }
18886
18887 jboolean  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_is_ok"))) TS_CResult_WarningMessageDecodeErrorZ_is_ok(uint32_t o) {
18888         LDKCResult_WarningMessageDecodeErrorZ* o_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(o & ~1);
18889         jboolean ret_conv = CResult_WarningMessageDecodeErrorZ_is_ok(o_conv);
18890         return ret_conv;
18891 }
18892
18893 void  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_free"))) TS_CResult_WarningMessageDecodeErrorZ_free(uint32_t _res) {
18894         if ((_res & 1) != 0) return;
18895         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18896         CHECK_ACCESS(_res_ptr);
18897         LDKCResult_WarningMessageDecodeErrorZ _res_conv = *(LDKCResult_WarningMessageDecodeErrorZ*)(_res_ptr);
18898         FREE((void*)_res);
18899         CResult_WarningMessageDecodeErrorZ_free(_res_conv);
18900 }
18901
18902 static inline uintptr_t CResult_WarningMessageDecodeErrorZ_clone_ptr(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR arg) {
18903         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
18904         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(arg);
18905         return (uint32_t)ret_conv;
18906 }
18907 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_clone_ptr"))) TS_CResult_WarningMessageDecodeErrorZ_clone_ptr(uint32_t arg) {
18908         LDKCResult_WarningMessageDecodeErrorZ* arg_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(arg & ~1);
18909         uint32_t ret_conv = CResult_WarningMessageDecodeErrorZ_clone_ptr(arg_conv);
18910         return ret_conv;
18911 }
18912
18913 uint32_t  __attribute__((export_name("TS_CResult_WarningMessageDecodeErrorZ_clone"))) TS_CResult_WarningMessageDecodeErrorZ_clone(uint32_t orig) {
18914         LDKCResult_WarningMessageDecodeErrorZ* orig_conv = (LDKCResult_WarningMessageDecodeErrorZ*)(orig & ~1);
18915         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
18916         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(orig_conv);
18917         return (uint32_t)ret_conv;
18918 }
18919
18920 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
18921         LDKUnsignedNodeAnnouncement o_conv;
18922         o_conv.inner = (void*)(o & (~1));
18923         o_conv.is_owned = (o & 1) || (o == 0);
18924         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18925         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
18926         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
18927         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
18928         return (uint32_t)ret_conv;
18929 }
18930
18931 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(uint32_t e) {
18932         LDKDecodeError e_conv;
18933         e_conv.inner = (void*)(e & (~1));
18934         e_conv.is_owned = (e & 1) || (e == 0);
18935         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18936         e_conv = DecodeError_clone(&e_conv);
18937         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
18938         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
18939         return (uint32_t)ret_conv;
18940 }
18941
18942 jboolean  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
18943         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(o & ~1);
18944         jboolean ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
18945         return ret_conv;
18946 }
18947
18948 void  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
18949         if ((_res & 1) != 0) return;
18950         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
18951         CHECK_ACCESS(_res_ptr);
18952         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
18953         FREE((void*)_res);
18954         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
18955 }
18956
18957 static inline uintptr_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
18958         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
18959         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
18960         return (uint32_t)ret_conv;
18961 }
18962 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
18963         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
18964         uint32_t ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
18965         return ret_conv;
18966 }
18967
18968 uint32_t  __attribute__((export_name("TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
18969         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
18970         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
18971         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
18972         return (uint32_t)ret_conv;
18973 }
18974
18975 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
18976         LDKNodeAnnouncement o_conv;
18977         o_conv.inner = (void*)(o & (~1));
18978         o_conv.is_owned = (o & 1) || (o == 0);
18979         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18980         o_conv = NodeAnnouncement_clone(&o_conv);
18981         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
18982         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
18983         return (uint32_t)ret_conv;
18984 }
18985
18986 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_err"))) TS_CResult_NodeAnnouncementDecodeErrorZ_err(uint32_t e) {
18987         LDKDecodeError e_conv;
18988         e_conv.inner = (void*)(e & (~1));
18989         e_conv.is_owned = (e & 1) || (e == 0);
18990         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18991         e_conv = DecodeError_clone(&e_conv);
18992         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
18993         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
18994         return (uint32_t)ret_conv;
18995 }
18996
18997 jboolean  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_is_ok"))) TS_CResult_NodeAnnouncementDecodeErrorZ_is_ok(uint32_t o) {
18998         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(o & ~1);
18999         jboolean ret_conv = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
19000         return ret_conv;
19001 }
19002
19003 void  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_free"))) TS_CResult_NodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
19004         if ((_res & 1) != 0) return;
19005         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19006         CHECK_ACCESS(_res_ptr);
19007         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
19008         FREE((void*)_res);
19009         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
19010 }
19011
19012 static inline uintptr_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
19013         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
19014         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
19015         return (uint32_t)ret_conv;
19016 }
19017 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_clone_ptr"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(uint32_t arg) {
19018         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
19019         uint32_t ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
19020         return ret_conv;
19021 }
19022
19023 uint32_t  __attribute__((export_name("TS_CResult_NodeAnnouncementDecodeErrorZ_clone"))) TS_CResult_NodeAnnouncementDecodeErrorZ_clone(uint32_t orig) {
19024         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
19025         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
19026         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
19027         return (uint32_t)ret_conv;
19028 }
19029
19030 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok(uint32_t o) {
19031         LDKQueryShortChannelIds o_conv;
19032         o_conv.inner = (void*)(o & (~1));
19033         o_conv.is_owned = (o & 1) || (o == 0);
19034         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19035         o_conv = QueryShortChannelIds_clone(&o_conv);
19036         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
19037         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
19038         return (uint32_t)ret_conv;
19039 }
19040
19041 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_err"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_err(uint32_t e) {
19042         LDKDecodeError e_conv;
19043         e_conv.inner = (void*)(e & (~1));
19044         e_conv.is_owned = (e & 1) || (e == 0);
19045         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19046         e_conv = DecodeError_clone(&e_conv);
19047         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
19048         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
19049         return (uint32_t)ret_conv;
19050 }
19051
19052 jboolean  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_is_ok"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(uint32_t o) {
19053         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(o & ~1);
19054         jboolean ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
19055         return ret_conv;
19056 }
19057
19058 void  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_free"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_free(uint32_t _res) {
19059         if ((_res & 1) != 0) return;
19060         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19061         CHECK_ACCESS(_res_ptr);
19062         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
19063         FREE((void*)_res);
19064         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
19065 }
19066
19067 static inline uintptr_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
19068         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
19069         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
19070         return (uint32_t)ret_conv;
19071 }
19072 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(uint32_t arg) {
19073         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
19074         uint32_t ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
19075         return ret_conv;
19076 }
19077
19078 uint32_t  __attribute__((export_name("TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_clone(uint32_t orig) {
19079         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
19080         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
19081         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
19082         return (uint32_t)ret_conv;
19083 }
19084
19085 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(uint32_t o) {
19086         LDKReplyShortChannelIdsEnd o_conv;
19087         o_conv.inner = (void*)(o & (~1));
19088         o_conv.is_owned = (o & 1) || (o == 0);
19089         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19090         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
19091         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
19092         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
19093         return (uint32_t)ret_conv;
19094 }
19095
19096 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(uint32_t e) {
19097         LDKDecodeError e_conv;
19098         e_conv.inner = (void*)(e & (~1));
19099         e_conv.is_owned = (e & 1) || (e == 0);
19100         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19101         e_conv = DecodeError_clone(&e_conv);
19102         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
19103         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
19104         return (uint32_t)ret_conv;
19105 }
19106
19107 jboolean  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(uint32_t o) {
19108         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(o & ~1);
19109         jboolean ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
19110         return ret_conv;
19111 }
19112
19113 void  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(uint32_t _res) {
19114         if ((_res & 1) != 0) return;
19115         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19116         CHECK_ACCESS(_res_ptr);
19117         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
19118         FREE((void*)_res);
19119         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
19120 }
19121
19122 static inline uintptr_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
19123         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
19124         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
19125         return (uint32_t)ret_conv;
19126 }
19127 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(uint32_t arg) {
19128         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
19129         uint32_t ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
19130         return ret_conv;
19131 }
19132
19133 uint32_t  __attribute__((export_name("TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(uint32_t orig) {
19134         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
19135         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
19136         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
19137         return (uint32_t)ret_conv;
19138 }
19139
19140 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_ok(uint32_t o) {
19141         LDKQueryChannelRange o_conv;
19142         o_conv.inner = (void*)(o & (~1));
19143         o_conv.is_owned = (o & 1) || (o == 0);
19144         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19145         o_conv = QueryChannelRange_clone(&o_conv);
19146         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
19147         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
19148         return (uint32_t)ret_conv;
19149 }
19150
19151 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_err"))) TS_CResult_QueryChannelRangeDecodeErrorZ_err(uint32_t e) {
19152         LDKDecodeError e_conv;
19153         e_conv.inner = (void*)(e & (~1));
19154         e_conv.is_owned = (e & 1) || (e == 0);
19155         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19156         e_conv = DecodeError_clone(&e_conv);
19157         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
19158         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
19159         return (uint32_t)ret_conv;
19160 }
19161
19162 jboolean  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_is_ok"))) TS_CResult_QueryChannelRangeDecodeErrorZ_is_ok(uint32_t o) {
19163         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(o & ~1);
19164         jboolean ret_conv = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
19165         return ret_conv;
19166 }
19167
19168 void  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_free"))) TS_CResult_QueryChannelRangeDecodeErrorZ_free(uint32_t _res) {
19169         if ((_res & 1) != 0) return;
19170         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19171         CHECK_ACCESS(_res_ptr);
19172         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
19173         FREE((void*)_res);
19174         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
19175 }
19176
19177 static inline uintptr_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
19178         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
19179         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
19180         return (uint32_t)ret_conv;
19181 }
19182 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_clone_ptr"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
19183         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
19184         uint32_t ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
19185         return ret_conv;
19186 }
19187
19188 uint32_t  __attribute__((export_name("TS_CResult_QueryChannelRangeDecodeErrorZ_clone"))) TS_CResult_QueryChannelRangeDecodeErrorZ_clone(uint32_t orig) {
19189         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
19190         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
19191         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
19192         return (uint32_t)ret_conv;
19193 }
19194
19195 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_ok(uint32_t o) {
19196         LDKReplyChannelRange o_conv;
19197         o_conv.inner = (void*)(o & (~1));
19198         o_conv.is_owned = (o & 1) || (o == 0);
19199         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19200         o_conv = ReplyChannelRange_clone(&o_conv);
19201         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
19202         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
19203         return (uint32_t)ret_conv;
19204 }
19205
19206 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_err"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_err(uint32_t e) {
19207         LDKDecodeError e_conv;
19208         e_conv.inner = (void*)(e & (~1));
19209         e_conv.is_owned = (e & 1) || (e == 0);
19210         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19211         e_conv = DecodeError_clone(&e_conv);
19212         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
19213         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
19214         return (uint32_t)ret_conv;
19215 }
19216
19217 jboolean  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_is_ok"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_is_ok(uint32_t o) {
19218         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(o & ~1);
19219         jboolean ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
19220         return ret_conv;
19221 }
19222
19223 void  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_free"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_free(uint32_t _res) {
19224         if ((_res & 1) != 0) return;
19225         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19226         CHECK_ACCESS(_res_ptr);
19227         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
19228         FREE((void*)_res);
19229         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
19230 }
19231
19232 static inline uintptr_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
19233         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
19234         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
19235         return (uint32_t)ret_conv;
19236 }
19237 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(uint32_t arg) {
19238         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
19239         uint32_t ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
19240         return ret_conv;
19241 }
19242
19243 uint32_t  __attribute__((export_name("TS_CResult_ReplyChannelRangeDecodeErrorZ_clone"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_clone(uint32_t orig) {
19244         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
19245         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
19246         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
19247         return (uint32_t)ret_conv;
19248 }
19249
19250 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_ok(uint32_t o) {
19251         LDKGossipTimestampFilter o_conv;
19252         o_conv.inner = (void*)(o & (~1));
19253         o_conv.is_owned = (o & 1) || (o == 0);
19254         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19255         o_conv = GossipTimestampFilter_clone(&o_conv);
19256         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
19257         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
19258         return (uint32_t)ret_conv;
19259 }
19260
19261 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_err"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_err(uint32_t e) {
19262         LDKDecodeError e_conv;
19263         e_conv.inner = (void*)(e & (~1));
19264         e_conv.is_owned = (e & 1) || (e == 0);
19265         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19266         e_conv = DecodeError_clone(&e_conv);
19267         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
19268         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
19269         return (uint32_t)ret_conv;
19270 }
19271
19272 jboolean  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_is_ok"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_is_ok(uint32_t o) {
19273         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(o & ~1);
19274         jboolean ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
19275         return ret_conv;
19276 }
19277
19278 void  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_free"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_free(uint32_t _res) {
19279         if ((_res & 1) != 0) return;
19280         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19281         CHECK_ACCESS(_res_ptr);
19282         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
19283         FREE((void*)_res);
19284         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
19285 }
19286
19287 static inline uintptr_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
19288         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
19289         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
19290         return (uint32_t)ret_conv;
19291 }
19292 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(uint32_t arg) {
19293         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
19294         uint32_t ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
19295         return ret_conv;
19296 }
19297
19298 uint32_t  __attribute__((export_name("TS_CResult_GossipTimestampFilterDecodeErrorZ_clone"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_clone(uint32_t orig) {
19299         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
19300         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
19301         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
19302         return (uint32_t)ret_conv;
19303 }
19304
19305 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_ok"))) TS_CResult_InvoiceSignOrCreationErrorZ_ok(uint32_t o) {
19306         LDKInvoice o_conv;
19307         o_conv.inner = (void*)(o & (~1));
19308         o_conv.is_owned = (o & 1) || (o == 0);
19309         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19310         o_conv = Invoice_clone(&o_conv);
19311         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
19312         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
19313         return (uint32_t)ret_conv;
19314 }
19315
19316 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_err"))) TS_CResult_InvoiceSignOrCreationErrorZ_err(uint32_t e) {
19317         void* e_ptr = (void*)(((uintptr_t)e) & ~1);
19318         CHECK_ACCESS(e_ptr);
19319         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
19320         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)(((uintptr_t)e) & ~1));
19321         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
19322         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
19323         return (uint32_t)ret_conv;
19324 }
19325
19326 jboolean  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_is_ok"))) TS_CResult_InvoiceSignOrCreationErrorZ_is_ok(uint32_t o) {
19327         LDKCResult_InvoiceSignOrCreationErrorZ* o_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(o & ~1);
19328         jboolean ret_conv = CResult_InvoiceSignOrCreationErrorZ_is_ok(o_conv);
19329         return ret_conv;
19330 }
19331
19332 void  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_free"))) TS_CResult_InvoiceSignOrCreationErrorZ_free(uint32_t _res) {
19333         if ((_res & 1) != 0) return;
19334         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19335         CHECK_ACCESS(_res_ptr);
19336         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
19337         FREE((void*)_res);
19338         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
19339 }
19340
19341 static inline uintptr_t CResult_InvoiceSignOrCreationErrorZ_clone_ptr(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR arg) {
19342         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
19343         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(arg);
19344         return (uint32_t)ret_conv;
19345 }
19346 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_clone_ptr"))) TS_CResult_InvoiceSignOrCreationErrorZ_clone_ptr(uint32_t arg) {
19347         LDKCResult_InvoiceSignOrCreationErrorZ* arg_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
19348         uint32_t ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone_ptr(arg_conv);
19349         return ret_conv;
19350 }
19351
19352 uint32_t  __attribute__((export_name("TS_CResult_InvoiceSignOrCreationErrorZ_clone"))) TS_CResult_InvoiceSignOrCreationErrorZ_clone(uint32_t orig) {
19353         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
19354         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
19355         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
19356         return (uint32_t)ret_conv;
19357 }
19358
19359 uint32_t  __attribute__((export_name("TS_COption_FilterZ_some"))) TS_COption_FilterZ_some(uint32_t o) {
19360         void* o_ptr = (void*)(((uintptr_t)o) & ~1);
19361         CHECK_ACCESS(o_ptr);
19362         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
19363         if (o_conv.free == LDKFilter_JCalls_free) {
19364                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19365                 LDKFilter_JCalls_cloned(&o_conv);
19366         }
19367         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
19368         *ret_copy = COption_FilterZ_some(o_conv);
19369         uint32_t ret_ref = (uintptr_t)ret_copy;
19370         return ret_ref;
19371 }
19372
19373 uint32_t  __attribute__((export_name("TS_COption_FilterZ_none"))) TS_COption_FilterZ_none() {
19374         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
19375         *ret_copy = COption_FilterZ_none();
19376         uint32_t ret_ref = (uintptr_t)ret_copy;
19377         return ret_ref;
19378 }
19379
19380 void  __attribute__((export_name("TS_COption_FilterZ_free"))) TS_COption_FilterZ_free(uint32_t _res) {
19381         if ((_res & 1) != 0) return;
19382         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19383         CHECK_ACCESS(_res_ptr);
19384         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
19385         FREE((void*)_res);
19386         COption_FilterZ_free(_res_conv);
19387 }
19388
19389 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_ok"))) TS_CResult_LockedChannelMonitorNoneZ_ok(uint32_t o) {
19390         LDKLockedChannelMonitor o_conv;
19391         o_conv.inner = (void*)(o & (~1));
19392         o_conv.is_owned = (o & 1) || (o == 0);
19393         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19394         // WARNING: we need a move here but no clone is available for LDKLockedChannelMonitor
19395         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
19396         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
19397         return (uint32_t)ret_conv;
19398 }
19399
19400 uint32_t  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_err"))) TS_CResult_LockedChannelMonitorNoneZ_err() {
19401         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
19402         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
19403         return (uint32_t)ret_conv;
19404 }
19405
19406 jboolean  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_is_ok"))) TS_CResult_LockedChannelMonitorNoneZ_is_ok(uint32_t o) {
19407         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(o & ~1);
19408         jboolean ret_conv = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
19409         return ret_conv;
19410 }
19411
19412 void  __attribute__((export_name("TS_CResult_LockedChannelMonitorNoneZ_free"))) TS_CResult_LockedChannelMonitorNoneZ_free(uint32_t _res) {
19413         if ((_res & 1) != 0) return;
19414         void* _res_ptr = (void*)(((uintptr_t)_res) & ~1);
19415         CHECK_ACCESS(_res_ptr);
19416         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
19417         FREE((void*)_res);
19418         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
19419 }
19420
19421 void  __attribute__((export_name("TS_CVec_OutPointZ_free"))) TS_CVec_OutPointZ_free(uint32_tArray _res) {
19422         LDKCVec_OutPointZ _res_constr;
19423         _res_constr.datalen = _res->arr_len;
19424         if (_res_constr.datalen > 0)
19425                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
19426         else
19427                 _res_constr.data = NULL;
19428         uint32_t* _res_vals = _res->elems /* XXX _res leaks */;
19429         for (size_t k = 0; k < _res_constr.datalen; k++) {
19430                 uint32_t _res_conv_10 = _res_vals[k];
19431                 LDKOutPoint _res_conv_10_conv;
19432                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
19433                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
19434                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
19435                 _res_constr.data[k] = _res_conv_10_conv;
19436         }
19437         CVec_OutPointZ_free(_res_constr);
19438 }
19439
19440 void  __attribute__((export_name("TS_PaymentPurpose_free"))) TS_PaymentPurpose_free(uint32_t this_ptr) {
19441         if ((this_ptr & 1) != 0) return;
19442         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
19443         CHECK_ACCESS(this_ptr_ptr);
19444         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
19445         FREE((void*)this_ptr);
19446         PaymentPurpose_free(this_ptr_conv);
19447 }
19448
19449 static inline uintptr_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
19450         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
19451         *ret_copy = PaymentPurpose_clone(arg);
19452 uint32_t ret_ref = (uintptr_t)ret_copy;
19453         return ret_ref;
19454 }
19455 uint32_t  __attribute__((export_name("TS_PaymentPurpose_clone_ptr"))) TS_PaymentPurpose_clone_ptr(uint32_t arg) {
19456         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)arg;
19457         uint32_t ret_conv = PaymentPurpose_clone_ptr(arg_conv);
19458         return ret_conv;
19459 }
19460
19461 uint32_t  __attribute__((export_name("TS_PaymentPurpose_clone"))) TS_PaymentPurpose_clone(uint32_t orig) {
19462         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
19463         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
19464         *ret_copy = PaymentPurpose_clone(orig_conv);
19465         uint32_t ret_ref = (uintptr_t)ret_copy;
19466         return ret_ref;
19467 }
19468
19469 uint32_t  __attribute__((export_name("TS_PaymentPurpose_invoice_payment"))) TS_PaymentPurpose_invoice_payment(int8_tArray payment_preimage, int8_tArray payment_secret) {
19470         LDKThirtyTwoBytes payment_preimage_ref;
19471         CHECK(payment_preimage->arr_len == 32);
19472         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
19473         LDKThirtyTwoBytes payment_secret_ref;
19474         CHECK(payment_secret->arr_len == 32);
19475         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
19476         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
19477         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref);
19478         uint32_t ret_ref = (uintptr_t)ret_copy;
19479         return ret_ref;
19480 }
19481
19482 uint32_t  __attribute__((export_name("TS_PaymentPurpose_spontaneous_payment"))) TS_PaymentPurpose_spontaneous_payment(int8_tArray a) {
19483         LDKThirtyTwoBytes a_ref;
19484         CHECK(a->arr_len == 32);
19485         memcpy(a_ref.data, a->elems, 32); FREE(a);
19486         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
19487         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
19488         uint32_t ret_ref = (uintptr_t)ret_copy;
19489         return ret_ref;
19490 }
19491
19492 void  __attribute__((export_name("TS_ClosureReason_free"))) TS_ClosureReason_free(uint32_t this_ptr) {
19493         if ((this_ptr & 1) != 0) return;
19494         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
19495         CHECK_ACCESS(this_ptr_ptr);
19496         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
19497         FREE((void*)this_ptr);
19498         ClosureReason_free(this_ptr_conv);
19499 }
19500
19501 static inline uintptr_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
19502         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19503         *ret_copy = ClosureReason_clone(arg);
19504 uint32_t ret_ref = (uintptr_t)ret_copy;
19505         return ret_ref;
19506 }
19507 uint32_t  __attribute__((export_name("TS_ClosureReason_clone_ptr"))) TS_ClosureReason_clone_ptr(uint32_t arg) {
19508         LDKClosureReason* arg_conv = (LDKClosureReason*)arg;
19509         uint32_t ret_conv = ClosureReason_clone_ptr(arg_conv);
19510         return ret_conv;
19511 }
19512
19513 uint32_t  __attribute__((export_name("TS_ClosureReason_clone"))) TS_ClosureReason_clone(uint32_t orig) {
19514         LDKClosureReason* orig_conv = (LDKClosureReason*)orig;
19515         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19516         *ret_copy = ClosureReason_clone(orig_conv);
19517         uint32_t ret_ref = (uintptr_t)ret_copy;
19518         return ret_ref;
19519 }
19520
19521 uint32_t  __attribute__((export_name("TS_ClosureReason_counterparty_force_closed"))) TS_ClosureReason_counterparty_force_closed(jstring peer_msg) {
19522         LDKStr peer_msg_conv = str_ref_to_owned_c(peer_msg);
19523         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19524         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
19525         uint32_t ret_ref = (uintptr_t)ret_copy;
19526         return ret_ref;
19527 }
19528
19529 uint32_t  __attribute__((export_name("TS_ClosureReason_holder_force_closed"))) TS_ClosureReason_holder_force_closed() {
19530         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19531         *ret_copy = ClosureReason_holder_force_closed();
19532         uint32_t ret_ref = (uintptr_t)ret_copy;
19533         return ret_ref;
19534 }
19535
19536 uint32_t  __attribute__((export_name("TS_ClosureReason_cooperative_closure"))) TS_ClosureReason_cooperative_closure() {
19537         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19538         *ret_copy = ClosureReason_cooperative_closure();
19539         uint32_t ret_ref = (uintptr_t)ret_copy;
19540         return ret_ref;
19541 }
19542
19543 uint32_t  __attribute__((export_name("TS_ClosureReason_commitment_tx_confirmed"))) TS_ClosureReason_commitment_tx_confirmed() {
19544         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19545         *ret_copy = ClosureReason_commitment_tx_confirmed();
19546         uint32_t ret_ref = (uintptr_t)ret_copy;
19547         return ret_ref;
19548 }
19549
19550 uint32_t  __attribute__((export_name("TS_ClosureReason_funding_timed_out"))) TS_ClosureReason_funding_timed_out() {
19551         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19552         *ret_copy = ClosureReason_funding_timed_out();
19553         uint32_t ret_ref = (uintptr_t)ret_copy;
19554         return ret_ref;
19555 }
19556
19557 uint32_t  __attribute__((export_name("TS_ClosureReason_processing_error"))) TS_ClosureReason_processing_error(jstring err) {
19558         LDKStr err_conv = str_ref_to_owned_c(err);
19559         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19560         *ret_copy = ClosureReason_processing_error(err_conv);
19561         uint32_t ret_ref = (uintptr_t)ret_copy;
19562         return ret_ref;
19563 }
19564
19565 uint32_t  __attribute__((export_name("TS_ClosureReason_disconnected_peer"))) TS_ClosureReason_disconnected_peer() {
19566         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19567         *ret_copy = ClosureReason_disconnected_peer();
19568         uint32_t ret_ref = (uintptr_t)ret_copy;
19569         return ret_ref;
19570 }
19571
19572 uint32_t  __attribute__((export_name("TS_ClosureReason_outdated_channel_manager"))) TS_ClosureReason_outdated_channel_manager() {
19573         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19574         *ret_copy = ClosureReason_outdated_channel_manager();
19575         uint32_t ret_ref = (uintptr_t)ret_copy;
19576         return ret_ref;
19577 }
19578
19579 int8_tArray  __attribute__((export_name("TS_ClosureReason_write"))) TS_ClosureReason_write(uint32_t obj) {
19580         LDKClosureReason* obj_conv = (LDKClosureReason*)obj;
19581         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
19582         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
19583         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
19584         CVec_u8Z_free(ret_var);
19585         return ret_arr;
19586 }
19587
19588 uint32_t  __attribute__((export_name("TS_ClosureReason_read"))) TS_ClosureReason_read(int8_tArray ser) {
19589         LDKu8slice ser_ref;
19590         ser_ref.datalen = ser->arr_len;
19591         ser_ref.data = ser->elems /* XXX ser leaks */;
19592         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
19593         *ret_conv = ClosureReason_read(ser_ref);
19594         return (uint32_t)ret_conv;
19595 }
19596
19597 void  __attribute__((export_name("TS_Event_free"))) TS_Event_free(uint32_t this_ptr) {
19598         if ((this_ptr & 1) != 0) return;
19599         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
19600         CHECK_ACCESS(this_ptr_ptr);
19601         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
19602         FREE((void*)this_ptr);
19603         Event_free(this_ptr_conv);
19604 }
19605
19606 static inline uintptr_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
19607         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19608         *ret_copy = Event_clone(arg);
19609 uint32_t ret_ref = (uintptr_t)ret_copy;
19610         return ret_ref;
19611 }
19612 uint32_t  __attribute__((export_name("TS_Event_clone_ptr"))) TS_Event_clone_ptr(uint32_t arg) {
19613         LDKEvent* arg_conv = (LDKEvent*)arg;
19614         uint32_t ret_conv = Event_clone_ptr(arg_conv);
19615         return ret_conv;
19616 }
19617
19618 uint32_t  __attribute__((export_name("TS_Event_clone"))) TS_Event_clone(uint32_t orig) {
19619         LDKEvent* orig_conv = (LDKEvent*)orig;
19620         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19621         *ret_copy = Event_clone(orig_conv);
19622         uint32_t ret_ref = (uintptr_t)ret_copy;
19623         return ret_ref;
19624 }
19625
19626 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) {
19627         LDKThirtyTwoBytes temporary_channel_id_ref;
19628         CHECK(temporary_channel_id->arr_len == 32);
19629         memcpy(temporary_channel_id_ref.data, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
19630         LDKCVec_u8Z output_script_ref;
19631         output_script_ref.datalen = output_script->arr_len;
19632         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
19633         memcpy(output_script_ref.data, output_script->elems, output_script_ref.datalen); FREE(output_script);
19634         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19635         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
19636         uint32_t ret_ref = (uintptr_t)ret_copy;
19637         return ret_ref;
19638 }
19639
19640 uint32_t  __attribute__((export_name("TS_Event_payment_received"))) TS_Event_payment_received(int8_tArray payment_hash, int64_t amt, uint32_t purpose) {
19641         LDKThirtyTwoBytes payment_hash_ref;
19642         CHECK(payment_hash->arr_len == 32);
19643         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
19644         void* purpose_ptr = (void*)(((uintptr_t)purpose) & ~1);
19645         CHECK_ACCESS(purpose_ptr);
19646         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
19647         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uintptr_t)purpose) & ~1));
19648         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19649         *ret_copy = Event_payment_received(payment_hash_ref, amt, purpose_conv);
19650         uint32_t ret_ref = (uintptr_t)ret_copy;
19651         return ret_ref;
19652 }
19653
19654 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) {
19655         LDKThirtyTwoBytes payment_id_ref;
19656         CHECK(payment_id->arr_len == 32);
19657         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
19658         LDKThirtyTwoBytes payment_preimage_ref;
19659         CHECK(payment_preimage->arr_len == 32);
19660         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
19661         LDKThirtyTwoBytes payment_hash_ref;
19662         CHECK(payment_hash->arr_len == 32);
19663         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
19664         void* fee_paid_msat_ptr = (void*)(((uintptr_t)fee_paid_msat) & ~1);
19665         CHECK_ACCESS(fee_paid_msat_ptr);
19666         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
19667         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_paid_msat) & ~1));
19668         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19669         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
19670         uint32_t ret_ref = (uintptr_t)ret_copy;
19671         return ret_ref;
19672 }
19673
19674 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) {
19675         LDKThirtyTwoBytes payment_id_ref;
19676         CHECK(payment_id->arr_len == 32);
19677         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
19678         LDKThirtyTwoBytes payment_hash_ref;
19679         CHECK(payment_hash->arr_len == 32);
19680         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
19681         void* network_update_ptr = (void*)(((uintptr_t)network_update) & ~1);
19682         CHECK_ACCESS(network_update_ptr);
19683         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
19684         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uintptr_t)network_update) & ~1));
19685         LDKCVec_RouteHopZ path_constr;
19686         path_constr.datalen = path->arr_len;
19687         if (path_constr.datalen > 0)
19688                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
19689         else
19690                 path_constr.data = NULL;
19691         uint32_t* path_vals = path->elems /* XXX path leaks */;
19692         for (size_t k = 0; k < path_constr.datalen; k++) {
19693                 uint32_t path_conv_10 = path_vals[k];
19694                 LDKRouteHop path_conv_10_conv;
19695                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
19696                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
19697                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
19698                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
19699                 path_constr.data[k] = path_conv_10_conv;
19700         }
19701         void* short_channel_id_ptr = (void*)(((uintptr_t)short_channel_id) & ~1);
19702         CHECK_ACCESS(short_channel_id_ptr);
19703         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
19704         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id) & ~1));
19705         LDKRouteParameters retry_conv;
19706         retry_conv.inner = (void*)(retry & (~1));
19707         retry_conv.is_owned = (retry & 1) || (retry == 0);
19708         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_conv);
19709         retry_conv = RouteParameters_clone(&retry_conv);
19710         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19711         *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);
19712         uint32_t ret_ref = (uintptr_t)ret_copy;
19713         return ret_ref;
19714 }
19715
19716 uint32_t  __attribute__((export_name("TS_Event_payment_failed"))) TS_Event_payment_failed(int8_tArray payment_id, int8_tArray payment_hash) {
19717         LDKThirtyTwoBytes payment_id_ref;
19718         CHECK(payment_id->arr_len == 32);
19719         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
19720         LDKThirtyTwoBytes payment_hash_ref;
19721         CHECK(payment_hash->arr_len == 32);
19722         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
19723         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19724         *ret_copy = Event_payment_failed(payment_id_ref, payment_hash_ref);
19725         uint32_t ret_ref = (uintptr_t)ret_copy;
19726         return ret_ref;
19727 }
19728
19729 uint32_t  __attribute__((export_name("TS_Event_pending_htlcs_forwardable"))) TS_Event_pending_htlcs_forwardable(int64_t time_forwardable) {
19730         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19731         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
19732         uint32_t ret_ref = (uintptr_t)ret_copy;
19733         return ret_ref;
19734 }
19735
19736 uint32_t  __attribute__((export_name("TS_Event_spendable_outputs"))) TS_Event_spendable_outputs(uint32_tArray outputs) {
19737         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
19738         outputs_constr.datalen = outputs->arr_len;
19739         if (outputs_constr.datalen > 0)
19740                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
19741         else
19742                 outputs_constr.data = NULL;
19743         uint32_t* outputs_vals = outputs->elems /* XXX outputs leaks */;
19744         for (size_t b = 0; b < outputs_constr.datalen; b++) {
19745                 uint32_t outputs_conv_27 = outputs_vals[b];
19746                 void* outputs_conv_27_ptr = (void*)(((uintptr_t)outputs_conv_27) & ~1);
19747                 CHECK_ACCESS(outputs_conv_27_ptr);
19748                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
19749                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)outputs_conv_27) & ~1));
19750                 outputs_constr.data[b] = outputs_conv_27_conv;
19751         }
19752         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19753         *ret_copy = Event_spendable_outputs(outputs_constr);
19754         uint32_t ret_ref = (uintptr_t)ret_copy;
19755         return ret_ref;
19756 }
19757
19758 uint32_t  __attribute__((export_name("TS_Event_payment_forwarded"))) TS_Event_payment_forwarded(uint32_t fee_earned_msat, jboolean claim_from_onchain_tx) {
19759         void* fee_earned_msat_ptr = (void*)(((uintptr_t)fee_earned_msat) & ~1);
19760         CHECK_ACCESS(fee_earned_msat_ptr);
19761         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
19762         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)fee_earned_msat) & ~1));
19763         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19764         *ret_copy = Event_payment_forwarded(fee_earned_msat_conv, claim_from_onchain_tx);
19765         uint32_t ret_ref = (uintptr_t)ret_copy;
19766         return ret_ref;
19767 }
19768
19769 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) {
19770         LDKThirtyTwoBytes channel_id_ref;
19771         CHECK(channel_id->arr_len == 32);
19772         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
19773         void* reason_ptr = (void*)(((uintptr_t)reason) & ~1);
19774         CHECK_ACCESS(reason_ptr);
19775         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
19776         reason_conv = ClosureReason_clone((LDKClosureReason*)(((uintptr_t)reason) & ~1));
19777         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19778         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
19779         uint32_t ret_ref = (uintptr_t)ret_copy;
19780         return ret_ref;
19781 }
19782
19783 uint32_t  __attribute__((export_name("TS_Event_discard_funding"))) TS_Event_discard_funding(int8_tArray channel_id, int8_tArray transaction) {
19784         LDKThirtyTwoBytes channel_id_ref;
19785         CHECK(channel_id->arr_len == 32);
19786         memcpy(channel_id_ref.data, channel_id->elems, 32); FREE(channel_id);
19787         LDKTransaction transaction_ref;
19788         transaction_ref.datalen = transaction->arr_len;
19789         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
19790         memcpy(transaction_ref.data, transaction->elems, transaction_ref.datalen); FREE(transaction);
19791         transaction_ref.data_is_owned = true;
19792         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19793         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
19794         uint32_t ret_ref = (uintptr_t)ret_copy;
19795         return ret_ref;
19796 }
19797
19798 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) {
19799         LDKThirtyTwoBytes payment_id_ref;
19800         CHECK(payment_id->arr_len == 32);
19801         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
19802         LDKThirtyTwoBytes payment_hash_ref;
19803         CHECK(payment_hash->arr_len == 32);
19804         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
19805         LDKCVec_RouteHopZ path_constr;
19806         path_constr.datalen = path->arr_len;
19807         if (path_constr.datalen > 0)
19808                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
19809         else
19810                 path_constr.data = NULL;
19811         uint32_t* path_vals = path->elems /* XXX path leaks */;
19812         for (size_t k = 0; k < path_constr.datalen; k++) {
19813                 uint32_t path_conv_10 = path_vals[k];
19814                 LDKRouteHop path_conv_10_conv;
19815                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
19816                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
19817                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
19818                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
19819                 path_constr.data[k] = path_conv_10_conv;
19820         }
19821         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19822         *ret_copy = Event_payment_path_successful(payment_id_ref, payment_hash_ref, path_constr);
19823         uint32_t ret_ref = (uintptr_t)ret_copy;
19824         return ret_ref;
19825 }
19826
19827 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) {
19828         LDKThirtyTwoBytes temporary_channel_id_ref;
19829         CHECK(temporary_channel_id->arr_len == 32);
19830         memcpy(temporary_channel_id_ref.data, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
19831         LDKPublicKey counterparty_node_id_ref;
19832         CHECK(counterparty_node_id->arr_len == 33);
19833         memcpy(counterparty_node_id_ref.compressed_form, counterparty_node_id->elems, 33); FREE(counterparty_node_id);
19834         LDKChannelTypeFeatures channel_type_conv;
19835         channel_type_conv.inner = (void*)(channel_type & (~1));
19836         channel_type_conv.is_owned = (channel_type & 1) || (channel_type == 0);
19837         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_conv);
19838         channel_type_conv = ChannelTypeFeatures_clone(&channel_type_conv);
19839         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19840         *ret_copy = Event_open_channel_request(temporary_channel_id_ref, counterparty_node_id_ref, funding_satoshis, push_msat, channel_type_conv);
19841         uint32_t ret_ref = (uintptr_t)ret_copy;
19842         return ret_ref;
19843 }
19844
19845 int8_tArray  __attribute__((export_name("TS_Event_write"))) TS_Event_write(uint32_t obj) {
19846         LDKEvent* obj_conv = (LDKEvent*)obj;
19847         LDKCVec_u8Z ret_var = Event_write(obj_conv);
19848         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
19849         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
19850         CVec_u8Z_free(ret_var);
19851         return ret_arr;
19852 }
19853
19854 uint32_t  __attribute__((export_name("TS_Event_read"))) TS_Event_read(int8_tArray ser) {
19855         LDKu8slice ser_ref;
19856         ser_ref.datalen = ser->arr_len;
19857         ser_ref.data = ser->elems /* XXX ser leaks */;
19858         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
19859         *ret_conv = Event_read(ser_ref);
19860         return (uint32_t)ret_conv;
19861 }
19862
19863 void  __attribute__((export_name("TS_MessageSendEvent_free"))) TS_MessageSendEvent_free(uint32_t this_ptr) {
19864         if ((this_ptr & 1) != 0) return;
19865         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
19866         CHECK_ACCESS(this_ptr_ptr);
19867         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
19868         FREE((void*)this_ptr);
19869         MessageSendEvent_free(this_ptr_conv);
19870 }
19871
19872 static inline uintptr_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
19873         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19874         *ret_copy = MessageSendEvent_clone(arg);
19875 uint32_t ret_ref = (uintptr_t)ret_copy;
19876         return ret_ref;
19877 }
19878 uint32_t  __attribute__((export_name("TS_MessageSendEvent_clone_ptr"))) TS_MessageSendEvent_clone_ptr(uint32_t arg) {
19879         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)arg;
19880         uint32_t ret_conv = MessageSendEvent_clone_ptr(arg_conv);
19881         return ret_conv;
19882 }
19883
19884 uint32_t  __attribute__((export_name("TS_MessageSendEvent_clone"))) TS_MessageSendEvent_clone(uint32_t orig) {
19885         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
19886         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19887         *ret_copy = MessageSendEvent_clone(orig_conv);
19888         uint32_t ret_ref = (uintptr_t)ret_copy;
19889         return ret_ref;
19890 }
19891
19892 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_accept_channel"))) TS_MessageSendEvent_send_accept_channel(int8_tArray node_id, uint32_t msg) {
19893         LDKPublicKey node_id_ref;
19894         CHECK(node_id->arr_len == 33);
19895         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19896         LDKAcceptChannel msg_conv;
19897         msg_conv.inner = (void*)(msg & (~1));
19898         msg_conv.is_owned = (msg & 1) || (msg == 0);
19899         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19900         msg_conv = AcceptChannel_clone(&msg_conv);
19901         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19902         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
19903         uint32_t ret_ref = (uintptr_t)ret_copy;
19904         return ret_ref;
19905 }
19906
19907 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_open_channel"))) TS_MessageSendEvent_send_open_channel(int8_tArray node_id, uint32_t msg) {
19908         LDKPublicKey node_id_ref;
19909         CHECK(node_id->arr_len == 33);
19910         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19911         LDKOpenChannel msg_conv;
19912         msg_conv.inner = (void*)(msg & (~1));
19913         msg_conv.is_owned = (msg & 1) || (msg == 0);
19914         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19915         msg_conv = OpenChannel_clone(&msg_conv);
19916         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19917         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
19918         uint32_t ret_ref = (uintptr_t)ret_copy;
19919         return ret_ref;
19920 }
19921
19922 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_funding_created"))) TS_MessageSendEvent_send_funding_created(int8_tArray node_id, uint32_t msg) {
19923         LDKPublicKey node_id_ref;
19924         CHECK(node_id->arr_len == 33);
19925         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19926         LDKFundingCreated msg_conv;
19927         msg_conv.inner = (void*)(msg & (~1));
19928         msg_conv.is_owned = (msg & 1) || (msg == 0);
19929         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19930         msg_conv = FundingCreated_clone(&msg_conv);
19931         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19932         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
19933         uint32_t ret_ref = (uintptr_t)ret_copy;
19934         return ret_ref;
19935 }
19936
19937 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_funding_signed"))) TS_MessageSendEvent_send_funding_signed(int8_tArray node_id, uint32_t msg) {
19938         LDKPublicKey node_id_ref;
19939         CHECK(node_id->arr_len == 33);
19940         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19941         LDKFundingSigned msg_conv;
19942         msg_conv.inner = (void*)(msg & (~1));
19943         msg_conv.is_owned = (msg & 1) || (msg == 0);
19944         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19945         msg_conv = FundingSigned_clone(&msg_conv);
19946         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19947         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
19948         uint32_t ret_ref = (uintptr_t)ret_copy;
19949         return ret_ref;
19950 }
19951
19952 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_funding_locked"))) TS_MessageSendEvent_send_funding_locked(int8_tArray node_id, uint32_t msg) {
19953         LDKPublicKey node_id_ref;
19954         CHECK(node_id->arr_len == 33);
19955         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19956         LDKFundingLocked msg_conv;
19957         msg_conv.inner = (void*)(msg & (~1));
19958         msg_conv.is_owned = (msg & 1) || (msg == 0);
19959         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19960         msg_conv = FundingLocked_clone(&msg_conv);
19961         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19962         *ret_copy = MessageSendEvent_send_funding_locked(node_id_ref, msg_conv);
19963         uint32_t ret_ref = (uintptr_t)ret_copy;
19964         return ret_ref;
19965 }
19966
19967 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_announcement_signatures"))) TS_MessageSendEvent_send_announcement_signatures(int8_tArray node_id, uint32_t msg) {
19968         LDKPublicKey node_id_ref;
19969         CHECK(node_id->arr_len == 33);
19970         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19971         LDKAnnouncementSignatures msg_conv;
19972         msg_conv.inner = (void*)(msg & (~1));
19973         msg_conv.is_owned = (msg & 1) || (msg == 0);
19974         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19975         msg_conv = AnnouncementSignatures_clone(&msg_conv);
19976         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19977         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
19978         uint32_t ret_ref = (uintptr_t)ret_copy;
19979         return ret_ref;
19980 }
19981
19982 uint32_t  __attribute__((export_name("TS_MessageSendEvent_update_htlcs"))) TS_MessageSendEvent_update_htlcs(int8_tArray node_id, uint32_t updates) {
19983         LDKPublicKey node_id_ref;
19984         CHECK(node_id->arr_len == 33);
19985         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
19986         LDKCommitmentUpdate updates_conv;
19987         updates_conv.inner = (void*)(updates & (~1));
19988         updates_conv.is_owned = (updates & 1) || (updates == 0);
19989         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
19990         updates_conv = CommitmentUpdate_clone(&updates_conv);
19991         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19992         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
19993         uint32_t ret_ref = (uintptr_t)ret_copy;
19994         return ret_ref;
19995 }
19996
19997 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_revoke_and_ack"))) TS_MessageSendEvent_send_revoke_and_ack(int8_tArray node_id, uint32_t msg) {
19998         LDKPublicKey node_id_ref;
19999         CHECK(node_id->arr_len == 33);
20000         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20001         LDKRevokeAndACK msg_conv;
20002         msg_conv.inner = (void*)(msg & (~1));
20003         msg_conv.is_owned = (msg & 1) || (msg == 0);
20004         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20005         msg_conv = RevokeAndACK_clone(&msg_conv);
20006         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20007         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
20008         uint32_t ret_ref = (uintptr_t)ret_copy;
20009         return ret_ref;
20010 }
20011
20012 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_closing_signed"))) TS_MessageSendEvent_send_closing_signed(int8_tArray node_id, uint32_t msg) {
20013         LDKPublicKey node_id_ref;
20014         CHECK(node_id->arr_len == 33);
20015         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20016         LDKClosingSigned msg_conv;
20017         msg_conv.inner = (void*)(msg & (~1));
20018         msg_conv.is_owned = (msg & 1) || (msg == 0);
20019         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20020         msg_conv = ClosingSigned_clone(&msg_conv);
20021         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20022         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
20023         uint32_t ret_ref = (uintptr_t)ret_copy;
20024         return ret_ref;
20025 }
20026
20027 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_shutdown"))) TS_MessageSendEvent_send_shutdown(int8_tArray node_id, uint32_t msg) {
20028         LDKPublicKey node_id_ref;
20029         CHECK(node_id->arr_len == 33);
20030         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20031         LDKShutdown msg_conv;
20032         msg_conv.inner = (void*)(msg & (~1));
20033         msg_conv.is_owned = (msg & 1) || (msg == 0);
20034         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20035         msg_conv = Shutdown_clone(&msg_conv);
20036         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20037         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
20038         uint32_t ret_ref = (uintptr_t)ret_copy;
20039         return ret_ref;
20040 }
20041
20042 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_reestablish"))) TS_MessageSendEvent_send_channel_reestablish(int8_tArray node_id, uint32_t msg) {
20043         LDKPublicKey node_id_ref;
20044         CHECK(node_id->arr_len == 33);
20045         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20046         LDKChannelReestablish msg_conv;
20047         msg_conv.inner = (void*)(msg & (~1));
20048         msg_conv.is_owned = (msg & 1) || (msg == 0);
20049         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20050         msg_conv = ChannelReestablish_clone(&msg_conv);
20051         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20052         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
20053         uint32_t ret_ref = (uintptr_t)ret_copy;
20054         return ret_ref;
20055 }
20056
20057 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_channel_announcement"))) TS_MessageSendEvent_broadcast_channel_announcement(uint32_t msg, uint32_t update_msg) {
20058         LDKChannelAnnouncement msg_conv;
20059         msg_conv.inner = (void*)(msg & (~1));
20060         msg_conv.is_owned = (msg & 1) || (msg == 0);
20061         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20062         msg_conv = ChannelAnnouncement_clone(&msg_conv);
20063         LDKChannelUpdate update_msg_conv;
20064         update_msg_conv.inner = (void*)(update_msg & (~1));
20065         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
20066         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
20067         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
20068         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20069         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
20070         uint32_t ret_ref = (uintptr_t)ret_copy;
20071         return ret_ref;
20072 }
20073
20074 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_node_announcement"))) TS_MessageSendEvent_broadcast_node_announcement(uint32_t msg) {
20075         LDKNodeAnnouncement msg_conv;
20076         msg_conv.inner = (void*)(msg & (~1));
20077         msg_conv.is_owned = (msg & 1) || (msg == 0);
20078         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20079         msg_conv = NodeAnnouncement_clone(&msg_conv);
20080         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20081         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
20082         uint32_t ret_ref = (uintptr_t)ret_copy;
20083         return ret_ref;
20084 }
20085
20086 uint32_t  __attribute__((export_name("TS_MessageSendEvent_broadcast_channel_update"))) TS_MessageSendEvent_broadcast_channel_update(uint32_t msg) {
20087         LDKChannelUpdate msg_conv;
20088         msg_conv.inner = (void*)(msg & (~1));
20089         msg_conv.is_owned = (msg & 1) || (msg == 0);
20090         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20091         msg_conv = ChannelUpdate_clone(&msg_conv);
20092         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20093         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
20094         uint32_t ret_ref = (uintptr_t)ret_copy;
20095         return ret_ref;
20096 }
20097
20098 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_update"))) TS_MessageSendEvent_send_channel_update(int8_tArray node_id, uint32_t msg) {
20099         LDKPublicKey node_id_ref;
20100         CHECK(node_id->arr_len == 33);
20101         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20102         LDKChannelUpdate msg_conv;
20103         msg_conv.inner = (void*)(msg & (~1));
20104         msg_conv.is_owned = (msg & 1) || (msg == 0);
20105         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20106         msg_conv = ChannelUpdate_clone(&msg_conv);
20107         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20108         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
20109         uint32_t ret_ref = (uintptr_t)ret_copy;
20110         return ret_ref;
20111 }
20112
20113 uint32_t  __attribute__((export_name("TS_MessageSendEvent_handle_error"))) TS_MessageSendEvent_handle_error(int8_tArray node_id, uint32_t action) {
20114         LDKPublicKey node_id_ref;
20115         CHECK(node_id->arr_len == 33);
20116         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20117         void* action_ptr = (void*)(((uintptr_t)action) & ~1);
20118         CHECK_ACCESS(action_ptr);
20119         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
20120         action_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action) & ~1));
20121         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20122         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
20123         uint32_t ret_ref = (uintptr_t)ret_copy;
20124         return ret_ref;
20125 }
20126
20127 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_channel_range_query"))) TS_MessageSendEvent_send_channel_range_query(int8_tArray node_id, uint32_t msg) {
20128         LDKPublicKey node_id_ref;
20129         CHECK(node_id->arr_len == 33);
20130         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20131         LDKQueryChannelRange msg_conv;
20132         msg_conv.inner = (void*)(msg & (~1));
20133         msg_conv.is_owned = (msg & 1) || (msg == 0);
20134         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20135         msg_conv = QueryChannelRange_clone(&msg_conv);
20136         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20137         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
20138         uint32_t ret_ref = (uintptr_t)ret_copy;
20139         return ret_ref;
20140 }
20141
20142 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_short_ids_query"))) TS_MessageSendEvent_send_short_ids_query(int8_tArray node_id, uint32_t msg) {
20143         LDKPublicKey node_id_ref;
20144         CHECK(node_id->arr_len == 33);
20145         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20146         LDKQueryShortChannelIds msg_conv;
20147         msg_conv.inner = (void*)(msg & (~1));
20148         msg_conv.is_owned = (msg & 1) || (msg == 0);
20149         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20150         msg_conv = QueryShortChannelIds_clone(&msg_conv);
20151         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20152         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
20153         uint32_t ret_ref = (uintptr_t)ret_copy;
20154         return ret_ref;
20155 }
20156
20157 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_reply_channel_range"))) TS_MessageSendEvent_send_reply_channel_range(int8_tArray node_id, uint32_t msg) {
20158         LDKPublicKey node_id_ref;
20159         CHECK(node_id->arr_len == 33);
20160         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20161         LDKReplyChannelRange msg_conv;
20162         msg_conv.inner = (void*)(msg & (~1));
20163         msg_conv.is_owned = (msg & 1) || (msg == 0);
20164         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20165         msg_conv = ReplyChannelRange_clone(&msg_conv);
20166         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20167         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
20168         uint32_t ret_ref = (uintptr_t)ret_copy;
20169         return ret_ref;
20170 }
20171
20172 uint32_t  __attribute__((export_name("TS_MessageSendEvent_send_gossip_timestamp_filter"))) TS_MessageSendEvent_send_gossip_timestamp_filter(int8_tArray node_id, uint32_t msg) {
20173         LDKPublicKey node_id_ref;
20174         CHECK(node_id->arr_len == 33);
20175         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
20176         LDKGossipTimestampFilter msg_conv;
20177         msg_conv.inner = (void*)(msg & (~1));
20178         msg_conv.is_owned = (msg & 1) || (msg == 0);
20179         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
20180         msg_conv = GossipTimestampFilter_clone(&msg_conv);
20181         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
20182         *ret_copy = MessageSendEvent_send_gossip_timestamp_filter(node_id_ref, msg_conv);
20183         uint32_t ret_ref = (uintptr_t)ret_copy;
20184         return ret_ref;
20185 }
20186
20187 void  __attribute__((export_name("TS_MessageSendEventsProvider_free"))) TS_MessageSendEventsProvider_free(uint32_t this_ptr) {
20188         if ((this_ptr & 1) != 0) return;
20189         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20190         CHECK_ACCESS(this_ptr_ptr);
20191         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
20192         FREE((void*)this_ptr);
20193         MessageSendEventsProvider_free(this_ptr_conv);
20194 }
20195
20196 void  __attribute__((export_name("TS_EventsProvider_free"))) TS_EventsProvider_free(uint32_t this_ptr) {
20197         if ((this_ptr & 1) != 0) return;
20198         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20199         CHECK_ACCESS(this_ptr_ptr);
20200         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
20201         FREE((void*)this_ptr);
20202         EventsProvider_free(this_ptr_conv);
20203 }
20204
20205 void  __attribute__((export_name("TS_EventHandler_free"))) TS_EventHandler_free(uint32_t this_ptr) {
20206         if ((this_ptr & 1) != 0) return;
20207         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20208         CHECK_ACCESS(this_ptr_ptr);
20209         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
20210         FREE((void*)this_ptr);
20211         EventHandler_free(this_ptr_conv);
20212 }
20213
20214 void  __attribute__((export_name("TS_APIError_free"))) TS_APIError_free(uint32_t this_ptr) {
20215         if ((this_ptr & 1) != 0) return;
20216         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20217         CHECK_ACCESS(this_ptr_ptr);
20218         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
20219         FREE((void*)this_ptr);
20220         APIError_free(this_ptr_conv);
20221 }
20222
20223 static inline uintptr_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
20224         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20225         *ret_copy = APIError_clone(arg);
20226 uint32_t ret_ref = (uintptr_t)ret_copy;
20227         return ret_ref;
20228 }
20229 uint32_t  __attribute__((export_name("TS_APIError_clone_ptr"))) TS_APIError_clone_ptr(uint32_t arg) {
20230         LDKAPIError* arg_conv = (LDKAPIError*)arg;
20231         uint32_t ret_conv = APIError_clone_ptr(arg_conv);
20232         return ret_conv;
20233 }
20234
20235 uint32_t  __attribute__((export_name("TS_APIError_clone"))) TS_APIError_clone(uint32_t orig) {
20236         LDKAPIError* orig_conv = (LDKAPIError*)orig;
20237         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20238         *ret_copy = APIError_clone(orig_conv);
20239         uint32_t ret_ref = (uintptr_t)ret_copy;
20240         return ret_ref;
20241 }
20242
20243 uint32_t  __attribute__((export_name("TS_APIError_apimisuse_error"))) TS_APIError_apimisuse_error(jstring err) {
20244         LDKStr err_conv = str_ref_to_owned_c(err);
20245         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20246         *ret_copy = APIError_apimisuse_error(err_conv);
20247         uint32_t ret_ref = (uintptr_t)ret_copy;
20248         return ret_ref;
20249 }
20250
20251 uint32_t  __attribute__((export_name("TS_APIError_fee_rate_too_high"))) TS_APIError_fee_rate_too_high(jstring err, int32_t feerate) {
20252         LDKStr err_conv = str_ref_to_owned_c(err);
20253         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20254         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
20255         uint32_t ret_ref = (uintptr_t)ret_copy;
20256         return ret_ref;
20257 }
20258
20259 uint32_t  __attribute__((export_name("TS_APIError_route_error"))) TS_APIError_route_error(jstring err) {
20260         LDKStr err_conv = str_ref_to_owned_c(err);
20261         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20262         *ret_copy = APIError_route_error(err_conv);
20263         uint32_t ret_ref = (uintptr_t)ret_copy;
20264         return ret_ref;
20265 }
20266
20267 uint32_t  __attribute__((export_name("TS_APIError_channel_unavailable"))) TS_APIError_channel_unavailable(jstring err) {
20268         LDKStr err_conv = str_ref_to_owned_c(err);
20269         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20270         *ret_copy = APIError_channel_unavailable(err_conv);
20271         uint32_t ret_ref = (uintptr_t)ret_copy;
20272         return ret_ref;
20273 }
20274
20275 uint32_t  __attribute__((export_name("TS_APIError_monitor_update_failed"))) TS_APIError_monitor_update_failed() {
20276         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20277         *ret_copy = APIError_monitor_update_failed();
20278         uint32_t ret_ref = (uintptr_t)ret_copy;
20279         return ret_ref;
20280 }
20281
20282 uint32_t  __attribute__((export_name("TS_APIError_incompatible_shutdown_script"))) TS_APIError_incompatible_shutdown_script(uint32_t script) {
20283         LDKShutdownScript script_conv;
20284         script_conv.inner = (void*)(script & (~1));
20285         script_conv.is_owned = (script & 1) || (script == 0);
20286         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
20287         script_conv = ShutdownScript_clone(&script_conv);
20288         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
20289         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
20290         uint32_t ret_ref = (uintptr_t)ret_copy;
20291         return ret_ref;
20292 }
20293
20294 uint32_t  __attribute__((export_name("TS_sign"))) TS_sign(int8_tArray msg, int8_tArray sk) {
20295         LDKu8slice msg_ref;
20296         msg_ref.datalen = msg->arr_len;
20297         msg_ref.data = msg->elems /* XXX msg leaks */;
20298         unsigned char sk_arr[32];
20299         CHECK(sk->arr_len == 32);
20300         memcpy(sk_arr, sk->elems, 32); FREE(sk);
20301         unsigned char (*sk_ref)[32] = &sk_arr;
20302         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
20303         *ret_conv = sign(msg_ref, sk_ref);
20304         return (uint32_t)ret_conv;
20305 }
20306
20307 uint32_t  __attribute__((export_name("TS_recover_pk"))) TS_recover_pk(int8_tArray msg, jstring sig) {
20308         LDKu8slice msg_ref;
20309         msg_ref.datalen = msg->arr_len;
20310         msg_ref.data = msg->elems /* XXX msg leaks */;
20311         LDKStr sig_conv = str_ref_to_owned_c(sig);
20312         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
20313         *ret_conv = recover_pk(msg_ref, sig_conv);
20314         return (uint32_t)ret_conv;
20315 }
20316
20317 jboolean  __attribute__((export_name("TS_verify"))) TS_verify(int8_tArray msg, jstring sig, int8_tArray pk) {
20318         LDKu8slice msg_ref;
20319         msg_ref.datalen = msg->arr_len;
20320         msg_ref.data = msg->elems /* XXX msg leaks */;
20321         LDKStr sig_conv = str_ref_to_owned_c(sig);
20322         LDKPublicKey pk_ref;
20323         CHECK(pk->arr_len == 33);
20324         memcpy(pk_ref.compressed_form, pk->elems, 33); FREE(pk);
20325         jboolean ret_conv = verify(msg_ref, sig_conv, pk_ref);
20326         return ret_conv;
20327 }
20328
20329 int8_tArray  __attribute__((export_name("TS_construct_invoice_preimage"))) TS_construct_invoice_preimage(int8_tArray hrp_bytes, ptrArray data_without_signature) {
20330         LDKu8slice hrp_bytes_ref;
20331         hrp_bytes_ref.datalen = hrp_bytes->arr_len;
20332         hrp_bytes_ref.data = hrp_bytes->elems /* XXX hrp_bytes leaks */;
20333         LDKCVec_u5Z data_without_signature_constr;
20334         data_without_signature_constr.datalen = data_without_signature->arr_len;
20335         if (data_without_signature_constr.datalen > 0)
20336                 data_without_signature_constr.data = MALLOC(data_without_signature_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
20337         else
20338                 data_without_signature_constr.data = NULL;
20339         int8_t* data_without_signature_vals = (void*) data_without_signature->elems /* XXX data_without_signature leaks */;
20340         for (size_t h = 0; h < data_without_signature_constr.datalen; h++) {
20341                 int8_t data_without_signature_conv_7 = data_without_signature_vals[h];
20342                 
20343                 data_without_signature_constr.data[h] = (LDKu5){ ._0 = data_without_signature_conv_7 };
20344         }
20345         LDKCVec_u8Z ret_var = construct_invoice_preimage(hrp_bytes_ref, data_without_signature_constr);
20346         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
20347         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
20348         CVec_u8Z_free(ret_var);
20349         return ret_arr;
20350 }
20351
20352 uint32_t  __attribute__((export_name("TS_Level_clone"))) TS_Level_clone(uint32_t orig) {
20353         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
20354         uint32_t ret_conv = LDKLevel_to_js(Level_clone(orig_conv));
20355         return ret_conv;
20356 }
20357
20358 uint32_t  __attribute__((export_name("TS_Level_gossip"))) TS_Level_gossip() {
20359         uint32_t ret_conv = LDKLevel_to_js(Level_gossip());
20360         return ret_conv;
20361 }
20362
20363 uint32_t  __attribute__((export_name("TS_Level_trace"))) TS_Level_trace() {
20364         uint32_t ret_conv = LDKLevel_to_js(Level_trace());
20365         return ret_conv;
20366 }
20367
20368 uint32_t  __attribute__((export_name("TS_Level_debug"))) TS_Level_debug() {
20369         uint32_t ret_conv = LDKLevel_to_js(Level_debug());
20370         return ret_conv;
20371 }
20372
20373 uint32_t  __attribute__((export_name("TS_Level_info"))) TS_Level_info() {
20374         uint32_t ret_conv = LDKLevel_to_js(Level_info());
20375         return ret_conv;
20376 }
20377
20378 uint32_t  __attribute__((export_name("TS_Level_warn"))) TS_Level_warn() {
20379         uint32_t ret_conv = LDKLevel_to_js(Level_warn());
20380         return ret_conv;
20381 }
20382
20383 uint32_t  __attribute__((export_name("TS_Level_error"))) TS_Level_error() {
20384         uint32_t ret_conv = LDKLevel_to_js(Level_error());
20385         return ret_conv;
20386 }
20387
20388 jboolean  __attribute__((export_name("TS_Level_eq"))) TS_Level_eq(uint32_t a, uint32_t b) {
20389         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
20390         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
20391         jboolean ret_conv = Level_eq(a_conv, b_conv);
20392         return ret_conv;
20393 }
20394
20395 int64_t  __attribute__((export_name("TS_Level_hash"))) TS_Level_hash(uint32_t o) {
20396         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
20397         int64_t ret_conv = Level_hash(o_conv);
20398         return ret_conv;
20399 }
20400
20401 uint32_t  __attribute__((export_name("TS_Level_max"))) TS_Level_max() {
20402         uint32_t ret_conv = LDKLevel_to_js(Level_max());
20403         return ret_conv;
20404 }
20405
20406 void  __attribute__((export_name("TS_Record_free"))) TS_Record_free(uint32_t this_obj) {
20407         LDKRecord this_obj_conv;
20408         this_obj_conv.inner = (void*)(this_obj & (~1));
20409         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20411         Record_free(this_obj_conv);
20412 }
20413
20414 uint32_t  __attribute__((export_name("TS_Record_get_level"))) TS_Record_get_level(uint32_t this_ptr) {
20415         LDKRecord this_ptr_conv;
20416         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20417         this_ptr_conv.is_owned = false;
20418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20419         uint32_t ret_conv = LDKLevel_to_js(Record_get_level(&this_ptr_conv));
20420         return ret_conv;
20421 }
20422
20423 void  __attribute__((export_name("TS_Record_set_level"))) TS_Record_set_level(uint32_t this_ptr, uint32_t val) {
20424         LDKRecord this_ptr_conv;
20425         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20426         this_ptr_conv.is_owned = false;
20427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20428         LDKLevel val_conv = LDKLevel_from_js(val);
20429         Record_set_level(&this_ptr_conv, val_conv);
20430 }
20431
20432 jstring  __attribute__((export_name("TS_Record_get_args"))) TS_Record_get_args(uint32_t this_ptr) {
20433         LDKRecord this_ptr_conv;
20434         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20435         this_ptr_conv.is_owned = false;
20436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20437         LDKStr ret_str = Record_get_args(&this_ptr_conv);
20438         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
20439         Str_free(ret_str);
20440         return ret_conv;
20441 }
20442
20443 void  __attribute__((export_name("TS_Record_set_args"))) TS_Record_set_args(uint32_t this_ptr, jstring val) {
20444         LDKRecord this_ptr_conv;
20445         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20446         this_ptr_conv.is_owned = false;
20447         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20448         LDKStr val_conv = str_ref_to_owned_c(val);
20449         Record_set_args(&this_ptr_conv, val_conv);
20450 }
20451
20452 jstring  __attribute__((export_name("TS_Record_get_module_path"))) TS_Record_get_module_path(uint32_t this_ptr) {
20453         LDKRecord this_ptr_conv;
20454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20455         this_ptr_conv.is_owned = false;
20456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20457         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
20458         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
20459         Str_free(ret_str);
20460         return ret_conv;
20461 }
20462
20463 void  __attribute__((export_name("TS_Record_set_module_path"))) TS_Record_set_module_path(uint32_t this_ptr, jstring val) {
20464         LDKRecord this_ptr_conv;
20465         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20466         this_ptr_conv.is_owned = false;
20467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20468         LDKStr val_conv = str_ref_to_owned_c(val);
20469         Record_set_module_path(&this_ptr_conv, val_conv);
20470 }
20471
20472 jstring  __attribute__((export_name("TS_Record_get_file"))) TS_Record_get_file(uint32_t this_ptr) {
20473         LDKRecord this_ptr_conv;
20474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20475         this_ptr_conv.is_owned = false;
20476         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20477         LDKStr ret_str = Record_get_file(&this_ptr_conv);
20478         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
20479         Str_free(ret_str);
20480         return ret_conv;
20481 }
20482
20483 void  __attribute__((export_name("TS_Record_set_file"))) TS_Record_set_file(uint32_t this_ptr, jstring val) {
20484         LDKRecord this_ptr_conv;
20485         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20486         this_ptr_conv.is_owned = false;
20487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20488         LDKStr val_conv = str_ref_to_owned_c(val);
20489         Record_set_file(&this_ptr_conv, val_conv);
20490 }
20491
20492 int32_t  __attribute__((export_name("TS_Record_get_line"))) TS_Record_get_line(uint32_t this_ptr) {
20493         LDKRecord this_ptr_conv;
20494         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20495         this_ptr_conv.is_owned = false;
20496         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20497         int32_t ret_conv = Record_get_line(&this_ptr_conv);
20498         return ret_conv;
20499 }
20500
20501 void  __attribute__((export_name("TS_Record_set_line"))) TS_Record_set_line(uint32_t this_ptr, int32_t val) {
20502         LDKRecord this_ptr_conv;
20503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20504         this_ptr_conv.is_owned = false;
20505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20506         Record_set_line(&this_ptr_conv, val);
20507 }
20508
20509 static inline uintptr_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
20510         LDKRecord ret_var = Record_clone(arg);
20511 uint32_t ret_ref = 0;
20512 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20513 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20514 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20515 ret_ref = (uintptr_t)ret_var.inner;
20516 if (ret_var.is_owned) {
20517         ret_ref |= 1;
20518 }
20519         return ret_ref;
20520 }
20521 uint32_t  __attribute__((export_name("TS_Record_clone_ptr"))) TS_Record_clone_ptr(uint32_t arg) {
20522         LDKRecord arg_conv;
20523         arg_conv.inner = (void*)(arg & (~1));
20524         arg_conv.is_owned = false;
20525         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20526         uint32_t ret_conv = Record_clone_ptr(&arg_conv);
20527         return ret_conv;
20528 }
20529
20530 uint32_t  __attribute__((export_name("TS_Record_clone"))) TS_Record_clone(uint32_t orig) {
20531         LDKRecord orig_conv;
20532         orig_conv.inner = (void*)(orig & (~1));
20533         orig_conv.is_owned = false;
20534         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20535         LDKRecord ret_var = Record_clone(&orig_conv);
20536         uint32_t ret_ref = 0;
20537         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20538         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20539         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20540         ret_ref = (uintptr_t)ret_var.inner;
20541         if (ret_var.is_owned) {
20542                 ret_ref |= 1;
20543         }
20544         return ret_ref;
20545 }
20546
20547 void  __attribute__((export_name("TS_Logger_free"))) TS_Logger_free(uint32_t this_ptr) {
20548         if ((this_ptr & 1) != 0) return;
20549         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
20550         CHECK_ACCESS(this_ptr_ptr);
20551         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
20552         FREE((void*)this_ptr);
20553         Logger_free(this_ptr_conv);
20554 }
20555
20556 void  __attribute__((export_name("TS_ChannelHandshakeConfig_free"))) TS_ChannelHandshakeConfig_free(uint32_t this_obj) {
20557         LDKChannelHandshakeConfig this_obj_conv;
20558         this_obj_conv.inner = (void*)(this_obj & (~1));
20559         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20561         ChannelHandshakeConfig_free(this_obj_conv);
20562 }
20563
20564 int32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_minimum_depth"))) TS_ChannelHandshakeConfig_get_minimum_depth(uint32_t this_ptr) {
20565         LDKChannelHandshakeConfig this_ptr_conv;
20566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20567         this_ptr_conv.is_owned = false;
20568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20569         int32_t ret_conv = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
20570         return ret_conv;
20571 }
20572
20573 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_minimum_depth"))) TS_ChannelHandshakeConfig_set_minimum_depth(uint32_t this_ptr, int32_t val) {
20574         LDKChannelHandshakeConfig this_ptr_conv;
20575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20576         this_ptr_conv.is_owned = false;
20577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20578         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
20579 }
20580
20581 int16_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_our_to_self_delay"))) TS_ChannelHandshakeConfig_get_our_to_self_delay(uint32_t this_ptr) {
20582         LDKChannelHandshakeConfig this_ptr_conv;
20583         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20584         this_ptr_conv.is_owned = false;
20585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20586         int16_t ret_conv = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
20587         return ret_conv;
20588 }
20589
20590 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) {
20591         LDKChannelHandshakeConfig this_ptr_conv;
20592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20593         this_ptr_conv.is_owned = false;
20594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20595         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
20596 }
20597
20598 int64_t  __attribute__((export_name("TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat"))) TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat(uint32_t this_ptr) {
20599         LDKChannelHandshakeConfig this_ptr_conv;
20600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20601         this_ptr_conv.is_owned = false;
20602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20603         int64_t ret_conv = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
20604         return ret_conv;
20605 }
20606
20607 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) {
20608         LDKChannelHandshakeConfig this_ptr_conv;
20609         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20610         this_ptr_conv.is_owned = false;
20611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20612         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
20613 }
20614
20615 jboolean  __attribute__((export_name("TS_ChannelHandshakeConfig_get_negotiate_scid_privacy"))) TS_ChannelHandshakeConfig_get_negotiate_scid_privacy(uint32_t this_ptr) {
20616         LDKChannelHandshakeConfig this_ptr_conv;
20617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20618         this_ptr_conv.is_owned = false;
20619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20620         jboolean ret_conv = ChannelHandshakeConfig_get_negotiate_scid_privacy(&this_ptr_conv);
20621         return ret_conv;
20622 }
20623
20624 void  __attribute__((export_name("TS_ChannelHandshakeConfig_set_negotiate_scid_privacy"))) TS_ChannelHandshakeConfig_set_negotiate_scid_privacy(uint32_t this_ptr, jboolean val) {
20625         LDKChannelHandshakeConfig this_ptr_conv;
20626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20627         this_ptr_conv.is_owned = false;
20628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20629         ChannelHandshakeConfig_set_negotiate_scid_privacy(&this_ptr_conv, val);
20630 }
20631
20632 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) {
20633         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg, negotiate_scid_privacy_arg);
20634         uint32_t ret_ref = 0;
20635         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20636         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20637         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20638         ret_ref = (uintptr_t)ret_var.inner;
20639         if (ret_var.is_owned) {
20640                 ret_ref |= 1;
20641         }
20642         return ret_ref;
20643 }
20644
20645 static inline uintptr_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
20646         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
20647 uint32_t ret_ref = 0;
20648 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20649 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20650 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20651 ret_ref = (uintptr_t)ret_var.inner;
20652 if (ret_var.is_owned) {
20653         ret_ref |= 1;
20654 }
20655         return ret_ref;
20656 }
20657 uint32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_clone_ptr"))) TS_ChannelHandshakeConfig_clone_ptr(uint32_t arg) {
20658         LDKChannelHandshakeConfig arg_conv;
20659         arg_conv.inner = (void*)(arg & (~1));
20660         arg_conv.is_owned = false;
20661         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20662         uint32_t ret_conv = ChannelHandshakeConfig_clone_ptr(&arg_conv);
20663         return ret_conv;
20664 }
20665
20666 uint32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_clone"))) TS_ChannelHandshakeConfig_clone(uint32_t orig) {
20667         LDKChannelHandshakeConfig orig_conv;
20668         orig_conv.inner = (void*)(orig & (~1));
20669         orig_conv.is_owned = false;
20670         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20671         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
20672         uint32_t ret_ref = 0;
20673         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20674         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20675         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20676         ret_ref = (uintptr_t)ret_var.inner;
20677         if (ret_var.is_owned) {
20678                 ret_ref |= 1;
20679         }
20680         return ret_ref;
20681 }
20682
20683 uint32_t  __attribute__((export_name("TS_ChannelHandshakeConfig_default"))) TS_ChannelHandshakeConfig_default() {
20684         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
20685         uint32_t ret_ref = 0;
20686         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20687         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20688         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20689         ret_ref = (uintptr_t)ret_var.inner;
20690         if (ret_var.is_owned) {
20691                 ret_ref |= 1;
20692         }
20693         return ret_ref;
20694 }
20695
20696 void  __attribute__((export_name("TS_ChannelHandshakeLimits_free"))) TS_ChannelHandshakeLimits_free(uint32_t this_obj) {
20697         LDKChannelHandshakeLimits this_obj_conv;
20698         this_obj_conv.inner = (void*)(this_obj & (~1));
20699         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20701         ChannelHandshakeLimits_free(this_obj_conv);
20702 }
20703
20704 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_min_funding_satoshis"))) TS_ChannelHandshakeLimits_get_min_funding_satoshis(uint32_t this_ptr) {
20705         LDKChannelHandshakeLimits this_ptr_conv;
20706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20707         this_ptr_conv.is_owned = false;
20708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20709         int64_t ret_conv = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
20710         return ret_conv;
20711 }
20712
20713 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_min_funding_satoshis"))) TS_ChannelHandshakeLimits_set_min_funding_satoshis(uint32_t this_ptr, int64_t val) {
20714         LDKChannelHandshakeLimits this_ptr_conv;
20715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20716         this_ptr_conv.is_owned = false;
20717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20718         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
20719 }
20720
20721 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat"))) TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat(uint32_t this_ptr) {
20722         LDKChannelHandshakeLimits this_ptr_conv;
20723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20724         this_ptr_conv.is_owned = false;
20725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20726         int64_t ret_conv = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
20727         return ret_conv;
20728 }
20729
20730 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) {
20731         LDKChannelHandshakeLimits this_ptr_conv;
20732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20733         this_ptr_conv.is_owned = false;
20734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20735         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
20736 }
20737
20738 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) {
20739         LDKChannelHandshakeLimits this_ptr_conv;
20740         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20741         this_ptr_conv.is_owned = false;
20742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20743         int64_t ret_conv = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
20744         return ret_conv;
20745 }
20746
20747 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) {
20748         LDKChannelHandshakeLimits this_ptr_conv;
20749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20750         this_ptr_conv.is_owned = false;
20751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20752         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
20753 }
20754
20755 int64_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis"))) TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis(uint32_t this_ptr) {
20756         LDKChannelHandshakeLimits this_ptr_conv;
20757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20758         this_ptr_conv.is_owned = false;
20759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20760         int64_t ret_conv = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
20761         return ret_conv;
20762 }
20763
20764 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) {
20765         LDKChannelHandshakeLimits this_ptr_conv;
20766         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20767         this_ptr_conv.is_owned = false;
20768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20769         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
20770 }
20771
20772 int16_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs"))) TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs(uint32_t this_ptr) {
20773         LDKChannelHandshakeLimits this_ptr_conv;
20774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20775         this_ptr_conv.is_owned = false;
20776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20777         int16_t ret_conv = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
20778         return ret_conv;
20779 }
20780
20781 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) {
20782         LDKChannelHandshakeLimits this_ptr_conv;
20783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20784         this_ptr_conv.is_owned = false;
20785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20786         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
20787 }
20788
20789 int32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_max_minimum_depth"))) TS_ChannelHandshakeLimits_get_max_minimum_depth(uint32_t this_ptr) {
20790         LDKChannelHandshakeLimits this_ptr_conv;
20791         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20792         this_ptr_conv.is_owned = false;
20793         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20794         int32_t ret_conv = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
20795         return ret_conv;
20796 }
20797
20798 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_max_minimum_depth"))) TS_ChannelHandshakeLimits_set_max_minimum_depth(uint32_t this_ptr, int32_t val) {
20799         LDKChannelHandshakeLimits this_ptr_conv;
20800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20801         this_ptr_conv.is_owned = false;
20802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20803         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
20804 }
20805
20806 jboolean  __attribute__((export_name("TS_ChannelHandshakeLimits_get_force_announced_channel_preference"))) TS_ChannelHandshakeLimits_get_force_announced_channel_preference(uint32_t this_ptr) {
20807         LDKChannelHandshakeLimits this_ptr_conv;
20808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20809         this_ptr_conv.is_owned = false;
20810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20811         jboolean ret_conv = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
20812         return ret_conv;
20813 }
20814
20815 void  __attribute__((export_name("TS_ChannelHandshakeLimits_set_force_announced_channel_preference"))) TS_ChannelHandshakeLimits_set_force_announced_channel_preference(uint32_t this_ptr, jboolean val) {
20816         LDKChannelHandshakeLimits this_ptr_conv;
20817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20818         this_ptr_conv.is_owned = false;
20819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20820         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
20821 }
20822
20823 int16_t  __attribute__((export_name("TS_ChannelHandshakeLimits_get_their_to_self_delay"))) TS_ChannelHandshakeLimits_get_their_to_self_delay(uint32_t this_ptr) {
20824         LDKChannelHandshakeLimits this_ptr_conv;
20825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20826         this_ptr_conv.is_owned = false;
20827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20828         int16_t ret_conv = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
20829         return ret_conv;
20830 }
20831
20832 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) {
20833         LDKChannelHandshakeLimits this_ptr_conv;
20834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20835         this_ptr_conv.is_owned = false;
20836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20837         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
20838 }
20839
20840 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) {
20841         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);
20842         uint32_t ret_ref = 0;
20843         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20844         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20845         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20846         ret_ref = (uintptr_t)ret_var.inner;
20847         if (ret_var.is_owned) {
20848                 ret_ref |= 1;
20849         }
20850         return ret_ref;
20851 }
20852
20853 static inline uintptr_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
20854         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
20855 uint32_t ret_ref = 0;
20856 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20857 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20858 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20859 ret_ref = (uintptr_t)ret_var.inner;
20860 if (ret_var.is_owned) {
20861         ret_ref |= 1;
20862 }
20863         return ret_ref;
20864 }
20865 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_clone_ptr"))) TS_ChannelHandshakeLimits_clone_ptr(uint32_t arg) {
20866         LDKChannelHandshakeLimits arg_conv;
20867         arg_conv.inner = (void*)(arg & (~1));
20868         arg_conv.is_owned = false;
20869         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20870         uint32_t ret_conv = ChannelHandshakeLimits_clone_ptr(&arg_conv);
20871         return ret_conv;
20872 }
20873
20874 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_clone"))) TS_ChannelHandshakeLimits_clone(uint32_t orig) {
20875         LDKChannelHandshakeLimits orig_conv;
20876         orig_conv.inner = (void*)(orig & (~1));
20877         orig_conv.is_owned = false;
20878         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20879         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
20880         uint32_t ret_ref = 0;
20881         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20882         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20883         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20884         ret_ref = (uintptr_t)ret_var.inner;
20885         if (ret_var.is_owned) {
20886                 ret_ref |= 1;
20887         }
20888         return ret_ref;
20889 }
20890
20891 uint32_t  __attribute__((export_name("TS_ChannelHandshakeLimits_default"))) TS_ChannelHandshakeLimits_default() {
20892         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
20893         uint32_t ret_ref = 0;
20894         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20895         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20896         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20897         ret_ref = (uintptr_t)ret_var.inner;
20898         if (ret_var.is_owned) {
20899                 ret_ref |= 1;
20900         }
20901         return ret_ref;
20902 }
20903
20904 void  __attribute__((export_name("TS_ChannelConfig_free"))) TS_ChannelConfig_free(uint32_t this_obj) {
20905         LDKChannelConfig this_obj_conv;
20906         this_obj_conv.inner = (void*)(this_obj & (~1));
20907         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20909         ChannelConfig_free(this_obj_conv);
20910 }
20911
20912 int32_t  __attribute__((export_name("TS_ChannelConfig_get_forwarding_fee_proportional_millionths"))) TS_ChannelConfig_get_forwarding_fee_proportional_millionths(uint32_t this_ptr) {
20913         LDKChannelConfig this_ptr_conv;
20914         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20915         this_ptr_conv.is_owned = false;
20916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20917         int32_t ret_conv = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
20918         return ret_conv;
20919 }
20920
20921 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) {
20922         LDKChannelConfig this_ptr_conv;
20923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20924         this_ptr_conv.is_owned = false;
20925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20926         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
20927 }
20928
20929 int32_t  __attribute__((export_name("TS_ChannelConfig_get_forwarding_fee_base_msat"))) TS_ChannelConfig_get_forwarding_fee_base_msat(uint32_t this_ptr) {
20930         LDKChannelConfig this_ptr_conv;
20931         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20932         this_ptr_conv.is_owned = false;
20933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20934         int32_t ret_conv = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
20935         return ret_conv;
20936 }
20937
20938 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) {
20939         LDKChannelConfig this_ptr_conv;
20940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20941         this_ptr_conv.is_owned = false;
20942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20943         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
20944 }
20945
20946 int16_t  __attribute__((export_name("TS_ChannelConfig_get_cltv_expiry_delta"))) TS_ChannelConfig_get_cltv_expiry_delta(uint32_t this_ptr) {
20947         LDKChannelConfig this_ptr_conv;
20948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20949         this_ptr_conv.is_owned = false;
20950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20951         int16_t ret_conv = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
20952         return ret_conv;
20953 }
20954
20955 void  __attribute__((export_name("TS_ChannelConfig_set_cltv_expiry_delta"))) TS_ChannelConfig_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
20956         LDKChannelConfig this_ptr_conv;
20957         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20958         this_ptr_conv.is_owned = false;
20959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20960         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
20961 }
20962
20963 jboolean  __attribute__((export_name("TS_ChannelConfig_get_announced_channel"))) TS_ChannelConfig_get_announced_channel(uint32_t this_ptr) {
20964         LDKChannelConfig this_ptr_conv;
20965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20966         this_ptr_conv.is_owned = false;
20967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20968         jboolean ret_conv = ChannelConfig_get_announced_channel(&this_ptr_conv);
20969         return ret_conv;
20970 }
20971
20972 void  __attribute__((export_name("TS_ChannelConfig_set_announced_channel"))) TS_ChannelConfig_set_announced_channel(uint32_t this_ptr, jboolean val) {
20973         LDKChannelConfig this_ptr_conv;
20974         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20975         this_ptr_conv.is_owned = false;
20976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20977         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
20978 }
20979
20980 jboolean  __attribute__((export_name("TS_ChannelConfig_get_commit_upfront_shutdown_pubkey"))) TS_ChannelConfig_get_commit_upfront_shutdown_pubkey(uint32_t this_ptr) {
20981         LDKChannelConfig this_ptr_conv;
20982         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20983         this_ptr_conv.is_owned = false;
20984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20985         jboolean ret_conv = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
20986         return ret_conv;
20987 }
20988
20989 void  __attribute__((export_name("TS_ChannelConfig_set_commit_upfront_shutdown_pubkey"))) TS_ChannelConfig_set_commit_upfront_shutdown_pubkey(uint32_t this_ptr, jboolean val) {
20990         LDKChannelConfig this_ptr_conv;
20991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20992         this_ptr_conv.is_owned = false;
20993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20994         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
20995 }
20996
20997 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) {
20998         LDKChannelConfig this_ptr_conv;
20999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21000         this_ptr_conv.is_owned = false;
21001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21002         int64_t ret_conv = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
21003         return ret_conv;
21004 }
21005
21006 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) {
21007         LDKChannelConfig this_ptr_conv;
21008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21009         this_ptr_conv.is_owned = false;
21010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21011         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
21012 }
21013
21014 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) {
21015         LDKChannelConfig this_ptr_conv;
21016         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21017         this_ptr_conv.is_owned = false;
21018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21019         int64_t ret_conv = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
21020         return ret_conv;
21021 }
21022
21023 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) {
21024         LDKChannelConfig this_ptr_conv;
21025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21026         this_ptr_conv.is_owned = false;
21027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21028         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
21029 }
21030
21031 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) {
21032         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);
21033         uint32_t ret_ref = 0;
21034         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21035         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21036         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21037         ret_ref = (uintptr_t)ret_var.inner;
21038         if (ret_var.is_owned) {
21039                 ret_ref |= 1;
21040         }
21041         return ret_ref;
21042 }
21043
21044 static inline uintptr_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
21045         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
21046 uint32_t ret_ref = 0;
21047 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21048 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21049 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21050 ret_ref = (uintptr_t)ret_var.inner;
21051 if (ret_var.is_owned) {
21052         ret_ref |= 1;
21053 }
21054         return ret_ref;
21055 }
21056 uint32_t  __attribute__((export_name("TS_ChannelConfig_clone_ptr"))) TS_ChannelConfig_clone_ptr(uint32_t arg) {
21057         LDKChannelConfig arg_conv;
21058         arg_conv.inner = (void*)(arg & (~1));
21059         arg_conv.is_owned = false;
21060         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21061         uint32_t ret_conv = ChannelConfig_clone_ptr(&arg_conv);
21062         return ret_conv;
21063 }
21064
21065 uint32_t  __attribute__((export_name("TS_ChannelConfig_clone"))) TS_ChannelConfig_clone(uint32_t orig) {
21066         LDKChannelConfig orig_conv;
21067         orig_conv.inner = (void*)(orig & (~1));
21068         orig_conv.is_owned = false;
21069         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21070         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
21071         uint32_t ret_ref = 0;
21072         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21073         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21074         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21075         ret_ref = (uintptr_t)ret_var.inner;
21076         if (ret_var.is_owned) {
21077                 ret_ref |= 1;
21078         }
21079         return ret_ref;
21080 }
21081
21082 uint32_t  __attribute__((export_name("TS_ChannelConfig_default"))) TS_ChannelConfig_default() {
21083         LDKChannelConfig ret_var = ChannelConfig_default();
21084         uint32_t ret_ref = 0;
21085         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21086         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21087         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21088         ret_ref = (uintptr_t)ret_var.inner;
21089         if (ret_var.is_owned) {
21090                 ret_ref |= 1;
21091         }
21092         return ret_ref;
21093 }
21094
21095 int8_tArray  __attribute__((export_name("TS_ChannelConfig_write"))) TS_ChannelConfig_write(uint32_t obj) {
21096         LDKChannelConfig obj_conv;
21097         obj_conv.inner = (void*)(obj & (~1));
21098         obj_conv.is_owned = false;
21099         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
21100         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
21101         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
21102         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
21103         CVec_u8Z_free(ret_var);
21104         return ret_arr;
21105 }
21106
21107 uint32_t  __attribute__((export_name("TS_ChannelConfig_read"))) TS_ChannelConfig_read(int8_tArray ser) {
21108         LDKu8slice ser_ref;
21109         ser_ref.datalen = ser->arr_len;
21110         ser_ref.data = ser->elems /* XXX ser leaks */;
21111         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
21112         *ret_conv = ChannelConfig_read(ser_ref);
21113         return (uint32_t)ret_conv;
21114 }
21115
21116 void  __attribute__((export_name("TS_UserConfig_free"))) TS_UserConfig_free(uint32_t this_obj) {
21117         LDKUserConfig this_obj_conv;
21118         this_obj_conv.inner = (void*)(this_obj & (~1));
21119         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21121         UserConfig_free(this_obj_conv);
21122 }
21123
21124 uint32_t  __attribute__((export_name("TS_UserConfig_get_own_channel_config"))) TS_UserConfig_get_own_channel_config(uint32_t this_ptr) {
21125         LDKUserConfig this_ptr_conv;
21126         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21127         this_ptr_conv.is_owned = false;
21128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21129         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
21130         uint32_t ret_ref = 0;
21131         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21132         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21133         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21134         ret_ref = (uintptr_t)ret_var.inner;
21135         if (ret_var.is_owned) {
21136                 ret_ref |= 1;
21137         }
21138         return ret_ref;
21139 }
21140
21141 void  __attribute__((export_name("TS_UserConfig_set_own_channel_config"))) TS_UserConfig_set_own_channel_config(uint32_t this_ptr, uint32_t val) {
21142         LDKUserConfig this_ptr_conv;
21143         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21144         this_ptr_conv.is_owned = false;
21145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21146         LDKChannelHandshakeConfig val_conv;
21147         val_conv.inner = (void*)(val & (~1));
21148         val_conv.is_owned = (val & 1) || (val == 0);
21149         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
21150         val_conv = ChannelHandshakeConfig_clone(&val_conv);
21151         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
21152 }
21153
21154 uint32_t  __attribute__((export_name("TS_UserConfig_get_peer_channel_config_limits"))) TS_UserConfig_get_peer_channel_config_limits(uint32_t this_ptr) {
21155         LDKUserConfig this_ptr_conv;
21156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21157         this_ptr_conv.is_owned = false;
21158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21159         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
21160         uint32_t ret_ref = 0;
21161         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21162         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21163         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21164         ret_ref = (uintptr_t)ret_var.inner;
21165         if (ret_var.is_owned) {
21166                 ret_ref |= 1;
21167         }
21168         return ret_ref;
21169 }
21170
21171 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) {
21172         LDKUserConfig this_ptr_conv;
21173         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21174         this_ptr_conv.is_owned = false;
21175         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21176         LDKChannelHandshakeLimits val_conv;
21177         val_conv.inner = (void*)(val & (~1));
21178         val_conv.is_owned = (val & 1) || (val == 0);
21179         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
21180         val_conv = ChannelHandshakeLimits_clone(&val_conv);
21181         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
21182 }
21183
21184 uint32_t  __attribute__((export_name("TS_UserConfig_get_channel_options"))) TS_UserConfig_get_channel_options(uint32_t this_ptr) {
21185         LDKUserConfig this_ptr_conv;
21186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21187         this_ptr_conv.is_owned = false;
21188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21189         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
21190         uint32_t ret_ref = 0;
21191         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21192         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21193         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21194         ret_ref = (uintptr_t)ret_var.inner;
21195         if (ret_var.is_owned) {
21196                 ret_ref |= 1;
21197         }
21198         return ret_ref;
21199 }
21200
21201 void  __attribute__((export_name("TS_UserConfig_set_channel_options"))) TS_UserConfig_set_channel_options(uint32_t this_ptr, uint32_t val) {
21202         LDKUserConfig this_ptr_conv;
21203         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21204         this_ptr_conv.is_owned = false;
21205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21206         LDKChannelConfig val_conv;
21207         val_conv.inner = (void*)(val & (~1));
21208         val_conv.is_owned = (val & 1) || (val == 0);
21209         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
21210         val_conv = ChannelConfig_clone(&val_conv);
21211         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
21212 }
21213
21214 jboolean  __attribute__((export_name("TS_UserConfig_get_accept_forwards_to_priv_channels"))) TS_UserConfig_get_accept_forwards_to_priv_channels(uint32_t this_ptr) {
21215         LDKUserConfig this_ptr_conv;
21216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21217         this_ptr_conv.is_owned = false;
21218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21219         jboolean ret_conv = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
21220         return ret_conv;
21221 }
21222
21223 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) {
21224         LDKUserConfig this_ptr_conv;
21225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21226         this_ptr_conv.is_owned = false;
21227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21228         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
21229 }
21230
21231 jboolean  __attribute__((export_name("TS_UserConfig_get_accept_inbound_channels"))) TS_UserConfig_get_accept_inbound_channels(uint32_t this_ptr) {
21232         LDKUserConfig this_ptr_conv;
21233         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21234         this_ptr_conv.is_owned = false;
21235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21236         jboolean ret_conv = UserConfig_get_accept_inbound_channels(&this_ptr_conv);
21237         return ret_conv;
21238 }
21239
21240 void  __attribute__((export_name("TS_UserConfig_set_accept_inbound_channels"))) TS_UserConfig_set_accept_inbound_channels(uint32_t this_ptr, jboolean val) {
21241         LDKUserConfig this_ptr_conv;
21242         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21243         this_ptr_conv.is_owned = false;
21244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21245         UserConfig_set_accept_inbound_channels(&this_ptr_conv, val);
21246 }
21247
21248 jboolean  __attribute__((export_name("TS_UserConfig_get_manually_accept_inbound_channels"))) TS_UserConfig_get_manually_accept_inbound_channels(uint32_t this_ptr) {
21249         LDKUserConfig this_ptr_conv;
21250         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21251         this_ptr_conv.is_owned = false;
21252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21253         jboolean ret_conv = UserConfig_get_manually_accept_inbound_channels(&this_ptr_conv);
21254         return ret_conv;
21255 }
21256
21257 void  __attribute__((export_name("TS_UserConfig_set_manually_accept_inbound_channels"))) TS_UserConfig_set_manually_accept_inbound_channels(uint32_t this_ptr, jboolean val) {
21258         LDKUserConfig this_ptr_conv;
21259         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21260         this_ptr_conv.is_owned = false;
21261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21262         UserConfig_set_manually_accept_inbound_channels(&this_ptr_conv, val);
21263 }
21264
21265 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) {
21266         LDKChannelHandshakeConfig own_channel_config_arg_conv;
21267         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
21268         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
21269         CHECK_INNER_FIELD_ACCESS_OR_NULL(own_channel_config_arg_conv);
21270         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
21271         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
21272         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
21273         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
21274         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_channel_config_limits_arg_conv);
21275         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
21276         LDKChannelConfig channel_options_arg_conv;
21277         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
21278         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
21279         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_options_arg_conv);
21280         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
21281         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);
21282         uint32_t ret_ref = 0;
21283         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21284         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21285         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21286         ret_ref = (uintptr_t)ret_var.inner;
21287         if (ret_var.is_owned) {
21288                 ret_ref |= 1;
21289         }
21290         return ret_ref;
21291 }
21292
21293 static inline uintptr_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
21294         LDKUserConfig ret_var = UserConfig_clone(arg);
21295 uint32_t ret_ref = 0;
21296 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21297 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21298 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21299 ret_ref = (uintptr_t)ret_var.inner;
21300 if (ret_var.is_owned) {
21301         ret_ref |= 1;
21302 }
21303         return ret_ref;
21304 }
21305 uint32_t  __attribute__((export_name("TS_UserConfig_clone_ptr"))) TS_UserConfig_clone_ptr(uint32_t arg) {
21306         LDKUserConfig arg_conv;
21307         arg_conv.inner = (void*)(arg & (~1));
21308         arg_conv.is_owned = false;
21309         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21310         uint32_t ret_conv = UserConfig_clone_ptr(&arg_conv);
21311         return ret_conv;
21312 }
21313
21314 uint32_t  __attribute__((export_name("TS_UserConfig_clone"))) TS_UserConfig_clone(uint32_t orig) {
21315         LDKUserConfig orig_conv;
21316         orig_conv.inner = (void*)(orig & (~1));
21317         orig_conv.is_owned = false;
21318         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21319         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
21320         uint32_t ret_ref = 0;
21321         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21322         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21323         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21324         ret_ref = (uintptr_t)ret_var.inner;
21325         if (ret_var.is_owned) {
21326                 ret_ref |= 1;
21327         }
21328         return ret_ref;
21329 }
21330
21331 uint32_t  __attribute__((export_name("TS_UserConfig_default"))) TS_UserConfig_default() {
21332         LDKUserConfig ret_var = UserConfig_default();
21333         uint32_t ret_ref = 0;
21334         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21335         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21336         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21337         ret_ref = (uintptr_t)ret_var.inner;
21338         if (ret_var.is_owned) {
21339                 ret_ref |= 1;
21340         }
21341         return ret_ref;
21342 }
21343
21344 void  __attribute__((export_name("TS_BestBlock_free"))) TS_BestBlock_free(uint32_t this_obj) {
21345         LDKBestBlock this_obj_conv;
21346         this_obj_conv.inner = (void*)(this_obj & (~1));
21347         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21349         BestBlock_free(this_obj_conv);
21350 }
21351
21352 static inline uintptr_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
21353         LDKBestBlock ret_var = BestBlock_clone(arg);
21354 uint32_t ret_ref = 0;
21355 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21356 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21357 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21358 ret_ref = (uintptr_t)ret_var.inner;
21359 if (ret_var.is_owned) {
21360         ret_ref |= 1;
21361 }
21362         return ret_ref;
21363 }
21364 uint32_t  __attribute__((export_name("TS_BestBlock_clone_ptr"))) TS_BestBlock_clone_ptr(uint32_t arg) {
21365         LDKBestBlock arg_conv;
21366         arg_conv.inner = (void*)(arg & (~1));
21367         arg_conv.is_owned = false;
21368         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21369         uint32_t ret_conv = BestBlock_clone_ptr(&arg_conv);
21370         return ret_conv;
21371 }
21372
21373 uint32_t  __attribute__((export_name("TS_BestBlock_clone"))) TS_BestBlock_clone(uint32_t orig) {
21374         LDKBestBlock orig_conv;
21375         orig_conv.inner = (void*)(orig & (~1));
21376         orig_conv.is_owned = false;
21377         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21378         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
21379         uint32_t ret_ref = 0;
21380         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21381         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21382         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21383         ret_ref = (uintptr_t)ret_var.inner;
21384         if (ret_var.is_owned) {
21385                 ret_ref |= 1;
21386         }
21387         return ret_ref;
21388 }
21389
21390 uint32_t  __attribute__((export_name("TS_BestBlock_from_genesis"))) TS_BestBlock_from_genesis(uint32_t network) {
21391         LDKNetwork network_conv = LDKNetwork_from_js(network);
21392         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
21393         uint32_t ret_ref = 0;
21394         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21395         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21396         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21397         ret_ref = (uintptr_t)ret_var.inner;
21398         if (ret_var.is_owned) {
21399                 ret_ref |= 1;
21400         }
21401         return ret_ref;
21402 }
21403
21404 uint32_t  __attribute__((export_name("TS_BestBlock_new"))) TS_BestBlock_new(int8_tArray block_hash, int32_t height) {
21405         LDKThirtyTwoBytes block_hash_ref;
21406         CHECK(block_hash->arr_len == 32);
21407         memcpy(block_hash_ref.data, block_hash->elems, 32); FREE(block_hash);
21408         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
21409         uint32_t ret_ref = 0;
21410         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21411         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21412         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21413         ret_ref = (uintptr_t)ret_var.inner;
21414         if (ret_var.is_owned) {
21415                 ret_ref |= 1;
21416         }
21417         return ret_ref;
21418 }
21419
21420 int8_tArray  __attribute__((export_name("TS_BestBlock_block_hash"))) TS_BestBlock_block_hash(uint32_t this_arg) {
21421         LDKBestBlock this_arg_conv;
21422         this_arg_conv.inner = (void*)(this_arg & (~1));
21423         this_arg_conv.is_owned = false;
21424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21425         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
21426         memcpy(ret_arr->elems, BestBlock_block_hash(&this_arg_conv).data, 32);
21427         return ret_arr;
21428 }
21429
21430 int32_t  __attribute__((export_name("TS_BestBlock_height"))) TS_BestBlock_height(uint32_t this_arg) {
21431         LDKBestBlock this_arg_conv;
21432         this_arg_conv.inner = (void*)(this_arg & (~1));
21433         this_arg_conv.is_owned = false;
21434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21435         int32_t ret_conv = BestBlock_height(&this_arg_conv);
21436         return ret_conv;
21437 }
21438
21439 uint32_t  __attribute__((export_name("TS_AccessError_clone"))) TS_AccessError_clone(uint32_t orig) {
21440         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
21441         uint32_t ret_conv = LDKAccessError_to_js(AccessError_clone(orig_conv));
21442         return ret_conv;
21443 }
21444
21445 uint32_t  __attribute__((export_name("TS_AccessError_unknown_chain"))) TS_AccessError_unknown_chain() {
21446         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_chain());
21447         return ret_conv;
21448 }
21449
21450 uint32_t  __attribute__((export_name("TS_AccessError_unknown_tx"))) TS_AccessError_unknown_tx() {
21451         uint32_t ret_conv = LDKAccessError_to_js(AccessError_unknown_tx());
21452         return ret_conv;
21453 }
21454
21455 void  __attribute__((export_name("TS_Access_free"))) TS_Access_free(uint32_t this_ptr) {
21456         if ((this_ptr & 1) != 0) return;
21457         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21458         CHECK_ACCESS(this_ptr_ptr);
21459         LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
21460         FREE((void*)this_ptr);
21461         Access_free(this_ptr_conv);
21462 }
21463
21464 void  __attribute__((export_name("TS_Listen_free"))) TS_Listen_free(uint32_t this_ptr) {
21465         if ((this_ptr & 1) != 0) return;
21466         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21467         CHECK_ACCESS(this_ptr_ptr);
21468         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
21469         FREE((void*)this_ptr);
21470         Listen_free(this_ptr_conv);
21471 }
21472
21473 void  __attribute__((export_name("TS_Confirm_free"))) TS_Confirm_free(uint32_t this_ptr) {
21474         if ((this_ptr & 1) != 0) return;
21475         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21476         CHECK_ACCESS(this_ptr_ptr);
21477         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
21478         FREE((void*)this_ptr);
21479         Confirm_free(this_ptr_conv);
21480 }
21481
21482 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_clone"))) TS_ChannelMonitorUpdateErr_clone(uint32_t orig) {
21483         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
21484         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_clone(orig_conv));
21485         return ret_conv;
21486 }
21487
21488 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_temporary_failure"))) TS_ChannelMonitorUpdateErr_temporary_failure() {
21489         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_temporary_failure());
21490         return ret_conv;
21491 }
21492
21493 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdateErr_permanent_failure"))) TS_ChannelMonitorUpdateErr_permanent_failure() {
21494         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_permanent_failure());
21495         return ret_conv;
21496 }
21497
21498 void  __attribute__((export_name("TS_Watch_free"))) TS_Watch_free(uint32_t this_ptr) {
21499         if ((this_ptr & 1) != 0) return;
21500         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21501         CHECK_ACCESS(this_ptr_ptr);
21502         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
21503         FREE((void*)this_ptr);
21504         Watch_free(this_ptr_conv);
21505 }
21506
21507 void  __attribute__((export_name("TS_Filter_free"))) TS_Filter_free(uint32_t this_ptr) {
21508         if ((this_ptr & 1) != 0) return;
21509         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21510         CHECK_ACCESS(this_ptr_ptr);
21511         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
21512         FREE((void*)this_ptr);
21513         Filter_free(this_ptr_conv);
21514 }
21515
21516 void  __attribute__((export_name("TS_WatchedOutput_free"))) TS_WatchedOutput_free(uint32_t this_obj) {
21517         LDKWatchedOutput this_obj_conv;
21518         this_obj_conv.inner = (void*)(this_obj & (~1));
21519         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21521         WatchedOutput_free(this_obj_conv);
21522 }
21523
21524 int8_tArray  __attribute__((export_name("TS_WatchedOutput_get_block_hash"))) TS_WatchedOutput_get_block_hash(uint32_t this_ptr) {
21525         LDKWatchedOutput this_ptr_conv;
21526         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21527         this_ptr_conv.is_owned = false;
21528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21529         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
21530         memcpy(ret_arr->elems, WatchedOutput_get_block_hash(&this_ptr_conv).data, 32);
21531         return ret_arr;
21532 }
21533
21534 void  __attribute__((export_name("TS_WatchedOutput_set_block_hash"))) TS_WatchedOutput_set_block_hash(uint32_t this_ptr, int8_tArray val) {
21535         LDKWatchedOutput this_ptr_conv;
21536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21537         this_ptr_conv.is_owned = false;
21538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21539         LDKThirtyTwoBytes val_ref;
21540         CHECK(val->arr_len == 32);
21541         memcpy(val_ref.data, val->elems, 32); FREE(val);
21542         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
21543 }
21544
21545 uint32_t  __attribute__((export_name("TS_WatchedOutput_get_outpoint"))) TS_WatchedOutput_get_outpoint(uint32_t this_ptr) {
21546         LDKWatchedOutput this_ptr_conv;
21547         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21548         this_ptr_conv.is_owned = false;
21549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21550         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
21551         uint32_t ret_ref = 0;
21552         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21553         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21554         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21555         ret_ref = (uintptr_t)ret_var.inner;
21556         if (ret_var.is_owned) {
21557                 ret_ref |= 1;
21558         }
21559         return ret_ref;
21560 }
21561
21562 void  __attribute__((export_name("TS_WatchedOutput_set_outpoint"))) TS_WatchedOutput_set_outpoint(uint32_t this_ptr, uint32_t val) {
21563         LDKWatchedOutput this_ptr_conv;
21564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21565         this_ptr_conv.is_owned = false;
21566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21567         LDKOutPoint val_conv;
21568         val_conv.inner = (void*)(val & (~1));
21569         val_conv.is_owned = (val & 1) || (val == 0);
21570         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
21571         val_conv = OutPoint_clone(&val_conv);
21572         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
21573 }
21574
21575 int8_tArray  __attribute__((export_name("TS_WatchedOutput_get_script_pubkey"))) TS_WatchedOutput_get_script_pubkey(uint32_t this_ptr) {
21576         LDKWatchedOutput this_ptr_conv;
21577         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21578         this_ptr_conv.is_owned = false;
21579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21580         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
21581         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
21582         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
21583         return ret_arr;
21584 }
21585
21586 void  __attribute__((export_name("TS_WatchedOutput_set_script_pubkey"))) TS_WatchedOutput_set_script_pubkey(uint32_t this_ptr, int8_tArray val) {
21587         LDKWatchedOutput this_ptr_conv;
21588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21589         this_ptr_conv.is_owned = false;
21590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21591         LDKCVec_u8Z val_ref;
21592         val_ref.datalen = val->arr_len;
21593         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
21594         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
21595         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
21596 }
21597
21598 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) {
21599         LDKThirtyTwoBytes block_hash_arg_ref;
21600         CHECK(block_hash_arg->arr_len == 32);
21601         memcpy(block_hash_arg_ref.data, block_hash_arg->elems, 32); FREE(block_hash_arg);
21602         LDKOutPoint outpoint_arg_conv;
21603         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
21604         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
21605         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
21606         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
21607         LDKCVec_u8Z script_pubkey_arg_ref;
21608         script_pubkey_arg_ref.datalen = script_pubkey_arg->arr_len;
21609         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
21610         memcpy(script_pubkey_arg_ref.data, script_pubkey_arg->elems, script_pubkey_arg_ref.datalen); FREE(script_pubkey_arg);
21611         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
21612         uint32_t ret_ref = 0;
21613         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21614         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21615         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21616         ret_ref = (uintptr_t)ret_var.inner;
21617         if (ret_var.is_owned) {
21618                 ret_ref |= 1;
21619         }
21620         return ret_ref;
21621 }
21622
21623 static inline uintptr_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
21624         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
21625 uint32_t ret_ref = 0;
21626 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21627 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21628 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21629 ret_ref = (uintptr_t)ret_var.inner;
21630 if (ret_var.is_owned) {
21631         ret_ref |= 1;
21632 }
21633         return ret_ref;
21634 }
21635 uint32_t  __attribute__((export_name("TS_WatchedOutput_clone_ptr"))) TS_WatchedOutput_clone_ptr(uint32_t arg) {
21636         LDKWatchedOutput arg_conv;
21637         arg_conv.inner = (void*)(arg & (~1));
21638         arg_conv.is_owned = false;
21639         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21640         uint32_t ret_conv = WatchedOutput_clone_ptr(&arg_conv);
21641         return ret_conv;
21642 }
21643
21644 uint32_t  __attribute__((export_name("TS_WatchedOutput_clone"))) TS_WatchedOutput_clone(uint32_t orig) {
21645         LDKWatchedOutput orig_conv;
21646         orig_conv.inner = (void*)(orig & (~1));
21647         orig_conv.is_owned = false;
21648         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21649         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
21650         uint32_t ret_ref = 0;
21651         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21652         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21653         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21654         ret_ref = (uintptr_t)ret_var.inner;
21655         if (ret_var.is_owned) {
21656                 ret_ref |= 1;
21657         }
21658         return ret_ref;
21659 }
21660
21661 int64_t  __attribute__((export_name("TS_WatchedOutput_hash"))) TS_WatchedOutput_hash(uint32_t o) {
21662         LDKWatchedOutput o_conv;
21663         o_conv.inner = (void*)(o & (~1));
21664         o_conv.is_owned = false;
21665         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21666         int64_t ret_conv = WatchedOutput_hash(&o_conv);
21667         return ret_conv;
21668 }
21669
21670 void  __attribute__((export_name("TS_BroadcasterInterface_free"))) TS_BroadcasterInterface_free(uint32_t this_ptr) {
21671         if ((this_ptr & 1) != 0) return;
21672         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21673         CHECK_ACCESS(this_ptr_ptr);
21674         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
21675         FREE((void*)this_ptr);
21676         BroadcasterInterface_free(this_ptr_conv);
21677 }
21678
21679 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_clone"))) TS_ConfirmationTarget_clone(uint32_t orig) {
21680         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
21681         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_clone(orig_conv));
21682         return ret_conv;
21683 }
21684
21685 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_background"))) TS_ConfirmationTarget_background() {
21686         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_background());
21687         return ret_conv;
21688 }
21689
21690 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_normal"))) TS_ConfirmationTarget_normal() {
21691         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_normal());
21692         return ret_conv;
21693 }
21694
21695 uint32_t  __attribute__((export_name("TS_ConfirmationTarget_high_priority"))) TS_ConfirmationTarget_high_priority() {
21696         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_high_priority());
21697         return ret_conv;
21698 }
21699
21700 jboolean  __attribute__((export_name("TS_ConfirmationTarget_eq"))) TS_ConfirmationTarget_eq(uint32_t a, uint32_t b) {
21701         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1);
21702         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1);
21703         jboolean ret_conv = ConfirmationTarget_eq(a_conv, b_conv);
21704         return ret_conv;
21705 }
21706
21707 void  __attribute__((export_name("TS_FeeEstimator_free"))) TS_FeeEstimator_free(uint32_t this_ptr) {
21708         if ((this_ptr & 1) != 0) return;
21709         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21710         CHECK_ACCESS(this_ptr_ptr);
21711         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
21712         FREE((void*)this_ptr);
21713         FeeEstimator_free(this_ptr_conv);
21714 }
21715
21716 void  __attribute__((export_name("TS_MonitorUpdateId_free"))) TS_MonitorUpdateId_free(uint32_t this_obj) {
21717         LDKMonitorUpdateId this_obj_conv;
21718         this_obj_conv.inner = (void*)(this_obj & (~1));
21719         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21721         MonitorUpdateId_free(this_obj_conv);
21722 }
21723
21724 static inline uintptr_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
21725         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
21726 uint32_t ret_ref = 0;
21727 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21728 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21729 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21730 ret_ref = (uintptr_t)ret_var.inner;
21731 if (ret_var.is_owned) {
21732         ret_ref |= 1;
21733 }
21734         return ret_ref;
21735 }
21736 uint32_t  __attribute__((export_name("TS_MonitorUpdateId_clone_ptr"))) TS_MonitorUpdateId_clone_ptr(uint32_t arg) {
21737         LDKMonitorUpdateId arg_conv;
21738         arg_conv.inner = (void*)(arg & (~1));
21739         arg_conv.is_owned = false;
21740         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21741         uint32_t ret_conv = MonitorUpdateId_clone_ptr(&arg_conv);
21742         return ret_conv;
21743 }
21744
21745 uint32_t  __attribute__((export_name("TS_MonitorUpdateId_clone"))) TS_MonitorUpdateId_clone(uint32_t orig) {
21746         LDKMonitorUpdateId orig_conv;
21747         orig_conv.inner = (void*)(orig & (~1));
21748         orig_conv.is_owned = false;
21749         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21750         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
21751         uint32_t ret_ref = 0;
21752         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21753         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21754         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21755         ret_ref = (uintptr_t)ret_var.inner;
21756         if (ret_var.is_owned) {
21757                 ret_ref |= 1;
21758         }
21759         return ret_ref;
21760 }
21761
21762 int64_t  __attribute__((export_name("TS_MonitorUpdateId_hash"))) TS_MonitorUpdateId_hash(uint32_t o) {
21763         LDKMonitorUpdateId o_conv;
21764         o_conv.inner = (void*)(o & (~1));
21765         o_conv.is_owned = false;
21766         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21767         int64_t ret_conv = MonitorUpdateId_hash(&o_conv);
21768         return ret_conv;
21769 }
21770
21771 jboolean  __attribute__((export_name("TS_MonitorUpdateId_eq"))) TS_MonitorUpdateId_eq(uint32_t a, uint32_t b) {
21772         LDKMonitorUpdateId a_conv;
21773         a_conv.inner = (void*)(a & (~1));
21774         a_conv.is_owned = false;
21775         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
21776         LDKMonitorUpdateId b_conv;
21777         b_conv.inner = (void*)(b & (~1));
21778         b_conv.is_owned = false;
21779         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
21780         jboolean ret_conv = MonitorUpdateId_eq(&a_conv, &b_conv);
21781         return ret_conv;
21782 }
21783
21784 void  __attribute__((export_name("TS_Persist_free"))) TS_Persist_free(uint32_t this_ptr) {
21785         if ((this_ptr & 1) != 0) return;
21786         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
21787         CHECK_ACCESS(this_ptr_ptr);
21788         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
21789         FREE((void*)this_ptr);
21790         Persist_free(this_ptr_conv);
21791 }
21792
21793 void  __attribute__((export_name("TS_LockedChannelMonitor_free"))) TS_LockedChannelMonitor_free(uint32_t this_obj) {
21794         LDKLockedChannelMonitor this_obj_conv;
21795         this_obj_conv.inner = (void*)(this_obj & (~1));
21796         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21798         LockedChannelMonitor_free(this_obj_conv);
21799 }
21800
21801 void  __attribute__((export_name("TS_ChainMonitor_free"))) TS_ChainMonitor_free(uint32_t this_obj) {
21802         LDKChainMonitor this_obj_conv;
21803         this_obj_conv.inner = (void*)(this_obj & (~1));
21804         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21806         ChainMonitor_free(this_obj_conv);
21807 }
21808
21809 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) {
21810         void* chain_source_ptr = (void*)(((uintptr_t)chain_source) & ~1);
21811         CHECK_ACCESS(chain_source_ptr);
21812         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
21813         // WARNING: we may need a move here but no clone is available for LDKCOption_FilterZ
21814         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
21815                 // Manually implement clone for Java trait instances
21816                 if (chain_source_conv.some.free == LDKFilter_JCalls_free) {
21817                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21818                         LDKFilter_JCalls_cloned(&chain_source_conv.some);
21819                 }
21820         }
21821         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
21822         CHECK_ACCESS(broadcaster_ptr);
21823         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
21824         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
21825                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21826                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
21827         }
21828         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
21829         CHECK_ACCESS(logger_ptr);
21830         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
21831         if (logger_conv.free == LDKLogger_JCalls_free) {
21832                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21833                 LDKLogger_JCalls_cloned(&logger_conv);
21834         }
21835         void* feeest_ptr = (void*)(((uintptr_t)feeest) & ~1);
21836         CHECK_ACCESS(feeest_ptr);
21837         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
21838         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
21839                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21840                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
21841         }
21842         void* persister_ptr = (void*)(((uintptr_t)persister) & ~1);
21843         CHECK_ACCESS(persister_ptr);
21844         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
21845         if (persister_conv.free == LDKPersist_JCalls_free) {
21846                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21847                 LDKPersist_JCalls_cloned(&persister_conv);
21848         }
21849         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
21850         uint32_t ret_ref = 0;
21851         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21852         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21853         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21854         ret_ref = (uintptr_t)ret_var.inner;
21855         if (ret_var.is_owned) {
21856                 ret_ref |= 1;
21857         }
21858         return ret_ref;
21859 }
21860
21861 uint32_tArray  __attribute__((export_name("TS_ChainMonitor_get_claimable_balances"))) TS_ChainMonitor_get_claimable_balances(uint32_t this_arg, uint32_tArray ignored_channels) {
21862         LDKChainMonitor this_arg_conv;
21863         this_arg_conv.inner = (void*)(this_arg & (~1));
21864         this_arg_conv.is_owned = false;
21865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21866         LDKCVec_ChannelDetailsZ ignored_channels_constr;
21867         ignored_channels_constr.datalen = ignored_channels->arr_len;
21868         if (ignored_channels_constr.datalen > 0)
21869                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
21870         else
21871                 ignored_channels_constr.data = NULL;
21872         uint32_t* ignored_channels_vals = ignored_channels->elems /* XXX ignored_channels leaks */;
21873         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
21874                 uint32_t ignored_channels_conv_16 = ignored_channels_vals[q];
21875                 LDKChannelDetails ignored_channels_conv_16_conv;
21876                 ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1));
21877                 ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0);
21878                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
21879                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
21880                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
21881         }
21882         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
21883         uint32_tArray ret_arr = NULL;
21884         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
21885         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
21886         for (size_t j = 0; j < ret_var.datalen; j++) {
21887                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
21888                 *ret_conv_9_copy = ret_var.data[j];
21889                 uint32_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
21890                 ret_arr_ptr[j] = ret_conv_9_ref;
21891         }
21892         
21893         FREE(ret_var.data);
21894         return ret_arr;
21895 }
21896
21897 uint32_t  __attribute__((export_name("TS_ChainMonitor_get_monitor"))) TS_ChainMonitor_get_monitor(uint32_t this_arg, uint32_t funding_txo) {
21898         LDKChainMonitor this_arg_conv;
21899         this_arg_conv.inner = (void*)(this_arg & (~1));
21900         this_arg_conv.is_owned = false;
21901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21902         LDKOutPoint funding_txo_conv;
21903         funding_txo_conv.inner = (void*)(funding_txo & (~1));
21904         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
21905         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
21906         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
21907         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
21908         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
21909         return (uint32_t)ret_conv;
21910 }
21911
21912 uint32_tArray  __attribute__((export_name("TS_ChainMonitor_list_monitors"))) TS_ChainMonitor_list_monitors(uint32_t this_arg) {
21913         LDKChainMonitor this_arg_conv;
21914         this_arg_conv.inner = (void*)(this_arg & (~1));
21915         this_arg_conv.is_owned = false;
21916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21917         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
21918         uint32_tArray ret_arr = NULL;
21919         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
21920         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
21921         for (size_t k = 0; k < ret_var.datalen; k++) {
21922                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
21923                 uint32_t ret_conv_10_ref = 0;
21924                 CHECK((((uintptr_t)ret_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21925                 CHECK((((uintptr_t)&ret_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21926                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
21927                 ret_conv_10_ref = (uintptr_t)ret_conv_10_var.inner;
21928                 if (ret_conv_10_var.is_owned) {
21929                         ret_conv_10_ref |= 1;
21930                 }
21931                 ret_arr_ptr[k] = ret_conv_10_ref;
21932         }
21933         
21934         FREE(ret_var.data);
21935         return ret_arr;
21936 }
21937
21938 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) {
21939         LDKChainMonitor this_arg_conv;
21940         this_arg_conv.inner = (void*)(this_arg & (~1));
21941         this_arg_conv.is_owned = false;
21942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21943         LDKOutPoint funding_txo_conv;
21944         funding_txo_conv.inner = (void*)(funding_txo & (~1));
21945         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
21946         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
21947         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
21948         LDKMonitorUpdateId completed_update_id_conv;
21949         completed_update_id_conv.inner = (void*)(completed_update_id & (~1));
21950         completed_update_id_conv.is_owned = (completed_update_id & 1) || (completed_update_id == 0);
21951         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
21952         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
21953         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
21954         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
21955         return (uint32_t)ret_conv;
21956 }
21957
21958 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Listen"))) TS_ChainMonitor_as_Listen(uint32_t this_arg) {
21959         LDKChainMonitor this_arg_conv;
21960         this_arg_conv.inner = (void*)(this_arg & (~1));
21961         this_arg_conv.is_owned = false;
21962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21963         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
21964         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
21965         return (uint32_t)ret_ret;
21966 }
21967
21968 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Confirm"))) TS_ChainMonitor_as_Confirm(uint32_t this_arg) {
21969         LDKChainMonitor this_arg_conv;
21970         this_arg_conv.inner = (void*)(this_arg & (~1));
21971         this_arg_conv.is_owned = false;
21972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21973         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
21974         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
21975         return (uint32_t)ret_ret;
21976 }
21977
21978 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_Watch"))) TS_ChainMonitor_as_Watch(uint32_t this_arg) {
21979         LDKChainMonitor this_arg_conv;
21980         this_arg_conv.inner = (void*)(this_arg & (~1));
21981         this_arg_conv.is_owned = false;
21982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21983         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
21984         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
21985         return (uint32_t)ret_ret;
21986 }
21987
21988 uint32_t  __attribute__((export_name("TS_ChainMonitor_as_EventsProvider"))) TS_ChainMonitor_as_EventsProvider(uint32_t this_arg) {
21989         LDKChainMonitor this_arg_conv;
21990         this_arg_conv.inner = (void*)(this_arg & (~1));
21991         this_arg_conv.is_owned = false;
21992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21993         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
21994         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
21995         return (uint32_t)ret_ret;
21996 }
21997
21998 void  __attribute__((export_name("TS_ChannelMonitorUpdate_free"))) TS_ChannelMonitorUpdate_free(uint32_t this_obj) {
21999         LDKChannelMonitorUpdate this_obj_conv;
22000         this_obj_conv.inner = (void*)(this_obj & (~1));
22001         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22003         ChannelMonitorUpdate_free(this_obj_conv);
22004 }
22005
22006 int64_t  __attribute__((export_name("TS_ChannelMonitorUpdate_get_update_id"))) TS_ChannelMonitorUpdate_get_update_id(uint32_t this_ptr) {
22007         LDKChannelMonitorUpdate this_ptr_conv;
22008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22009         this_ptr_conv.is_owned = false;
22010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22011         int64_t ret_conv = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
22012         return ret_conv;
22013 }
22014
22015 void  __attribute__((export_name("TS_ChannelMonitorUpdate_set_update_id"))) TS_ChannelMonitorUpdate_set_update_id(uint32_t this_ptr, int64_t val) {
22016         LDKChannelMonitorUpdate this_ptr_conv;
22017         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22018         this_ptr_conv.is_owned = false;
22019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22020         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
22021 }
22022
22023 static inline uintptr_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
22024         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
22025 uint32_t ret_ref = 0;
22026 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22027 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22028 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22029 ret_ref = (uintptr_t)ret_var.inner;
22030 if (ret_var.is_owned) {
22031         ret_ref |= 1;
22032 }
22033         return ret_ref;
22034 }
22035 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdate_clone_ptr"))) TS_ChannelMonitorUpdate_clone_ptr(uint32_t arg) {
22036         LDKChannelMonitorUpdate arg_conv;
22037         arg_conv.inner = (void*)(arg & (~1));
22038         arg_conv.is_owned = false;
22039         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22040         uint32_t ret_conv = ChannelMonitorUpdate_clone_ptr(&arg_conv);
22041         return ret_conv;
22042 }
22043
22044 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdate_clone"))) TS_ChannelMonitorUpdate_clone(uint32_t orig) {
22045         LDKChannelMonitorUpdate orig_conv;
22046         orig_conv.inner = (void*)(orig & (~1));
22047         orig_conv.is_owned = false;
22048         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22049         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
22050         uint32_t ret_ref = 0;
22051         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22052         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22053         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22054         ret_ref = (uintptr_t)ret_var.inner;
22055         if (ret_var.is_owned) {
22056                 ret_ref |= 1;
22057         }
22058         return ret_ref;
22059 }
22060
22061 int8_tArray  __attribute__((export_name("TS_ChannelMonitorUpdate_write"))) TS_ChannelMonitorUpdate_write(uint32_t obj) {
22062         LDKChannelMonitorUpdate obj_conv;
22063         obj_conv.inner = (void*)(obj & (~1));
22064         obj_conv.is_owned = false;
22065         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22066         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
22067         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22068         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22069         CVec_u8Z_free(ret_var);
22070         return ret_arr;
22071 }
22072
22073 uint32_t  __attribute__((export_name("TS_ChannelMonitorUpdate_read"))) TS_ChannelMonitorUpdate_read(int8_tArray ser) {
22074         LDKu8slice ser_ref;
22075         ser_ref.datalen = ser->arr_len;
22076         ser_ref.data = ser->elems /* XXX ser leaks */;
22077         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
22078         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
22079         return (uint32_t)ret_conv;
22080 }
22081
22082 void  __attribute__((export_name("TS_MonitorEvent_free"))) TS_MonitorEvent_free(uint32_t this_ptr) {
22083         if ((this_ptr & 1) != 0) return;
22084         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22085         CHECK_ACCESS(this_ptr_ptr);
22086         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
22087         FREE((void*)this_ptr);
22088         MonitorEvent_free(this_ptr_conv);
22089 }
22090
22091 static inline uintptr_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
22092         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22093         *ret_copy = MonitorEvent_clone(arg);
22094 uint32_t ret_ref = (uintptr_t)ret_copy;
22095         return ret_ref;
22096 }
22097 uint32_t  __attribute__((export_name("TS_MonitorEvent_clone_ptr"))) TS_MonitorEvent_clone_ptr(uint32_t arg) {
22098         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)arg;
22099         uint32_t ret_conv = MonitorEvent_clone_ptr(arg_conv);
22100         return ret_conv;
22101 }
22102
22103 uint32_t  __attribute__((export_name("TS_MonitorEvent_clone"))) TS_MonitorEvent_clone(uint32_t orig) {
22104         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
22105         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22106         *ret_copy = MonitorEvent_clone(orig_conv);
22107         uint32_t ret_ref = (uintptr_t)ret_copy;
22108         return ret_ref;
22109 }
22110
22111 uint32_t  __attribute__((export_name("TS_MonitorEvent_htlcevent"))) TS_MonitorEvent_htlcevent(uint32_t a) {
22112         LDKHTLCUpdate a_conv;
22113         a_conv.inner = (void*)(a & (~1));
22114         a_conv.is_owned = (a & 1) || (a == 0);
22115         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
22116         a_conv = HTLCUpdate_clone(&a_conv);
22117         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22118         *ret_copy = MonitorEvent_htlcevent(a_conv);
22119         uint32_t ret_ref = (uintptr_t)ret_copy;
22120         return ret_ref;
22121 }
22122
22123 uint32_t  __attribute__((export_name("TS_MonitorEvent_commitment_tx_confirmed"))) TS_MonitorEvent_commitment_tx_confirmed(uint32_t a) {
22124         LDKOutPoint a_conv;
22125         a_conv.inner = (void*)(a & (~1));
22126         a_conv.is_owned = (a & 1) || (a == 0);
22127         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
22128         a_conv = OutPoint_clone(&a_conv);
22129         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22130         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
22131         uint32_t ret_ref = (uintptr_t)ret_copy;
22132         return ret_ref;
22133 }
22134
22135 uint32_t  __attribute__((export_name("TS_MonitorEvent_update_completed"))) TS_MonitorEvent_update_completed(uint32_t funding_txo, int64_t monitor_update_id) {
22136         LDKOutPoint funding_txo_conv;
22137         funding_txo_conv.inner = (void*)(funding_txo & (~1));
22138         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
22139         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
22140         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
22141         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22142         *ret_copy = MonitorEvent_update_completed(funding_txo_conv, monitor_update_id);
22143         uint32_t ret_ref = (uintptr_t)ret_copy;
22144         return ret_ref;
22145 }
22146
22147 uint32_t  __attribute__((export_name("TS_MonitorEvent_update_failed"))) TS_MonitorEvent_update_failed(uint32_t a) {
22148         LDKOutPoint a_conv;
22149         a_conv.inner = (void*)(a & (~1));
22150         a_conv.is_owned = (a & 1) || (a == 0);
22151         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
22152         a_conv = OutPoint_clone(&a_conv);
22153         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22154         *ret_copy = MonitorEvent_update_failed(a_conv);
22155         uint32_t ret_ref = (uintptr_t)ret_copy;
22156         return ret_ref;
22157 }
22158
22159 int8_tArray  __attribute__((export_name("TS_MonitorEvent_write"))) TS_MonitorEvent_write(uint32_t obj) {
22160         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)obj;
22161         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
22162         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22163         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22164         CVec_u8Z_free(ret_var);
22165         return ret_arr;
22166 }
22167
22168 uint32_t  __attribute__((export_name("TS_MonitorEvent_read"))) TS_MonitorEvent_read(int8_tArray ser) {
22169         LDKu8slice ser_ref;
22170         ser_ref.datalen = ser->arr_len;
22171         ser_ref.data = ser->elems /* XXX ser leaks */;
22172         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
22173         *ret_conv = MonitorEvent_read(ser_ref);
22174         return (uint32_t)ret_conv;
22175 }
22176
22177 void  __attribute__((export_name("TS_HTLCUpdate_free"))) TS_HTLCUpdate_free(uint32_t this_obj) {
22178         LDKHTLCUpdate this_obj_conv;
22179         this_obj_conv.inner = (void*)(this_obj & (~1));
22180         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22182         HTLCUpdate_free(this_obj_conv);
22183 }
22184
22185 static inline uintptr_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
22186         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
22187 uint32_t ret_ref = 0;
22188 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22189 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22190 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22191 ret_ref = (uintptr_t)ret_var.inner;
22192 if (ret_var.is_owned) {
22193         ret_ref |= 1;
22194 }
22195         return ret_ref;
22196 }
22197 uint32_t  __attribute__((export_name("TS_HTLCUpdate_clone_ptr"))) TS_HTLCUpdate_clone_ptr(uint32_t arg) {
22198         LDKHTLCUpdate arg_conv;
22199         arg_conv.inner = (void*)(arg & (~1));
22200         arg_conv.is_owned = false;
22201         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22202         uint32_t ret_conv = HTLCUpdate_clone_ptr(&arg_conv);
22203         return ret_conv;
22204 }
22205
22206 uint32_t  __attribute__((export_name("TS_HTLCUpdate_clone"))) TS_HTLCUpdate_clone(uint32_t orig) {
22207         LDKHTLCUpdate orig_conv;
22208         orig_conv.inner = (void*)(orig & (~1));
22209         orig_conv.is_owned = false;
22210         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22211         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
22212         uint32_t ret_ref = 0;
22213         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22214         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22215         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22216         ret_ref = (uintptr_t)ret_var.inner;
22217         if (ret_var.is_owned) {
22218                 ret_ref |= 1;
22219         }
22220         return ret_ref;
22221 }
22222
22223 int8_tArray  __attribute__((export_name("TS_HTLCUpdate_write"))) TS_HTLCUpdate_write(uint32_t obj) {
22224         LDKHTLCUpdate obj_conv;
22225         obj_conv.inner = (void*)(obj & (~1));
22226         obj_conv.is_owned = false;
22227         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22228         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
22229         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22230         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22231         CVec_u8Z_free(ret_var);
22232         return ret_arr;
22233 }
22234
22235 uint32_t  __attribute__((export_name("TS_HTLCUpdate_read"))) TS_HTLCUpdate_read(int8_tArray ser) {
22236         LDKu8slice ser_ref;
22237         ser_ref.datalen = ser->arr_len;
22238         ser_ref.data = ser->elems /* XXX ser leaks */;
22239         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
22240         *ret_conv = HTLCUpdate_read(ser_ref);
22241         return (uint32_t)ret_conv;
22242 }
22243
22244 void  __attribute__((export_name("TS_Balance_free"))) TS_Balance_free(uint32_t this_ptr) {
22245         if ((this_ptr & 1) != 0) return;
22246         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
22247         CHECK_ACCESS(this_ptr_ptr);
22248         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
22249         FREE((void*)this_ptr);
22250         Balance_free(this_ptr_conv);
22251 }
22252
22253 static inline uintptr_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
22254         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22255         *ret_copy = Balance_clone(arg);
22256 uint32_t ret_ref = (uintptr_t)ret_copy;
22257         return ret_ref;
22258 }
22259 uint32_t  __attribute__((export_name("TS_Balance_clone_ptr"))) TS_Balance_clone_ptr(uint32_t arg) {
22260         LDKBalance* arg_conv = (LDKBalance*)arg;
22261         uint32_t ret_conv = Balance_clone_ptr(arg_conv);
22262         return ret_conv;
22263 }
22264
22265 uint32_t  __attribute__((export_name("TS_Balance_clone"))) TS_Balance_clone(uint32_t orig) {
22266         LDKBalance* orig_conv = (LDKBalance*)orig;
22267         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22268         *ret_copy = Balance_clone(orig_conv);
22269         uint32_t ret_ref = (uintptr_t)ret_copy;
22270         return ret_ref;
22271 }
22272
22273 uint32_t  __attribute__((export_name("TS_Balance_claimable_on_channel_close"))) TS_Balance_claimable_on_channel_close(int64_t claimable_amount_satoshis) {
22274         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22275         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
22276         uint32_t ret_ref = (uintptr_t)ret_copy;
22277         return ret_ref;
22278 }
22279
22280 uint32_t  __attribute__((export_name("TS_Balance_claimable_awaiting_confirmations"))) TS_Balance_claimable_awaiting_confirmations(int64_t claimable_amount_satoshis, int32_t confirmation_height) {
22281         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22282         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
22283         uint32_t ret_ref = (uintptr_t)ret_copy;
22284         return ret_ref;
22285 }
22286
22287 uint32_t  __attribute__((export_name("TS_Balance_contentious_claimable"))) TS_Balance_contentious_claimable(int64_t claimable_amount_satoshis, int32_t timeout_height) {
22288         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22289         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
22290         uint32_t ret_ref = (uintptr_t)ret_copy;
22291         return ret_ref;
22292 }
22293
22294 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) {
22295         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22296         *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
22297         uint32_t ret_ref = (uintptr_t)ret_copy;
22298         return ret_ref;
22299 }
22300
22301 jboolean  __attribute__((export_name("TS_Balance_eq"))) TS_Balance_eq(uint32_t a, uint32_t b) {
22302         LDKBalance* a_conv = (LDKBalance*)a;
22303         LDKBalance* b_conv = (LDKBalance*)b;
22304         jboolean ret_conv = Balance_eq(a_conv, b_conv);
22305         return ret_conv;
22306 }
22307
22308 void  __attribute__((export_name("TS_ChannelMonitor_free"))) TS_ChannelMonitor_free(uint32_t this_obj) {
22309         LDKChannelMonitor this_obj_conv;
22310         this_obj_conv.inner = (void*)(this_obj & (~1));
22311         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22313         ChannelMonitor_free(this_obj_conv);
22314 }
22315
22316 static inline uintptr_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
22317         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
22318 uint32_t ret_ref = 0;
22319 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22320 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22321 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22322 ret_ref = (uintptr_t)ret_var.inner;
22323 if (ret_var.is_owned) {
22324         ret_ref |= 1;
22325 }
22326         return ret_ref;
22327 }
22328 uint32_t  __attribute__((export_name("TS_ChannelMonitor_clone_ptr"))) TS_ChannelMonitor_clone_ptr(uint32_t arg) {
22329         LDKChannelMonitor arg_conv;
22330         arg_conv.inner = (void*)(arg & (~1));
22331         arg_conv.is_owned = false;
22332         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22333         uint32_t ret_conv = ChannelMonitor_clone_ptr(&arg_conv);
22334         return ret_conv;
22335 }
22336
22337 uint32_t  __attribute__((export_name("TS_ChannelMonitor_clone"))) TS_ChannelMonitor_clone(uint32_t orig) {
22338         LDKChannelMonitor orig_conv;
22339         orig_conv.inner = (void*)(orig & (~1));
22340         orig_conv.is_owned = false;
22341         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22342         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
22343         uint32_t ret_ref = 0;
22344         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22345         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22346         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22347         ret_ref = (uintptr_t)ret_var.inner;
22348         if (ret_var.is_owned) {
22349                 ret_ref |= 1;
22350         }
22351         return ret_ref;
22352 }
22353
22354 int8_tArray  __attribute__((export_name("TS_ChannelMonitor_write"))) TS_ChannelMonitor_write(uint32_t obj) {
22355         LDKChannelMonitor obj_conv;
22356         obj_conv.inner = (void*)(obj & (~1));
22357         obj_conv.is_owned = false;
22358         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22359         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
22360         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22361         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22362         CVec_u8Z_free(ret_var);
22363         return ret_arr;
22364 }
22365
22366 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) {
22367         LDKChannelMonitor this_arg_conv;
22368         this_arg_conv.inner = (void*)(this_arg & (~1));
22369         this_arg_conv.is_owned = false;
22370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22371         LDKChannelMonitorUpdate updates_conv;
22372         updates_conv.inner = (void*)(updates & (~1));
22373         updates_conv.is_owned = false;
22374         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
22375         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22376         if (!(broadcaster & 1)) { CHECK_ACCESS(broadcaster_ptr); }
22377         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
22378         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22379         if (!(fee_estimator & 1)) { CHECK_ACCESS(fee_estimator_ptr); }
22380         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator_ptr;
22381         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22382         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
22383         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
22384         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
22385         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
22386         return (uint32_t)ret_conv;
22387 }
22388
22389 int64_t  __attribute__((export_name("TS_ChannelMonitor_get_latest_update_id"))) TS_ChannelMonitor_get_latest_update_id(uint32_t this_arg) {
22390         LDKChannelMonitor this_arg_conv;
22391         this_arg_conv.inner = (void*)(this_arg & (~1));
22392         this_arg_conv.is_owned = false;
22393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22394         int64_t ret_conv = ChannelMonitor_get_latest_update_id(&this_arg_conv);
22395         return ret_conv;
22396 }
22397
22398 uint32_t  __attribute__((export_name("TS_ChannelMonitor_get_funding_txo"))) TS_ChannelMonitor_get_funding_txo(uint32_t this_arg) {
22399         LDKChannelMonitor this_arg_conv;
22400         this_arg_conv.inner = (void*)(this_arg & (~1));
22401         this_arg_conv.is_owned = false;
22402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22403         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
22404         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
22405         return ((uint32_t)ret_conv);
22406 }
22407
22408 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_outputs_to_watch"))) TS_ChannelMonitor_get_outputs_to_watch(uint32_t this_arg) {
22409         LDKChannelMonitor this_arg_conv;
22410         this_arg_conv.inner = (void*)(this_arg & (~1));
22411         this_arg_conv.is_owned = false;
22412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22413         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
22414         uint32_tArray ret_arr = NULL;
22415         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22416         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22417         for (size_t o = 0; o < ret_var.datalen; o++) {
22418                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
22419                 *ret_conv_40_conv = ret_var.data[o];
22420                 ret_arr_ptr[o] = ((uint32_t)ret_conv_40_conv);
22421         }
22422         
22423         FREE(ret_var.data);
22424         return ret_arr;
22425 }
22426
22427 void  __attribute__((export_name("TS_ChannelMonitor_load_outputs_to_watch"))) TS_ChannelMonitor_load_outputs_to_watch(uint32_t this_arg, uint32_t filter) {
22428         LDKChannelMonitor this_arg_conv;
22429         this_arg_conv.inner = (void*)(this_arg & (~1));
22430         this_arg_conv.is_owned = false;
22431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22432         void* filter_ptr = (void*)(((uintptr_t)filter) & ~1);
22433         if (!(filter & 1)) { CHECK_ACCESS(filter_ptr); }
22434         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
22435         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
22436 }
22437
22438 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) {
22439         LDKChannelMonitor this_arg_conv;
22440         this_arg_conv.inner = (void*)(this_arg & (~1));
22441         this_arg_conv.is_owned = false;
22442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22443         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
22444         uint32_tArray ret_arr = NULL;
22445         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22446         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22447         for (size_t o = 0; o < ret_var.datalen; o++) {
22448                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22449                 *ret_conv_14_copy = ret_var.data[o];
22450                 uint32_t ret_conv_14_ref = (uintptr_t)ret_conv_14_copy;
22451                 ret_arr_ptr[o] = ret_conv_14_ref;
22452         }
22453         
22454         FREE(ret_var.data);
22455         return ret_arr;
22456 }
22457
22458 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_and_clear_pending_events"))) TS_ChannelMonitor_get_and_clear_pending_events(uint32_t this_arg) {
22459         LDKChannelMonitor this_arg_conv;
22460         this_arg_conv.inner = (void*)(this_arg & (~1));
22461         this_arg_conv.is_owned = false;
22462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22463         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
22464         uint32_tArray ret_arr = NULL;
22465         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22466         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22467         for (size_t h = 0; h < ret_var.datalen; h++) {
22468                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
22469                 *ret_conv_7_copy = ret_var.data[h];
22470                 uint32_t ret_conv_7_ref = (uintptr_t)ret_conv_7_copy;
22471                 ret_arr_ptr[h] = ret_conv_7_ref;
22472         }
22473         
22474         FREE(ret_var.data);
22475         return ret_arr;
22476 }
22477
22478 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) {
22479         LDKChannelMonitor this_arg_conv;
22480         this_arg_conv.inner = (void*)(this_arg & (~1));
22481         this_arg_conv.is_owned = false;
22482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22483         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22484         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
22485         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
22486         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
22487         ptrArray ret_arr = NULL;
22488         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
22489         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
22490         for (size_t m = 0; m < ret_var.datalen; m++) {
22491                 LDKTransaction ret_conv_12_var = ret_var.data[m];
22492                 int8_tArray ret_conv_12_arr = init_int8_tArray(ret_conv_12_var.datalen, __LINE__);
22493                 memcpy(ret_conv_12_arr->elems, ret_conv_12_var.data, ret_conv_12_var.datalen);
22494                 Transaction_free(ret_conv_12_var);
22495                 ret_arr_ptr[m] = ret_conv_12_arr;
22496         }
22497         
22498         FREE(ret_var.data);
22499         return ret_arr;
22500 }
22501
22502 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) {
22503         LDKChannelMonitor this_arg_conv;
22504         this_arg_conv.inner = (void*)(this_arg & (~1));
22505         this_arg_conv.is_owned = false;
22506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22507         unsigned char header_arr[80];
22508         CHECK(header->arr_len == 80);
22509         memcpy(header_arr, header->elems, 80); FREE(header);
22510         unsigned char (*header_ref)[80] = &header_arr;
22511         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
22512         txdata_constr.datalen = txdata->arr_len;
22513         if (txdata_constr.datalen > 0)
22514                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
22515         else
22516                 txdata_constr.data = NULL;
22517         uint32_t* txdata_vals = txdata->elems /* XXX txdata leaks */;
22518         for (size_t c = 0; c < txdata_constr.datalen; c++) {
22519                 uint32_t txdata_conv_28 = txdata_vals[c];
22520                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
22521                 CHECK_ACCESS(txdata_conv_28_ptr);
22522                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
22523                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
22524                 txdata_constr.data[c] = txdata_conv_28_conv;
22525         }
22526         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22527         CHECK_ACCESS(broadcaster_ptr);
22528         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22529         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
22530                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22531                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
22532         }
22533         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22534         CHECK_ACCESS(fee_estimator_ptr);
22535         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22536         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
22537                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22538                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
22539         }
22540         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22541         CHECK_ACCESS(logger_ptr);
22542         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22543         if (logger_conv.free == LDKLogger_JCalls_free) {
22544                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22545                 LDKLogger_JCalls_cloned(&logger_conv);
22546         }
22547         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);
22548         uint32_tArray ret_arr = NULL;
22549         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22550         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22551         for (size_t n = 0; n < ret_var.datalen; n++) {
22552                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22553                 *ret_conv_39_conv = ret_var.data[n];
22554                 ret_arr_ptr[n] = ((uint32_t)ret_conv_39_conv);
22555         }
22556         
22557         FREE(ret_var.data);
22558         return ret_arr;
22559 }
22560
22561 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) {
22562         LDKChannelMonitor this_arg_conv;
22563         this_arg_conv.inner = (void*)(this_arg & (~1));
22564         this_arg_conv.is_owned = false;
22565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22566         unsigned char header_arr[80];
22567         CHECK(header->arr_len == 80);
22568         memcpy(header_arr, header->elems, 80); FREE(header);
22569         unsigned char (*header_ref)[80] = &header_arr;
22570         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22571         CHECK_ACCESS(broadcaster_ptr);
22572         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22573         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
22574                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22575                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
22576         }
22577         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22578         CHECK_ACCESS(fee_estimator_ptr);
22579         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22580         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
22581                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22582                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
22583         }
22584         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22585         CHECK_ACCESS(logger_ptr);
22586         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22587         if (logger_conv.free == LDKLogger_JCalls_free) {
22588                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22589                 LDKLogger_JCalls_cloned(&logger_conv);
22590         }
22591         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
22592 }
22593
22594 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) {
22595         LDKChannelMonitor this_arg_conv;
22596         this_arg_conv.inner = (void*)(this_arg & (~1));
22597         this_arg_conv.is_owned = false;
22598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22599         unsigned char header_arr[80];
22600         CHECK(header->arr_len == 80);
22601         memcpy(header_arr, header->elems, 80); FREE(header);
22602         unsigned char (*header_ref)[80] = &header_arr;
22603         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
22604         txdata_constr.datalen = txdata->arr_len;
22605         if (txdata_constr.datalen > 0)
22606                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
22607         else
22608                 txdata_constr.data = NULL;
22609         uint32_t* txdata_vals = txdata->elems /* XXX txdata leaks */;
22610         for (size_t c = 0; c < txdata_constr.datalen; c++) {
22611                 uint32_t txdata_conv_28 = txdata_vals[c];
22612                 void* txdata_conv_28_ptr = (void*)(((uintptr_t)txdata_conv_28) & ~1);
22613                 CHECK_ACCESS(txdata_conv_28_ptr);
22614                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
22615                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uintptr_t)txdata_conv_28) & ~1));
22616                 txdata_constr.data[c] = txdata_conv_28_conv;
22617         }
22618         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22619         CHECK_ACCESS(broadcaster_ptr);
22620         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22621         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
22622                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22623                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
22624         }
22625         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22626         CHECK_ACCESS(fee_estimator_ptr);
22627         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22628         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
22629                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22630                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
22631         }
22632         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22633         CHECK_ACCESS(logger_ptr);
22634         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22635         if (logger_conv.free == LDKLogger_JCalls_free) {
22636                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22637                 LDKLogger_JCalls_cloned(&logger_conv);
22638         }
22639         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);
22640         uint32_tArray ret_arr = NULL;
22641         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22642         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22643         for (size_t n = 0; n < ret_var.datalen; n++) {
22644                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22645                 *ret_conv_39_conv = ret_var.data[n];
22646                 ret_arr_ptr[n] = ((uint32_t)ret_conv_39_conv);
22647         }
22648         
22649         FREE(ret_var.data);
22650         return ret_arr;
22651 }
22652
22653 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) {
22654         LDKChannelMonitor this_arg_conv;
22655         this_arg_conv.inner = (void*)(this_arg & (~1));
22656         this_arg_conv.is_owned = false;
22657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22658         unsigned char txid_arr[32];
22659         CHECK(txid->arr_len == 32);
22660         memcpy(txid_arr, txid->elems, 32); FREE(txid);
22661         unsigned char (*txid_ref)[32] = &txid_arr;
22662         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22663         CHECK_ACCESS(broadcaster_ptr);
22664         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22665         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
22666                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22667                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
22668         }
22669         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22670         CHECK_ACCESS(fee_estimator_ptr);
22671         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22672         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
22673                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22674                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
22675         }
22676         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22677         CHECK_ACCESS(logger_ptr);
22678         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22679         if (logger_conv.free == LDKLogger_JCalls_free) {
22680                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22681                 LDKLogger_JCalls_cloned(&logger_conv);
22682         }
22683         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
22684 }
22685
22686 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) {
22687         LDKChannelMonitor this_arg_conv;
22688         this_arg_conv.inner = (void*)(this_arg & (~1));
22689         this_arg_conv.is_owned = false;
22690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22691         unsigned char header_arr[80];
22692         CHECK(header->arr_len == 80);
22693         memcpy(header_arr, header->elems, 80); FREE(header);
22694         unsigned char (*header_ref)[80] = &header_arr;
22695         void* broadcaster_ptr = (void*)(((uintptr_t)broadcaster) & ~1);
22696         CHECK_ACCESS(broadcaster_ptr);
22697         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22698         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
22699                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22700                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
22701         }
22702         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
22703         CHECK_ACCESS(fee_estimator_ptr);
22704         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22705         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
22706                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22707                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
22708         }
22709         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
22710         CHECK_ACCESS(logger_ptr);
22711         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22712         if (logger_conv.free == LDKLogger_JCalls_free) {
22713                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22714                 LDKLogger_JCalls_cloned(&logger_conv);
22715         }
22716         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
22717         uint32_tArray ret_arr = NULL;
22718         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22719         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22720         for (size_t n = 0; n < ret_var.datalen; n++) {
22721                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22722                 *ret_conv_39_conv = ret_var.data[n];
22723                 ret_arr_ptr[n] = ((uint32_t)ret_conv_39_conv);
22724         }
22725         
22726         FREE(ret_var.data);
22727         return ret_arr;
22728 }
22729
22730 ptrArray  __attribute__((export_name("TS_ChannelMonitor_get_relevant_txids"))) TS_ChannelMonitor_get_relevant_txids(uint32_t this_arg) {
22731         LDKChannelMonitor this_arg_conv;
22732         this_arg_conv.inner = (void*)(this_arg & (~1));
22733         this_arg_conv.is_owned = false;
22734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22735         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
22736         ptrArray ret_arr = NULL;
22737         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
22738         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
22739         for (size_t m = 0; m < ret_var.datalen; m++) {
22740                 int8_tArray ret_conv_12_arr = init_int8_tArray(32, __LINE__);
22741                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].data, 32);
22742                 ret_arr_ptr[m] = ret_conv_12_arr;
22743         }
22744         
22745         FREE(ret_var.data);
22746         return ret_arr;
22747 }
22748
22749 uint32_t  __attribute__((export_name("TS_ChannelMonitor_current_best_block"))) TS_ChannelMonitor_current_best_block(uint32_t this_arg) {
22750         LDKChannelMonitor this_arg_conv;
22751         this_arg_conv.inner = (void*)(this_arg & (~1));
22752         this_arg_conv.is_owned = false;
22753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22754         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
22755         uint32_t ret_ref = 0;
22756         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22757         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22758         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22759         ret_ref = (uintptr_t)ret_var.inner;
22760         if (ret_var.is_owned) {
22761                 ret_ref |= 1;
22762         }
22763         return ret_ref;
22764 }
22765
22766 uint32_tArray  __attribute__((export_name("TS_ChannelMonitor_get_claimable_balances"))) TS_ChannelMonitor_get_claimable_balances(uint32_t this_arg) {
22767         LDKChannelMonitor this_arg_conv;
22768         this_arg_conv.inner = (void*)(this_arg & (~1));
22769         this_arg_conv.is_owned = false;
22770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22771         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
22772         uint32_tArray ret_arr = NULL;
22773         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
22774         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
22775         for (size_t j = 0; j < ret_var.datalen; j++) {
22776                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22777                 *ret_conv_9_copy = ret_var.data[j];
22778                 uint32_t ret_conv_9_ref = (uintptr_t)ret_conv_9_copy;
22779                 ret_arr_ptr[j] = ret_conv_9_ref;
22780         }
22781         
22782         FREE(ret_var.data);
22783         return ret_arr;
22784 }
22785
22786 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelMonitorZ_read"))) TS_C2Tuple_BlockHashChannelMonitorZ_read(int8_tArray ser, uint32_t arg) {
22787         LDKu8slice ser_ref;
22788         ser_ref.datalen = ser->arr_len;
22789         ser_ref.data = ser->elems /* XXX ser leaks */;
22790         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
22791         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
22792         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
22793         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
22794         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
22795         return (uint32_t)ret_conv;
22796 }
22797
22798 void  __attribute__((export_name("TS_OutPoint_free"))) TS_OutPoint_free(uint32_t this_obj) {
22799         LDKOutPoint this_obj_conv;
22800         this_obj_conv.inner = (void*)(this_obj & (~1));
22801         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22803         OutPoint_free(this_obj_conv);
22804 }
22805
22806 int8_tArray  __attribute__((export_name("TS_OutPoint_get_txid"))) TS_OutPoint_get_txid(uint32_t this_ptr) {
22807         LDKOutPoint this_ptr_conv;
22808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22809         this_ptr_conv.is_owned = false;
22810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22811         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
22812         memcpy(ret_arr->elems, *OutPoint_get_txid(&this_ptr_conv), 32);
22813         return ret_arr;
22814 }
22815
22816 void  __attribute__((export_name("TS_OutPoint_set_txid"))) TS_OutPoint_set_txid(uint32_t this_ptr, int8_tArray val) {
22817         LDKOutPoint this_ptr_conv;
22818         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22819         this_ptr_conv.is_owned = false;
22820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22821         LDKThirtyTwoBytes val_ref;
22822         CHECK(val->arr_len == 32);
22823         memcpy(val_ref.data, val->elems, 32); FREE(val);
22824         OutPoint_set_txid(&this_ptr_conv, val_ref);
22825 }
22826
22827 int16_t  __attribute__((export_name("TS_OutPoint_get_index"))) TS_OutPoint_get_index(uint32_t this_ptr) {
22828         LDKOutPoint this_ptr_conv;
22829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22830         this_ptr_conv.is_owned = false;
22831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22832         int16_t ret_conv = OutPoint_get_index(&this_ptr_conv);
22833         return ret_conv;
22834 }
22835
22836 void  __attribute__((export_name("TS_OutPoint_set_index"))) TS_OutPoint_set_index(uint32_t this_ptr, int16_t val) {
22837         LDKOutPoint this_ptr_conv;
22838         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22839         this_ptr_conv.is_owned = false;
22840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22841         OutPoint_set_index(&this_ptr_conv, val);
22842 }
22843
22844 uint32_t  __attribute__((export_name("TS_OutPoint_new"))) TS_OutPoint_new(int8_tArray txid_arg, int16_t index_arg) {
22845         LDKThirtyTwoBytes txid_arg_ref;
22846         CHECK(txid_arg->arr_len == 32);
22847         memcpy(txid_arg_ref.data, txid_arg->elems, 32); FREE(txid_arg);
22848         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
22849         uint32_t ret_ref = 0;
22850         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22851         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22852         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22853         ret_ref = (uintptr_t)ret_var.inner;
22854         if (ret_var.is_owned) {
22855                 ret_ref |= 1;
22856         }
22857         return ret_ref;
22858 }
22859
22860 static inline uintptr_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
22861         LDKOutPoint ret_var = OutPoint_clone(arg);
22862 uint32_t ret_ref = 0;
22863 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22864 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22865 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22866 ret_ref = (uintptr_t)ret_var.inner;
22867 if (ret_var.is_owned) {
22868         ret_ref |= 1;
22869 }
22870         return ret_ref;
22871 }
22872 uint32_t  __attribute__((export_name("TS_OutPoint_clone_ptr"))) TS_OutPoint_clone_ptr(uint32_t arg) {
22873         LDKOutPoint arg_conv;
22874         arg_conv.inner = (void*)(arg & (~1));
22875         arg_conv.is_owned = false;
22876         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22877         uint32_t ret_conv = OutPoint_clone_ptr(&arg_conv);
22878         return ret_conv;
22879 }
22880
22881 uint32_t  __attribute__((export_name("TS_OutPoint_clone"))) TS_OutPoint_clone(uint32_t orig) {
22882         LDKOutPoint orig_conv;
22883         orig_conv.inner = (void*)(orig & (~1));
22884         orig_conv.is_owned = false;
22885         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22886         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
22887         uint32_t ret_ref = 0;
22888         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22889         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22890         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22891         ret_ref = (uintptr_t)ret_var.inner;
22892         if (ret_var.is_owned) {
22893                 ret_ref |= 1;
22894         }
22895         return ret_ref;
22896 }
22897
22898 jboolean  __attribute__((export_name("TS_OutPoint_eq"))) TS_OutPoint_eq(uint32_t a, uint32_t b) {
22899         LDKOutPoint a_conv;
22900         a_conv.inner = (void*)(a & (~1));
22901         a_conv.is_owned = false;
22902         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
22903         LDKOutPoint b_conv;
22904         b_conv.inner = (void*)(b & (~1));
22905         b_conv.is_owned = false;
22906         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
22907         jboolean ret_conv = OutPoint_eq(&a_conv, &b_conv);
22908         return ret_conv;
22909 }
22910
22911 int64_t  __attribute__((export_name("TS_OutPoint_hash"))) TS_OutPoint_hash(uint32_t o) {
22912         LDKOutPoint o_conv;
22913         o_conv.inner = (void*)(o & (~1));
22914         o_conv.is_owned = false;
22915         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22916         int64_t ret_conv = OutPoint_hash(&o_conv);
22917         return ret_conv;
22918 }
22919
22920 int8_tArray  __attribute__((export_name("TS_OutPoint_to_channel_id"))) TS_OutPoint_to_channel_id(uint32_t this_arg) {
22921         LDKOutPoint this_arg_conv;
22922         this_arg_conv.inner = (void*)(this_arg & (~1));
22923         this_arg_conv.is_owned = false;
22924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22925         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
22926         memcpy(ret_arr->elems, OutPoint_to_channel_id(&this_arg_conv).data, 32);
22927         return ret_arr;
22928 }
22929
22930 int8_tArray  __attribute__((export_name("TS_OutPoint_write"))) TS_OutPoint_write(uint32_t obj) {
22931         LDKOutPoint obj_conv;
22932         obj_conv.inner = (void*)(obj & (~1));
22933         obj_conv.is_owned = false;
22934         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22935         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
22936         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
22937         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
22938         CVec_u8Z_free(ret_var);
22939         return ret_arr;
22940 }
22941
22942 uint32_t  __attribute__((export_name("TS_OutPoint_read"))) TS_OutPoint_read(int8_tArray ser) {
22943         LDKu8slice ser_ref;
22944         ser_ref.datalen = ser->arr_len;
22945         ser_ref.data = ser->elems /* XXX ser leaks */;
22946         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
22947         *ret_conv = OutPoint_read(ser_ref);
22948         return (uint32_t)ret_conv;
22949 }
22950
22951 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_free"))) TS_DelayedPaymentOutputDescriptor_free(uint32_t this_obj) {
22952         LDKDelayedPaymentOutputDescriptor this_obj_conv;
22953         this_obj_conv.inner = (void*)(this_obj & (~1));
22954         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22955         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22956         DelayedPaymentOutputDescriptor_free(this_obj_conv);
22957 }
22958
22959 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_outpoint"))) TS_DelayedPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
22960         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22961         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22962         this_ptr_conv.is_owned = false;
22963         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22964         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
22965         uint32_t ret_ref = 0;
22966         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22967         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22968         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22969         ret_ref = (uintptr_t)ret_var.inner;
22970         if (ret_var.is_owned) {
22971                 ret_ref |= 1;
22972         }
22973         return ret_ref;
22974 }
22975
22976 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_outpoint"))) TS_DelayedPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
22977         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22978         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22979         this_ptr_conv.is_owned = false;
22980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22981         LDKOutPoint val_conv;
22982         val_conv.inner = (void*)(val & (~1));
22983         val_conv.is_owned = (val & 1) || (val == 0);
22984         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
22985         val_conv = OutPoint_clone(&val_conv);
22986         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
22987 }
22988
22989 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_per_commitment_point"))) TS_DelayedPaymentOutputDescriptor_get_per_commitment_point(uint32_t this_ptr) {
22990         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22992         this_ptr_conv.is_owned = false;
22993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22994         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
22995         memcpy(ret_arr->elems, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
22996         return ret_arr;
22997 }
22998
22999 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_per_commitment_point"))) TS_DelayedPaymentOutputDescriptor_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
23000         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23002         this_ptr_conv.is_owned = false;
23003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23004         LDKPublicKey val_ref;
23005         CHECK(val->arr_len == 33);
23006         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
23007         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
23008 }
23009
23010 int16_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_to_self_delay"))) TS_DelayedPaymentOutputDescriptor_get_to_self_delay(uint32_t this_ptr) {
23011         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23013         this_ptr_conv.is_owned = false;
23014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23015         int16_t ret_conv = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
23016         return ret_conv;
23017 }
23018
23019 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_to_self_delay"))) TS_DelayedPaymentOutputDescriptor_set_to_self_delay(uint32_t this_ptr, int16_t val) {
23020         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23021         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23022         this_ptr_conv.is_owned = false;
23023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23024         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
23025 }
23026
23027 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_output"))) TS_DelayedPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
23028         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23029         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23030         this_ptr_conv.is_owned = false;
23031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23032         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
23033         CHECK_ACCESS(val_ptr);
23034         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
23035         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
23036         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
23037 }
23038
23039 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey"))) TS_DelayedPaymentOutputDescriptor_get_revocation_pubkey(uint32_t this_ptr) {
23040         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23041         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23042         this_ptr_conv.is_owned = false;
23043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23044         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
23045         memcpy(ret_arr->elems, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form, 33);
23046         return ret_arr;
23047 }
23048
23049 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey"))) TS_DelayedPaymentOutputDescriptor_set_revocation_pubkey(uint32_t this_ptr, int8_tArray val) {
23050         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23051         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23052         this_ptr_conv.is_owned = false;
23053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23054         LDKPublicKey val_ref;
23055         CHECK(val->arr_len == 33);
23056         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
23057         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
23058 }
23059
23060 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_channel_keys_id"))) TS_DelayedPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
23061         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23062         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23063         this_ptr_conv.is_owned = false;
23064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23065         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23066         memcpy(ret_arr->elems, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
23067         return ret_arr;
23068 }
23069
23070 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_channel_keys_id"))) TS_DelayedPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
23071         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23072         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23073         this_ptr_conv.is_owned = false;
23074         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23075         LDKThirtyTwoBytes val_ref;
23076         CHECK(val->arr_len == 32);
23077         memcpy(val_ref.data, val->elems, 32); FREE(val);
23078         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
23079 }
23080
23081 int64_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis"))) TS_DelayedPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
23082         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23083         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23084         this_ptr_conv.is_owned = false;
23085         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23086         int64_t ret_conv = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
23087         return ret_conv;
23088 }
23089
23090 void  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis"))) TS_DelayedPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
23091         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
23092         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23093         this_ptr_conv.is_owned = false;
23094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23095         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
23096 }
23097
23098 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) {
23099         LDKOutPoint outpoint_arg_conv;
23100         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
23101         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
23102         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
23103         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
23104         LDKPublicKey per_commitment_point_arg_ref;
23105         CHECK(per_commitment_point_arg->arr_len == 33);
23106         memcpy(per_commitment_point_arg_ref.compressed_form, per_commitment_point_arg->elems, 33); FREE(per_commitment_point_arg);
23107         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
23108         CHECK_ACCESS(output_arg_ptr);
23109         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
23110         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
23111         LDKPublicKey revocation_pubkey_arg_ref;
23112         CHECK(revocation_pubkey_arg->arr_len == 33);
23113         memcpy(revocation_pubkey_arg_ref.compressed_form, revocation_pubkey_arg->elems, 33); FREE(revocation_pubkey_arg);
23114         LDKThirtyTwoBytes channel_keys_id_arg_ref;
23115         CHECK(channel_keys_id_arg->arr_len == 32);
23116         memcpy(channel_keys_id_arg_ref.data, channel_keys_id_arg->elems, 32); FREE(channel_keys_id_arg);
23117         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);
23118         uint32_t ret_ref = 0;
23119         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23120         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23121         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23122         ret_ref = (uintptr_t)ret_var.inner;
23123         if (ret_var.is_owned) {
23124                 ret_ref |= 1;
23125         }
23126         return ret_ref;
23127 }
23128
23129 static inline uintptr_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
23130         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
23131 uint32_t ret_ref = 0;
23132 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23133 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23134 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23135 ret_ref = (uintptr_t)ret_var.inner;
23136 if (ret_var.is_owned) {
23137         ret_ref |= 1;
23138 }
23139         return ret_ref;
23140 }
23141 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_clone_ptr"))) TS_DelayedPaymentOutputDescriptor_clone_ptr(uint32_t arg) {
23142         LDKDelayedPaymentOutputDescriptor arg_conv;
23143         arg_conv.inner = (void*)(arg & (~1));
23144         arg_conv.is_owned = false;
23145         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23146         uint32_t ret_conv = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
23147         return ret_conv;
23148 }
23149
23150 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_clone"))) TS_DelayedPaymentOutputDescriptor_clone(uint32_t orig) {
23151         LDKDelayedPaymentOutputDescriptor orig_conv;
23152         orig_conv.inner = (void*)(orig & (~1));
23153         orig_conv.is_owned = false;
23154         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23155         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
23156         uint32_t ret_ref = 0;
23157         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23158         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23159         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23160         ret_ref = (uintptr_t)ret_var.inner;
23161         if (ret_var.is_owned) {
23162                 ret_ref |= 1;
23163         }
23164         return ret_ref;
23165 }
23166
23167 int8_tArray  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_write"))) TS_DelayedPaymentOutputDescriptor_write(uint32_t obj) {
23168         LDKDelayedPaymentOutputDescriptor obj_conv;
23169         obj_conv.inner = (void*)(obj & (~1));
23170         obj_conv.is_owned = false;
23171         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23172         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
23173         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23174         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23175         CVec_u8Z_free(ret_var);
23176         return ret_arr;
23177 }
23178
23179 uint32_t  __attribute__((export_name("TS_DelayedPaymentOutputDescriptor_read"))) TS_DelayedPaymentOutputDescriptor_read(int8_tArray ser) {
23180         LDKu8slice ser_ref;
23181         ser_ref.datalen = ser->arr_len;
23182         ser_ref.data = ser->elems /* XXX ser leaks */;
23183         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
23184         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
23185         return (uint32_t)ret_conv;
23186 }
23187
23188 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_free"))) TS_StaticPaymentOutputDescriptor_free(uint32_t this_obj) {
23189         LDKStaticPaymentOutputDescriptor this_obj_conv;
23190         this_obj_conv.inner = (void*)(this_obj & (~1));
23191         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23193         StaticPaymentOutputDescriptor_free(this_obj_conv);
23194 }
23195
23196 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_outpoint"))) TS_StaticPaymentOutputDescriptor_get_outpoint(uint32_t this_ptr) {
23197         LDKStaticPaymentOutputDescriptor this_ptr_conv;
23198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23199         this_ptr_conv.is_owned = false;
23200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23201         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
23202         uint32_t ret_ref = 0;
23203         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23204         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23205         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23206         ret_ref = (uintptr_t)ret_var.inner;
23207         if (ret_var.is_owned) {
23208                 ret_ref |= 1;
23209         }
23210         return ret_ref;
23211 }
23212
23213 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_outpoint"))) TS_StaticPaymentOutputDescriptor_set_outpoint(uint32_t this_ptr, uint32_t val) {
23214         LDKStaticPaymentOutputDescriptor this_ptr_conv;
23215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23216         this_ptr_conv.is_owned = false;
23217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23218         LDKOutPoint val_conv;
23219         val_conv.inner = (void*)(val & (~1));
23220         val_conv.is_owned = (val & 1) || (val == 0);
23221         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
23222         val_conv = OutPoint_clone(&val_conv);
23223         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
23224 }
23225
23226 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_output"))) TS_StaticPaymentOutputDescriptor_set_output(uint32_t this_ptr, uint32_t val) {
23227         LDKStaticPaymentOutputDescriptor this_ptr_conv;
23228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23229         this_ptr_conv.is_owned = false;
23230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23231         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
23232         CHECK_ACCESS(val_ptr);
23233         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
23234         val_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)val) & ~1));
23235         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
23236 }
23237
23238 int8_tArray  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_channel_keys_id"))) TS_StaticPaymentOutputDescriptor_get_channel_keys_id(uint32_t this_ptr) {
23239         LDKStaticPaymentOutputDescriptor this_ptr_conv;
23240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23241         this_ptr_conv.is_owned = false;
23242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23243         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23244         memcpy(ret_arr->elems, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv), 32);
23245         return ret_arr;
23246 }
23247
23248 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_channel_keys_id"))) TS_StaticPaymentOutputDescriptor_set_channel_keys_id(uint32_t this_ptr, int8_tArray val) {
23249         LDKStaticPaymentOutputDescriptor this_ptr_conv;
23250         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23251         this_ptr_conv.is_owned = false;
23252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23253         LDKThirtyTwoBytes val_ref;
23254         CHECK(val->arr_len == 32);
23255         memcpy(val_ref.data, val->elems, 32); FREE(val);
23256         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
23257 }
23258
23259 int64_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis"))) TS_StaticPaymentOutputDescriptor_get_channel_value_satoshis(uint32_t this_ptr) {
23260         LDKStaticPaymentOutputDescriptor this_ptr_conv;
23261         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23262         this_ptr_conv.is_owned = false;
23263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23264         int64_t ret_conv = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
23265         return ret_conv;
23266 }
23267
23268 void  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis"))) TS_StaticPaymentOutputDescriptor_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
23269         LDKStaticPaymentOutputDescriptor this_ptr_conv;
23270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23271         this_ptr_conv.is_owned = false;
23272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23273         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
23274 }
23275
23276 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) {
23277         LDKOutPoint outpoint_arg_conv;
23278         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
23279         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
23280         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
23281         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
23282         void* output_arg_ptr = (void*)(((uintptr_t)output_arg) & ~1);
23283         CHECK_ACCESS(output_arg_ptr);
23284         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
23285         output_arg_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output_arg) & ~1));
23286         LDKThirtyTwoBytes channel_keys_id_arg_ref;
23287         CHECK(channel_keys_id_arg->arr_len == 32);
23288         memcpy(channel_keys_id_arg_ref.data, channel_keys_id_arg->elems, 32); FREE(channel_keys_id_arg);
23289         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
23290         uint32_t ret_ref = 0;
23291         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23292         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23293         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23294         ret_ref = (uintptr_t)ret_var.inner;
23295         if (ret_var.is_owned) {
23296                 ret_ref |= 1;
23297         }
23298         return ret_ref;
23299 }
23300
23301 static inline uintptr_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
23302         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
23303 uint32_t ret_ref = 0;
23304 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23305 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23306 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23307 ret_ref = (uintptr_t)ret_var.inner;
23308 if (ret_var.is_owned) {
23309         ret_ref |= 1;
23310 }
23311         return ret_ref;
23312 }
23313 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_clone_ptr"))) TS_StaticPaymentOutputDescriptor_clone_ptr(uint32_t arg) {
23314         LDKStaticPaymentOutputDescriptor arg_conv;
23315         arg_conv.inner = (void*)(arg & (~1));
23316         arg_conv.is_owned = false;
23317         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23318         uint32_t ret_conv = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
23319         return ret_conv;
23320 }
23321
23322 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_clone"))) TS_StaticPaymentOutputDescriptor_clone(uint32_t orig) {
23323         LDKStaticPaymentOutputDescriptor orig_conv;
23324         orig_conv.inner = (void*)(orig & (~1));
23325         orig_conv.is_owned = false;
23326         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23327         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
23328         uint32_t ret_ref = 0;
23329         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23330         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23331         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23332         ret_ref = (uintptr_t)ret_var.inner;
23333         if (ret_var.is_owned) {
23334                 ret_ref |= 1;
23335         }
23336         return ret_ref;
23337 }
23338
23339 int8_tArray  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_write"))) TS_StaticPaymentOutputDescriptor_write(uint32_t obj) {
23340         LDKStaticPaymentOutputDescriptor obj_conv;
23341         obj_conv.inner = (void*)(obj & (~1));
23342         obj_conv.is_owned = false;
23343         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23344         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
23345         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23346         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23347         CVec_u8Z_free(ret_var);
23348         return ret_arr;
23349 }
23350
23351 uint32_t  __attribute__((export_name("TS_StaticPaymentOutputDescriptor_read"))) TS_StaticPaymentOutputDescriptor_read(int8_tArray ser) {
23352         LDKu8slice ser_ref;
23353         ser_ref.datalen = ser->arr_len;
23354         ser_ref.data = ser->elems /* XXX ser leaks */;
23355         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
23356         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
23357         return (uint32_t)ret_conv;
23358 }
23359
23360 void  __attribute__((export_name("TS_SpendableOutputDescriptor_free"))) TS_SpendableOutputDescriptor_free(uint32_t this_ptr) {
23361         if ((this_ptr & 1) != 0) return;
23362         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23363         CHECK_ACCESS(this_ptr_ptr);
23364         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
23365         FREE((void*)this_ptr);
23366         SpendableOutputDescriptor_free(this_ptr_conv);
23367 }
23368
23369 static inline uintptr_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
23370         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
23371         *ret_copy = SpendableOutputDescriptor_clone(arg);
23372 uint32_t ret_ref = (uintptr_t)ret_copy;
23373         return ret_ref;
23374 }
23375 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_clone_ptr"))) TS_SpendableOutputDescriptor_clone_ptr(uint32_t arg) {
23376         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)arg;
23377         uint32_t ret_conv = SpendableOutputDescriptor_clone_ptr(arg_conv);
23378         return ret_conv;
23379 }
23380
23381 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_clone"))) TS_SpendableOutputDescriptor_clone(uint32_t orig) {
23382         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
23383         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
23384         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
23385         uint32_t ret_ref = (uintptr_t)ret_copy;
23386         return ret_ref;
23387 }
23388
23389 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_static_output"))) TS_SpendableOutputDescriptor_static_output(uint32_t outpoint, uint32_t output) {
23390         LDKOutPoint outpoint_conv;
23391         outpoint_conv.inner = (void*)(outpoint & (~1));
23392         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
23393         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
23394         outpoint_conv = OutPoint_clone(&outpoint_conv);
23395         void* output_ptr = (void*)(((uintptr_t)output) & ~1);
23396         CHECK_ACCESS(output_ptr);
23397         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
23398         output_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)output) & ~1));
23399         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
23400         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
23401         uint32_t ret_ref = (uintptr_t)ret_copy;
23402         return ret_ref;
23403 }
23404
23405 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_delayed_payment_output"))) TS_SpendableOutputDescriptor_delayed_payment_output(uint32_t a) {
23406         LDKDelayedPaymentOutputDescriptor a_conv;
23407         a_conv.inner = (void*)(a & (~1));
23408         a_conv.is_owned = (a & 1) || (a == 0);
23409         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23410         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
23411         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
23412         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
23413         uint32_t ret_ref = (uintptr_t)ret_copy;
23414         return ret_ref;
23415 }
23416
23417 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_static_payment_output"))) TS_SpendableOutputDescriptor_static_payment_output(uint32_t a) {
23418         LDKStaticPaymentOutputDescriptor a_conv;
23419         a_conv.inner = (void*)(a & (~1));
23420         a_conv.is_owned = (a & 1) || (a == 0);
23421         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23422         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
23423         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
23424         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
23425         uint32_t ret_ref = (uintptr_t)ret_copy;
23426         return ret_ref;
23427 }
23428
23429 int8_tArray  __attribute__((export_name("TS_SpendableOutputDescriptor_write"))) TS_SpendableOutputDescriptor_write(uint32_t obj) {
23430         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
23431         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
23432         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23433         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23434         CVec_u8Z_free(ret_var);
23435         return ret_arr;
23436 }
23437
23438 uint32_t  __attribute__((export_name("TS_SpendableOutputDescriptor_read"))) TS_SpendableOutputDescriptor_read(int8_tArray ser) {
23439         LDKu8slice ser_ref;
23440         ser_ref.datalen = ser->arr_len;
23441         ser_ref.data = ser->elems /* XXX ser leaks */;
23442         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
23443         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
23444         return (uint32_t)ret_conv;
23445 }
23446
23447 void  __attribute__((export_name("TS_BaseSign_free"))) TS_BaseSign_free(uint32_t this_ptr) {
23448         if ((this_ptr & 1) != 0) return;
23449         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23450         CHECK_ACCESS(this_ptr_ptr);
23451         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
23452         FREE((void*)this_ptr);
23453         BaseSign_free(this_ptr_conv);
23454 }
23455
23456 static inline uintptr_t Sign_clone_ptr(LDKSign *NONNULL_PTR arg) {
23457         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
23458         *ret_ret = Sign_clone(arg);
23459         return (uint32_t)ret_ret;
23460 }
23461 uint32_t  __attribute__((export_name("TS_Sign_clone_ptr"))) TS_Sign_clone_ptr(uint32_t arg) {
23462         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
23463         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
23464         LDKSign* arg_conv = (LDKSign*)arg_ptr;
23465         uint32_t ret_conv = Sign_clone_ptr(arg_conv);
23466         return ret_conv;
23467 }
23468
23469 uint32_t  __attribute__((export_name("TS_Sign_clone"))) TS_Sign_clone(uint32_t orig) {
23470         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
23471         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
23472         LDKSign* orig_conv = (LDKSign*)orig_ptr;
23473         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
23474         *ret_ret = Sign_clone(orig_conv);
23475         return (uint32_t)ret_ret;
23476 }
23477
23478 void  __attribute__((export_name("TS_Sign_free"))) TS_Sign_free(uint32_t this_ptr) {
23479         if ((this_ptr & 1) != 0) return;
23480         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23481         CHECK_ACCESS(this_ptr_ptr);
23482         LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
23483         FREE((void*)this_ptr);
23484         Sign_free(this_ptr_conv);
23485 }
23486
23487 uint32_t  __attribute__((export_name("TS_Recipient_clone"))) TS_Recipient_clone(uint32_t orig) {
23488         LDKRecipient* orig_conv = (LDKRecipient*)(orig & ~1);
23489         uint32_t ret_conv = LDKRecipient_to_js(Recipient_clone(orig_conv));
23490         return ret_conv;
23491 }
23492
23493 uint32_t  __attribute__((export_name("TS_Recipient_node"))) TS_Recipient_node() {
23494         uint32_t ret_conv = LDKRecipient_to_js(Recipient_node());
23495         return ret_conv;
23496 }
23497
23498 uint32_t  __attribute__((export_name("TS_Recipient_phantom_node"))) TS_Recipient_phantom_node() {
23499         uint32_t ret_conv = LDKRecipient_to_js(Recipient_phantom_node());
23500         return ret_conv;
23501 }
23502
23503 void  __attribute__((export_name("TS_KeysInterface_free"))) TS_KeysInterface_free(uint32_t this_ptr) {
23504         if ((this_ptr & 1) != 0) return;
23505         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
23506         CHECK_ACCESS(this_ptr_ptr);
23507         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
23508         FREE((void*)this_ptr);
23509         KeysInterface_free(this_ptr_conv);
23510 }
23511
23512 void  __attribute__((export_name("TS_InMemorySigner_free"))) TS_InMemorySigner_free(uint32_t this_obj) {
23513         LDKInMemorySigner this_obj_conv;
23514         this_obj_conv.inner = (void*)(this_obj & (~1));
23515         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23517         InMemorySigner_free(this_obj_conv);
23518 }
23519
23520 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_funding_key"))) TS_InMemorySigner_get_funding_key(uint32_t this_ptr) {
23521         LDKInMemorySigner this_ptr_conv;
23522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23523         this_ptr_conv.is_owned = false;
23524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23525         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23526         memcpy(ret_arr->elems, *InMemorySigner_get_funding_key(&this_ptr_conv), 32);
23527         return ret_arr;
23528 }
23529
23530 void  __attribute__((export_name("TS_InMemorySigner_set_funding_key"))) TS_InMemorySigner_set_funding_key(uint32_t this_ptr, int8_tArray val) {
23531         LDKInMemorySigner this_ptr_conv;
23532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23533         this_ptr_conv.is_owned = false;
23534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23535         LDKSecretKey val_ref;
23536         CHECK(val->arr_len == 32);
23537         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
23538         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
23539 }
23540
23541 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_revocation_base_key"))) TS_InMemorySigner_get_revocation_base_key(uint32_t this_ptr) {
23542         LDKInMemorySigner this_ptr_conv;
23543         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23544         this_ptr_conv.is_owned = false;
23545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23546         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23547         memcpy(ret_arr->elems, *InMemorySigner_get_revocation_base_key(&this_ptr_conv), 32);
23548         return ret_arr;
23549 }
23550
23551 void  __attribute__((export_name("TS_InMemorySigner_set_revocation_base_key"))) TS_InMemorySigner_set_revocation_base_key(uint32_t this_ptr, int8_tArray val) {
23552         LDKInMemorySigner this_ptr_conv;
23553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23554         this_ptr_conv.is_owned = false;
23555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23556         LDKSecretKey val_ref;
23557         CHECK(val->arr_len == 32);
23558         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
23559         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
23560 }
23561
23562 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_payment_key"))) TS_InMemorySigner_get_payment_key(uint32_t this_ptr) {
23563         LDKInMemorySigner this_ptr_conv;
23564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23565         this_ptr_conv.is_owned = false;
23566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23567         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23568         memcpy(ret_arr->elems, *InMemorySigner_get_payment_key(&this_ptr_conv), 32);
23569         return ret_arr;
23570 }
23571
23572 void  __attribute__((export_name("TS_InMemorySigner_set_payment_key"))) TS_InMemorySigner_set_payment_key(uint32_t this_ptr, int8_tArray val) {
23573         LDKInMemorySigner this_ptr_conv;
23574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23575         this_ptr_conv.is_owned = false;
23576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23577         LDKSecretKey val_ref;
23578         CHECK(val->arr_len == 32);
23579         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
23580         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
23581 }
23582
23583 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_delayed_payment_base_key"))) TS_InMemorySigner_get_delayed_payment_base_key(uint32_t this_ptr) {
23584         LDKInMemorySigner this_ptr_conv;
23585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23586         this_ptr_conv.is_owned = false;
23587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23588         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23589         memcpy(ret_arr->elems, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv), 32);
23590         return ret_arr;
23591 }
23592
23593 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) {
23594         LDKInMemorySigner this_ptr_conv;
23595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23596         this_ptr_conv.is_owned = false;
23597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23598         LDKSecretKey val_ref;
23599         CHECK(val->arr_len == 32);
23600         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
23601         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
23602 }
23603
23604 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_htlc_base_key"))) TS_InMemorySigner_get_htlc_base_key(uint32_t this_ptr) {
23605         LDKInMemorySigner this_ptr_conv;
23606         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23607         this_ptr_conv.is_owned = false;
23608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23609         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23610         memcpy(ret_arr->elems, *InMemorySigner_get_htlc_base_key(&this_ptr_conv), 32);
23611         return ret_arr;
23612 }
23613
23614 void  __attribute__((export_name("TS_InMemorySigner_set_htlc_base_key"))) TS_InMemorySigner_set_htlc_base_key(uint32_t this_ptr, int8_tArray val) {
23615         LDKInMemorySigner this_ptr_conv;
23616         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23617         this_ptr_conv.is_owned = false;
23618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23619         LDKSecretKey val_ref;
23620         CHECK(val->arr_len == 32);
23621         memcpy(val_ref.bytes, val->elems, 32); FREE(val);
23622         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
23623 }
23624
23625 int8_tArray  __attribute__((export_name("TS_InMemorySigner_get_commitment_seed"))) TS_InMemorySigner_get_commitment_seed(uint32_t this_ptr) {
23626         LDKInMemorySigner this_ptr_conv;
23627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23628         this_ptr_conv.is_owned = false;
23629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23630         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
23631         memcpy(ret_arr->elems, *InMemorySigner_get_commitment_seed(&this_ptr_conv), 32);
23632         return ret_arr;
23633 }
23634
23635 void  __attribute__((export_name("TS_InMemorySigner_set_commitment_seed"))) TS_InMemorySigner_set_commitment_seed(uint32_t this_ptr, int8_tArray val) {
23636         LDKInMemorySigner this_ptr_conv;
23637         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23638         this_ptr_conv.is_owned = false;
23639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23640         LDKThirtyTwoBytes val_ref;
23641         CHECK(val->arr_len == 32);
23642         memcpy(val_ref.data, val->elems, 32); FREE(val);
23643         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
23644 }
23645
23646 static inline uintptr_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
23647         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
23648 uint32_t ret_ref = 0;
23649 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23650 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23651 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23652 ret_ref = (uintptr_t)ret_var.inner;
23653 if (ret_var.is_owned) {
23654         ret_ref |= 1;
23655 }
23656         return ret_ref;
23657 }
23658 uint32_t  __attribute__((export_name("TS_InMemorySigner_clone_ptr"))) TS_InMemorySigner_clone_ptr(uint32_t arg) {
23659         LDKInMemorySigner arg_conv;
23660         arg_conv.inner = (void*)(arg & (~1));
23661         arg_conv.is_owned = false;
23662         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23663         uint32_t ret_conv = InMemorySigner_clone_ptr(&arg_conv);
23664         return ret_conv;
23665 }
23666
23667 uint32_t  __attribute__((export_name("TS_InMemorySigner_clone"))) TS_InMemorySigner_clone(uint32_t orig) {
23668         LDKInMemorySigner orig_conv;
23669         orig_conv.inner = (void*)(orig & (~1));
23670         orig_conv.is_owned = false;
23671         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23672         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
23673         uint32_t ret_ref = 0;
23674         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23675         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23676         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23677         ret_ref = (uintptr_t)ret_var.inner;
23678         if (ret_var.is_owned) {
23679                 ret_ref |= 1;
23680         }
23681         return ret_ref;
23682 }
23683
23684 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) {
23685         LDKSecretKey node_secret_ref;
23686         CHECK(node_secret->arr_len == 32);
23687         memcpy(node_secret_ref.bytes, node_secret->elems, 32); FREE(node_secret);
23688         LDKSecretKey funding_key_ref;
23689         CHECK(funding_key->arr_len == 32);
23690         memcpy(funding_key_ref.bytes, funding_key->elems, 32); FREE(funding_key);
23691         LDKSecretKey revocation_base_key_ref;
23692         CHECK(revocation_base_key->arr_len == 32);
23693         memcpy(revocation_base_key_ref.bytes, revocation_base_key->elems, 32); FREE(revocation_base_key);
23694         LDKSecretKey payment_key_ref;
23695         CHECK(payment_key->arr_len == 32);
23696         memcpy(payment_key_ref.bytes, payment_key->elems, 32); FREE(payment_key);
23697         LDKSecretKey delayed_payment_base_key_ref;
23698         CHECK(delayed_payment_base_key->arr_len == 32);
23699         memcpy(delayed_payment_base_key_ref.bytes, delayed_payment_base_key->elems, 32); FREE(delayed_payment_base_key);
23700         LDKSecretKey htlc_base_key_ref;
23701         CHECK(htlc_base_key->arr_len == 32);
23702         memcpy(htlc_base_key_ref.bytes, htlc_base_key->elems, 32); FREE(htlc_base_key);
23703         LDKThirtyTwoBytes commitment_seed_ref;
23704         CHECK(commitment_seed->arr_len == 32);
23705         memcpy(commitment_seed_ref.data, commitment_seed->elems, 32); FREE(commitment_seed);
23706         LDKThirtyTwoBytes channel_keys_id_ref;
23707         CHECK(channel_keys_id->arr_len == 32);
23708         memcpy(channel_keys_id_ref.data, channel_keys_id->elems, 32); FREE(channel_keys_id);
23709         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);
23710         uint32_t ret_ref = 0;
23711         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23712         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23713         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23714         ret_ref = (uintptr_t)ret_var.inner;
23715         if (ret_var.is_owned) {
23716                 ret_ref |= 1;
23717         }
23718         return ret_ref;
23719 }
23720
23721 uint32_t  __attribute__((export_name("TS_InMemorySigner_counterparty_pubkeys"))) TS_InMemorySigner_counterparty_pubkeys(uint32_t this_arg) {
23722         LDKInMemorySigner this_arg_conv;
23723         this_arg_conv.inner = (void*)(this_arg & (~1));
23724         this_arg_conv.is_owned = false;
23725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23726         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
23727         uint32_t ret_ref = 0;
23728         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23729         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23730         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23731         ret_ref = (uintptr_t)ret_var.inner;
23732         if (ret_var.is_owned) {
23733                 ret_ref |= 1;
23734         }
23735         return ret_ref;
23736 }
23737
23738 int16_t  __attribute__((export_name("TS_InMemorySigner_counterparty_selected_contest_delay"))) TS_InMemorySigner_counterparty_selected_contest_delay(uint32_t this_arg) {
23739         LDKInMemorySigner this_arg_conv;
23740         this_arg_conv.inner = (void*)(this_arg & (~1));
23741         this_arg_conv.is_owned = false;
23742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23743         int16_t ret_conv = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
23744         return ret_conv;
23745 }
23746
23747 int16_t  __attribute__((export_name("TS_InMemorySigner_holder_selected_contest_delay"))) TS_InMemorySigner_holder_selected_contest_delay(uint32_t this_arg) {
23748         LDKInMemorySigner this_arg_conv;
23749         this_arg_conv.inner = (void*)(this_arg & (~1));
23750         this_arg_conv.is_owned = false;
23751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23752         int16_t ret_conv = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
23753         return ret_conv;
23754 }
23755
23756 jboolean  __attribute__((export_name("TS_InMemorySigner_is_outbound"))) TS_InMemorySigner_is_outbound(uint32_t this_arg) {
23757         LDKInMemorySigner this_arg_conv;
23758         this_arg_conv.inner = (void*)(this_arg & (~1));
23759         this_arg_conv.is_owned = false;
23760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23761         jboolean ret_conv = InMemorySigner_is_outbound(&this_arg_conv);
23762         return ret_conv;
23763 }
23764
23765 uint32_t  __attribute__((export_name("TS_InMemorySigner_funding_outpoint"))) TS_InMemorySigner_funding_outpoint(uint32_t this_arg) {
23766         LDKInMemorySigner this_arg_conv;
23767         this_arg_conv.inner = (void*)(this_arg & (~1));
23768         this_arg_conv.is_owned = false;
23769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23770         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
23771         uint32_t ret_ref = 0;
23772         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23773         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23774         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23775         ret_ref = (uintptr_t)ret_var.inner;
23776         if (ret_var.is_owned) {
23777                 ret_ref |= 1;
23778         }
23779         return ret_ref;
23780 }
23781
23782 uint32_t  __attribute__((export_name("TS_InMemorySigner_get_channel_parameters"))) TS_InMemorySigner_get_channel_parameters(uint32_t this_arg) {
23783         LDKInMemorySigner this_arg_conv;
23784         this_arg_conv.inner = (void*)(this_arg & (~1));
23785         this_arg_conv.is_owned = false;
23786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23787         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
23788         uint32_t ret_ref = 0;
23789         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23790         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23791         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23792         ret_ref = (uintptr_t)ret_var.inner;
23793         if (ret_var.is_owned) {
23794                 ret_ref |= 1;
23795         }
23796         return ret_ref;
23797 }
23798
23799 jboolean  __attribute__((export_name("TS_InMemorySigner_opt_anchors"))) TS_InMemorySigner_opt_anchors(uint32_t this_arg) {
23800         LDKInMemorySigner this_arg_conv;
23801         this_arg_conv.inner = (void*)(this_arg & (~1));
23802         this_arg_conv.is_owned = false;
23803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23804         jboolean ret_conv = InMemorySigner_opt_anchors(&this_arg_conv);
23805         return ret_conv;
23806 }
23807
23808 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) {
23809         LDKInMemorySigner this_arg_conv;
23810         this_arg_conv.inner = (void*)(this_arg & (~1));
23811         this_arg_conv.is_owned = false;
23812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23813         LDKTransaction spend_tx_ref;
23814         spend_tx_ref.datalen = spend_tx->arr_len;
23815         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
23816         memcpy(spend_tx_ref.data, spend_tx->elems, spend_tx_ref.datalen); FREE(spend_tx);
23817         spend_tx_ref.data_is_owned = true;
23818         LDKStaticPaymentOutputDescriptor descriptor_conv;
23819         descriptor_conv.inner = (void*)(descriptor & (~1));
23820         descriptor_conv.is_owned = false;
23821         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
23822         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
23823         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
23824         return (uint32_t)ret_conv;
23825 }
23826
23827 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) {
23828         LDKInMemorySigner this_arg_conv;
23829         this_arg_conv.inner = (void*)(this_arg & (~1));
23830         this_arg_conv.is_owned = false;
23831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23832         LDKTransaction spend_tx_ref;
23833         spend_tx_ref.datalen = spend_tx->arr_len;
23834         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
23835         memcpy(spend_tx_ref.data, spend_tx->elems, spend_tx_ref.datalen); FREE(spend_tx);
23836         spend_tx_ref.data_is_owned = true;
23837         LDKDelayedPaymentOutputDescriptor descriptor_conv;
23838         descriptor_conv.inner = (void*)(descriptor & (~1));
23839         descriptor_conv.is_owned = false;
23840         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
23841         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
23842         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
23843         return (uint32_t)ret_conv;
23844 }
23845
23846 uint32_t  __attribute__((export_name("TS_InMemorySigner_as_BaseSign"))) TS_InMemorySigner_as_BaseSign(uint32_t this_arg) {
23847         LDKInMemorySigner this_arg_conv;
23848         this_arg_conv.inner = (void*)(this_arg & (~1));
23849         this_arg_conv.is_owned = false;
23850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23851         LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
23852         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
23853         return (uint32_t)ret_ret;
23854 }
23855
23856 uint32_t  __attribute__((export_name("TS_InMemorySigner_as_Sign"))) TS_InMemorySigner_as_Sign(uint32_t this_arg) {
23857         LDKInMemorySigner this_arg_conv;
23858         this_arg_conv.inner = (void*)(this_arg & (~1));
23859         this_arg_conv.is_owned = false;
23860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23861         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
23862         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
23863         return (uint32_t)ret_ret;
23864 }
23865
23866 int8_tArray  __attribute__((export_name("TS_InMemorySigner_write"))) TS_InMemorySigner_write(uint32_t obj) {
23867         LDKInMemorySigner obj_conv;
23868         obj_conv.inner = (void*)(obj & (~1));
23869         obj_conv.is_owned = false;
23870         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23871         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
23872         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
23873         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
23874         CVec_u8Z_free(ret_var);
23875         return ret_arr;
23876 }
23877
23878 uint32_t  __attribute__((export_name("TS_InMemorySigner_read"))) TS_InMemorySigner_read(int8_tArray ser, int8_tArray arg) {
23879         LDKu8slice ser_ref;
23880         ser_ref.datalen = ser->arr_len;
23881         ser_ref.data = ser->elems /* XXX ser leaks */;
23882         LDKSecretKey arg_ref;
23883         CHECK(arg->arr_len == 32);
23884         memcpy(arg_ref.bytes, arg->elems, 32); FREE(arg);
23885         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
23886         *ret_conv = InMemorySigner_read(ser_ref, arg_ref);
23887         return (uint32_t)ret_conv;
23888 }
23889
23890 void  __attribute__((export_name("TS_KeysManager_free"))) TS_KeysManager_free(uint32_t this_obj) {
23891         LDKKeysManager this_obj_conv;
23892         this_obj_conv.inner = (void*)(this_obj & (~1));
23893         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23895         KeysManager_free(this_obj_conv);
23896 }
23897
23898 uint32_t  __attribute__((export_name("TS_KeysManager_new"))) TS_KeysManager_new(int8_tArray seed, int64_t starting_time_secs, int32_t starting_time_nanos) {
23899         unsigned char seed_arr[32];
23900         CHECK(seed->arr_len == 32);
23901         memcpy(seed_arr, seed->elems, 32); FREE(seed);
23902         unsigned char (*seed_ref)[32] = &seed_arr;
23903         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
23904         uint32_t ret_ref = 0;
23905         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23906         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23907         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23908         ret_ref = (uintptr_t)ret_var.inner;
23909         if (ret_var.is_owned) {
23910                 ret_ref |= 1;
23911         }
23912         return ret_ref;
23913 }
23914
23915 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) {
23916         LDKKeysManager this_arg_conv;
23917         this_arg_conv.inner = (void*)(this_arg & (~1));
23918         this_arg_conv.is_owned = false;
23919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23920         unsigned char params_arr[32];
23921         CHECK(params->arr_len == 32);
23922         memcpy(params_arr, params->elems, 32); FREE(params);
23923         unsigned char (*params_ref)[32] = &params_arr;
23924         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
23925         uint32_t ret_ref = 0;
23926         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23927         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23928         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23929         ret_ref = (uintptr_t)ret_var.inner;
23930         if (ret_var.is_owned) {
23931                 ret_ref |= 1;
23932         }
23933         return ret_ref;
23934 }
23935
23936 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) {
23937         LDKKeysManager this_arg_conv;
23938         this_arg_conv.inner = (void*)(this_arg & (~1));
23939         this_arg_conv.is_owned = false;
23940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23941         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
23942         descriptors_constr.datalen = descriptors->arr_len;
23943         if (descriptors_constr.datalen > 0)
23944                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
23945         else
23946                 descriptors_constr.data = NULL;
23947         uint32_t* descriptors_vals = descriptors->elems /* XXX descriptors leaks */;
23948         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
23949                 uint32_t descriptors_conv_27 = descriptors_vals[b];
23950                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
23951                 CHECK_ACCESS(descriptors_conv_27_ptr);
23952                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
23953                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
23954                 descriptors_constr.data[b] = descriptors_conv_27_conv;
23955         }
23956         LDKCVec_TxOutZ outputs_constr;
23957         outputs_constr.datalen = outputs->arr_len;
23958         if (outputs_constr.datalen > 0)
23959                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
23960         else
23961                 outputs_constr.data = NULL;
23962         uint32_t* outputs_vals = outputs->elems /* XXX outputs leaks */;
23963         for (size_t h = 0; h < outputs_constr.datalen; h++) {
23964                 uint32_t outputs_conv_7 = outputs_vals[h];
23965                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
23966                 CHECK_ACCESS(outputs_conv_7_ptr);
23967                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
23968                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
23969                 outputs_constr.data[h] = outputs_conv_7_conv;
23970         }
23971         LDKCVec_u8Z change_destination_script_ref;
23972         change_destination_script_ref.datalen = change_destination_script->arr_len;
23973         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
23974         memcpy(change_destination_script_ref.data, change_destination_script->elems, change_destination_script_ref.datalen); FREE(change_destination_script);
23975         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
23976         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
23977         return (uint32_t)ret_conv;
23978 }
23979
23980 uint32_t  __attribute__((export_name("TS_KeysManager_as_KeysInterface"))) TS_KeysManager_as_KeysInterface(uint32_t this_arg) {
23981         LDKKeysManager this_arg_conv;
23982         this_arg_conv.inner = (void*)(this_arg & (~1));
23983         this_arg_conv.is_owned = false;
23984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23985         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
23986         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
23987         return (uint32_t)ret_ret;
23988 }
23989
23990 void  __attribute__((export_name("TS_PhantomKeysManager_free"))) TS_PhantomKeysManager_free(uint32_t this_obj) {
23991         LDKPhantomKeysManager this_obj_conv;
23992         this_obj_conv.inner = (void*)(this_obj & (~1));
23993         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23995         PhantomKeysManager_free(this_obj_conv);
23996 }
23997
23998 uint32_t  __attribute__((export_name("TS_PhantomKeysManager_as_KeysInterface"))) TS_PhantomKeysManager_as_KeysInterface(uint32_t this_arg) {
23999         LDKPhantomKeysManager this_arg_conv;
24000         this_arg_conv.inner = (void*)(this_arg & (~1));
24001         this_arg_conv.is_owned = false;
24002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24003         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
24004         *ret_ret = PhantomKeysManager_as_KeysInterface(&this_arg_conv);
24005         return (uint32_t)ret_ret;
24006 }
24007
24008 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) {
24009         unsigned char seed_arr[32];
24010         CHECK(seed->arr_len == 32);
24011         memcpy(seed_arr, seed->elems, 32); FREE(seed);
24012         unsigned char (*seed_ref)[32] = &seed_arr;
24013         unsigned char cross_node_seed_arr[32];
24014         CHECK(cross_node_seed->arr_len == 32);
24015         memcpy(cross_node_seed_arr, cross_node_seed->elems, 32); FREE(cross_node_seed);
24016         unsigned char (*cross_node_seed_ref)[32] = &cross_node_seed_arr;
24017         LDKPhantomKeysManager ret_var = PhantomKeysManager_new(seed_ref, starting_time_secs, starting_time_nanos, cross_node_seed_ref);
24018         uint32_t ret_ref = 0;
24019         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24020         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24021         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24022         ret_ref = (uintptr_t)ret_var.inner;
24023         if (ret_var.is_owned) {
24024                 ret_ref |= 1;
24025         }
24026         return ret_ref;
24027 }
24028
24029 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) {
24030         LDKPhantomKeysManager this_arg_conv;
24031         this_arg_conv.inner = (void*)(this_arg & (~1));
24032         this_arg_conv.is_owned = false;
24033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24034         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
24035         descriptors_constr.datalen = descriptors->arr_len;
24036         if (descriptors_constr.datalen > 0)
24037                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
24038         else
24039                 descriptors_constr.data = NULL;
24040         uint32_t* descriptors_vals = descriptors->elems /* XXX descriptors leaks */;
24041         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
24042                 uint32_t descriptors_conv_27 = descriptors_vals[b];
24043                 void* descriptors_conv_27_ptr = (void*)(((uintptr_t)descriptors_conv_27) & ~1);
24044                 CHECK_ACCESS(descriptors_conv_27_ptr);
24045                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
24046                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uintptr_t)descriptors_conv_27) & ~1));
24047                 descriptors_constr.data[b] = descriptors_conv_27_conv;
24048         }
24049         LDKCVec_TxOutZ outputs_constr;
24050         outputs_constr.datalen = outputs->arr_len;
24051         if (outputs_constr.datalen > 0)
24052                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
24053         else
24054                 outputs_constr.data = NULL;
24055         uint32_t* outputs_vals = outputs->elems /* XXX outputs leaks */;
24056         for (size_t h = 0; h < outputs_constr.datalen; h++) {
24057                 uint32_t outputs_conv_7 = outputs_vals[h];
24058                 void* outputs_conv_7_ptr = (void*)(((uintptr_t)outputs_conv_7) & ~1);
24059                 CHECK_ACCESS(outputs_conv_7_ptr);
24060                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
24061                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uintptr_t)outputs_conv_7) & ~1));
24062                 outputs_constr.data[h] = outputs_conv_7_conv;
24063         }
24064         LDKCVec_u8Z change_destination_script_ref;
24065         change_destination_script_ref.datalen = change_destination_script->arr_len;
24066         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
24067         memcpy(change_destination_script_ref.data, change_destination_script->elems, change_destination_script_ref.datalen); FREE(change_destination_script);
24068         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
24069         *ret_conv = PhantomKeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
24070         return (uint32_t)ret_conv;
24071 }
24072
24073 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) {
24074         LDKPhantomKeysManager this_arg_conv;
24075         this_arg_conv.inner = (void*)(this_arg & (~1));
24076         this_arg_conv.is_owned = false;
24077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24078         unsigned char params_arr[32];
24079         CHECK(params->arr_len == 32);
24080         memcpy(params_arr, params->elems, 32); FREE(params);
24081         unsigned char (*params_ref)[32] = &params_arr;
24082         LDKInMemorySigner ret_var = PhantomKeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
24083         uint32_t ret_ref = 0;
24084         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24085         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24086         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24087         ret_ref = (uintptr_t)ret_var.inner;
24088         if (ret_var.is_owned) {
24089                 ret_ref |= 1;
24090         }
24091         return ret_ref;
24092 }
24093
24094 void  __attribute__((export_name("TS_ChannelManager_free"))) TS_ChannelManager_free(uint32_t this_obj) {
24095         LDKChannelManager this_obj_conv;
24096         this_obj_conv.inner = (void*)(this_obj & (~1));
24097         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24099         ChannelManager_free(this_obj_conv);
24100 }
24101
24102 void  __attribute__((export_name("TS_ChainParameters_free"))) TS_ChainParameters_free(uint32_t this_obj) {
24103         LDKChainParameters this_obj_conv;
24104         this_obj_conv.inner = (void*)(this_obj & (~1));
24105         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24107         ChainParameters_free(this_obj_conv);
24108 }
24109
24110 uint32_t  __attribute__((export_name("TS_ChainParameters_get_network"))) TS_ChainParameters_get_network(uint32_t this_ptr) {
24111         LDKChainParameters this_ptr_conv;
24112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24113         this_ptr_conv.is_owned = false;
24114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24115         uint32_t ret_conv = LDKNetwork_to_js(ChainParameters_get_network(&this_ptr_conv));
24116         return ret_conv;
24117 }
24118
24119 void  __attribute__((export_name("TS_ChainParameters_set_network"))) TS_ChainParameters_set_network(uint32_t this_ptr, uint32_t val) {
24120         LDKChainParameters this_ptr_conv;
24121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24122         this_ptr_conv.is_owned = false;
24123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24124         LDKNetwork val_conv = LDKNetwork_from_js(val);
24125         ChainParameters_set_network(&this_ptr_conv, val_conv);
24126 }
24127
24128 uint32_t  __attribute__((export_name("TS_ChainParameters_get_best_block"))) TS_ChainParameters_get_best_block(uint32_t this_ptr) {
24129         LDKChainParameters this_ptr_conv;
24130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24131         this_ptr_conv.is_owned = false;
24132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24133         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
24134         uint32_t ret_ref = 0;
24135         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24136         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24137         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24138         ret_ref = (uintptr_t)ret_var.inner;
24139         if (ret_var.is_owned) {
24140                 ret_ref |= 1;
24141         }
24142         return ret_ref;
24143 }
24144
24145 void  __attribute__((export_name("TS_ChainParameters_set_best_block"))) TS_ChainParameters_set_best_block(uint32_t this_ptr, uint32_t val) {
24146         LDKChainParameters this_ptr_conv;
24147         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24148         this_ptr_conv.is_owned = false;
24149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24150         LDKBestBlock val_conv;
24151         val_conv.inner = (void*)(val & (~1));
24152         val_conv.is_owned = (val & 1) || (val == 0);
24153         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24154         val_conv = BestBlock_clone(&val_conv);
24155         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
24156 }
24157
24158 uint32_t  __attribute__((export_name("TS_ChainParameters_new"))) TS_ChainParameters_new(uint32_t network_arg, uint32_t best_block_arg) {
24159         LDKNetwork network_arg_conv = LDKNetwork_from_js(network_arg);
24160         LDKBestBlock best_block_arg_conv;
24161         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
24162         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
24163         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
24164         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
24165         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
24166         uint32_t ret_ref = 0;
24167         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24168         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24169         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24170         ret_ref = (uintptr_t)ret_var.inner;
24171         if (ret_var.is_owned) {
24172                 ret_ref |= 1;
24173         }
24174         return ret_ref;
24175 }
24176
24177 static inline uintptr_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
24178         LDKChainParameters ret_var = ChainParameters_clone(arg);
24179 uint32_t ret_ref = 0;
24180 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24181 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24182 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24183 ret_ref = (uintptr_t)ret_var.inner;
24184 if (ret_var.is_owned) {
24185         ret_ref |= 1;
24186 }
24187         return ret_ref;
24188 }
24189 uint32_t  __attribute__((export_name("TS_ChainParameters_clone_ptr"))) TS_ChainParameters_clone_ptr(uint32_t arg) {
24190         LDKChainParameters arg_conv;
24191         arg_conv.inner = (void*)(arg & (~1));
24192         arg_conv.is_owned = false;
24193         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24194         uint32_t ret_conv = ChainParameters_clone_ptr(&arg_conv);
24195         return ret_conv;
24196 }
24197
24198 uint32_t  __attribute__((export_name("TS_ChainParameters_clone"))) TS_ChainParameters_clone(uint32_t orig) {
24199         LDKChainParameters orig_conv;
24200         orig_conv.inner = (void*)(orig & (~1));
24201         orig_conv.is_owned = false;
24202         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24203         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
24204         uint32_t ret_ref = 0;
24205         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24206         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24207         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24208         ret_ref = (uintptr_t)ret_var.inner;
24209         if (ret_var.is_owned) {
24210                 ret_ref |= 1;
24211         }
24212         return ret_ref;
24213 }
24214
24215 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_free"))) TS_CounterpartyForwardingInfo_free(uint32_t this_obj) {
24216         LDKCounterpartyForwardingInfo this_obj_conv;
24217         this_obj_conv.inner = (void*)(this_obj & (~1));
24218         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24220         CounterpartyForwardingInfo_free(this_obj_conv);
24221 }
24222
24223 int32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_fee_base_msat"))) TS_CounterpartyForwardingInfo_get_fee_base_msat(uint32_t this_ptr) {
24224         LDKCounterpartyForwardingInfo this_ptr_conv;
24225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24226         this_ptr_conv.is_owned = false;
24227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24228         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
24229         return ret_conv;
24230 }
24231
24232 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_fee_base_msat"))) TS_CounterpartyForwardingInfo_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
24233         LDKCounterpartyForwardingInfo this_ptr_conv;
24234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24235         this_ptr_conv.is_owned = false;
24236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24237         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
24238 }
24239
24240 int32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_fee_proportional_millionths"))) TS_CounterpartyForwardingInfo_get_fee_proportional_millionths(uint32_t this_ptr) {
24241         LDKCounterpartyForwardingInfo this_ptr_conv;
24242         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24243         this_ptr_conv.is_owned = false;
24244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24245         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
24246         return ret_conv;
24247 }
24248
24249 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_fee_proportional_millionths"))) TS_CounterpartyForwardingInfo_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
24250         LDKCounterpartyForwardingInfo this_ptr_conv;
24251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24252         this_ptr_conv.is_owned = false;
24253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24254         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
24255 }
24256
24257 int16_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_get_cltv_expiry_delta"))) TS_CounterpartyForwardingInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
24258         LDKCounterpartyForwardingInfo this_ptr_conv;
24259         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24260         this_ptr_conv.is_owned = false;
24261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24262         int16_t ret_conv = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
24263         return ret_conv;
24264 }
24265
24266 void  __attribute__((export_name("TS_CounterpartyForwardingInfo_set_cltv_expiry_delta"))) TS_CounterpartyForwardingInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
24267         LDKCounterpartyForwardingInfo this_ptr_conv;
24268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24269         this_ptr_conv.is_owned = false;
24270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24271         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
24272 }
24273
24274 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) {
24275         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
24276         uint32_t ret_ref = 0;
24277         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24278         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24279         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24280         ret_ref = (uintptr_t)ret_var.inner;
24281         if (ret_var.is_owned) {
24282                 ret_ref |= 1;
24283         }
24284         return ret_ref;
24285 }
24286
24287 static inline uintptr_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
24288         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
24289 uint32_t ret_ref = 0;
24290 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24291 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24292 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24293 ret_ref = (uintptr_t)ret_var.inner;
24294 if (ret_var.is_owned) {
24295         ret_ref |= 1;
24296 }
24297         return ret_ref;
24298 }
24299 uint32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_clone_ptr"))) TS_CounterpartyForwardingInfo_clone_ptr(uint32_t arg) {
24300         LDKCounterpartyForwardingInfo arg_conv;
24301         arg_conv.inner = (void*)(arg & (~1));
24302         arg_conv.is_owned = false;
24303         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24304         uint32_t ret_conv = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
24305         return ret_conv;
24306 }
24307
24308 uint32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_clone"))) TS_CounterpartyForwardingInfo_clone(uint32_t orig) {
24309         LDKCounterpartyForwardingInfo orig_conv;
24310         orig_conv.inner = (void*)(orig & (~1));
24311         orig_conv.is_owned = false;
24312         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24313         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
24314         uint32_t ret_ref = 0;
24315         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24316         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24317         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24318         ret_ref = (uintptr_t)ret_var.inner;
24319         if (ret_var.is_owned) {
24320                 ret_ref |= 1;
24321         }
24322         return ret_ref;
24323 }
24324
24325 void  __attribute__((export_name("TS_ChannelCounterparty_free"))) TS_ChannelCounterparty_free(uint32_t this_obj) {
24326         LDKChannelCounterparty this_obj_conv;
24327         this_obj_conv.inner = (void*)(this_obj & (~1));
24328         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24330         ChannelCounterparty_free(this_obj_conv);
24331 }
24332
24333 int8_tArray  __attribute__((export_name("TS_ChannelCounterparty_get_node_id"))) TS_ChannelCounterparty_get_node_id(uint32_t this_ptr) {
24334         LDKChannelCounterparty this_ptr_conv;
24335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24336         this_ptr_conv.is_owned = false;
24337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24338         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
24339         memcpy(ret_arr->elems, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form, 33);
24340         return ret_arr;
24341 }
24342
24343 void  __attribute__((export_name("TS_ChannelCounterparty_set_node_id"))) TS_ChannelCounterparty_set_node_id(uint32_t this_ptr, int8_tArray val) {
24344         LDKChannelCounterparty this_ptr_conv;
24345         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24346         this_ptr_conv.is_owned = false;
24347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24348         LDKPublicKey val_ref;
24349         CHECK(val->arr_len == 33);
24350         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
24351         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
24352 }
24353
24354 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_get_features"))) TS_ChannelCounterparty_get_features(uint32_t this_ptr) {
24355         LDKChannelCounterparty this_ptr_conv;
24356         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24357         this_ptr_conv.is_owned = false;
24358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24359         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
24360         uint32_t ret_ref = 0;
24361         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24362         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24363         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24364         ret_ref = (uintptr_t)ret_var.inner;
24365         if (ret_var.is_owned) {
24366                 ret_ref |= 1;
24367         }
24368         return ret_ref;
24369 }
24370
24371 void  __attribute__((export_name("TS_ChannelCounterparty_set_features"))) TS_ChannelCounterparty_set_features(uint32_t this_ptr, uint32_t val) {
24372         LDKChannelCounterparty this_ptr_conv;
24373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24374         this_ptr_conv.is_owned = false;
24375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24376         LDKInitFeatures val_conv;
24377         val_conv.inner = (void*)(val & (~1));
24378         val_conv.is_owned = (val & 1) || (val == 0);
24379         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24380         val_conv = InitFeatures_clone(&val_conv);
24381         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
24382 }
24383
24384 int64_t  __attribute__((export_name("TS_ChannelCounterparty_get_unspendable_punishment_reserve"))) TS_ChannelCounterparty_get_unspendable_punishment_reserve(uint32_t this_ptr) {
24385         LDKChannelCounterparty this_ptr_conv;
24386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24387         this_ptr_conv.is_owned = false;
24388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24389         int64_t ret_conv = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
24390         return ret_conv;
24391 }
24392
24393 void  __attribute__((export_name("TS_ChannelCounterparty_set_unspendable_punishment_reserve"))) TS_ChannelCounterparty_set_unspendable_punishment_reserve(uint32_t this_ptr, int64_t val) {
24394         LDKChannelCounterparty this_ptr_conv;
24395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24396         this_ptr_conv.is_owned = false;
24397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24398         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
24399 }
24400
24401 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_get_forwarding_info"))) TS_ChannelCounterparty_get_forwarding_info(uint32_t this_ptr) {
24402         LDKChannelCounterparty this_ptr_conv;
24403         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24404         this_ptr_conv.is_owned = false;
24405         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24406         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
24407         uint32_t ret_ref = 0;
24408         if ((uintptr_t)ret_var.inner > 4096) {
24409                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24410                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24411         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24412                 ret_ref = (uintptr_t)ret_var.inner;
24413                 if (ret_var.is_owned) {
24414                         ret_ref |= 1;
24415                 }
24416         }
24417         return ret_ref;
24418 }
24419
24420 void  __attribute__((export_name("TS_ChannelCounterparty_set_forwarding_info"))) TS_ChannelCounterparty_set_forwarding_info(uint32_t this_ptr, uint32_t val) {
24421         LDKChannelCounterparty this_ptr_conv;
24422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24423         this_ptr_conv.is_owned = false;
24424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24425         LDKCounterpartyForwardingInfo val_conv;
24426         val_conv.inner = (void*)(val & (~1));
24427         val_conv.is_owned = (val & 1) || (val == 0);
24428         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24429         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
24430         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
24431 }
24432
24433 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) {
24434         LDKPublicKey node_id_arg_ref;
24435         CHECK(node_id_arg->arr_len == 33);
24436         memcpy(node_id_arg_ref.compressed_form, node_id_arg->elems, 33); FREE(node_id_arg);
24437         LDKInitFeatures features_arg_conv;
24438         features_arg_conv.inner = (void*)(features_arg & (~1));
24439         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
24440         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
24441         features_arg_conv = InitFeatures_clone(&features_arg_conv);
24442         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
24443         forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1));
24444         forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0);
24445         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
24446         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
24447         LDKChannelCounterparty ret_var = ChannelCounterparty_new(node_id_arg_ref, features_arg_conv, unspendable_punishment_reserve_arg, forwarding_info_arg_conv);
24448         uint32_t ret_ref = 0;
24449         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24450         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24451         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24452         ret_ref = (uintptr_t)ret_var.inner;
24453         if (ret_var.is_owned) {
24454                 ret_ref |= 1;
24455         }
24456         return ret_ref;
24457 }
24458
24459 static inline uintptr_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
24460         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
24461 uint32_t ret_ref = 0;
24462 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24463 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24464 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24465 ret_ref = (uintptr_t)ret_var.inner;
24466 if (ret_var.is_owned) {
24467         ret_ref |= 1;
24468 }
24469         return ret_ref;
24470 }
24471 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_clone_ptr"))) TS_ChannelCounterparty_clone_ptr(uint32_t arg) {
24472         LDKChannelCounterparty arg_conv;
24473         arg_conv.inner = (void*)(arg & (~1));
24474         arg_conv.is_owned = false;
24475         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24476         uint32_t ret_conv = ChannelCounterparty_clone_ptr(&arg_conv);
24477         return ret_conv;
24478 }
24479
24480 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_clone"))) TS_ChannelCounterparty_clone(uint32_t orig) {
24481         LDKChannelCounterparty orig_conv;
24482         orig_conv.inner = (void*)(orig & (~1));
24483         orig_conv.is_owned = false;
24484         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24485         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
24486         uint32_t ret_ref = 0;
24487         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24488         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24489         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24490         ret_ref = (uintptr_t)ret_var.inner;
24491         if (ret_var.is_owned) {
24492                 ret_ref |= 1;
24493         }
24494         return ret_ref;
24495 }
24496
24497 void  __attribute__((export_name("TS_ChannelDetails_free"))) TS_ChannelDetails_free(uint32_t this_obj) {
24498         LDKChannelDetails this_obj_conv;
24499         this_obj_conv.inner = (void*)(this_obj & (~1));
24500         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24502         ChannelDetails_free(this_obj_conv);
24503 }
24504
24505 int8_tArray  __attribute__((export_name("TS_ChannelDetails_get_channel_id"))) TS_ChannelDetails_get_channel_id(uint32_t this_ptr) {
24506         LDKChannelDetails this_ptr_conv;
24507         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24508         this_ptr_conv.is_owned = false;
24509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24510         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
24511         memcpy(ret_arr->elems, *ChannelDetails_get_channel_id(&this_ptr_conv), 32);
24512         return ret_arr;
24513 }
24514
24515 void  __attribute__((export_name("TS_ChannelDetails_set_channel_id"))) TS_ChannelDetails_set_channel_id(uint32_t this_ptr, int8_tArray val) {
24516         LDKChannelDetails this_ptr_conv;
24517         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24518         this_ptr_conv.is_owned = false;
24519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24520         LDKThirtyTwoBytes val_ref;
24521         CHECK(val->arr_len == 32);
24522         memcpy(val_ref.data, val->elems, 32); FREE(val);
24523         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
24524 }
24525
24526 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_counterparty"))) TS_ChannelDetails_get_counterparty(uint32_t this_ptr) {
24527         LDKChannelDetails this_ptr_conv;
24528         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24529         this_ptr_conv.is_owned = false;
24530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24531         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
24532         uint32_t ret_ref = 0;
24533         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24534         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24535         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24536         ret_ref = (uintptr_t)ret_var.inner;
24537         if (ret_var.is_owned) {
24538                 ret_ref |= 1;
24539         }
24540         return ret_ref;
24541 }
24542
24543 void  __attribute__((export_name("TS_ChannelDetails_set_counterparty"))) TS_ChannelDetails_set_counterparty(uint32_t this_ptr, uint32_t val) {
24544         LDKChannelDetails this_ptr_conv;
24545         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24546         this_ptr_conv.is_owned = false;
24547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24548         LDKChannelCounterparty val_conv;
24549         val_conv.inner = (void*)(val & (~1));
24550         val_conv.is_owned = (val & 1) || (val == 0);
24551         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24552         val_conv = ChannelCounterparty_clone(&val_conv);
24553         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
24554 }
24555
24556 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_funding_txo"))) TS_ChannelDetails_get_funding_txo(uint32_t this_ptr) {
24557         LDKChannelDetails this_ptr_conv;
24558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24559         this_ptr_conv.is_owned = false;
24560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24561         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
24562         uint32_t ret_ref = 0;
24563         if ((uintptr_t)ret_var.inner > 4096) {
24564                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24565                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24566         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24567                 ret_ref = (uintptr_t)ret_var.inner;
24568                 if (ret_var.is_owned) {
24569                         ret_ref |= 1;
24570                 }
24571         }
24572         return ret_ref;
24573 }
24574
24575 void  __attribute__((export_name("TS_ChannelDetails_set_funding_txo"))) TS_ChannelDetails_set_funding_txo(uint32_t this_ptr, uint32_t val) {
24576         LDKChannelDetails this_ptr_conv;
24577         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24578         this_ptr_conv.is_owned = false;
24579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24580         LDKOutPoint val_conv;
24581         val_conv.inner = (void*)(val & (~1));
24582         val_conv.is_owned = (val & 1) || (val == 0);
24583         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24584         val_conv = OutPoint_clone(&val_conv);
24585         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
24586 }
24587
24588 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_channel_type"))) TS_ChannelDetails_get_channel_type(uint32_t this_ptr) {
24589         LDKChannelDetails this_ptr_conv;
24590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24591         this_ptr_conv.is_owned = false;
24592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24593         LDKChannelTypeFeatures ret_var = ChannelDetails_get_channel_type(&this_ptr_conv);
24594         uint32_t ret_ref = 0;
24595         if ((uintptr_t)ret_var.inner > 4096) {
24596                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24597                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24598         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24599                 ret_ref = (uintptr_t)ret_var.inner;
24600                 if (ret_var.is_owned) {
24601                         ret_ref |= 1;
24602                 }
24603         }
24604         return ret_ref;
24605 }
24606
24607 void  __attribute__((export_name("TS_ChannelDetails_set_channel_type"))) TS_ChannelDetails_set_channel_type(uint32_t this_ptr, uint32_t val) {
24608         LDKChannelDetails this_ptr_conv;
24609         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24610         this_ptr_conv.is_owned = false;
24611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24612         LDKChannelTypeFeatures val_conv;
24613         val_conv.inner = (void*)(val & (~1));
24614         val_conv.is_owned = (val & 1) || (val == 0);
24615         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24616         val_conv = ChannelTypeFeatures_clone(&val_conv);
24617         ChannelDetails_set_channel_type(&this_ptr_conv, val_conv);
24618 }
24619
24620 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_short_channel_id"))) TS_ChannelDetails_get_short_channel_id(uint32_t this_ptr) {
24621         LDKChannelDetails this_ptr_conv;
24622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24623         this_ptr_conv.is_owned = false;
24624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24625         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24626         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
24627         uint32_t ret_ref = (uintptr_t)ret_copy;
24628         return ret_ref;
24629 }
24630
24631 void  __attribute__((export_name("TS_ChannelDetails_set_short_channel_id"))) TS_ChannelDetails_set_short_channel_id(uint32_t this_ptr, uint32_t val) {
24632         LDKChannelDetails this_ptr_conv;
24633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24634         this_ptr_conv.is_owned = false;
24635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24636         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
24637         CHECK_ACCESS(val_ptr);
24638         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
24639         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
24640         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
24641 }
24642
24643 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_scid_alias"))) TS_ChannelDetails_get_inbound_scid_alias(uint32_t this_ptr) {
24644         LDKChannelDetails this_ptr_conv;
24645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24646         this_ptr_conv.is_owned = false;
24647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24648         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24649         *ret_copy = ChannelDetails_get_inbound_scid_alias(&this_ptr_conv);
24650         uint32_t ret_ref = (uintptr_t)ret_copy;
24651         return ret_ref;
24652 }
24653
24654 void  __attribute__((export_name("TS_ChannelDetails_set_inbound_scid_alias"))) TS_ChannelDetails_set_inbound_scid_alias(uint32_t this_ptr, uint32_t val) {
24655         LDKChannelDetails this_ptr_conv;
24656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24657         this_ptr_conv.is_owned = false;
24658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24659         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
24660         CHECK_ACCESS(val_ptr);
24661         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
24662         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
24663         ChannelDetails_set_inbound_scid_alias(&this_ptr_conv, val_conv);
24664 }
24665
24666 int64_t  __attribute__((export_name("TS_ChannelDetails_get_channel_value_satoshis"))) TS_ChannelDetails_get_channel_value_satoshis(uint32_t this_ptr) {
24667         LDKChannelDetails this_ptr_conv;
24668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24669         this_ptr_conv.is_owned = false;
24670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24671         int64_t ret_conv = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
24672         return ret_conv;
24673 }
24674
24675 void  __attribute__((export_name("TS_ChannelDetails_set_channel_value_satoshis"))) TS_ChannelDetails_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
24676         LDKChannelDetails this_ptr_conv;
24677         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24678         this_ptr_conv.is_owned = false;
24679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24680         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
24681 }
24682
24683 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_unspendable_punishment_reserve"))) TS_ChannelDetails_get_unspendable_punishment_reserve(uint32_t this_ptr) {
24684         LDKChannelDetails this_ptr_conv;
24685         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24686         this_ptr_conv.is_owned = false;
24687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24688         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24689         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
24690         uint32_t ret_ref = (uintptr_t)ret_copy;
24691         return ret_ref;
24692 }
24693
24694 void  __attribute__((export_name("TS_ChannelDetails_set_unspendable_punishment_reserve"))) TS_ChannelDetails_set_unspendable_punishment_reserve(uint32_t this_ptr, uint32_t val) {
24695         LDKChannelDetails this_ptr_conv;
24696         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24697         this_ptr_conv.is_owned = false;
24698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24699         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
24700         CHECK_ACCESS(val_ptr);
24701         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
24702         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
24703         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
24704 }
24705
24706 int64_t  __attribute__((export_name("TS_ChannelDetails_get_user_channel_id"))) TS_ChannelDetails_get_user_channel_id(uint32_t this_ptr) {
24707         LDKChannelDetails this_ptr_conv;
24708         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24709         this_ptr_conv.is_owned = false;
24710         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24711         int64_t ret_conv = ChannelDetails_get_user_channel_id(&this_ptr_conv);
24712         return ret_conv;
24713 }
24714
24715 void  __attribute__((export_name("TS_ChannelDetails_set_user_channel_id"))) TS_ChannelDetails_set_user_channel_id(uint32_t this_ptr, int64_t val) {
24716         LDKChannelDetails this_ptr_conv;
24717         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24718         this_ptr_conv.is_owned = false;
24719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24720         ChannelDetails_set_user_channel_id(&this_ptr_conv, val);
24721 }
24722
24723 int64_t  __attribute__((export_name("TS_ChannelDetails_get_balance_msat"))) TS_ChannelDetails_get_balance_msat(uint32_t this_ptr) {
24724         LDKChannelDetails this_ptr_conv;
24725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24726         this_ptr_conv.is_owned = false;
24727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24728         int64_t ret_conv = ChannelDetails_get_balance_msat(&this_ptr_conv);
24729         return ret_conv;
24730 }
24731
24732 void  __attribute__((export_name("TS_ChannelDetails_set_balance_msat"))) TS_ChannelDetails_set_balance_msat(uint32_t this_ptr, int64_t val) {
24733         LDKChannelDetails this_ptr_conv;
24734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24735         this_ptr_conv.is_owned = false;
24736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24737         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
24738 }
24739
24740 int64_t  __attribute__((export_name("TS_ChannelDetails_get_outbound_capacity_msat"))) TS_ChannelDetails_get_outbound_capacity_msat(uint32_t this_ptr) {
24741         LDKChannelDetails this_ptr_conv;
24742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24743         this_ptr_conv.is_owned = false;
24744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24745         int64_t ret_conv = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
24746         return ret_conv;
24747 }
24748
24749 void  __attribute__((export_name("TS_ChannelDetails_set_outbound_capacity_msat"))) TS_ChannelDetails_set_outbound_capacity_msat(uint32_t this_ptr, int64_t val) {
24750         LDKChannelDetails this_ptr_conv;
24751         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24752         this_ptr_conv.is_owned = false;
24753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24754         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
24755 }
24756
24757 int64_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_capacity_msat"))) TS_ChannelDetails_get_inbound_capacity_msat(uint32_t this_ptr) {
24758         LDKChannelDetails this_ptr_conv;
24759         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24760         this_ptr_conv.is_owned = false;
24761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24762         int64_t ret_conv = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
24763         return ret_conv;
24764 }
24765
24766 void  __attribute__((export_name("TS_ChannelDetails_set_inbound_capacity_msat"))) TS_ChannelDetails_set_inbound_capacity_msat(uint32_t this_ptr, int64_t val) {
24767         LDKChannelDetails this_ptr_conv;
24768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24769         this_ptr_conv.is_owned = false;
24770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24771         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
24772 }
24773
24774 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_confirmations_required"))) TS_ChannelDetails_get_confirmations_required(uint32_t this_ptr) {
24775         LDKChannelDetails this_ptr_conv;
24776         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24777         this_ptr_conv.is_owned = false;
24778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24779         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
24780         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
24781         uint32_t ret_ref = (uintptr_t)ret_copy;
24782         return ret_ref;
24783 }
24784
24785 void  __attribute__((export_name("TS_ChannelDetails_set_confirmations_required"))) TS_ChannelDetails_set_confirmations_required(uint32_t this_ptr, uint32_t val) {
24786         LDKChannelDetails this_ptr_conv;
24787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24788         this_ptr_conv.is_owned = false;
24789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24790         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
24791         CHECK_ACCESS(val_ptr);
24792         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
24793         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
24794         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
24795 }
24796
24797 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_force_close_spend_delay"))) TS_ChannelDetails_get_force_close_spend_delay(uint32_t this_ptr) {
24798         LDKChannelDetails this_ptr_conv;
24799         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24800         this_ptr_conv.is_owned = false;
24801         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24802         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
24803         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
24804         uint32_t ret_ref = (uintptr_t)ret_copy;
24805         return ret_ref;
24806 }
24807
24808 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) {
24809         LDKChannelDetails this_ptr_conv;
24810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24811         this_ptr_conv.is_owned = false;
24812         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24813         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
24814         CHECK_ACCESS(val_ptr);
24815         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
24816         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)val) & ~1));
24817         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
24818 }
24819
24820 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_outbound"))) TS_ChannelDetails_get_is_outbound(uint32_t this_ptr) {
24821         LDKChannelDetails this_ptr_conv;
24822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24823         this_ptr_conv.is_owned = false;
24824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24825         jboolean ret_conv = ChannelDetails_get_is_outbound(&this_ptr_conv);
24826         return ret_conv;
24827 }
24828
24829 void  __attribute__((export_name("TS_ChannelDetails_set_is_outbound"))) TS_ChannelDetails_set_is_outbound(uint32_t this_ptr, jboolean val) {
24830         LDKChannelDetails this_ptr_conv;
24831         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24832         this_ptr_conv.is_owned = false;
24833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24834         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
24835 }
24836
24837 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_funding_locked"))) TS_ChannelDetails_get_is_funding_locked(uint32_t this_ptr) {
24838         LDKChannelDetails this_ptr_conv;
24839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24840         this_ptr_conv.is_owned = false;
24841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24842         jboolean ret_conv = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
24843         return ret_conv;
24844 }
24845
24846 void  __attribute__((export_name("TS_ChannelDetails_set_is_funding_locked"))) TS_ChannelDetails_set_is_funding_locked(uint32_t this_ptr, jboolean val) {
24847         LDKChannelDetails this_ptr_conv;
24848         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24849         this_ptr_conv.is_owned = false;
24850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24851         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
24852 }
24853
24854 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_usable"))) TS_ChannelDetails_get_is_usable(uint32_t this_ptr) {
24855         LDKChannelDetails this_ptr_conv;
24856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24857         this_ptr_conv.is_owned = false;
24858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24859         jboolean ret_conv = ChannelDetails_get_is_usable(&this_ptr_conv);
24860         return ret_conv;
24861 }
24862
24863 void  __attribute__((export_name("TS_ChannelDetails_set_is_usable"))) TS_ChannelDetails_set_is_usable(uint32_t this_ptr, jboolean val) {
24864         LDKChannelDetails this_ptr_conv;
24865         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24866         this_ptr_conv.is_owned = false;
24867         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24868         ChannelDetails_set_is_usable(&this_ptr_conv, val);
24869 }
24870
24871 jboolean  __attribute__((export_name("TS_ChannelDetails_get_is_public"))) TS_ChannelDetails_get_is_public(uint32_t this_ptr) {
24872         LDKChannelDetails this_ptr_conv;
24873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24874         this_ptr_conv.is_owned = false;
24875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24876         jboolean ret_conv = ChannelDetails_get_is_public(&this_ptr_conv);
24877         return ret_conv;
24878 }
24879
24880 void  __attribute__((export_name("TS_ChannelDetails_set_is_public"))) TS_ChannelDetails_set_is_public(uint32_t this_ptr, jboolean val) {
24881         LDKChannelDetails this_ptr_conv;
24882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24883         this_ptr_conv.is_owned = false;
24884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24885         ChannelDetails_set_is_public(&this_ptr_conv, val);
24886 }
24887
24888 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) {
24889         LDKThirtyTwoBytes channel_id_arg_ref;
24890         CHECK(channel_id_arg->arr_len == 32);
24891         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
24892         LDKChannelCounterparty counterparty_arg_conv;
24893         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
24894         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
24895         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
24896         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
24897         LDKOutPoint funding_txo_arg_conv;
24898         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
24899         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
24900         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
24901         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
24902         LDKChannelTypeFeatures channel_type_arg_conv;
24903         channel_type_arg_conv.inner = (void*)(channel_type_arg & (~1));
24904         channel_type_arg_conv.is_owned = (channel_type_arg & 1) || (channel_type_arg == 0);
24905         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_arg_conv);
24906         channel_type_arg_conv = ChannelTypeFeatures_clone(&channel_type_arg_conv);
24907         void* short_channel_id_arg_ptr = (void*)(((uintptr_t)short_channel_id_arg) & ~1);
24908         CHECK_ACCESS(short_channel_id_arg_ptr);
24909         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
24910         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_arg) & ~1));
24911         void* inbound_scid_alias_arg_ptr = (void*)(((uintptr_t)inbound_scid_alias_arg) & ~1);
24912         CHECK_ACCESS(inbound_scid_alias_arg_ptr);
24913         LDKCOption_u64Z inbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(inbound_scid_alias_arg_ptr);
24914         inbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)inbound_scid_alias_arg) & ~1));
24915         void* unspendable_punishment_reserve_arg_ptr = (void*)(((uintptr_t)unspendable_punishment_reserve_arg) & ~1);
24916         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
24917         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
24918         void* confirmations_required_arg_ptr = (void*)(((uintptr_t)confirmations_required_arg) & ~1);
24919         CHECK_ACCESS(confirmations_required_arg_ptr);
24920         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
24921         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)confirmations_required_arg) & ~1));
24922         void* force_close_spend_delay_arg_ptr = (void*)(((uintptr_t)force_close_spend_delay_arg) & ~1);
24923         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
24924         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
24925         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uintptr_t)force_close_spend_delay_arg) & ~1));
24926         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);
24927         uint32_t ret_ref = 0;
24928         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24929         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24930         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24931         ret_ref = (uintptr_t)ret_var.inner;
24932         if (ret_var.is_owned) {
24933                 ret_ref |= 1;
24934         }
24935         return ret_ref;
24936 }
24937
24938 static inline uintptr_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
24939         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
24940 uint32_t ret_ref = 0;
24941 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24942 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24943 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24944 ret_ref = (uintptr_t)ret_var.inner;
24945 if (ret_var.is_owned) {
24946         ret_ref |= 1;
24947 }
24948         return ret_ref;
24949 }
24950 uint32_t  __attribute__((export_name("TS_ChannelDetails_clone_ptr"))) TS_ChannelDetails_clone_ptr(uint32_t arg) {
24951         LDKChannelDetails arg_conv;
24952         arg_conv.inner = (void*)(arg & (~1));
24953         arg_conv.is_owned = false;
24954         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24955         uint32_t ret_conv = ChannelDetails_clone_ptr(&arg_conv);
24956         return ret_conv;
24957 }
24958
24959 uint32_t  __attribute__((export_name("TS_ChannelDetails_clone"))) TS_ChannelDetails_clone(uint32_t orig) {
24960         LDKChannelDetails orig_conv;
24961         orig_conv.inner = (void*)(orig & (~1));
24962         orig_conv.is_owned = false;
24963         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24964         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
24965         uint32_t ret_ref = 0;
24966         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24967         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24968         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24969         ret_ref = (uintptr_t)ret_var.inner;
24970         if (ret_var.is_owned) {
24971                 ret_ref |= 1;
24972         }
24973         return ret_ref;
24974 }
24975
24976 uint32_t  __attribute__((export_name("TS_ChannelDetails_get_inbound_payment_scid"))) TS_ChannelDetails_get_inbound_payment_scid(uint32_t this_arg) {
24977         LDKChannelDetails this_arg_conv;
24978         this_arg_conv.inner = (void*)(this_arg & (~1));
24979         this_arg_conv.is_owned = false;
24980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24981         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24982         *ret_copy = ChannelDetails_get_inbound_payment_scid(&this_arg_conv);
24983         uint32_t ret_ref = (uintptr_t)ret_copy;
24984         return ret_ref;
24985 }
24986
24987 void  __attribute__((export_name("TS_PaymentSendFailure_free"))) TS_PaymentSendFailure_free(uint32_t this_ptr) {
24988         if ((this_ptr & 1) != 0) return;
24989         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
24990         CHECK_ACCESS(this_ptr_ptr);
24991         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
24992         FREE((void*)this_ptr);
24993         PaymentSendFailure_free(this_ptr_conv);
24994 }
24995
24996 static inline uintptr_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
24997         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
24998         *ret_copy = PaymentSendFailure_clone(arg);
24999 uint32_t ret_ref = (uintptr_t)ret_copy;
25000         return ret_ref;
25001 }
25002 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_clone_ptr"))) TS_PaymentSendFailure_clone_ptr(uint32_t arg) {
25003         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)arg;
25004         uint32_t ret_conv = PaymentSendFailure_clone_ptr(arg_conv);
25005         return ret_conv;
25006 }
25007
25008 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_clone"))) TS_PaymentSendFailure_clone(uint32_t orig) {
25009         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
25010         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
25011         *ret_copy = PaymentSendFailure_clone(orig_conv);
25012         uint32_t ret_ref = (uintptr_t)ret_copy;
25013         return ret_ref;
25014 }
25015
25016 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_parameter_error"))) TS_PaymentSendFailure_parameter_error(uint32_t a) {
25017         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
25018         CHECK_ACCESS(a_ptr);
25019         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
25020         a_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a) & ~1));
25021         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
25022         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
25023         uint32_t ret_ref = (uintptr_t)ret_copy;
25024         return ret_ref;
25025 }
25026
25027 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_path_parameter_error"))) TS_PaymentSendFailure_path_parameter_error(uint32_tArray a) {
25028         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
25029         a_constr.datalen = a->arr_len;
25030         if (a_constr.datalen > 0)
25031                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
25032         else
25033                 a_constr.data = NULL;
25034         uint32_t* a_vals = a->elems /* XXX a leaks */;
25035         for (size_t w = 0; w < a_constr.datalen; w++) {
25036                 uint32_t a_conv_22 = a_vals[w];
25037                 void* a_conv_22_ptr = (void*)(((uintptr_t)a_conv_22) & ~1);
25038                 CHECK_ACCESS(a_conv_22_ptr);
25039                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
25040                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uintptr_t)a_conv_22) & ~1));
25041                 a_constr.data[w] = a_conv_22_conv;
25042         }
25043         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
25044         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
25045         uint32_t ret_ref = (uintptr_t)ret_copy;
25046         return ret_ref;
25047 }
25048
25049 uint32_t  __attribute__((export_name("TS_PaymentSendFailure_all_failed_retry_safe"))) TS_PaymentSendFailure_all_failed_retry_safe(uint32_tArray a) {
25050         LDKCVec_APIErrorZ a_constr;
25051         a_constr.datalen = a->arr_len;
25052         if (a_constr.datalen > 0)
25053                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
25054         else
25055                 a_constr.data = NULL;
25056         uint32_t* a_vals = a->elems /* XXX a leaks */;
25057         for (size_t k = 0; k < a_constr.datalen; k++) {
25058                 uint32_t a_conv_10 = a_vals[k];
25059                 void* a_conv_10_ptr = (void*)(((uintptr_t)a_conv_10) & ~1);
25060                 CHECK_ACCESS(a_conv_10_ptr);
25061                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
25062                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uintptr_t)a_conv_10) & ~1));
25063                 a_constr.data[k] = a_conv_10_conv;
25064         }
25065         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
25066         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
25067         uint32_t ret_ref = (uintptr_t)ret_copy;
25068         return ret_ref;
25069 }
25070
25071 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) {
25072         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
25073         results_constr.datalen = results->arr_len;
25074         if (results_constr.datalen > 0)
25075                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
25076         else
25077                 results_constr.data = NULL;
25078         uint32_t* results_vals = results->elems /* XXX results leaks */;
25079         for (size_t w = 0; w < results_constr.datalen; w++) {
25080                 uint32_t results_conv_22 = results_vals[w];
25081                 void* results_conv_22_ptr = (void*)(((uintptr_t)results_conv_22) & ~1);
25082                 CHECK_ACCESS(results_conv_22_ptr);
25083                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
25084                 results_constr.data[w] = results_conv_22_conv;
25085         }
25086         LDKRouteParameters failed_paths_retry_conv;
25087         failed_paths_retry_conv.inner = (void*)(failed_paths_retry & (~1));
25088         failed_paths_retry_conv.is_owned = (failed_paths_retry & 1) || (failed_paths_retry == 0);
25089         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
25090         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
25091         LDKThirtyTwoBytes payment_id_ref;
25092         CHECK(payment_id->arr_len == 32);
25093         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
25094         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
25095         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
25096         uint32_t ret_ref = (uintptr_t)ret_copy;
25097         return ret_ref;
25098 }
25099
25100 void  __attribute__((export_name("TS_PhantomRouteHints_free"))) TS_PhantomRouteHints_free(uint32_t this_obj) {
25101         LDKPhantomRouteHints this_obj_conv;
25102         this_obj_conv.inner = (void*)(this_obj & (~1));
25103         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25105         PhantomRouteHints_free(this_obj_conv);
25106 }
25107
25108 uint32_tArray  __attribute__((export_name("TS_PhantomRouteHints_get_channels"))) TS_PhantomRouteHints_get_channels(uint32_t this_ptr) {
25109         LDKPhantomRouteHints this_ptr_conv;
25110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25111         this_ptr_conv.is_owned = false;
25112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25113         LDKCVec_ChannelDetailsZ ret_var = PhantomRouteHints_get_channels(&this_ptr_conv);
25114         uint32_tArray ret_arr = NULL;
25115         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
25116         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
25117         for (size_t q = 0; q < ret_var.datalen; q++) {
25118                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
25119                 uint32_t ret_conv_16_ref = 0;
25120                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25121                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25122                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
25123                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
25124                 if (ret_conv_16_var.is_owned) {
25125                         ret_conv_16_ref |= 1;
25126                 }
25127                 ret_arr_ptr[q] = ret_conv_16_ref;
25128         }
25129         
25130         FREE(ret_var.data);
25131         return ret_arr;
25132 }
25133
25134 void  __attribute__((export_name("TS_PhantomRouteHints_set_channels"))) TS_PhantomRouteHints_set_channels(uint32_t this_ptr, uint32_tArray val) {
25135         LDKPhantomRouteHints this_ptr_conv;
25136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25137         this_ptr_conv.is_owned = false;
25138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25139         LDKCVec_ChannelDetailsZ val_constr;
25140         val_constr.datalen = val->arr_len;
25141         if (val_constr.datalen > 0)
25142                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
25143         else
25144                 val_constr.data = NULL;
25145         uint32_t* val_vals = val->elems /* XXX val leaks */;
25146         for (size_t q = 0; q < val_constr.datalen; q++) {
25147                 uint32_t val_conv_16 = val_vals[q];
25148                 LDKChannelDetails val_conv_16_conv;
25149                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
25150                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
25151                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
25152                 val_conv_16_conv = ChannelDetails_clone(&val_conv_16_conv);
25153                 val_constr.data[q] = val_conv_16_conv;
25154         }
25155         PhantomRouteHints_set_channels(&this_ptr_conv, val_constr);
25156 }
25157
25158 int64_t  __attribute__((export_name("TS_PhantomRouteHints_get_phantom_scid"))) TS_PhantomRouteHints_get_phantom_scid(uint32_t this_ptr) {
25159         LDKPhantomRouteHints this_ptr_conv;
25160         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25161         this_ptr_conv.is_owned = false;
25162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25163         int64_t ret_conv = PhantomRouteHints_get_phantom_scid(&this_ptr_conv);
25164         return ret_conv;
25165 }
25166
25167 void  __attribute__((export_name("TS_PhantomRouteHints_set_phantom_scid"))) TS_PhantomRouteHints_set_phantom_scid(uint32_t this_ptr, int64_t val) {
25168         LDKPhantomRouteHints this_ptr_conv;
25169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25170         this_ptr_conv.is_owned = false;
25171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25172         PhantomRouteHints_set_phantom_scid(&this_ptr_conv, val);
25173 }
25174
25175 int8_tArray  __attribute__((export_name("TS_PhantomRouteHints_get_real_node_pubkey"))) TS_PhantomRouteHints_get_real_node_pubkey(uint32_t this_ptr) {
25176         LDKPhantomRouteHints this_ptr_conv;
25177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25178         this_ptr_conv.is_owned = false;
25179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25180         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
25181         memcpy(ret_arr->elems, PhantomRouteHints_get_real_node_pubkey(&this_ptr_conv).compressed_form, 33);
25182         return ret_arr;
25183 }
25184
25185 void  __attribute__((export_name("TS_PhantomRouteHints_set_real_node_pubkey"))) TS_PhantomRouteHints_set_real_node_pubkey(uint32_t this_ptr, int8_tArray val) {
25186         LDKPhantomRouteHints this_ptr_conv;
25187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25188         this_ptr_conv.is_owned = false;
25189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25190         LDKPublicKey val_ref;
25191         CHECK(val->arr_len == 33);
25192         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
25193         PhantomRouteHints_set_real_node_pubkey(&this_ptr_conv, val_ref);
25194 }
25195
25196 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) {
25197         LDKCVec_ChannelDetailsZ channels_arg_constr;
25198         channels_arg_constr.datalen = channels_arg->arr_len;
25199         if (channels_arg_constr.datalen > 0)
25200                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
25201         else
25202                 channels_arg_constr.data = NULL;
25203         uint32_t* channels_arg_vals = channels_arg->elems /* XXX channels_arg leaks */;
25204         for (size_t q = 0; q < channels_arg_constr.datalen; q++) {
25205                 uint32_t channels_arg_conv_16 = channels_arg_vals[q];
25206                 LDKChannelDetails channels_arg_conv_16_conv;
25207                 channels_arg_conv_16_conv.inner = (void*)(channels_arg_conv_16 & (~1));
25208                 channels_arg_conv_16_conv.is_owned = (channels_arg_conv_16 & 1) || (channels_arg_conv_16 == 0);
25209                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channels_arg_conv_16_conv);
25210                 channels_arg_conv_16_conv = ChannelDetails_clone(&channels_arg_conv_16_conv);
25211                 channels_arg_constr.data[q] = channels_arg_conv_16_conv;
25212         }
25213         LDKPublicKey real_node_pubkey_arg_ref;
25214         CHECK(real_node_pubkey_arg->arr_len == 33);
25215         memcpy(real_node_pubkey_arg_ref.compressed_form, real_node_pubkey_arg->elems, 33); FREE(real_node_pubkey_arg);
25216         LDKPhantomRouteHints ret_var = PhantomRouteHints_new(channels_arg_constr, phantom_scid_arg, real_node_pubkey_arg_ref);
25217         uint32_t ret_ref = 0;
25218         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25219         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25220         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25221         ret_ref = (uintptr_t)ret_var.inner;
25222         if (ret_var.is_owned) {
25223                 ret_ref |= 1;
25224         }
25225         return ret_ref;
25226 }
25227
25228 static inline uintptr_t PhantomRouteHints_clone_ptr(LDKPhantomRouteHints *NONNULL_PTR arg) {
25229         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(arg);
25230 uint32_t ret_ref = 0;
25231 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25232 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25233 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25234 ret_ref = (uintptr_t)ret_var.inner;
25235 if (ret_var.is_owned) {
25236         ret_ref |= 1;
25237 }
25238         return ret_ref;
25239 }
25240 uint32_t  __attribute__((export_name("TS_PhantomRouteHints_clone_ptr"))) TS_PhantomRouteHints_clone_ptr(uint32_t arg) {
25241         LDKPhantomRouteHints arg_conv;
25242         arg_conv.inner = (void*)(arg & (~1));
25243         arg_conv.is_owned = false;
25244         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25245         uint32_t ret_conv = PhantomRouteHints_clone_ptr(&arg_conv);
25246         return ret_conv;
25247 }
25248
25249 uint32_t  __attribute__((export_name("TS_PhantomRouteHints_clone"))) TS_PhantomRouteHints_clone(uint32_t orig) {
25250         LDKPhantomRouteHints orig_conv;
25251         orig_conv.inner = (void*)(orig & (~1));
25252         orig_conv.is_owned = false;
25253         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25254         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(&orig_conv);
25255         uint32_t ret_ref = 0;
25256         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25257         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25258         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25259         ret_ref = (uintptr_t)ret_var.inner;
25260         if (ret_var.is_owned) {
25261                 ret_ref |= 1;
25262         }
25263         return ret_ref;
25264 }
25265
25266 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) {
25267         void* fee_est_ptr = (void*)(((uintptr_t)fee_est) & ~1);
25268         CHECK_ACCESS(fee_est_ptr);
25269         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
25270         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
25271                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25272                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
25273         }
25274         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
25275         CHECK_ACCESS(chain_monitor_ptr);
25276         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
25277         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
25278                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25279                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
25280         }
25281         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
25282         CHECK_ACCESS(tx_broadcaster_ptr);
25283         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
25284         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
25285                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25286                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
25287         }
25288         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
25289         CHECK_ACCESS(logger_ptr);
25290         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
25291         if (logger_conv.free == LDKLogger_JCalls_free) {
25292                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25293                 LDKLogger_JCalls_cloned(&logger_conv);
25294         }
25295         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
25296         CHECK_ACCESS(keys_manager_ptr);
25297         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
25298         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
25299                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25300                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
25301         }
25302         LDKUserConfig config_conv;
25303         config_conv.inner = (void*)(config & (~1));
25304         config_conv.is_owned = (config & 1) || (config == 0);
25305         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
25306         config_conv = UserConfig_clone(&config_conv);
25307         LDKChainParameters params_conv;
25308         params_conv.inner = (void*)(params & (~1));
25309         params_conv.is_owned = (params & 1) || (params == 0);
25310         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
25311         params_conv = ChainParameters_clone(&params_conv);
25312         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
25313         uint32_t ret_ref = 0;
25314         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25315         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25316         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25317         ret_ref = (uintptr_t)ret_var.inner;
25318         if (ret_var.is_owned) {
25319                 ret_ref |= 1;
25320         }
25321         return ret_ref;
25322 }
25323
25324 uint32_t  __attribute__((export_name("TS_ChannelManager_get_current_default_configuration"))) TS_ChannelManager_get_current_default_configuration(uint32_t this_arg) {
25325         LDKChannelManager this_arg_conv;
25326         this_arg_conv.inner = (void*)(this_arg & (~1));
25327         this_arg_conv.is_owned = false;
25328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25329         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
25330         uint32_t ret_ref = 0;
25331         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25332         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25333         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25334         ret_ref = (uintptr_t)ret_var.inner;
25335         if (ret_var.is_owned) {
25336                 ret_ref |= 1;
25337         }
25338         return ret_ref;
25339 }
25340
25341 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) {
25342         LDKChannelManager this_arg_conv;
25343         this_arg_conv.inner = (void*)(this_arg & (~1));
25344         this_arg_conv.is_owned = false;
25345         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25346         LDKPublicKey their_network_key_ref;
25347         CHECK(their_network_key->arr_len == 33);
25348         memcpy(their_network_key_ref.compressed_form, their_network_key->elems, 33); FREE(their_network_key);
25349         LDKUserConfig override_config_conv;
25350         override_config_conv.inner = (void*)(override_config & (~1));
25351         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
25352         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
25353         override_config_conv = UserConfig_clone(&override_config_conv);
25354         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
25355         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id, override_config_conv);
25356         return (uint32_t)ret_conv;
25357 }
25358
25359 uint32_tArray  __attribute__((export_name("TS_ChannelManager_list_channels"))) TS_ChannelManager_list_channels(uint32_t this_arg) {
25360         LDKChannelManager this_arg_conv;
25361         this_arg_conv.inner = (void*)(this_arg & (~1));
25362         this_arg_conv.is_owned = false;
25363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25364         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
25365         uint32_tArray ret_arr = NULL;
25366         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
25367         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
25368         for (size_t q = 0; q < ret_var.datalen; q++) {
25369                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
25370                 uint32_t ret_conv_16_ref = 0;
25371                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25372                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25373                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
25374                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
25375                 if (ret_conv_16_var.is_owned) {
25376                         ret_conv_16_ref |= 1;
25377                 }
25378                 ret_arr_ptr[q] = ret_conv_16_ref;
25379         }
25380         
25381         FREE(ret_var.data);
25382         return ret_arr;
25383 }
25384
25385 uint32_tArray  __attribute__((export_name("TS_ChannelManager_list_usable_channels"))) TS_ChannelManager_list_usable_channels(uint32_t this_arg) {
25386         LDKChannelManager this_arg_conv;
25387         this_arg_conv.inner = (void*)(this_arg & (~1));
25388         this_arg_conv.is_owned = false;
25389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25390         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
25391         uint32_tArray ret_arr = NULL;
25392         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
25393         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
25394         for (size_t q = 0; q < ret_var.datalen; q++) {
25395                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
25396                 uint32_t ret_conv_16_ref = 0;
25397                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25398                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25399                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
25400                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
25401                 if (ret_conv_16_var.is_owned) {
25402                         ret_conv_16_ref |= 1;
25403                 }
25404                 ret_arr_ptr[q] = ret_conv_16_ref;
25405         }
25406         
25407         FREE(ret_var.data);
25408         return ret_arr;
25409 }
25410
25411 uint32_t  __attribute__((export_name("TS_ChannelManager_close_channel"))) TS_ChannelManager_close_channel(uint32_t this_arg, int8_tArray channel_id) {
25412         LDKChannelManager this_arg_conv;
25413         this_arg_conv.inner = (void*)(this_arg & (~1));
25414         this_arg_conv.is_owned = false;
25415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25416         unsigned char channel_id_arr[32];
25417         CHECK(channel_id->arr_len == 32);
25418         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
25419         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
25420         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
25421         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
25422         return (uint32_t)ret_conv;
25423 }
25424
25425 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) {
25426         LDKChannelManager this_arg_conv;
25427         this_arg_conv.inner = (void*)(this_arg & (~1));
25428         this_arg_conv.is_owned = false;
25429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25430         unsigned char channel_id_arr[32];
25431         CHECK(channel_id->arr_len == 32);
25432         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
25433         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
25434         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
25435         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, target_feerate_sats_per_1000_weight);
25436         return (uint32_t)ret_conv;
25437 }
25438
25439 uint32_t  __attribute__((export_name("TS_ChannelManager_force_close_channel"))) TS_ChannelManager_force_close_channel(uint32_t this_arg, int8_tArray channel_id) {
25440         LDKChannelManager this_arg_conv;
25441         this_arg_conv.inner = (void*)(this_arg & (~1));
25442         this_arg_conv.is_owned = false;
25443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25444         unsigned char channel_id_arr[32];
25445         CHECK(channel_id->arr_len == 32);
25446         memcpy(channel_id_arr, channel_id->elems, 32); FREE(channel_id);
25447         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
25448         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
25449         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
25450         return (uint32_t)ret_conv;
25451 }
25452
25453 void  __attribute__((export_name("TS_ChannelManager_force_close_all_channels"))) TS_ChannelManager_force_close_all_channels(uint32_t this_arg) {
25454         LDKChannelManager this_arg_conv;
25455         this_arg_conv.inner = (void*)(this_arg & (~1));
25456         this_arg_conv.is_owned = false;
25457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25458         ChannelManager_force_close_all_channels(&this_arg_conv);
25459 }
25460
25461 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) {
25462         LDKChannelManager this_arg_conv;
25463         this_arg_conv.inner = (void*)(this_arg & (~1));
25464         this_arg_conv.is_owned = false;
25465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25466         LDKRoute route_conv;
25467         route_conv.inner = (void*)(route & (~1));
25468         route_conv.is_owned = false;
25469         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
25470         LDKThirtyTwoBytes payment_hash_ref;
25471         CHECK(payment_hash->arr_len == 32);
25472         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
25473         LDKThirtyTwoBytes payment_secret_ref;
25474         CHECK(payment_secret->arr_len == 32);
25475         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
25476         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
25477         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
25478         return (uint32_t)ret_conv;
25479 }
25480
25481 uint32_t  __attribute__((export_name("TS_ChannelManager_retry_payment"))) TS_ChannelManager_retry_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_id) {
25482         LDKChannelManager this_arg_conv;
25483         this_arg_conv.inner = (void*)(this_arg & (~1));
25484         this_arg_conv.is_owned = false;
25485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25486         LDKRoute route_conv;
25487         route_conv.inner = (void*)(route & (~1));
25488         route_conv.is_owned = false;
25489         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
25490         LDKThirtyTwoBytes payment_id_ref;
25491         CHECK(payment_id->arr_len == 32);
25492         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
25493         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
25494         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
25495         return (uint32_t)ret_conv;
25496 }
25497
25498 void  __attribute__((export_name("TS_ChannelManager_abandon_payment"))) TS_ChannelManager_abandon_payment(uint32_t this_arg, int8_tArray payment_id) {
25499         LDKChannelManager this_arg_conv;
25500         this_arg_conv.inner = (void*)(this_arg & (~1));
25501         this_arg_conv.is_owned = false;
25502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25503         LDKThirtyTwoBytes payment_id_ref;
25504         CHECK(payment_id->arr_len == 32);
25505         memcpy(payment_id_ref.data, payment_id->elems, 32); FREE(payment_id);
25506         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
25507 }
25508
25509 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) {
25510         LDKChannelManager this_arg_conv;
25511         this_arg_conv.inner = (void*)(this_arg & (~1));
25512         this_arg_conv.is_owned = false;
25513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25514         LDKRoute route_conv;
25515         route_conv.inner = (void*)(route & (~1));
25516         route_conv.is_owned = false;
25517         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
25518         LDKThirtyTwoBytes payment_preimage_ref;
25519         CHECK(payment_preimage->arr_len == 32);
25520         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
25521         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
25522         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
25523         return (uint32_t)ret_conv;
25524 }
25525
25526 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) {
25527         LDKChannelManager this_arg_conv;
25528         this_arg_conv.inner = (void*)(this_arg & (~1));
25529         this_arg_conv.is_owned = false;
25530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25531         unsigned char temporary_channel_id_arr[32];
25532         CHECK(temporary_channel_id->arr_len == 32);
25533         memcpy(temporary_channel_id_arr, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
25534         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
25535         LDKTransaction funding_transaction_ref;
25536         funding_transaction_ref.datalen = funding_transaction->arr_len;
25537         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
25538         memcpy(funding_transaction_ref.data, funding_transaction->elems, funding_transaction_ref.datalen); FREE(funding_transaction);
25539         funding_transaction_ref.data_is_owned = true;
25540         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
25541         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
25542         return (uint32_t)ret_conv;
25543 }
25544
25545 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) {
25546         LDKChannelManager this_arg_conv;
25547         this_arg_conv.inner = (void*)(this_arg & (~1));
25548         this_arg_conv.is_owned = false;
25549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25550         LDKThreeBytes rgb_ref;
25551         CHECK(rgb->arr_len == 3);
25552         memcpy(rgb_ref.data, rgb->elems, 3); FREE(rgb);
25553         LDKThirtyTwoBytes alias_ref;
25554         CHECK(alias->arr_len == 32);
25555         memcpy(alias_ref.data, alias->elems, 32); FREE(alias);
25556         LDKCVec_NetAddressZ addresses_constr;
25557         addresses_constr.datalen = addresses->arr_len;
25558         if (addresses_constr.datalen > 0)
25559                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
25560         else
25561                 addresses_constr.data = NULL;
25562         uint32_t* addresses_vals = addresses->elems /* XXX addresses leaks */;
25563         for (size_t m = 0; m < addresses_constr.datalen; m++) {
25564                 uint32_t addresses_conv_12 = addresses_vals[m];
25565                 void* addresses_conv_12_ptr = (void*)(((uintptr_t)addresses_conv_12) & ~1);
25566                 CHECK_ACCESS(addresses_conv_12_ptr);
25567                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
25568                 addresses_constr.data[m] = addresses_conv_12_conv;
25569         }
25570         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
25571 }
25572
25573 void  __attribute__((export_name("TS_ChannelManager_process_pending_htlc_forwards"))) TS_ChannelManager_process_pending_htlc_forwards(uint32_t this_arg) {
25574         LDKChannelManager this_arg_conv;
25575         this_arg_conv.inner = (void*)(this_arg & (~1));
25576         this_arg_conv.is_owned = false;
25577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25578         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
25579 }
25580
25581 void  __attribute__((export_name("TS_ChannelManager_timer_tick_occurred"))) TS_ChannelManager_timer_tick_occurred(uint32_t this_arg) {
25582         LDKChannelManager this_arg_conv;
25583         this_arg_conv.inner = (void*)(this_arg & (~1));
25584         this_arg_conv.is_owned = false;
25585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25586         ChannelManager_timer_tick_occurred(&this_arg_conv);
25587 }
25588
25589 jboolean  __attribute__((export_name("TS_ChannelManager_fail_htlc_backwards"))) TS_ChannelManager_fail_htlc_backwards(uint32_t this_arg, int8_tArray payment_hash) {
25590         LDKChannelManager this_arg_conv;
25591         this_arg_conv.inner = (void*)(this_arg & (~1));
25592         this_arg_conv.is_owned = false;
25593         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25594         unsigned char payment_hash_arr[32];
25595         CHECK(payment_hash->arr_len == 32);
25596         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
25597         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
25598         jboolean ret_conv = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
25599         return ret_conv;
25600 }
25601
25602 jboolean  __attribute__((export_name("TS_ChannelManager_claim_funds"))) TS_ChannelManager_claim_funds(uint32_t this_arg, int8_tArray payment_preimage) {
25603         LDKChannelManager this_arg_conv;
25604         this_arg_conv.inner = (void*)(this_arg & (~1));
25605         this_arg_conv.is_owned = false;
25606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25607         LDKThirtyTwoBytes payment_preimage_ref;
25608         CHECK(payment_preimage->arr_len == 32);
25609         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
25610         jboolean ret_conv = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
25611         return ret_conv;
25612 }
25613
25614 int8_tArray  __attribute__((export_name("TS_ChannelManager_get_our_node_id"))) TS_ChannelManager_get_our_node_id(uint32_t this_arg) {
25615         LDKChannelManager this_arg_conv;
25616         this_arg_conv.inner = (void*)(this_arg & (~1));
25617         this_arg_conv.is_owned = false;
25618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25619         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
25620         memcpy(ret_arr->elems, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form, 33);
25621         return ret_arr;
25622 }
25623
25624 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) {
25625         LDKChannelManager this_arg_conv;
25626         this_arg_conv.inner = (void*)(this_arg & (~1));
25627         this_arg_conv.is_owned = false;
25628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25629         unsigned char temporary_channel_id_arr[32];
25630         CHECK(temporary_channel_id->arr_len == 32);
25631         memcpy(temporary_channel_id_arr, temporary_channel_id->elems, 32); FREE(temporary_channel_id);
25632         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
25633         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
25634         *ret_conv = ChannelManager_accept_inbound_channel(&this_arg_conv, temporary_channel_id_ref, user_channel_id);
25635         return (uint32_t)ret_conv;
25636 }
25637
25638 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) {
25639         LDKChannelManager this_arg_conv;
25640         this_arg_conv.inner = (void*)(this_arg & (~1));
25641         this_arg_conv.is_owned = false;
25642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25643         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
25644         CHECK_ACCESS(min_value_msat_ptr);
25645         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
25646         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
25647         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
25648         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
25649         return (uint32_t)ret_conv;
25650 }
25651
25652 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) {
25653         LDKChannelManager this_arg_conv;
25654         this_arg_conv.inner = (void*)(this_arg & (~1));
25655         this_arg_conv.is_owned = false;
25656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25657         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
25658         CHECK_ACCESS(min_value_msat_ptr);
25659         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
25660         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
25661         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
25662         *ret_conv = ChannelManager_create_inbound_payment_legacy(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
25663         return (uint32_t)ret_conv;
25664 }
25665
25666 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) {
25667         LDKChannelManager this_arg_conv;
25668         this_arg_conv.inner = (void*)(this_arg & (~1));
25669         this_arg_conv.is_owned = false;
25670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25671         LDKThirtyTwoBytes payment_hash_ref;
25672         CHECK(payment_hash->arr_len == 32);
25673         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
25674         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
25675         CHECK_ACCESS(min_value_msat_ptr);
25676         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
25677         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
25678         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
25679         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
25680         return (uint32_t)ret_conv;
25681 }
25682
25683 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) {
25684         LDKChannelManager this_arg_conv;
25685         this_arg_conv.inner = (void*)(this_arg & (~1));
25686         this_arg_conv.is_owned = false;
25687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25688         LDKThirtyTwoBytes payment_hash_ref;
25689         CHECK(payment_hash->arr_len == 32);
25690         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
25691         void* min_value_msat_ptr = (void*)(((uintptr_t)min_value_msat) & ~1);
25692         CHECK_ACCESS(min_value_msat_ptr);
25693         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
25694         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)min_value_msat) & ~1));
25695         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
25696         *ret_conv = ChannelManager_create_inbound_payment_for_hash_legacy(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
25697         return (uint32_t)ret_conv;
25698 }
25699
25700 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) {
25701         LDKChannelManager this_arg_conv;
25702         this_arg_conv.inner = (void*)(this_arg & (~1));
25703         this_arg_conv.is_owned = false;
25704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25705         LDKThirtyTwoBytes payment_hash_ref;
25706         CHECK(payment_hash->arr_len == 32);
25707         memcpy(payment_hash_ref.data, payment_hash->elems, 32); FREE(payment_hash);
25708         LDKThirtyTwoBytes payment_secret_ref;
25709         CHECK(payment_secret->arr_len == 32);
25710         memcpy(payment_secret_ref.data, payment_secret->elems, 32); FREE(payment_secret);
25711         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
25712         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
25713         return (uint32_t)ret_conv;
25714 }
25715
25716 int64_t  __attribute__((export_name("TS_ChannelManager_get_phantom_scid"))) TS_ChannelManager_get_phantom_scid(uint32_t this_arg) {
25717         LDKChannelManager this_arg_conv;
25718         this_arg_conv.inner = (void*)(this_arg & (~1));
25719         this_arg_conv.is_owned = false;
25720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25721         int64_t ret_conv = ChannelManager_get_phantom_scid(&this_arg_conv);
25722         return ret_conv;
25723 }
25724
25725 uint32_t  __attribute__((export_name("TS_ChannelManager_get_phantom_route_hints"))) TS_ChannelManager_get_phantom_route_hints(uint32_t this_arg) {
25726         LDKChannelManager this_arg_conv;
25727         this_arg_conv.inner = (void*)(this_arg & (~1));
25728         this_arg_conv.is_owned = false;
25729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25730         LDKPhantomRouteHints ret_var = ChannelManager_get_phantom_route_hints(&this_arg_conv);
25731         uint32_t ret_ref = 0;
25732         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25733         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25734         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25735         ret_ref = (uintptr_t)ret_var.inner;
25736         if (ret_var.is_owned) {
25737                 ret_ref |= 1;
25738         }
25739         return ret_ref;
25740 }
25741
25742 uint32_t  __attribute__((export_name("TS_ChannelManager_as_MessageSendEventsProvider"))) TS_ChannelManager_as_MessageSendEventsProvider(uint32_t this_arg) {
25743         LDKChannelManager this_arg_conv;
25744         this_arg_conv.inner = (void*)(this_arg & (~1));
25745         this_arg_conv.is_owned = false;
25746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25747         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
25748         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
25749         return (uint32_t)ret_ret;
25750 }
25751
25752 uint32_t  __attribute__((export_name("TS_ChannelManager_as_EventsProvider"))) TS_ChannelManager_as_EventsProvider(uint32_t this_arg) {
25753         LDKChannelManager this_arg_conv;
25754         this_arg_conv.inner = (void*)(this_arg & (~1));
25755         this_arg_conv.is_owned = false;
25756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25757         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
25758         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
25759         return (uint32_t)ret_ret;
25760 }
25761
25762 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Listen"))) TS_ChannelManager_as_Listen(uint32_t this_arg) {
25763         LDKChannelManager this_arg_conv;
25764         this_arg_conv.inner = (void*)(this_arg & (~1));
25765         this_arg_conv.is_owned = false;
25766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25767         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
25768         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
25769         return (uint32_t)ret_ret;
25770 }
25771
25772 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Confirm"))) TS_ChannelManager_as_Confirm(uint32_t this_arg) {
25773         LDKChannelManager this_arg_conv;
25774         this_arg_conv.inner = (void*)(this_arg & (~1));
25775         this_arg_conv.is_owned = false;
25776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25777         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
25778         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
25779         return (uint32_t)ret_ret;
25780 }
25781
25782 void  __attribute__((export_name("TS_ChannelManager_await_persistable_update"))) TS_ChannelManager_await_persistable_update(uint32_t this_arg) {
25783         LDKChannelManager this_arg_conv;
25784         this_arg_conv.inner = (void*)(this_arg & (~1));
25785         this_arg_conv.is_owned = false;
25786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25787         ChannelManager_await_persistable_update(&this_arg_conv);
25788 }
25789
25790 uint32_t  __attribute__((export_name("TS_ChannelManager_current_best_block"))) TS_ChannelManager_current_best_block(uint32_t this_arg) {
25791         LDKChannelManager this_arg_conv;
25792         this_arg_conv.inner = (void*)(this_arg & (~1));
25793         this_arg_conv.is_owned = false;
25794         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25795         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
25796         uint32_t ret_ref = 0;
25797         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25798         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25799         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25800         ret_ref = (uintptr_t)ret_var.inner;
25801         if (ret_var.is_owned) {
25802                 ret_ref |= 1;
25803         }
25804         return ret_ref;
25805 }
25806
25807 uint32_t  __attribute__((export_name("TS_ChannelManager_as_ChannelMessageHandler"))) TS_ChannelManager_as_ChannelMessageHandler(uint32_t this_arg) {
25808         LDKChannelManager this_arg_conv;
25809         this_arg_conv.inner = (void*)(this_arg & (~1));
25810         this_arg_conv.is_owned = false;
25811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25812         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
25813         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
25814         return (uint32_t)ret_ret;
25815 }
25816
25817 int8_tArray  __attribute__((export_name("TS_CounterpartyForwardingInfo_write"))) TS_CounterpartyForwardingInfo_write(uint32_t obj) {
25818         LDKCounterpartyForwardingInfo obj_conv;
25819         obj_conv.inner = (void*)(obj & (~1));
25820         obj_conv.is_owned = false;
25821         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25822         LDKCVec_u8Z ret_var = CounterpartyForwardingInfo_write(&obj_conv);
25823         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
25824         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
25825         CVec_u8Z_free(ret_var);
25826         return ret_arr;
25827 }
25828
25829 uint32_t  __attribute__((export_name("TS_CounterpartyForwardingInfo_read"))) TS_CounterpartyForwardingInfo_read(int8_tArray ser) {
25830         LDKu8slice ser_ref;
25831         ser_ref.datalen = ser->arr_len;
25832         ser_ref.data = ser->elems /* XXX ser leaks */;
25833         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
25834         *ret_conv = CounterpartyForwardingInfo_read(ser_ref);
25835         return (uint32_t)ret_conv;
25836 }
25837
25838 int8_tArray  __attribute__((export_name("TS_ChannelCounterparty_write"))) TS_ChannelCounterparty_write(uint32_t obj) {
25839         LDKChannelCounterparty obj_conv;
25840         obj_conv.inner = (void*)(obj & (~1));
25841         obj_conv.is_owned = false;
25842         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25843         LDKCVec_u8Z ret_var = ChannelCounterparty_write(&obj_conv);
25844         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
25845         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
25846         CVec_u8Z_free(ret_var);
25847         return ret_arr;
25848 }
25849
25850 uint32_t  __attribute__((export_name("TS_ChannelCounterparty_read"))) TS_ChannelCounterparty_read(int8_tArray ser) {
25851         LDKu8slice ser_ref;
25852         ser_ref.datalen = ser->arr_len;
25853         ser_ref.data = ser->elems /* XXX ser leaks */;
25854         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
25855         *ret_conv = ChannelCounterparty_read(ser_ref);
25856         return (uint32_t)ret_conv;
25857 }
25858
25859 int8_tArray  __attribute__((export_name("TS_ChannelDetails_write"))) TS_ChannelDetails_write(uint32_t obj) {
25860         LDKChannelDetails obj_conv;
25861         obj_conv.inner = (void*)(obj & (~1));
25862         obj_conv.is_owned = false;
25863         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25864         LDKCVec_u8Z ret_var = ChannelDetails_write(&obj_conv);
25865         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
25866         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
25867         CVec_u8Z_free(ret_var);
25868         return ret_arr;
25869 }
25870
25871 uint32_t  __attribute__((export_name("TS_ChannelDetails_read"))) TS_ChannelDetails_read(int8_tArray ser) {
25872         LDKu8slice ser_ref;
25873         ser_ref.datalen = ser->arr_len;
25874         ser_ref.data = ser->elems /* XXX ser leaks */;
25875         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
25876         *ret_conv = ChannelDetails_read(ser_ref);
25877         return (uint32_t)ret_conv;
25878 }
25879
25880 int8_tArray  __attribute__((export_name("TS_PhantomRouteHints_write"))) TS_PhantomRouteHints_write(uint32_t obj) {
25881         LDKPhantomRouteHints obj_conv;
25882         obj_conv.inner = (void*)(obj & (~1));
25883         obj_conv.is_owned = false;
25884         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25885         LDKCVec_u8Z ret_var = PhantomRouteHints_write(&obj_conv);
25886         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
25887         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
25888         CVec_u8Z_free(ret_var);
25889         return ret_arr;
25890 }
25891
25892 uint32_t  __attribute__((export_name("TS_PhantomRouteHints_read"))) TS_PhantomRouteHints_read(int8_tArray ser) {
25893         LDKu8slice ser_ref;
25894         ser_ref.datalen = ser->arr_len;
25895         ser_ref.data = ser->elems /* XXX ser leaks */;
25896         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
25897         *ret_conv = PhantomRouteHints_read(ser_ref);
25898         return (uint32_t)ret_conv;
25899 }
25900
25901 int8_tArray  __attribute__((export_name("TS_ChannelManager_write"))) TS_ChannelManager_write(uint32_t obj) {
25902         LDKChannelManager obj_conv;
25903         obj_conv.inner = (void*)(obj & (~1));
25904         obj_conv.is_owned = false;
25905         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25906         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
25907         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
25908         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
25909         CVec_u8Z_free(ret_var);
25910         return ret_arr;
25911 }
25912
25913 void  __attribute__((export_name("TS_ChannelManagerReadArgs_free"))) TS_ChannelManagerReadArgs_free(uint32_t this_obj) {
25914         LDKChannelManagerReadArgs this_obj_conv;
25915         this_obj_conv.inner = (void*)(this_obj & (~1));
25916         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25918         ChannelManagerReadArgs_free(this_obj_conv);
25919 }
25920
25921 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_keys_manager"))) TS_ChannelManagerReadArgs_get_keys_manager(uint32_t this_ptr) {
25922         LDKChannelManagerReadArgs this_ptr_conv;
25923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25924         this_ptr_conv.is_owned = false;
25925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25926         // WARNING: This object doesn't live past this scope, needs clone!
25927         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv)) | 1;
25928         return ret_ret;
25929 }
25930
25931 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_keys_manager"))) TS_ChannelManagerReadArgs_set_keys_manager(uint32_t this_ptr, uint32_t val) {
25932         LDKChannelManagerReadArgs this_ptr_conv;
25933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25934         this_ptr_conv.is_owned = false;
25935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25936         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25937         CHECK_ACCESS(val_ptr);
25938         LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
25939         if (val_conv.free == LDKKeysInterface_JCalls_free) {
25940                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25941                 LDKKeysInterface_JCalls_cloned(&val_conv);
25942         }
25943         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
25944 }
25945
25946 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_fee_estimator"))) TS_ChannelManagerReadArgs_get_fee_estimator(uint32_t this_ptr) {
25947         LDKChannelManagerReadArgs this_ptr_conv;
25948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25949         this_ptr_conv.is_owned = false;
25950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25951         // WARNING: This object doesn't live past this scope, needs clone!
25952         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv)) | 1;
25953         return ret_ret;
25954 }
25955
25956 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_fee_estimator"))) TS_ChannelManagerReadArgs_set_fee_estimator(uint32_t this_ptr, uint32_t val) {
25957         LDKChannelManagerReadArgs this_ptr_conv;
25958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25959         this_ptr_conv.is_owned = false;
25960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25961         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25962         CHECK_ACCESS(val_ptr);
25963         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
25964         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
25965                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25966                 LDKFeeEstimator_JCalls_cloned(&val_conv);
25967         }
25968         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
25969 }
25970
25971 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_chain_monitor"))) TS_ChannelManagerReadArgs_get_chain_monitor(uint32_t this_ptr) {
25972         LDKChannelManagerReadArgs this_ptr_conv;
25973         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25974         this_ptr_conv.is_owned = false;
25975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25976         // WARNING: This object doesn't live past this scope, needs clone!
25977         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv)) | 1;
25978         return ret_ret;
25979 }
25980
25981 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_chain_monitor"))) TS_ChannelManagerReadArgs_set_chain_monitor(uint32_t this_ptr, uint32_t val) {
25982         LDKChannelManagerReadArgs this_ptr_conv;
25983         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25984         this_ptr_conv.is_owned = false;
25985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25986         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
25987         CHECK_ACCESS(val_ptr);
25988         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
25989         if (val_conv.free == LDKWatch_JCalls_free) {
25990                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25991                 LDKWatch_JCalls_cloned(&val_conv);
25992         }
25993         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
25994 }
25995
25996 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_tx_broadcaster"))) TS_ChannelManagerReadArgs_get_tx_broadcaster(uint32_t this_ptr) {
25997         LDKChannelManagerReadArgs this_ptr_conv;
25998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25999         this_ptr_conv.is_owned = false;
26000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26001         // WARNING: This object doesn't live past this scope, needs clone!
26002         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv)) | 1;
26003         return ret_ret;
26004 }
26005
26006 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_tx_broadcaster"))) TS_ChannelManagerReadArgs_set_tx_broadcaster(uint32_t this_ptr, uint32_t val) {
26007         LDKChannelManagerReadArgs this_ptr_conv;
26008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26009         this_ptr_conv.is_owned = false;
26010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26011         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26012         CHECK_ACCESS(val_ptr);
26013         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
26014         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
26015                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26016                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
26017         }
26018         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
26019 }
26020
26021 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_logger"))) TS_ChannelManagerReadArgs_get_logger(uint32_t this_ptr) {
26022         LDKChannelManagerReadArgs this_ptr_conv;
26023         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26024         this_ptr_conv.is_owned = false;
26025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26026         // WARNING: This object doesn't live past this scope, needs clone!
26027         uint32_t ret_ret = ((uintptr_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv)) | 1;
26028         return ret_ret;
26029 }
26030
26031 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_logger"))) TS_ChannelManagerReadArgs_set_logger(uint32_t this_ptr, uint32_t val) {
26032         LDKChannelManagerReadArgs this_ptr_conv;
26033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26034         this_ptr_conv.is_owned = false;
26035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26036         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26037         CHECK_ACCESS(val_ptr);
26038         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
26039         if (val_conv.free == LDKLogger_JCalls_free) {
26040                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26041                 LDKLogger_JCalls_cloned(&val_conv);
26042         }
26043         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
26044 }
26045
26046 uint32_t  __attribute__((export_name("TS_ChannelManagerReadArgs_get_default_config"))) TS_ChannelManagerReadArgs_get_default_config(uint32_t this_ptr) {
26047         LDKChannelManagerReadArgs this_ptr_conv;
26048         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26049         this_ptr_conv.is_owned = false;
26050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26051         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
26052         uint32_t ret_ref = 0;
26053         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26054         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26055         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26056         ret_ref = (uintptr_t)ret_var.inner;
26057         if (ret_var.is_owned) {
26058                 ret_ref |= 1;
26059         }
26060         return ret_ref;
26061 }
26062
26063 void  __attribute__((export_name("TS_ChannelManagerReadArgs_set_default_config"))) TS_ChannelManagerReadArgs_set_default_config(uint32_t this_ptr, uint32_t val) {
26064         LDKChannelManagerReadArgs this_ptr_conv;
26065         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26066         this_ptr_conv.is_owned = false;
26067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26068         LDKUserConfig val_conv;
26069         val_conv.inner = (void*)(val & (~1));
26070         val_conv.is_owned = (val & 1) || (val == 0);
26071         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26072         val_conv = UserConfig_clone(&val_conv);
26073         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
26074 }
26075
26076 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) {
26077         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
26078         CHECK_ACCESS(keys_manager_ptr);
26079         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
26080         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
26081                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26082                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
26083         }
26084         void* fee_estimator_ptr = (void*)(((uintptr_t)fee_estimator) & ~1);
26085         CHECK_ACCESS(fee_estimator_ptr);
26086         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
26087         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
26088                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26089                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
26090         }
26091         void* chain_monitor_ptr = (void*)(((uintptr_t)chain_monitor) & ~1);
26092         CHECK_ACCESS(chain_monitor_ptr);
26093         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
26094         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
26095                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26096                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
26097         }
26098         void* tx_broadcaster_ptr = (void*)(((uintptr_t)tx_broadcaster) & ~1);
26099         CHECK_ACCESS(tx_broadcaster_ptr);
26100         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
26101         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
26102                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26103                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
26104         }
26105         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
26106         CHECK_ACCESS(logger_ptr);
26107         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
26108         if (logger_conv.free == LDKLogger_JCalls_free) {
26109                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26110                 LDKLogger_JCalls_cloned(&logger_conv);
26111         }
26112         LDKUserConfig default_config_conv;
26113         default_config_conv.inner = (void*)(default_config & (~1));
26114         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
26115         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
26116         default_config_conv = UserConfig_clone(&default_config_conv);
26117         LDKCVec_ChannelMonitorZ channel_monitors_constr;
26118         channel_monitors_constr.datalen = channel_monitors->arr_len;
26119         if (channel_monitors_constr.datalen > 0)
26120                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
26121         else
26122                 channel_monitors_constr.data = NULL;
26123         uint32_t* channel_monitors_vals = channel_monitors->elems /* XXX channel_monitors leaks */;
26124         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
26125                 uint32_t channel_monitors_conv_16 = channel_monitors_vals[q];
26126                 LDKChannelMonitor channel_monitors_conv_16_conv;
26127                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
26128                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
26129                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
26130                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
26131         }
26132         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);
26133         uint32_t ret_ref = 0;
26134         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26135         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26136         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26137         ret_ref = (uintptr_t)ret_var.inner;
26138         if (ret_var.is_owned) {
26139                 ret_ref |= 1;
26140         }
26141         return ret_ref;
26142 }
26143
26144 uint32_t  __attribute__((export_name("TS_C2Tuple_BlockHashChannelManagerZ_read"))) TS_C2Tuple_BlockHashChannelManagerZ_read(int8_tArray ser, uint32_t arg) {
26145         LDKu8slice ser_ref;
26146         ser_ref.datalen = ser->arr_len;
26147         ser_ref.data = ser->elems /* XXX ser leaks */;
26148         LDKChannelManagerReadArgs arg_conv;
26149         arg_conv.inner = (void*)(arg & (~1));
26150         arg_conv.is_owned = (arg & 1) || (arg == 0);
26151         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26152         // WARNING: we need a move here but no clone is available for LDKChannelManagerReadArgs
26153         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
26154         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
26155         return (uint32_t)ret_conv;
26156 }
26157
26158 void  __attribute__((export_name("TS_DecodeError_free"))) TS_DecodeError_free(uint32_t this_obj) {
26159         LDKDecodeError this_obj_conv;
26160         this_obj_conv.inner = (void*)(this_obj & (~1));
26161         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26163         DecodeError_free(this_obj_conv);
26164 }
26165
26166 static inline uintptr_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
26167         LDKDecodeError ret_var = DecodeError_clone(arg);
26168 uint32_t ret_ref = 0;
26169 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26170 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26171 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26172 ret_ref = (uintptr_t)ret_var.inner;
26173 if (ret_var.is_owned) {
26174         ret_ref |= 1;
26175 }
26176         return ret_ref;
26177 }
26178 uint32_t  __attribute__((export_name("TS_DecodeError_clone_ptr"))) TS_DecodeError_clone_ptr(uint32_t arg) {
26179         LDKDecodeError arg_conv;
26180         arg_conv.inner = (void*)(arg & (~1));
26181         arg_conv.is_owned = false;
26182         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26183         uint32_t ret_conv = DecodeError_clone_ptr(&arg_conv);
26184         return ret_conv;
26185 }
26186
26187 uint32_t  __attribute__((export_name("TS_DecodeError_clone"))) TS_DecodeError_clone(uint32_t orig) {
26188         LDKDecodeError orig_conv;
26189         orig_conv.inner = (void*)(orig & (~1));
26190         orig_conv.is_owned = false;
26191         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26192         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
26193         uint32_t ret_ref = 0;
26194         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26195         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26196         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26197         ret_ref = (uintptr_t)ret_var.inner;
26198         if (ret_var.is_owned) {
26199                 ret_ref |= 1;
26200         }
26201         return ret_ref;
26202 }
26203
26204 void  __attribute__((export_name("TS_Init_free"))) TS_Init_free(uint32_t this_obj) {
26205         LDKInit this_obj_conv;
26206         this_obj_conv.inner = (void*)(this_obj & (~1));
26207         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26209         Init_free(this_obj_conv);
26210 }
26211
26212 uint32_t  __attribute__((export_name("TS_Init_get_features"))) TS_Init_get_features(uint32_t this_ptr) {
26213         LDKInit this_ptr_conv;
26214         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26215         this_ptr_conv.is_owned = false;
26216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26217         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
26218         uint32_t ret_ref = 0;
26219         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26220         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26221         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26222         ret_ref = (uintptr_t)ret_var.inner;
26223         if (ret_var.is_owned) {
26224                 ret_ref |= 1;
26225         }
26226         return ret_ref;
26227 }
26228
26229 void  __attribute__((export_name("TS_Init_set_features"))) TS_Init_set_features(uint32_t this_ptr, uint32_t val) {
26230         LDKInit this_ptr_conv;
26231         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26232         this_ptr_conv.is_owned = false;
26233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26234         LDKInitFeatures val_conv;
26235         val_conv.inner = (void*)(val & (~1));
26236         val_conv.is_owned = (val & 1) || (val == 0);
26237         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26238         val_conv = InitFeatures_clone(&val_conv);
26239         Init_set_features(&this_ptr_conv, val_conv);
26240 }
26241
26242 uint32_t  __attribute__((export_name("TS_Init_get_remote_network_address"))) TS_Init_get_remote_network_address(uint32_t this_ptr) {
26243         LDKInit this_ptr_conv;
26244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26245         this_ptr_conv.is_owned = false;
26246         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26247         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
26248         *ret_copy = Init_get_remote_network_address(&this_ptr_conv);
26249         uint32_t ret_ref = (uintptr_t)ret_copy;
26250         return ret_ref;
26251 }
26252
26253 void  __attribute__((export_name("TS_Init_set_remote_network_address"))) TS_Init_set_remote_network_address(uint32_t this_ptr, uint32_t val) {
26254         LDKInit this_ptr_conv;
26255         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26256         this_ptr_conv.is_owned = false;
26257         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26258         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
26259         CHECK_ACCESS(val_ptr);
26260         LDKCOption_NetAddressZ val_conv = *(LDKCOption_NetAddressZ*)(val_ptr);
26261         val_conv = COption_NetAddressZ_clone((LDKCOption_NetAddressZ*)(((uintptr_t)val) & ~1));
26262         Init_set_remote_network_address(&this_ptr_conv, val_conv);
26263 }
26264
26265 uint32_t  __attribute__((export_name("TS_Init_new"))) TS_Init_new(uint32_t features_arg, uint32_t remote_network_address_arg) {
26266         LDKInitFeatures features_arg_conv;
26267         features_arg_conv.inner = (void*)(features_arg & (~1));
26268         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
26269         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
26270         features_arg_conv = InitFeatures_clone(&features_arg_conv);
26271         void* remote_network_address_arg_ptr = (void*)(((uintptr_t)remote_network_address_arg) & ~1);
26272         CHECK_ACCESS(remote_network_address_arg_ptr);
26273         LDKCOption_NetAddressZ remote_network_address_arg_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_arg_ptr);
26274         LDKInit ret_var = Init_new(features_arg_conv, remote_network_address_arg_conv);
26275         uint32_t ret_ref = 0;
26276         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26277         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26278         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26279         ret_ref = (uintptr_t)ret_var.inner;
26280         if (ret_var.is_owned) {
26281                 ret_ref |= 1;
26282         }
26283         return ret_ref;
26284 }
26285
26286 static inline uintptr_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
26287         LDKInit ret_var = Init_clone(arg);
26288 uint32_t ret_ref = 0;
26289 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26290 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26291 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26292 ret_ref = (uintptr_t)ret_var.inner;
26293 if (ret_var.is_owned) {
26294         ret_ref |= 1;
26295 }
26296         return ret_ref;
26297 }
26298 uint32_t  __attribute__((export_name("TS_Init_clone_ptr"))) TS_Init_clone_ptr(uint32_t arg) {
26299         LDKInit arg_conv;
26300         arg_conv.inner = (void*)(arg & (~1));
26301         arg_conv.is_owned = false;
26302         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26303         uint32_t ret_conv = Init_clone_ptr(&arg_conv);
26304         return ret_conv;
26305 }
26306
26307 uint32_t  __attribute__((export_name("TS_Init_clone"))) TS_Init_clone(uint32_t orig) {
26308         LDKInit orig_conv;
26309         orig_conv.inner = (void*)(orig & (~1));
26310         orig_conv.is_owned = false;
26311         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26312         LDKInit ret_var = Init_clone(&orig_conv);
26313         uint32_t ret_ref = 0;
26314         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26315         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26316         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26317         ret_ref = (uintptr_t)ret_var.inner;
26318         if (ret_var.is_owned) {
26319                 ret_ref |= 1;
26320         }
26321         return ret_ref;
26322 }
26323
26324 void  __attribute__((export_name("TS_ErrorMessage_free"))) TS_ErrorMessage_free(uint32_t this_obj) {
26325         LDKErrorMessage this_obj_conv;
26326         this_obj_conv.inner = (void*)(this_obj & (~1));
26327         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26329         ErrorMessage_free(this_obj_conv);
26330 }
26331
26332 int8_tArray  __attribute__((export_name("TS_ErrorMessage_get_channel_id"))) TS_ErrorMessage_get_channel_id(uint32_t this_ptr) {
26333         LDKErrorMessage this_ptr_conv;
26334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26335         this_ptr_conv.is_owned = false;
26336         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26337         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26338         memcpy(ret_arr->elems, *ErrorMessage_get_channel_id(&this_ptr_conv), 32);
26339         return ret_arr;
26340 }
26341
26342 void  __attribute__((export_name("TS_ErrorMessage_set_channel_id"))) TS_ErrorMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
26343         LDKErrorMessage this_ptr_conv;
26344         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26345         this_ptr_conv.is_owned = false;
26346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26347         LDKThirtyTwoBytes val_ref;
26348         CHECK(val->arr_len == 32);
26349         memcpy(val_ref.data, val->elems, 32); FREE(val);
26350         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
26351 }
26352
26353 jstring  __attribute__((export_name("TS_ErrorMessage_get_data"))) TS_ErrorMessage_get_data(uint32_t this_ptr) {
26354         LDKErrorMessage this_ptr_conv;
26355         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26356         this_ptr_conv.is_owned = false;
26357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26358         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
26359         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
26360         Str_free(ret_str);
26361         return ret_conv;
26362 }
26363
26364 void  __attribute__((export_name("TS_ErrorMessage_set_data"))) TS_ErrorMessage_set_data(uint32_t this_ptr, jstring val) {
26365         LDKErrorMessage this_ptr_conv;
26366         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26367         this_ptr_conv.is_owned = false;
26368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26369         LDKStr val_conv = str_ref_to_owned_c(val);
26370         ErrorMessage_set_data(&this_ptr_conv, val_conv);
26371 }
26372
26373 uint32_t  __attribute__((export_name("TS_ErrorMessage_new"))) TS_ErrorMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
26374         LDKThirtyTwoBytes channel_id_arg_ref;
26375         CHECK(channel_id_arg->arr_len == 32);
26376         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
26377         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
26378         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
26379         uint32_t ret_ref = 0;
26380         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26381         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26382         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26383         ret_ref = (uintptr_t)ret_var.inner;
26384         if (ret_var.is_owned) {
26385                 ret_ref |= 1;
26386         }
26387         return ret_ref;
26388 }
26389
26390 static inline uintptr_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
26391         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
26392 uint32_t ret_ref = 0;
26393 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26394 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26395 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26396 ret_ref = (uintptr_t)ret_var.inner;
26397 if (ret_var.is_owned) {
26398         ret_ref |= 1;
26399 }
26400         return ret_ref;
26401 }
26402 uint32_t  __attribute__((export_name("TS_ErrorMessage_clone_ptr"))) TS_ErrorMessage_clone_ptr(uint32_t arg) {
26403         LDKErrorMessage arg_conv;
26404         arg_conv.inner = (void*)(arg & (~1));
26405         arg_conv.is_owned = false;
26406         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26407         uint32_t ret_conv = ErrorMessage_clone_ptr(&arg_conv);
26408         return ret_conv;
26409 }
26410
26411 uint32_t  __attribute__((export_name("TS_ErrorMessage_clone"))) TS_ErrorMessage_clone(uint32_t orig) {
26412         LDKErrorMessage orig_conv;
26413         orig_conv.inner = (void*)(orig & (~1));
26414         orig_conv.is_owned = false;
26415         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26416         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
26417         uint32_t ret_ref = 0;
26418         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26419         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26420         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26421         ret_ref = (uintptr_t)ret_var.inner;
26422         if (ret_var.is_owned) {
26423                 ret_ref |= 1;
26424         }
26425         return ret_ref;
26426 }
26427
26428 void  __attribute__((export_name("TS_WarningMessage_free"))) TS_WarningMessage_free(uint32_t this_obj) {
26429         LDKWarningMessage this_obj_conv;
26430         this_obj_conv.inner = (void*)(this_obj & (~1));
26431         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26433         WarningMessage_free(this_obj_conv);
26434 }
26435
26436 int8_tArray  __attribute__((export_name("TS_WarningMessage_get_channel_id"))) TS_WarningMessage_get_channel_id(uint32_t this_ptr) {
26437         LDKWarningMessage this_ptr_conv;
26438         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26439         this_ptr_conv.is_owned = false;
26440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26441         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26442         memcpy(ret_arr->elems, *WarningMessage_get_channel_id(&this_ptr_conv), 32);
26443         return ret_arr;
26444 }
26445
26446 void  __attribute__((export_name("TS_WarningMessage_set_channel_id"))) TS_WarningMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
26447         LDKWarningMessage this_ptr_conv;
26448         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26449         this_ptr_conv.is_owned = false;
26450         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26451         LDKThirtyTwoBytes val_ref;
26452         CHECK(val->arr_len == 32);
26453         memcpy(val_ref.data, val->elems, 32); FREE(val);
26454         WarningMessage_set_channel_id(&this_ptr_conv, val_ref);
26455 }
26456
26457 jstring  __attribute__((export_name("TS_WarningMessage_get_data"))) TS_WarningMessage_get_data(uint32_t this_ptr) {
26458         LDKWarningMessage this_ptr_conv;
26459         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26460         this_ptr_conv.is_owned = false;
26461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26462         LDKStr ret_str = WarningMessage_get_data(&this_ptr_conv);
26463         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
26464         Str_free(ret_str);
26465         return ret_conv;
26466 }
26467
26468 void  __attribute__((export_name("TS_WarningMessage_set_data"))) TS_WarningMessage_set_data(uint32_t this_ptr, jstring val) {
26469         LDKWarningMessage this_ptr_conv;
26470         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26471         this_ptr_conv.is_owned = false;
26472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26473         LDKStr val_conv = str_ref_to_owned_c(val);
26474         WarningMessage_set_data(&this_ptr_conv, val_conv);
26475 }
26476
26477 uint32_t  __attribute__((export_name("TS_WarningMessage_new"))) TS_WarningMessage_new(int8_tArray channel_id_arg, jstring data_arg) {
26478         LDKThirtyTwoBytes channel_id_arg_ref;
26479         CHECK(channel_id_arg->arr_len == 32);
26480         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
26481         LDKStr data_arg_conv = str_ref_to_owned_c(data_arg);
26482         LDKWarningMessage ret_var = WarningMessage_new(channel_id_arg_ref, data_arg_conv);
26483         uint32_t ret_ref = 0;
26484         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26485         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26486         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26487         ret_ref = (uintptr_t)ret_var.inner;
26488         if (ret_var.is_owned) {
26489                 ret_ref |= 1;
26490         }
26491         return ret_ref;
26492 }
26493
26494 static inline uintptr_t WarningMessage_clone_ptr(LDKWarningMessage *NONNULL_PTR arg) {
26495         LDKWarningMessage ret_var = WarningMessage_clone(arg);
26496 uint32_t ret_ref = 0;
26497 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26498 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26499 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26500 ret_ref = (uintptr_t)ret_var.inner;
26501 if (ret_var.is_owned) {
26502         ret_ref |= 1;
26503 }
26504         return ret_ref;
26505 }
26506 uint32_t  __attribute__((export_name("TS_WarningMessage_clone_ptr"))) TS_WarningMessage_clone_ptr(uint32_t arg) {
26507         LDKWarningMessage arg_conv;
26508         arg_conv.inner = (void*)(arg & (~1));
26509         arg_conv.is_owned = false;
26510         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26511         uint32_t ret_conv = WarningMessage_clone_ptr(&arg_conv);
26512         return ret_conv;
26513 }
26514
26515 uint32_t  __attribute__((export_name("TS_WarningMessage_clone"))) TS_WarningMessage_clone(uint32_t orig) {
26516         LDKWarningMessage orig_conv;
26517         orig_conv.inner = (void*)(orig & (~1));
26518         orig_conv.is_owned = false;
26519         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26520         LDKWarningMessage ret_var = WarningMessage_clone(&orig_conv);
26521         uint32_t ret_ref = 0;
26522         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26523         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26524         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26525         ret_ref = (uintptr_t)ret_var.inner;
26526         if (ret_var.is_owned) {
26527                 ret_ref |= 1;
26528         }
26529         return ret_ref;
26530 }
26531
26532 void  __attribute__((export_name("TS_Ping_free"))) TS_Ping_free(uint32_t this_obj) {
26533         LDKPing this_obj_conv;
26534         this_obj_conv.inner = (void*)(this_obj & (~1));
26535         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26537         Ping_free(this_obj_conv);
26538 }
26539
26540 int16_t  __attribute__((export_name("TS_Ping_get_ponglen"))) TS_Ping_get_ponglen(uint32_t this_ptr) {
26541         LDKPing this_ptr_conv;
26542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26543         this_ptr_conv.is_owned = false;
26544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26545         int16_t ret_conv = Ping_get_ponglen(&this_ptr_conv);
26546         return ret_conv;
26547 }
26548
26549 void  __attribute__((export_name("TS_Ping_set_ponglen"))) TS_Ping_set_ponglen(uint32_t this_ptr, int16_t val) {
26550         LDKPing this_ptr_conv;
26551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26552         this_ptr_conv.is_owned = false;
26553         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26554         Ping_set_ponglen(&this_ptr_conv, val);
26555 }
26556
26557 int16_t  __attribute__((export_name("TS_Ping_get_byteslen"))) TS_Ping_get_byteslen(uint32_t this_ptr) {
26558         LDKPing this_ptr_conv;
26559         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26560         this_ptr_conv.is_owned = false;
26561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26562         int16_t ret_conv = Ping_get_byteslen(&this_ptr_conv);
26563         return ret_conv;
26564 }
26565
26566 void  __attribute__((export_name("TS_Ping_set_byteslen"))) TS_Ping_set_byteslen(uint32_t this_ptr, int16_t val) {
26567         LDKPing this_ptr_conv;
26568         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26569         this_ptr_conv.is_owned = false;
26570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26571         Ping_set_byteslen(&this_ptr_conv, val);
26572 }
26573
26574 uint32_t  __attribute__((export_name("TS_Ping_new"))) TS_Ping_new(int16_t ponglen_arg, int16_t byteslen_arg) {
26575         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
26576         uint32_t ret_ref = 0;
26577         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26578         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26579         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26580         ret_ref = (uintptr_t)ret_var.inner;
26581         if (ret_var.is_owned) {
26582                 ret_ref |= 1;
26583         }
26584         return ret_ref;
26585 }
26586
26587 static inline uintptr_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
26588         LDKPing ret_var = Ping_clone(arg);
26589 uint32_t ret_ref = 0;
26590 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26591 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26592 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26593 ret_ref = (uintptr_t)ret_var.inner;
26594 if (ret_var.is_owned) {
26595         ret_ref |= 1;
26596 }
26597         return ret_ref;
26598 }
26599 uint32_t  __attribute__((export_name("TS_Ping_clone_ptr"))) TS_Ping_clone_ptr(uint32_t arg) {
26600         LDKPing arg_conv;
26601         arg_conv.inner = (void*)(arg & (~1));
26602         arg_conv.is_owned = false;
26603         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26604         uint32_t ret_conv = Ping_clone_ptr(&arg_conv);
26605         return ret_conv;
26606 }
26607
26608 uint32_t  __attribute__((export_name("TS_Ping_clone"))) TS_Ping_clone(uint32_t orig) {
26609         LDKPing orig_conv;
26610         orig_conv.inner = (void*)(orig & (~1));
26611         orig_conv.is_owned = false;
26612         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26613         LDKPing ret_var = Ping_clone(&orig_conv);
26614         uint32_t ret_ref = 0;
26615         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26616         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26617         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26618         ret_ref = (uintptr_t)ret_var.inner;
26619         if (ret_var.is_owned) {
26620                 ret_ref |= 1;
26621         }
26622         return ret_ref;
26623 }
26624
26625 void  __attribute__((export_name("TS_Pong_free"))) TS_Pong_free(uint32_t this_obj) {
26626         LDKPong this_obj_conv;
26627         this_obj_conv.inner = (void*)(this_obj & (~1));
26628         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26630         Pong_free(this_obj_conv);
26631 }
26632
26633 int16_t  __attribute__((export_name("TS_Pong_get_byteslen"))) TS_Pong_get_byteslen(uint32_t this_ptr) {
26634         LDKPong this_ptr_conv;
26635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26636         this_ptr_conv.is_owned = false;
26637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26638         int16_t ret_conv = Pong_get_byteslen(&this_ptr_conv);
26639         return ret_conv;
26640 }
26641
26642 void  __attribute__((export_name("TS_Pong_set_byteslen"))) TS_Pong_set_byteslen(uint32_t this_ptr, int16_t val) {
26643         LDKPong this_ptr_conv;
26644         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26645         this_ptr_conv.is_owned = false;
26646         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26647         Pong_set_byteslen(&this_ptr_conv, val);
26648 }
26649
26650 uint32_t  __attribute__((export_name("TS_Pong_new"))) TS_Pong_new(int16_t byteslen_arg) {
26651         LDKPong ret_var = Pong_new(byteslen_arg);
26652         uint32_t ret_ref = 0;
26653         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26654         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26655         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26656         ret_ref = (uintptr_t)ret_var.inner;
26657         if (ret_var.is_owned) {
26658                 ret_ref |= 1;
26659         }
26660         return ret_ref;
26661 }
26662
26663 static inline uintptr_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
26664         LDKPong ret_var = Pong_clone(arg);
26665 uint32_t ret_ref = 0;
26666 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26667 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26668 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26669 ret_ref = (uintptr_t)ret_var.inner;
26670 if (ret_var.is_owned) {
26671         ret_ref |= 1;
26672 }
26673         return ret_ref;
26674 }
26675 uint32_t  __attribute__((export_name("TS_Pong_clone_ptr"))) TS_Pong_clone_ptr(uint32_t arg) {
26676         LDKPong arg_conv;
26677         arg_conv.inner = (void*)(arg & (~1));
26678         arg_conv.is_owned = false;
26679         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26680         uint32_t ret_conv = Pong_clone_ptr(&arg_conv);
26681         return ret_conv;
26682 }
26683
26684 uint32_t  __attribute__((export_name("TS_Pong_clone"))) TS_Pong_clone(uint32_t orig) {
26685         LDKPong orig_conv;
26686         orig_conv.inner = (void*)(orig & (~1));
26687         orig_conv.is_owned = false;
26688         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26689         LDKPong ret_var = Pong_clone(&orig_conv);
26690         uint32_t ret_ref = 0;
26691         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26692         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26693         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26694         ret_ref = (uintptr_t)ret_var.inner;
26695         if (ret_var.is_owned) {
26696                 ret_ref |= 1;
26697         }
26698         return ret_ref;
26699 }
26700
26701 void  __attribute__((export_name("TS_OpenChannel_free"))) TS_OpenChannel_free(uint32_t this_obj) {
26702         LDKOpenChannel this_obj_conv;
26703         this_obj_conv.inner = (void*)(this_obj & (~1));
26704         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26706         OpenChannel_free(this_obj_conv);
26707 }
26708
26709 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_chain_hash"))) TS_OpenChannel_get_chain_hash(uint32_t this_ptr) {
26710         LDKOpenChannel this_ptr_conv;
26711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26712         this_ptr_conv.is_owned = false;
26713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26714         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26715         memcpy(ret_arr->elems, *OpenChannel_get_chain_hash(&this_ptr_conv), 32);
26716         return ret_arr;
26717 }
26718
26719 void  __attribute__((export_name("TS_OpenChannel_set_chain_hash"))) TS_OpenChannel_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
26720         LDKOpenChannel this_ptr_conv;
26721         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26722         this_ptr_conv.is_owned = false;
26723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26724         LDKThirtyTwoBytes val_ref;
26725         CHECK(val->arr_len == 32);
26726         memcpy(val_ref.data, val->elems, 32); FREE(val);
26727         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
26728 }
26729
26730 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_temporary_channel_id"))) TS_OpenChannel_get_temporary_channel_id(uint32_t this_ptr) {
26731         LDKOpenChannel this_ptr_conv;
26732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26733         this_ptr_conv.is_owned = false;
26734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26735         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
26736         memcpy(ret_arr->elems, *OpenChannel_get_temporary_channel_id(&this_ptr_conv), 32);
26737         return ret_arr;
26738 }
26739
26740 void  __attribute__((export_name("TS_OpenChannel_set_temporary_channel_id"))) TS_OpenChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
26741         LDKOpenChannel this_ptr_conv;
26742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26743         this_ptr_conv.is_owned = false;
26744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26745         LDKThirtyTwoBytes val_ref;
26746         CHECK(val->arr_len == 32);
26747         memcpy(val_ref.data, val->elems, 32); FREE(val);
26748         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
26749 }
26750
26751 int64_t  __attribute__((export_name("TS_OpenChannel_get_funding_satoshis"))) TS_OpenChannel_get_funding_satoshis(uint32_t this_ptr) {
26752         LDKOpenChannel this_ptr_conv;
26753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26754         this_ptr_conv.is_owned = false;
26755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26756         int64_t ret_conv = OpenChannel_get_funding_satoshis(&this_ptr_conv);
26757         return ret_conv;
26758 }
26759
26760 void  __attribute__((export_name("TS_OpenChannel_set_funding_satoshis"))) TS_OpenChannel_set_funding_satoshis(uint32_t this_ptr, int64_t val) {
26761         LDKOpenChannel this_ptr_conv;
26762         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26763         this_ptr_conv.is_owned = false;
26764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26765         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
26766 }
26767
26768 int64_t  __attribute__((export_name("TS_OpenChannel_get_push_msat"))) TS_OpenChannel_get_push_msat(uint32_t this_ptr) {
26769         LDKOpenChannel this_ptr_conv;
26770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26771         this_ptr_conv.is_owned = false;
26772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26773         int64_t ret_conv = OpenChannel_get_push_msat(&this_ptr_conv);
26774         return ret_conv;
26775 }
26776
26777 void  __attribute__((export_name("TS_OpenChannel_set_push_msat"))) TS_OpenChannel_set_push_msat(uint32_t this_ptr, int64_t val) {
26778         LDKOpenChannel this_ptr_conv;
26779         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26780         this_ptr_conv.is_owned = false;
26781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26782         OpenChannel_set_push_msat(&this_ptr_conv, val);
26783 }
26784
26785 int64_t  __attribute__((export_name("TS_OpenChannel_get_dust_limit_satoshis"))) TS_OpenChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
26786         LDKOpenChannel this_ptr_conv;
26787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26788         this_ptr_conv.is_owned = false;
26789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26790         int64_t ret_conv = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
26791         return ret_conv;
26792 }
26793
26794 void  __attribute__((export_name("TS_OpenChannel_set_dust_limit_satoshis"))) TS_OpenChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
26795         LDKOpenChannel this_ptr_conv;
26796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26797         this_ptr_conv.is_owned = false;
26798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26799         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
26800 }
26801
26802 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) {
26803         LDKOpenChannel this_ptr_conv;
26804         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26805         this_ptr_conv.is_owned = false;
26806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26807         int64_t ret_conv = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
26808         return ret_conv;
26809 }
26810
26811 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) {
26812         LDKOpenChannel this_ptr_conv;
26813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26814         this_ptr_conv.is_owned = false;
26815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26816         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
26817 }
26818
26819 int64_t  __attribute__((export_name("TS_OpenChannel_get_channel_reserve_satoshis"))) TS_OpenChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
26820         LDKOpenChannel this_ptr_conv;
26821         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26822         this_ptr_conv.is_owned = false;
26823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26824         int64_t ret_conv = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
26825         return ret_conv;
26826 }
26827
26828 void  __attribute__((export_name("TS_OpenChannel_set_channel_reserve_satoshis"))) TS_OpenChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
26829         LDKOpenChannel this_ptr_conv;
26830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26831         this_ptr_conv.is_owned = false;
26832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26833         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
26834 }
26835
26836 int64_t  __attribute__((export_name("TS_OpenChannel_get_htlc_minimum_msat"))) TS_OpenChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
26837         LDKOpenChannel this_ptr_conv;
26838         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26839         this_ptr_conv.is_owned = false;
26840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26841         int64_t ret_conv = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
26842         return ret_conv;
26843 }
26844
26845 void  __attribute__((export_name("TS_OpenChannel_set_htlc_minimum_msat"))) TS_OpenChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
26846         LDKOpenChannel this_ptr_conv;
26847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26848         this_ptr_conv.is_owned = false;
26849         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26850         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
26851 }
26852
26853 int32_t  __attribute__((export_name("TS_OpenChannel_get_feerate_per_kw"))) TS_OpenChannel_get_feerate_per_kw(uint32_t this_ptr) {
26854         LDKOpenChannel this_ptr_conv;
26855         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26856         this_ptr_conv.is_owned = false;
26857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26858         int32_t ret_conv = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
26859         return ret_conv;
26860 }
26861
26862 void  __attribute__((export_name("TS_OpenChannel_set_feerate_per_kw"))) TS_OpenChannel_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
26863         LDKOpenChannel this_ptr_conv;
26864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26865         this_ptr_conv.is_owned = false;
26866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26867         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
26868 }
26869
26870 int16_t  __attribute__((export_name("TS_OpenChannel_get_to_self_delay"))) TS_OpenChannel_get_to_self_delay(uint32_t this_ptr) {
26871         LDKOpenChannel this_ptr_conv;
26872         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26873         this_ptr_conv.is_owned = false;
26874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26875         int16_t ret_conv = OpenChannel_get_to_self_delay(&this_ptr_conv);
26876         return ret_conv;
26877 }
26878
26879 void  __attribute__((export_name("TS_OpenChannel_set_to_self_delay"))) TS_OpenChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
26880         LDKOpenChannel this_ptr_conv;
26881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26882         this_ptr_conv.is_owned = false;
26883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26884         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
26885 }
26886
26887 int16_t  __attribute__((export_name("TS_OpenChannel_get_max_accepted_htlcs"))) TS_OpenChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
26888         LDKOpenChannel this_ptr_conv;
26889         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26890         this_ptr_conv.is_owned = false;
26891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26892         int16_t ret_conv = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
26893         return ret_conv;
26894 }
26895
26896 void  __attribute__((export_name("TS_OpenChannel_set_max_accepted_htlcs"))) TS_OpenChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
26897         LDKOpenChannel this_ptr_conv;
26898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26899         this_ptr_conv.is_owned = false;
26900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26901         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
26902 }
26903
26904 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_funding_pubkey"))) TS_OpenChannel_get_funding_pubkey(uint32_t this_ptr) {
26905         LDKOpenChannel this_ptr_conv;
26906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26907         this_ptr_conv.is_owned = false;
26908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26909         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26910         memcpy(ret_arr->elems, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
26911         return ret_arr;
26912 }
26913
26914 void  __attribute__((export_name("TS_OpenChannel_set_funding_pubkey"))) TS_OpenChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
26915         LDKOpenChannel this_ptr_conv;
26916         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26917         this_ptr_conv.is_owned = false;
26918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26919         LDKPublicKey val_ref;
26920         CHECK(val->arr_len == 33);
26921         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26922         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
26923 }
26924
26925 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_revocation_basepoint"))) TS_OpenChannel_get_revocation_basepoint(uint32_t this_ptr) {
26926         LDKOpenChannel this_ptr_conv;
26927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26928         this_ptr_conv.is_owned = false;
26929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26930         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26931         memcpy(ret_arr->elems, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
26932         return ret_arr;
26933 }
26934
26935 void  __attribute__((export_name("TS_OpenChannel_set_revocation_basepoint"))) TS_OpenChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
26936         LDKOpenChannel this_ptr_conv;
26937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26938         this_ptr_conv.is_owned = false;
26939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26940         LDKPublicKey val_ref;
26941         CHECK(val->arr_len == 33);
26942         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26943         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
26944 }
26945
26946 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_payment_point"))) TS_OpenChannel_get_payment_point(uint32_t this_ptr) {
26947         LDKOpenChannel this_ptr_conv;
26948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26949         this_ptr_conv.is_owned = false;
26950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26951         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26952         memcpy(ret_arr->elems, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
26953         return ret_arr;
26954 }
26955
26956 void  __attribute__((export_name("TS_OpenChannel_set_payment_point"))) TS_OpenChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
26957         LDKOpenChannel this_ptr_conv;
26958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26959         this_ptr_conv.is_owned = false;
26960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26961         LDKPublicKey val_ref;
26962         CHECK(val->arr_len == 33);
26963         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26964         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
26965 }
26966
26967 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_delayed_payment_basepoint"))) TS_OpenChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
26968         LDKOpenChannel this_ptr_conv;
26969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26970         this_ptr_conv.is_owned = false;
26971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26972         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26973         memcpy(ret_arr->elems, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
26974         return ret_arr;
26975 }
26976
26977 void  __attribute__((export_name("TS_OpenChannel_set_delayed_payment_basepoint"))) TS_OpenChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
26978         LDKOpenChannel this_ptr_conv;
26979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26980         this_ptr_conv.is_owned = false;
26981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26982         LDKPublicKey val_ref;
26983         CHECK(val->arr_len == 33);
26984         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
26985         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
26986 }
26987
26988 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_htlc_basepoint"))) TS_OpenChannel_get_htlc_basepoint(uint32_t this_ptr) {
26989         LDKOpenChannel this_ptr_conv;
26990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26991         this_ptr_conv.is_owned = false;
26992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26993         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
26994         memcpy(ret_arr->elems, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
26995         return ret_arr;
26996 }
26997
26998 void  __attribute__((export_name("TS_OpenChannel_set_htlc_basepoint"))) TS_OpenChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
26999         LDKOpenChannel this_ptr_conv;
27000         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27001         this_ptr_conv.is_owned = false;
27002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27003         LDKPublicKey val_ref;
27004         CHECK(val->arr_len == 33);
27005         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
27006         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
27007 }
27008
27009 int8_tArray  __attribute__((export_name("TS_OpenChannel_get_first_per_commitment_point"))) TS_OpenChannel_get_first_per_commitment_point(uint32_t this_ptr) {
27010         LDKOpenChannel this_ptr_conv;
27011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27012         this_ptr_conv.is_owned = false;
27013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27014         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
27015         memcpy(ret_arr->elems, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
27016         return ret_arr;
27017 }
27018
27019 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) {
27020         LDKOpenChannel this_ptr_conv;
27021         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27022         this_ptr_conv.is_owned = false;
27023         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27024         LDKPublicKey val_ref;
27025         CHECK(val->arr_len == 33);
27026         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
27027         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
27028 }
27029
27030 int8_t  __attribute__((export_name("TS_OpenChannel_get_channel_flags"))) TS_OpenChannel_get_channel_flags(uint32_t this_ptr) {
27031         LDKOpenChannel this_ptr_conv;
27032         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27033         this_ptr_conv.is_owned = false;
27034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27035         int8_t ret_conv = OpenChannel_get_channel_flags(&this_ptr_conv);
27036         return ret_conv;
27037 }
27038
27039 void  __attribute__((export_name("TS_OpenChannel_set_channel_flags"))) TS_OpenChannel_set_channel_flags(uint32_t this_ptr, int8_t val) {
27040         LDKOpenChannel this_ptr_conv;
27041         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27042         this_ptr_conv.is_owned = false;
27043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27044         OpenChannel_set_channel_flags(&this_ptr_conv, val);
27045 }
27046
27047 uint32_t  __attribute__((export_name("TS_OpenChannel_get_channel_type"))) TS_OpenChannel_get_channel_type(uint32_t this_ptr) {
27048         LDKOpenChannel this_ptr_conv;
27049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27050         this_ptr_conv.is_owned = false;
27051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27052         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
27053         uint32_t ret_ref = 0;
27054         if ((uintptr_t)ret_var.inner > 4096) {
27055                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27056                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27057         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27058                 ret_ref = (uintptr_t)ret_var.inner;
27059                 if (ret_var.is_owned) {
27060                         ret_ref |= 1;
27061                 }
27062         }
27063         return ret_ref;
27064 }
27065
27066 void  __attribute__((export_name("TS_OpenChannel_set_channel_type"))) TS_OpenChannel_set_channel_type(uint32_t this_ptr, uint32_t val) {
27067         LDKOpenChannel this_ptr_conv;
27068         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27069         this_ptr_conv.is_owned = false;
27070         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27071         LDKChannelTypeFeatures val_conv;
27072         val_conv.inner = (void*)(val & (~1));
27073         val_conv.is_owned = (val & 1) || (val == 0);
27074         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27075         val_conv = ChannelTypeFeatures_clone(&val_conv);
27076         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
27077 }
27078
27079 static inline uintptr_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
27080         LDKOpenChannel ret_var = OpenChannel_clone(arg);
27081 uint32_t ret_ref = 0;
27082 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27083 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27084 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27085 ret_ref = (uintptr_t)ret_var.inner;
27086 if (ret_var.is_owned) {
27087         ret_ref |= 1;
27088 }
27089         return ret_ref;
27090 }
27091 uint32_t  __attribute__((export_name("TS_OpenChannel_clone_ptr"))) TS_OpenChannel_clone_ptr(uint32_t arg) {
27092         LDKOpenChannel arg_conv;
27093         arg_conv.inner = (void*)(arg & (~1));
27094         arg_conv.is_owned = false;
27095         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27096         uint32_t ret_conv = OpenChannel_clone_ptr(&arg_conv);
27097         return ret_conv;
27098 }
27099
27100 uint32_t  __attribute__((export_name("TS_OpenChannel_clone"))) TS_OpenChannel_clone(uint32_t orig) {
27101         LDKOpenChannel orig_conv;
27102         orig_conv.inner = (void*)(orig & (~1));
27103         orig_conv.is_owned = false;
27104         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27105         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
27106         uint32_t ret_ref = 0;
27107         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27108         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27109         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27110         ret_ref = (uintptr_t)ret_var.inner;
27111         if (ret_var.is_owned) {
27112                 ret_ref |= 1;
27113         }
27114         return ret_ref;
27115 }
27116
27117 void  __attribute__((export_name("TS_AcceptChannel_free"))) TS_AcceptChannel_free(uint32_t this_obj) {
27118         LDKAcceptChannel this_obj_conv;
27119         this_obj_conv.inner = (void*)(this_obj & (~1));
27120         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27122         AcceptChannel_free(this_obj_conv);
27123 }
27124
27125 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_temporary_channel_id"))) TS_AcceptChannel_get_temporary_channel_id(uint32_t this_ptr) {
27126         LDKAcceptChannel this_ptr_conv;
27127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27128         this_ptr_conv.is_owned = false;
27129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27130         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27131         memcpy(ret_arr->elems, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv), 32);
27132         return ret_arr;
27133 }
27134
27135 void  __attribute__((export_name("TS_AcceptChannel_set_temporary_channel_id"))) TS_AcceptChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
27136         LDKAcceptChannel this_ptr_conv;
27137         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27138         this_ptr_conv.is_owned = false;
27139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27140         LDKThirtyTwoBytes val_ref;
27141         CHECK(val->arr_len == 32);
27142         memcpy(val_ref.data, val->elems, 32); FREE(val);
27143         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
27144 }
27145
27146 int64_t  __attribute__((export_name("TS_AcceptChannel_get_dust_limit_satoshis"))) TS_AcceptChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
27147         LDKAcceptChannel this_ptr_conv;
27148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27149         this_ptr_conv.is_owned = false;
27150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27151         int64_t ret_conv = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
27152         return ret_conv;
27153 }
27154
27155 void  __attribute__((export_name("TS_AcceptChannel_set_dust_limit_satoshis"))) TS_AcceptChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
27156         LDKAcceptChannel this_ptr_conv;
27157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27158         this_ptr_conv.is_owned = false;
27159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27160         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
27161 }
27162
27163 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) {
27164         LDKAcceptChannel this_ptr_conv;
27165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27166         this_ptr_conv.is_owned = false;
27167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27168         int64_t ret_conv = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
27169         return ret_conv;
27170 }
27171
27172 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) {
27173         LDKAcceptChannel this_ptr_conv;
27174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27175         this_ptr_conv.is_owned = false;
27176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27177         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
27178 }
27179
27180 int64_t  __attribute__((export_name("TS_AcceptChannel_get_channel_reserve_satoshis"))) TS_AcceptChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
27181         LDKAcceptChannel this_ptr_conv;
27182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27183         this_ptr_conv.is_owned = false;
27184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27185         int64_t ret_conv = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
27186         return ret_conv;
27187 }
27188
27189 void  __attribute__((export_name("TS_AcceptChannel_set_channel_reserve_satoshis"))) TS_AcceptChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
27190         LDKAcceptChannel this_ptr_conv;
27191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27192         this_ptr_conv.is_owned = false;
27193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27194         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
27195 }
27196
27197 int64_t  __attribute__((export_name("TS_AcceptChannel_get_htlc_minimum_msat"))) TS_AcceptChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
27198         LDKAcceptChannel this_ptr_conv;
27199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27200         this_ptr_conv.is_owned = false;
27201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27202         int64_t ret_conv = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
27203         return ret_conv;
27204 }
27205
27206 void  __attribute__((export_name("TS_AcceptChannel_set_htlc_minimum_msat"))) TS_AcceptChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
27207         LDKAcceptChannel this_ptr_conv;
27208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27209         this_ptr_conv.is_owned = false;
27210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27211         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
27212 }
27213
27214 int32_t  __attribute__((export_name("TS_AcceptChannel_get_minimum_depth"))) TS_AcceptChannel_get_minimum_depth(uint32_t this_ptr) {
27215         LDKAcceptChannel this_ptr_conv;
27216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27217         this_ptr_conv.is_owned = false;
27218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27219         int32_t ret_conv = AcceptChannel_get_minimum_depth(&this_ptr_conv);
27220         return ret_conv;
27221 }
27222
27223 void  __attribute__((export_name("TS_AcceptChannel_set_minimum_depth"))) TS_AcceptChannel_set_minimum_depth(uint32_t this_ptr, int32_t val) {
27224         LDKAcceptChannel this_ptr_conv;
27225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27226         this_ptr_conv.is_owned = false;
27227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27228         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
27229 }
27230
27231 int16_t  __attribute__((export_name("TS_AcceptChannel_get_to_self_delay"))) TS_AcceptChannel_get_to_self_delay(uint32_t this_ptr) {
27232         LDKAcceptChannel this_ptr_conv;
27233         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27234         this_ptr_conv.is_owned = false;
27235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27236         int16_t ret_conv = AcceptChannel_get_to_self_delay(&this_ptr_conv);
27237         return ret_conv;
27238 }
27239
27240 void  __attribute__((export_name("TS_AcceptChannel_set_to_self_delay"))) TS_AcceptChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
27241         LDKAcceptChannel this_ptr_conv;
27242         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27243         this_ptr_conv.is_owned = false;
27244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27245         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
27246 }
27247
27248 int16_t  __attribute__((export_name("TS_AcceptChannel_get_max_accepted_htlcs"))) TS_AcceptChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
27249         LDKAcceptChannel this_ptr_conv;
27250         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27251         this_ptr_conv.is_owned = false;
27252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27253         int16_t ret_conv = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
27254         return ret_conv;
27255 }
27256
27257 void  __attribute__((export_name("TS_AcceptChannel_set_max_accepted_htlcs"))) TS_AcceptChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
27258         LDKAcceptChannel this_ptr_conv;
27259         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27260         this_ptr_conv.is_owned = false;
27261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27262         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
27263 }
27264
27265 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_funding_pubkey"))) TS_AcceptChannel_get_funding_pubkey(uint32_t this_ptr) {
27266         LDKAcceptChannel this_ptr_conv;
27267         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27268         this_ptr_conv.is_owned = false;
27269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27270         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
27271         memcpy(ret_arr->elems, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
27272         return ret_arr;
27273 }
27274
27275 void  __attribute__((export_name("TS_AcceptChannel_set_funding_pubkey"))) TS_AcceptChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
27276         LDKAcceptChannel this_ptr_conv;
27277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27278         this_ptr_conv.is_owned = false;
27279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27280         LDKPublicKey val_ref;
27281         CHECK(val->arr_len == 33);
27282         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
27283         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
27284 }
27285
27286 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_revocation_basepoint"))) TS_AcceptChannel_get_revocation_basepoint(uint32_t this_ptr) {
27287         LDKAcceptChannel this_ptr_conv;
27288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27289         this_ptr_conv.is_owned = false;
27290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27291         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
27292         memcpy(ret_arr->elems, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
27293         return ret_arr;
27294 }
27295
27296 void  __attribute__((export_name("TS_AcceptChannel_set_revocation_basepoint"))) TS_AcceptChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
27297         LDKAcceptChannel this_ptr_conv;
27298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27299         this_ptr_conv.is_owned = false;
27300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27301         LDKPublicKey val_ref;
27302         CHECK(val->arr_len == 33);
27303         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
27304         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
27305 }
27306
27307 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_payment_point"))) TS_AcceptChannel_get_payment_point(uint32_t this_ptr) {
27308         LDKAcceptChannel this_ptr_conv;
27309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27310         this_ptr_conv.is_owned = false;
27311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27312         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
27313         memcpy(ret_arr->elems, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
27314         return ret_arr;
27315 }
27316
27317 void  __attribute__((export_name("TS_AcceptChannel_set_payment_point"))) TS_AcceptChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
27318         LDKAcceptChannel this_ptr_conv;
27319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27320         this_ptr_conv.is_owned = false;
27321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27322         LDKPublicKey val_ref;
27323         CHECK(val->arr_len == 33);
27324         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
27325         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
27326 }
27327
27328 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_delayed_payment_basepoint"))) TS_AcceptChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
27329         LDKAcceptChannel this_ptr_conv;
27330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27331         this_ptr_conv.is_owned = false;
27332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27333         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
27334         memcpy(ret_arr->elems, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
27335         return ret_arr;
27336 }
27337
27338 void  __attribute__((export_name("TS_AcceptChannel_set_delayed_payment_basepoint"))) TS_AcceptChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
27339         LDKAcceptChannel this_ptr_conv;
27340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27341         this_ptr_conv.is_owned = false;
27342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27343         LDKPublicKey val_ref;
27344         CHECK(val->arr_len == 33);
27345         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
27346         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
27347 }
27348
27349 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_htlc_basepoint"))) TS_AcceptChannel_get_htlc_basepoint(uint32_t this_ptr) {
27350         LDKAcceptChannel this_ptr_conv;
27351         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27352         this_ptr_conv.is_owned = false;
27353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27354         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
27355         memcpy(ret_arr->elems, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
27356         return ret_arr;
27357 }
27358
27359 void  __attribute__((export_name("TS_AcceptChannel_set_htlc_basepoint"))) TS_AcceptChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
27360         LDKAcceptChannel this_ptr_conv;
27361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27362         this_ptr_conv.is_owned = false;
27363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27364         LDKPublicKey val_ref;
27365         CHECK(val->arr_len == 33);
27366         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
27367         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
27368 }
27369
27370 int8_tArray  __attribute__((export_name("TS_AcceptChannel_get_first_per_commitment_point"))) TS_AcceptChannel_get_first_per_commitment_point(uint32_t this_ptr) {
27371         LDKAcceptChannel this_ptr_conv;
27372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27373         this_ptr_conv.is_owned = false;
27374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27375         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
27376         memcpy(ret_arr->elems, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
27377         return ret_arr;
27378 }
27379
27380 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) {
27381         LDKAcceptChannel this_ptr_conv;
27382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27383         this_ptr_conv.is_owned = false;
27384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27385         LDKPublicKey val_ref;
27386         CHECK(val->arr_len == 33);
27387         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
27388         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
27389 }
27390
27391 uint32_t  __attribute__((export_name("TS_AcceptChannel_get_channel_type"))) TS_AcceptChannel_get_channel_type(uint32_t this_ptr) {
27392         LDKAcceptChannel this_ptr_conv;
27393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27394         this_ptr_conv.is_owned = false;
27395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27396         LDKChannelTypeFeatures ret_var = AcceptChannel_get_channel_type(&this_ptr_conv);
27397         uint32_t ret_ref = 0;
27398         if ((uintptr_t)ret_var.inner > 4096) {
27399                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27400                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27401         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27402                 ret_ref = (uintptr_t)ret_var.inner;
27403                 if (ret_var.is_owned) {
27404                         ret_ref |= 1;
27405                 }
27406         }
27407         return ret_ref;
27408 }
27409
27410 void  __attribute__((export_name("TS_AcceptChannel_set_channel_type"))) TS_AcceptChannel_set_channel_type(uint32_t this_ptr, uint32_t val) {
27411         LDKAcceptChannel this_ptr_conv;
27412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27413         this_ptr_conv.is_owned = false;
27414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27415         LDKChannelTypeFeatures val_conv;
27416         val_conv.inner = (void*)(val & (~1));
27417         val_conv.is_owned = (val & 1) || (val == 0);
27418         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27419         val_conv = ChannelTypeFeatures_clone(&val_conv);
27420         AcceptChannel_set_channel_type(&this_ptr_conv, val_conv);
27421 }
27422
27423 static inline uintptr_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
27424         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
27425 uint32_t ret_ref = 0;
27426 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27427 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27428 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27429 ret_ref = (uintptr_t)ret_var.inner;
27430 if (ret_var.is_owned) {
27431         ret_ref |= 1;
27432 }
27433         return ret_ref;
27434 }
27435 uint32_t  __attribute__((export_name("TS_AcceptChannel_clone_ptr"))) TS_AcceptChannel_clone_ptr(uint32_t arg) {
27436         LDKAcceptChannel arg_conv;
27437         arg_conv.inner = (void*)(arg & (~1));
27438         arg_conv.is_owned = false;
27439         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27440         uint32_t ret_conv = AcceptChannel_clone_ptr(&arg_conv);
27441         return ret_conv;
27442 }
27443
27444 uint32_t  __attribute__((export_name("TS_AcceptChannel_clone"))) TS_AcceptChannel_clone(uint32_t orig) {
27445         LDKAcceptChannel orig_conv;
27446         orig_conv.inner = (void*)(orig & (~1));
27447         orig_conv.is_owned = false;
27448         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27449         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
27450         uint32_t ret_ref = 0;
27451         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27452         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27453         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27454         ret_ref = (uintptr_t)ret_var.inner;
27455         if (ret_var.is_owned) {
27456                 ret_ref |= 1;
27457         }
27458         return ret_ref;
27459 }
27460
27461 void  __attribute__((export_name("TS_FundingCreated_free"))) TS_FundingCreated_free(uint32_t this_obj) {
27462         LDKFundingCreated this_obj_conv;
27463         this_obj_conv.inner = (void*)(this_obj & (~1));
27464         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27466         FundingCreated_free(this_obj_conv);
27467 }
27468
27469 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_temporary_channel_id"))) TS_FundingCreated_get_temporary_channel_id(uint32_t this_ptr) {
27470         LDKFundingCreated this_ptr_conv;
27471         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27472         this_ptr_conv.is_owned = false;
27473         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27474         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27475         memcpy(ret_arr->elems, *FundingCreated_get_temporary_channel_id(&this_ptr_conv), 32);
27476         return ret_arr;
27477 }
27478
27479 void  __attribute__((export_name("TS_FundingCreated_set_temporary_channel_id"))) TS_FundingCreated_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
27480         LDKFundingCreated this_ptr_conv;
27481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27482         this_ptr_conv.is_owned = false;
27483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27484         LDKThirtyTwoBytes val_ref;
27485         CHECK(val->arr_len == 32);
27486         memcpy(val_ref.data, val->elems, 32); FREE(val);
27487         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
27488 }
27489
27490 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_funding_txid"))) TS_FundingCreated_get_funding_txid(uint32_t this_ptr) {
27491         LDKFundingCreated this_ptr_conv;
27492         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27493         this_ptr_conv.is_owned = false;
27494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27495         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27496         memcpy(ret_arr->elems, *FundingCreated_get_funding_txid(&this_ptr_conv), 32);
27497         return ret_arr;
27498 }
27499
27500 void  __attribute__((export_name("TS_FundingCreated_set_funding_txid"))) TS_FundingCreated_set_funding_txid(uint32_t this_ptr, int8_tArray val) {
27501         LDKFundingCreated this_ptr_conv;
27502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27503         this_ptr_conv.is_owned = false;
27504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27505         LDKThirtyTwoBytes val_ref;
27506         CHECK(val->arr_len == 32);
27507         memcpy(val_ref.data, val->elems, 32); FREE(val);
27508         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
27509 }
27510
27511 int16_t  __attribute__((export_name("TS_FundingCreated_get_funding_output_index"))) TS_FundingCreated_get_funding_output_index(uint32_t this_ptr) {
27512         LDKFundingCreated this_ptr_conv;
27513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27514         this_ptr_conv.is_owned = false;
27515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27516         int16_t ret_conv = FundingCreated_get_funding_output_index(&this_ptr_conv);
27517         return ret_conv;
27518 }
27519
27520 void  __attribute__((export_name("TS_FundingCreated_set_funding_output_index"))) TS_FundingCreated_set_funding_output_index(uint32_t this_ptr, int16_t val) {
27521         LDKFundingCreated this_ptr_conv;
27522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27523         this_ptr_conv.is_owned = false;
27524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27525         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
27526 }
27527
27528 int8_tArray  __attribute__((export_name("TS_FundingCreated_get_signature"))) TS_FundingCreated_get_signature(uint32_t this_ptr) {
27529         LDKFundingCreated this_ptr_conv;
27530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27531         this_ptr_conv.is_owned = false;
27532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27533         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
27534         memcpy(ret_arr->elems, FundingCreated_get_signature(&this_ptr_conv).compact_form, 64);
27535         return ret_arr;
27536 }
27537
27538 void  __attribute__((export_name("TS_FundingCreated_set_signature"))) TS_FundingCreated_set_signature(uint32_t this_ptr, int8_tArray val) {
27539         LDKFundingCreated this_ptr_conv;
27540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27541         this_ptr_conv.is_owned = false;
27542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27543         LDKSignature val_ref;
27544         CHECK(val->arr_len == 64);
27545         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
27546         FundingCreated_set_signature(&this_ptr_conv, val_ref);
27547 }
27548
27549 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) {
27550         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
27551         CHECK(temporary_channel_id_arg->arr_len == 32);
27552         memcpy(temporary_channel_id_arg_ref.data, temporary_channel_id_arg->elems, 32); FREE(temporary_channel_id_arg);
27553         LDKThirtyTwoBytes funding_txid_arg_ref;
27554         CHECK(funding_txid_arg->arr_len == 32);
27555         memcpy(funding_txid_arg_ref.data, funding_txid_arg->elems, 32); FREE(funding_txid_arg);
27556         LDKSignature signature_arg_ref;
27557         CHECK(signature_arg->arr_len == 64);
27558         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
27559         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
27560         uint32_t ret_ref = 0;
27561         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27562         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27563         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27564         ret_ref = (uintptr_t)ret_var.inner;
27565         if (ret_var.is_owned) {
27566                 ret_ref |= 1;
27567         }
27568         return ret_ref;
27569 }
27570
27571 static inline uintptr_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
27572         LDKFundingCreated ret_var = FundingCreated_clone(arg);
27573 uint32_t ret_ref = 0;
27574 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27575 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27576 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27577 ret_ref = (uintptr_t)ret_var.inner;
27578 if (ret_var.is_owned) {
27579         ret_ref |= 1;
27580 }
27581         return ret_ref;
27582 }
27583 uint32_t  __attribute__((export_name("TS_FundingCreated_clone_ptr"))) TS_FundingCreated_clone_ptr(uint32_t arg) {
27584         LDKFundingCreated arg_conv;
27585         arg_conv.inner = (void*)(arg & (~1));
27586         arg_conv.is_owned = false;
27587         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27588         uint32_t ret_conv = FundingCreated_clone_ptr(&arg_conv);
27589         return ret_conv;
27590 }
27591
27592 uint32_t  __attribute__((export_name("TS_FundingCreated_clone"))) TS_FundingCreated_clone(uint32_t orig) {
27593         LDKFundingCreated orig_conv;
27594         orig_conv.inner = (void*)(orig & (~1));
27595         orig_conv.is_owned = false;
27596         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27597         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
27598         uint32_t ret_ref = 0;
27599         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27600         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27601         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27602         ret_ref = (uintptr_t)ret_var.inner;
27603         if (ret_var.is_owned) {
27604                 ret_ref |= 1;
27605         }
27606         return ret_ref;
27607 }
27608
27609 void  __attribute__((export_name("TS_FundingSigned_free"))) TS_FundingSigned_free(uint32_t this_obj) {
27610         LDKFundingSigned this_obj_conv;
27611         this_obj_conv.inner = (void*)(this_obj & (~1));
27612         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27614         FundingSigned_free(this_obj_conv);
27615 }
27616
27617 int8_tArray  __attribute__((export_name("TS_FundingSigned_get_channel_id"))) TS_FundingSigned_get_channel_id(uint32_t this_ptr) {
27618         LDKFundingSigned this_ptr_conv;
27619         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27620         this_ptr_conv.is_owned = false;
27621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27622         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27623         memcpy(ret_arr->elems, *FundingSigned_get_channel_id(&this_ptr_conv), 32);
27624         return ret_arr;
27625 }
27626
27627 void  __attribute__((export_name("TS_FundingSigned_set_channel_id"))) TS_FundingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
27628         LDKFundingSigned this_ptr_conv;
27629         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27630         this_ptr_conv.is_owned = false;
27631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27632         LDKThirtyTwoBytes val_ref;
27633         CHECK(val->arr_len == 32);
27634         memcpy(val_ref.data, val->elems, 32); FREE(val);
27635         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
27636 }
27637
27638 int8_tArray  __attribute__((export_name("TS_FundingSigned_get_signature"))) TS_FundingSigned_get_signature(uint32_t this_ptr) {
27639         LDKFundingSigned this_ptr_conv;
27640         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27641         this_ptr_conv.is_owned = false;
27642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27643         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
27644         memcpy(ret_arr->elems, FundingSigned_get_signature(&this_ptr_conv).compact_form, 64);
27645         return ret_arr;
27646 }
27647
27648 void  __attribute__((export_name("TS_FundingSigned_set_signature"))) TS_FundingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
27649         LDKFundingSigned this_ptr_conv;
27650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27651         this_ptr_conv.is_owned = false;
27652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27653         LDKSignature val_ref;
27654         CHECK(val->arr_len == 64);
27655         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
27656         FundingSigned_set_signature(&this_ptr_conv, val_ref);
27657 }
27658
27659 uint32_t  __attribute__((export_name("TS_FundingSigned_new"))) TS_FundingSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg) {
27660         LDKThirtyTwoBytes channel_id_arg_ref;
27661         CHECK(channel_id_arg->arr_len == 32);
27662         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
27663         LDKSignature signature_arg_ref;
27664         CHECK(signature_arg->arr_len == 64);
27665         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
27666         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
27667         uint32_t ret_ref = 0;
27668         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27669         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27670         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27671         ret_ref = (uintptr_t)ret_var.inner;
27672         if (ret_var.is_owned) {
27673                 ret_ref |= 1;
27674         }
27675         return ret_ref;
27676 }
27677
27678 static inline uintptr_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
27679         LDKFundingSigned ret_var = FundingSigned_clone(arg);
27680 uint32_t ret_ref = 0;
27681 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27682 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27683 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27684 ret_ref = (uintptr_t)ret_var.inner;
27685 if (ret_var.is_owned) {
27686         ret_ref |= 1;
27687 }
27688         return ret_ref;
27689 }
27690 uint32_t  __attribute__((export_name("TS_FundingSigned_clone_ptr"))) TS_FundingSigned_clone_ptr(uint32_t arg) {
27691         LDKFundingSigned arg_conv;
27692         arg_conv.inner = (void*)(arg & (~1));
27693         arg_conv.is_owned = false;
27694         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27695         uint32_t ret_conv = FundingSigned_clone_ptr(&arg_conv);
27696         return ret_conv;
27697 }
27698
27699 uint32_t  __attribute__((export_name("TS_FundingSigned_clone"))) TS_FundingSigned_clone(uint32_t orig) {
27700         LDKFundingSigned orig_conv;
27701         orig_conv.inner = (void*)(orig & (~1));
27702         orig_conv.is_owned = false;
27703         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27704         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
27705         uint32_t ret_ref = 0;
27706         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27707         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27708         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27709         ret_ref = (uintptr_t)ret_var.inner;
27710         if (ret_var.is_owned) {
27711                 ret_ref |= 1;
27712         }
27713         return ret_ref;
27714 }
27715
27716 void  __attribute__((export_name("TS_FundingLocked_free"))) TS_FundingLocked_free(uint32_t this_obj) {
27717         LDKFundingLocked this_obj_conv;
27718         this_obj_conv.inner = (void*)(this_obj & (~1));
27719         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27721         FundingLocked_free(this_obj_conv);
27722 }
27723
27724 int8_tArray  __attribute__((export_name("TS_FundingLocked_get_channel_id"))) TS_FundingLocked_get_channel_id(uint32_t this_ptr) {
27725         LDKFundingLocked this_ptr_conv;
27726         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27727         this_ptr_conv.is_owned = false;
27728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27729         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27730         memcpy(ret_arr->elems, *FundingLocked_get_channel_id(&this_ptr_conv), 32);
27731         return ret_arr;
27732 }
27733
27734 void  __attribute__((export_name("TS_FundingLocked_set_channel_id"))) TS_FundingLocked_set_channel_id(uint32_t this_ptr, int8_tArray val) {
27735         LDKFundingLocked this_ptr_conv;
27736         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27737         this_ptr_conv.is_owned = false;
27738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27739         LDKThirtyTwoBytes val_ref;
27740         CHECK(val->arr_len == 32);
27741         memcpy(val_ref.data, val->elems, 32); FREE(val);
27742         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
27743 }
27744
27745 int8_tArray  __attribute__((export_name("TS_FundingLocked_get_next_per_commitment_point"))) TS_FundingLocked_get_next_per_commitment_point(uint32_t this_ptr) {
27746         LDKFundingLocked this_ptr_conv;
27747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27748         this_ptr_conv.is_owned = false;
27749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27750         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
27751         memcpy(ret_arr->elems, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
27752         return ret_arr;
27753 }
27754
27755 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) {
27756         LDKFundingLocked this_ptr_conv;
27757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27758         this_ptr_conv.is_owned = false;
27759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27760         LDKPublicKey val_ref;
27761         CHECK(val->arr_len == 33);
27762         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
27763         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
27764 }
27765
27766 uint32_t  __attribute__((export_name("TS_FundingLocked_get_short_channel_id_alias"))) TS_FundingLocked_get_short_channel_id_alias(uint32_t this_ptr) {
27767         LDKFundingLocked this_ptr_conv;
27768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27769         this_ptr_conv.is_owned = false;
27770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27771         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
27772         *ret_copy = FundingLocked_get_short_channel_id_alias(&this_ptr_conv);
27773         uint32_t ret_ref = (uintptr_t)ret_copy;
27774         return ret_ref;
27775 }
27776
27777 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) {
27778         LDKFundingLocked this_ptr_conv;
27779         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27780         this_ptr_conv.is_owned = false;
27781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27782         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
27783         CHECK_ACCESS(val_ptr);
27784         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
27785         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
27786         FundingLocked_set_short_channel_id_alias(&this_ptr_conv, val_conv);
27787 }
27788
27789 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) {
27790         LDKThirtyTwoBytes channel_id_arg_ref;
27791         CHECK(channel_id_arg->arr_len == 32);
27792         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
27793         LDKPublicKey next_per_commitment_point_arg_ref;
27794         CHECK(next_per_commitment_point_arg->arr_len == 33);
27795         memcpy(next_per_commitment_point_arg_ref.compressed_form, next_per_commitment_point_arg->elems, 33); FREE(next_per_commitment_point_arg);
27796         void* short_channel_id_alias_arg_ptr = (void*)(((uintptr_t)short_channel_id_alias_arg) & ~1);
27797         CHECK_ACCESS(short_channel_id_alias_arg_ptr);
27798         LDKCOption_u64Z short_channel_id_alias_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_alias_arg_ptr);
27799         short_channel_id_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)short_channel_id_alias_arg) & ~1));
27800         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref, short_channel_id_alias_arg_conv);
27801         uint32_t ret_ref = 0;
27802         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27803         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27804         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27805         ret_ref = (uintptr_t)ret_var.inner;
27806         if (ret_var.is_owned) {
27807                 ret_ref |= 1;
27808         }
27809         return ret_ref;
27810 }
27811
27812 static inline uintptr_t FundingLocked_clone_ptr(LDKFundingLocked *NONNULL_PTR arg) {
27813         LDKFundingLocked ret_var = FundingLocked_clone(arg);
27814 uint32_t ret_ref = 0;
27815 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27816 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27817 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27818 ret_ref = (uintptr_t)ret_var.inner;
27819 if (ret_var.is_owned) {
27820         ret_ref |= 1;
27821 }
27822         return ret_ref;
27823 }
27824 uint32_t  __attribute__((export_name("TS_FundingLocked_clone_ptr"))) TS_FundingLocked_clone_ptr(uint32_t arg) {
27825         LDKFundingLocked arg_conv;
27826         arg_conv.inner = (void*)(arg & (~1));
27827         arg_conv.is_owned = false;
27828         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27829         uint32_t ret_conv = FundingLocked_clone_ptr(&arg_conv);
27830         return ret_conv;
27831 }
27832
27833 uint32_t  __attribute__((export_name("TS_FundingLocked_clone"))) TS_FundingLocked_clone(uint32_t orig) {
27834         LDKFundingLocked orig_conv;
27835         orig_conv.inner = (void*)(orig & (~1));
27836         orig_conv.is_owned = false;
27837         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27838         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
27839         uint32_t ret_ref = 0;
27840         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27841         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27842         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27843         ret_ref = (uintptr_t)ret_var.inner;
27844         if (ret_var.is_owned) {
27845                 ret_ref |= 1;
27846         }
27847         return ret_ref;
27848 }
27849
27850 void  __attribute__((export_name("TS_Shutdown_free"))) TS_Shutdown_free(uint32_t this_obj) {
27851         LDKShutdown this_obj_conv;
27852         this_obj_conv.inner = (void*)(this_obj & (~1));
27853         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27855         Shutdown_free(this_obj_conv);
27856 }
27857
27858 int8_tArray  __attribute__((export_name("TS_Shutdown_get_channel_id"))) TS_Shutdown_get_channel_id(uint32_t this_ptr) {
27859         LDKShutdown this_ptr_conv;
27860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27861         this_ptr_conv.is_owned = false;
27862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27863         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
27864         memcpy(ret_arr->elems, *Shutdown_get_channel_id(&this_ptr_conv), 32);
27865         return ret_arr;
27866 }
27867
27868 void  __attribute__((export_name("TS_Shutdown_set_channel_id"))) TS_Shutdown_set_channel_id(uint32_t this_ptr, int8_tArray val) {
27869         LDKShutdown this_ptr_conv;
27870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27871         this_ptr_conv.is_owned = false;
27872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27873         LDKThirtyTwoBytes val_ref;
27874         CHECK(val->arr_len == 32);
27875         memcpy(val_ref.data, val->elems, 32); FREE(val);
27876         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
27877 }
27878
27879 int8_tArray  __attribute__((export_name("TS_Shutdown_get_scriptpubkey"))) TS_Shutdown_get_scriptpubkey(uint32_t this_ptr) {
27880         LDKShutdown this_ptr_conv;
27881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27882         this_ptr_conv.is_owned = false;
27883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27884         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
27885         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
27886         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
27887         return ret_arr;
27888 }
27889
27890 void  __attribute__((export_name("TS_Shutdown_set_scriptpubkey"))) TS_Shutdown_set_scriptpubkey(uint32_t this_ptr, int8_tArray val) {
27891         LDKShutdown this_ptr_conv;
27892         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27893         this_ptr_conv.is_owned = false;
27894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27895         LDKCVec_u8Z val_ref;
27896         val_ref.datalen = val->arr_len;
27897         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
27898         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
27899         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
27900 }
27901
27902 uint32_t  __attribute__((export_name("TS_Shutdown_new"))) TS_Shutdown_new(int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
27903         LDKThirtyTwoBytes channel_id_arg_ref;
27904         CHECK(channel_id_arg->arr_len == 32);
27905         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
27906         LDKCVec_u8Z scriptpubkey_arg_ref;
27907         scriptpubkey_arg_ref.datalen = scriptpubkey_arg->arr_len;
27908         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
27909         memcpy(scriptpubkey_arg_ref.data, scriptpubkey_arg->elems, scriptpubkey_arg_ref.datalen); FREE(scriptpubkey_arg);
27910         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
27911         uint32_t ret_ref = 0;
27912         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27913         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27914         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27915         ret_ref = (uintptr_t)ret_var.inner;
27916         if (ret_var.is_owned) {
27917                 ret_ref |= 1;
27918         }
27919         return ret_ref;
27920 }
27921
27922 static inline uintptr_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
27923         LDKShutdown ret_var = Shutdown_clone(arg);
27924 uint32_t ret_ref = 0;
27925 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27926 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27927 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27928 ret_ref = (uintptr_t)ret_var.inner;
27929 if (ret_var.is_owned) {
27930         ret_ref |= 1;
27931 }
27932         return ret_ref;
27933 }
27934 uint32_t  __attribute__((export_name("TS_Shutdown_clone_ptr"))) TS_Shutdown_clone_ptr(uint32_t arg) {
27935         LDKShutdown arg_conv;
27936         arg_conv.inner = (void*)(arg & (~1));
27937         arg_conv.is_owned = false;
27938         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27939         uint32_t ret_conv = Shutdown_clone_ptr(&arg_conv);
27940         return ret_conv;
27941 }
27942
27943 uint32_t  __attribute__((export_name("TS_Shutdown_clone"))) TS_Shutdown_clone(uint32_t orig) {
27944         LDKShutdown orig_conv;
27945         orig_conv.inner = (void*)(orig & (~1));
27946         orig_conv.is_owned = false;
27947         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27948         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
27949         uint32_t ret_ref = 0;
27950         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27951         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27952         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27953         ret_ref = (uintptr_t)ret_var.inner;
27954         if (ret_var.is_owned) {
27955                 ret_ref |= 1;
27956         }
27957         return ret_ref;
27958 }
27959
27960 void  __attribute__((export_name("TS_ClosingSignedFeeRange_free"))) TS_ClosingSignedFeeRange_free(uint32_t this_obj) {
27961         LDKClosingSignedFeeRange this_obj_conv;
27962         this_obj_conv.inner = (void*)(this_obj & (~1));
27963         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27965         ClosingSignedFeeRange_free(this_obj_conv);
27966 }
27967
27968 int64_t  __attribute__((export_name("TS_ClosingSignedFeeRange_get_min_fee_satoshis"))) TS_ClosingSignedFeeRange_get_min_fee_satoshis(uint32_t this_ptr) {
27969         LDKClosingSignedFeeRange this_ptr_conv;
27970         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27971         this_ptr_conv.is_owned = false;
27972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27973         int64_t ret_conv = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
27974         return ret_conv;
27975 }
27976
27977 void  __attribute__((export_name("TS_ClosingSignedFeeRange_set_min_fee_satoshis"))) TS_ClosingSignedFeeRange_set_min_fee_satoshis(uint32_t this_ptr, int64_t val) {
27978         LDKClosingSignedFeeRange this_ptr_conv;
27979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27980         this_ptr_conv.is_owned = false;
27981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27982         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
27983 }
27984
27985 int64_t  __attribute__((export_name("TS_ClosingSignedFeeRange_get_max_fee_satoshis"))) TS_ClosingSignedFeeRange_get_max_fee_satoshis(uint32_t this_ptr) {
27986         LDKClosingSignedFeeRange this_ptr_conv;
27987         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27988         this_ptr_conv.is_owned = false;
27989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27990         int64_t ret_conv = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
27991         return ret_conv;
27992 }
27993
27994 void  __attribute__((export_name("TS_ClosingSignedFeeRange_set_max_fee_satoshis"))) TS_ClosingSignedFeeRange_set_max_fee_satoshis(uint32_t this_ptr, int64_t val) {
27995         LDKClosingSignedFeeRange this_ptr_conv;
27996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27997         this_ptr_conv.is_owned = false;
27998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27999         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
28000 }
28001
28002 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_new"))) TS_ClosingSignedFeeRange_new(int64_t min_fee_satoshis_arg, int64_t max_fee_satoshis_arg) {
28003         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
28004         uint32_t ret_ref = 0;
28005         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28006         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28007         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28008         ret_ref = (uintptr_t)ret_var.inner;
28009         if (ret_var.is_owned) {
28010                 ret_ref |= 1;
28011         }
28012         return ret_ref;
28013 }
28014
28015 static inline uintptr_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
28016         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
28017 uint32_t ret_ref = 0;
28018 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28019 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28020 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28021 ret_ref = (uintptr_t)ret_var.inner;
28022 if (ret_var.is_owned) {
28023         ret_ref |= 1;
28024 }
28025         return ret_ref;
28026 }
28027 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_clone_ptr"))) TS_ClosingSignedFeeRange_clone_ptr(uint32_t arg) {
28028         LDKClosingSignedFeeRange arg_conv;
28029         arg_conv.inner = (void*)(arg & (~1));
28030         arg_conv.is_owned = false;
28031         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28032         uint32_t ret_conv = ClosingSignedFeeRange_clone_ptr(&arg_conv);
28033         return ret_conv;
28034 }
28035
28036 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_clone"))) TS_ClosingSignedFeeRange_clone(uint32_t orig) {
28037         LDKClosingSignedFeeRange orig_conv;
28038         orig_conv.inner = (void*)(orig & (~1));
28039         orig_conv.is_owned = false;
28040         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28041         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
28042         uint32_t ret_ref = 0;
28043         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28044         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28045         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28046         ret_ref = (uintptr_t)ret_var.inner;
28047         if (ret_var.is_owned) {
28048                 ret_ref |= 1;
28049         }
28050         return ret_ref;
28051 }
28052
28053 void  __attribute__((export_name("TS_ClosingSigned_free"))) TS_ClosingSigned_free(uint32_t this_obj) {
28054         LDKClosingSigned this_obj_conv;
28055         this_obj_conv.inner = (void*)(this_obj & (~1));
28056         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28058         ClosingSigned_free(this_obj_conv);
28059 }
28060
28061 int8_tArray  __attribute__((export_name("TS_ClosingSigned_get_channel_id"))) TS_ClosingSigned_get_channel_id(uint32_t this_ptr) {
28062         LDKClosingSigned this_ptr_conv;
28063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28064         this_ptr_conv.is_owned = false;
28065         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28066         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28067         memcpy(ret_arr->elems, *ClosingSigned_get_channel_id(&this_ptr_conv), 32);
28068         return ret_arr;
28069 }
28070
28071 void  __attribute__((export_name("TS_ClosingSigned_set_channel_id"))) TS_ClosingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28072         LDKClosingSigned this_ptr_conv;
28073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28074         this_ptr_conv.is_owned = false;
28075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28076         LDKThirtyTwoBytes val_ref;
28077         CHECK(val->arr_len == 32);
28078         memcpy(val_ref.data, val->elems, 32); FREE(val);
28079         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
28080 }
28081
28082 int64_t  __attribute__((export_name("TS_ClosingSigned_get_fee_satoshis"))) TS_ClosingSigned_get_fee_satoshis(uint32_t this_ptr) {
28083         LDKClosingSigned this_ptr_conv;
28084         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28085         this_ptr_conv.is_owned = false;
28086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28087         int64_t ret_conv = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
28088         return ret_conv;
28089 }
28090
28091 void  __attribute__((export_name("TS_ClosingSigned_set_fee_satoshis"))) TS_ClosingSigned_set_fee_satoshis(uint32_t this_ptr, int64_t val) {
28092         LDKClosingSigned this_ptr_conv;
28093         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28094         this_ptr_conv.is_owned = false;
28095         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28096         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
28097 }
28098
28099 int8_tArray  __attribute__((export_name("TS_ClosingSigned_get_signature"))) TS_ClosingSigned_get_signature(uint32_t this_ptr) {
28100         LDKClosingSigned this_ptr_conv;
28101         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28102         this_ptr_conv.is_owned = false;
28103         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28104         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
28105         memcpy(ret_arr->elems, ClosingSigned_get_signature(&this_ptr_conv).compact_form, 64);
28106         return ret_arr;
28107 }
28108
28109 void  __attribute__((export_name("TS_ClosingSigned_set_signature"))) TS_ClosingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
28110         LDKClosingSigned this_ptr_conv;
28111         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28112         this_ptr_conv.is_owned = false;
28113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28114         LDKSignature val_ref;
28115         CHECK(val->arr_len == 64);
28116         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
28117         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
28118 }
28119
28120 uint32_t  __attribute__((export_name("TS_ClosingSigned_get_fee_range"))) TS_ClosingSigned_get_fee_range(uint32_t this_ptr) {
28121         LDKClosingSigned this_ptr_conv;
28122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28123         this_ptr_conv.is_owned = false;
28124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28125         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
28126         uint32_t ret_ref = 0;
28127         if ((uintptr_t)ret_var.inner > 4096) {
28128                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28129                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28130         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28131                 ret_ref = (uintptr_t)ret_var.inner;
28132                 if (ret_var.is_owned) {
28133                         ret_ref |= 1;
28134                 }
28135         }
28136         return ret_ref;
28137 }
28138
28139 void  __attribute__((export_name("TS_ClosingSigned_set_fee_range"))) TS_ClosingSigned_set_fee_range(uint32_t this_ptr, uint32_t val) {
28140         LDKClosingSigned this_ptr_conv;
28141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28142         this_ptr_conv.is_owned = false;
28143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28144         LDKClosingSignedFeeRange val_conv;
28145         val_conv.inner = (void*)(val & (~1));
28146         val_conv.is_owned = (val & 1) || (val == 0);
28147         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28148         val_conv = ClosingSignedFeeRange_clone(&val_conv);
28149         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
28150 }
28151
28152 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) {
28153         LDKThirtyTwoBytes channel_id_arg_ref;
28154         CHECK(channel_id_arg->arr_len == 32);
28155         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28156         LDKSignature signature_arg_ref;
28157         CHECK(signature_arg->arr_len == 64);
28158         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
28159         LDKClosingSignedFeeRange fee_range_arg_conv;
28160         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
28161         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
28162         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
28163         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
28164         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
28165         uint32_t ret_ref = 0;
28166         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28167         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28168         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28169         ret_ref = (uintptr_t)ret_var.inner;
28170         if (ret_var.is_owned) {
28171                 ret_ref |= 1;
28172         }
28173         return ret_ref;
28174 }
28175
28176 static inline uintptr_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
28177         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
28178 uint32_t ret_ref = 0;
28179 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28180 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28181 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28182 ret_ref = (uintptr_t)ret_var.inner;
28183 if (ret_var.is_owned) {
28184         ret_ref |= 1;
28185 }
28186         return ret_ref;
28187 }
28188 uint32_t  __attribute__((export_name("TS_ClosingSigned_clone_ptr"))) TS_ClosingSigned_clone_ptr(uint32_t arg) {
28189         LDKClosingSigned arg_conv;
28190         arg_conv.inner = (void*)(arg & (~1));
28191         arg_conv.is_owned = false;
28192         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28193         uint32_t ret_conv = ClosingSigned_clone_ptr(&arg_conv);
28194         return ret_conv;
28195 }
28196
28197 uint32_t  __attribute__((export_name("TS_ClosingSigned_clone"))) TS_ClosingSigned_clone(uint32_t orig) {
28198         LDKClosingSigned orig_conv;
28199         orig_conv.inner = (void*)(orig & (~1));
28200         orig_conv.is_owned = false;
28201         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28202         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
28203         uint32_t ret_ref = 0;
28204         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28205         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28206         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28207         ret_ref = (uintptr_t)ret_var.inner;
28208         if (ret_var.is_owned) {
28209                 ret_ref |= 1;
28210         }
28211         return ret_ref;
28212 }
28213
28214 void  __attribute__((export_name("TS_UpdateAddHTLC_free"))) TS_UpdateAddHTLC_free(uint32_t this_obj) {
28215         LDKUpdateAddHTLC this_obj_conv;
28216         this_obj_conv.inner = (void*)(this_obj & (~1));
28217         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28219         UpdateAddHTLC_free(this_obj_conv);
28220 }
28221
28222 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_get_channel_id"))) TS_UpdateAddHTLC_get_channel_id(uint32_t this_ptr) {
28223         LDKUpdateAddHTLC this_ptr_conv;
28224         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28225         this_ptr_conv.is_owned = false;
28226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28227         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28228         memcpy(ret_arr->elems, *UpdateAddHTLC_get_channel_id(&this_ptr_conv), 32);
28229         return ret_arr;
28230 }
28231
28232 void  __attribute__((export_name("TS_UpdateAddHTLC_set_channel_id"))) TS_UpdateAddHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28233         LDKUpdateAddHTLC this_ptr_conv;
28234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28235         this_ptr_conv.is_owned = false;
28236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28237         LDKThirtyTwoBytes val_ref;
28238         CHECK(val->arr_len == 32);
28239         memcpy(val_ref.data, val->elems, 32); FREE(val);
28240         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
28241 }
28242
28243 int64_t  __attribute__((export_name("TS_UpdateAddHTLC_get_htlc_id"))) TS_UpdateAddHTLC_get_htlc_id(uint32_t this_ptr) {
28244         LDKUpdateAddHTLC this_ptr_conv;
28245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28246         this_ptr_conv.is_owned = false;
28247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28248         int64_t ret_conv = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
28249         return ret_conv;
28250 }
28251
28252 void  __attribute__((export_name("TS_UpdateAddHTLC_set_htlc_id"))) TS_UpdateAddHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
28253         LDKUpdateAddHTLC this_ptr_conv;
28254         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28255         this_ptr_conv.is_owned = false;
28256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28257         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
28258 }
28259
28260 int64_t  __attribute__((export_name("TS_UpdateAddHTLC_get_amount_msat"))) TS_UpdateAddHTLC_get_amount_msat(uint32_t this_ptr) {
28261         LDKUpdateAddHTLC this_ptr_conv;
28262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28263         this_ptr_conv.is_owned = false;
28264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28265         int64_t ret_conv = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
28266         return ret_conv;
28267 }
28268
28269 void  __attribute__((export_name("TS_UpdateAddHTLC_set_amount_msat"))) TS_UpdateAddHTLC_set_amount_msat(uint32_t this_ptr, int64_t val) {
28270         LDKUpdateAddHTLC this_ptr_conv;
28271         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28272         this_ptr_conv.is_owned = false;
28273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28274         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
28275 }
28276
28277 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_get_payment_hash"))) TS_UpdateAddHTLC_get_payment_hash(uint32_t this_ptr) {
28278         LDKUpdateAddHTLC this_ptr_conv;
28279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28280         this_ptr_conv.is_owned = false;
28281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28282         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28283         memcpy(ret_arr->elems, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv), 32);
28284         return ret_arr;
28285 }
28286
28287 void  __attribute__((export_name("TS_UpdateAddHTLC_set_payment_hash"))) TS_UpdateAddHTLC_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
28288         LDKUpdateAddHTLC this_ptr_conv;
28289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28290         this_ptr_conv.is_owned = false;
28291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28292         LDKThirtyTwoBytes val_ref;
28293         CHECK(val->arr_len == 32);
28294         memcpy(val_ref.data, val->elems, 32); FREE(val);
28295         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
28296 }
28297
28298 int32_t  __attribute__((export_name("TS_UpdateAddHTLC_get_cltv_expiry"))) TS_UpdateAddHTLC_get_cltv_expiry(uint32_t this_ptr) {
28299         LDKUpdateAddHTLC this_ptr_conv;
28300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28301         this_ptr_conv.is_owned = false;
28302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28303         int32_t ret_conv = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
28304         return ret_conv;
28305 }
28306
28307 void  __attribute__((export_name("TS_UpdateAddHTLC_set_cltv_expiry"))) TS_UpdateAddHTLC_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
28308         LDKUpdateAddHTLC this_ptr_conv;
28309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28310         this_ptr_conv.is_owned = false;
28311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28312         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
28313 }
28314
28315 static inline uintptr_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
28316         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
28317 uint32_t ret_ref = 0;
28318 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28319 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28320 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28321 ret_ref = (uintptr_t)ret_var.inner;
28322 if (ret_var.is_owned) {
28323         ret_ref |= 1;
28324 }
28325         return ret_ref;
28326 }
28327 uint32_t  __attribute__((export_name("TS_UpdateAddHTLC_clone_ptr"))) TS_UpdateAddHTLC_clone_ptr(uint32_t arg) {
28328         LDKUpdateAddHTLC arg_conv;
28329         arg_conv.inner = (void*)(arg & (~1));
28330         arg_conv.is_owned = false;
28331         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28332         uint32_t ret_conv = UpdateAddHTLC_clone_ptr(&arg_conv);
28333         return ret_conv;
28334 }
28335
28336 uint32_t  __attribute__((export_name("TS_UpdateAddHTLC_clone"))) TS_UpdateAddHTLC_clone(uint32_t orig) {
28337         LDKUpdateAddHTLC orig_conv;
28338         orig_conv.inner = (void*)(orig & (~1));
28339         orig_conv.is_owned = false;
28340         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28341         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
28342         uint32_t ret_ref = 0;
28343         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28344         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28345         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28346         ret_ref = (uintptr_t)ret_var.inner;
28347         if (ret_var.is_owned) {
28348                 ret_ref |= 1;
28349         }
28350         return ret_ref;
28351 }
28352
28353 void  __attribute__((export_name("TS_UpdateFulfillHTLC_free"))) TS_UpdateFulfillHTLC_free(uint32_t this_obj) {
28354         LDKUpdateFulfillHTLC this_obj_conv;
28355         this_obj_conv.inner = (void*)(this_obj & (~1));
28356         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28358         UpdateFulfillHTLC_free(this_obj_conv);
28359 }
28360
28361 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_get_channel_id"))) TS_UpdateFulfillHTLC_get_channel_id(uint32_t this_ptr) {
28362         LDKUpdateFulfillHTLC this_ptr_conv;
28363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28364         this_ptr_conv.is_owned = false;
28365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28366         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28367         memcpy(ret_arr->elems, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv), 32);
28368         return ret_arr;
28369 }
28370
28371 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_channel_id"))) TS_UpdateFulfillHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28372         LDKUpdateFulfillHTLC this_ptr_conv;
28373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28374         this_ptr_conv.is_owned = false;
28375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28376         LDKThirtyTwoBytes val_ref;
28377         CHECK(val->arr_len == 32);
28378         memcpy(val_ref.data, val->elems, 32); FREE(val);
28379         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
28380 }
28381
28382 int64_t  __attribute__((export_name("TS_UpdateFulfillHTLC_get_htlc_id"))) TS_UpdateFulfillHTLC_get_htlc_id(uint32_t this_ptr) {
28383         LDKUpdateFulfillHTLC this_ptr_conv;
28384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28385         this_ptr_conv.is_owned = false;
28386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28387         int64_t ret_conv = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
28388         return ret_conv;
28389 }
28390
28391 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_htlc_id"))) TS_UpdateFulfillHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
28392         LDKUpdateFulfillHTLC this_ptr_conv;
28393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28394         this_ptr_conv.is_owned = false;
28395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28396         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
28397 }
28398
28399 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_get_payment_preimage"))) TS_UpdateFulfillHTLC_get_payment_preimage(uint32_t this_ptr) {
28400         LDKUpdateFulfillHTLC this_ptr_conv;
28401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28402         this_ptr_conv.is_owned = false;
28403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28404         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28405         memcpy(ret_arr->elems, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv), 32);
28406         return ret_arr;
28407 }
28408
28409 void  __attribute__((export_name("TS_UpdateFulfillHTLC_set_payment_preimage"))) TS_UpdateFulfillHTLC_set_payment_preimage(uint32_t this_ptr, int8_tArray val) {
28410         LDKUpdateFulfillHTLC this_ptr_conv;
28411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28412         this_ptr_conv.is_owned = false;
28413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28414         LDKThirtyTwoBytes val_ref;
28415         CHECK(val->arr_len == 32);
28416         memcpy(val_ref.data, val->elems, 32); FREE(val);
28417         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
28418 }
28419
28420 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) {
28421         LDKThirtyTwoBytes channel_id_arg_ref;
28422         CHECK(channel_id_arg->arr_len == 32);
28423         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28424         LDKThirtyTwoBytes payment_preimage_arg_ref;
28425         CHECK(payment_preimage_arg->arr_len == 32);
28426         memcpy(payment_preimage_arg_ref.data, payment_preimage_arg->elems, 32); FREE(payment_preimage_arg);
28427         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
28428         uint32_t ret_ref = 0;
28429         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28430         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28431         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28432         ret_ref = (uintptr_t)ret_var.inner;
28433         if (ret_var.is_owned) {
28434                 ret_ref |= 1;
28435         }
28436         return ret_ref;
28437 }
28438
28439 static inline uintptr_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
28440         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
28441 uint32_t ret_ref = 0;
28442 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28443 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28444 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28445 ret_ref = (uintptr_t)ret_var.inner;
28446 if (ret_var.is_owned) {
28447         ret_ref |= 1;
28448 }
28449         return ret_ref;
28450 }
28451 uint32_t  __attribute__((export_name("TS_UpdateFulfillHTLC_clone_ptr"))) TS_UpdateFulfillHTLC_clone_ptr(uint32_t arg) {
28452         LDKUpdateFulfillHTLC arg_conv;
28453         arg_conv.inner = (void*)(arg & (~1));
28454         arg_conv.is_owned = false;
28455         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28456         uint32_t ret_conv = UpdateFulfillHTLC_clone_ptr(&arg_conv);
28457         return ret_conv;
28458 }
28459
28460 uint32_t  __attribute__((export_name("TS_UpdateFulfillHTLC_clone"))) TS_UpdateFulfillHTLC_clone(uint32_t orig) {
28461         LDKUpdateFulfillHTLC orig_conv;
28462         orig_conv.inner = (void*)(orig & (~1));
28463         orig_conv.is_owned = false;
28464         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28465         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
28466         uint32_t ret_ref = 0;
28467         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28468         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28469         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28470         ret_ref = (uintptr_t)ret_var.inner;
28471         if (ret_var.is_owned) {
28472                 ret_ref |= 1;
28473         }
28474         return ret_ref;
28475 }
28476
28477 void  __attribute__((export_name("TS_UpdateFailHTLC_free"))) TS_UpdateFailHTLC_free(uint32_t this_obj) {
28478         LDKUpdateFailHTLC this_obj_conv;
28479         this_obj_conv.inner = (void*)(this_obj & (~1));
28480         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28482         UpdateFailHTLC_free(this_obj_conv);
28483 }
28484
28485 int8_tArray  __attribute__((export_name("TS_UpdateFailHTLC_get_channel_id"))) TS_UpdateFailHTLC_get_channel_id(uint32_t this_ptr) {
28486         LDKUpdateFailHTLC this_ptr_conv;
28487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28488         this_ptr_conv.is_owned = false;
28489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28490         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28491         memcpy(ret_arr->elems, *UpdateFailHTLC_get_channel_id(&this_ptr_conv), 32);
28492         return ret_arr;
28493 }
28494
28495 void  __attribute__((export_name("TS_UpdateFailHTLC_set_channel_id"))) TS_UpdateFailHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28496         LDKUpdateFailHTLC this_ptr_conv;
28497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28498         this_ptr_conv.is_owned = false;
28499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28500         LDKThirtyTwoBytes val_ref;
28501         CHECK(val->arr_len == 32);
28502         memcpy(val_ref.data, val->elems, 32); FREE(val);
28503         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
28504 }
28505
28506 int64_t  __attribute__((export_name("TS_UpdateFailHTLC_get_htlc_id"))) TS_UpdateFailHTLC_get_htlc_id(uint32_t this_ptr) {
28507         LDKUpdateFailHTLC this_ptr_conv;
28508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28509         this_ptr_conv.is_owned = false;
28510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28511         int64_t ret_conv = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
28512         return ret_conv;
28513 }
28514
28515 void  __attribute__((export_name("TS_UpdateFailHTLC_set_htlc_id"))) TS_UpdateFailHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
28516         LDKUpdateFailHTLC this_ptr_conv;
28517         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28518         this_ptr_conv.is_owned = false;
28519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28520         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
28521 }
28522
28523 static inline uintptr_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
28524         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
28525 uint32_t ret_ref = 0;
28526 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28527 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28528 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28529 ret_ref = (uintptr_t)ret_var.inner;
28530 if (ret_var.is_owned) {
28531         ret_ref |= 1;
28532 }
28533         return ret_ref;
28534 }
28535 uint32_t  __attribute__((export_name("TS_UpdateFailHTLC_clone_ptr"))) TS_UpdateFailHTLC_clone_ptr(uint32_t arg) {
28536         LDKUpdateFailHTLC arg_conv;
28537         arg_conv.inner = (void*)(arg & (~1));
28538         arg_conv.is_owned = false;
28539         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28540         uint32_t ret_conv = UpdateFailHTLC_clone_ptr(&arg_conv);
28541         return ret_conv;
28542 }
28543
28544 uint32_t  __attribute__((export_name("TS_UpdateFailHTLC_clone"))) TS_UpdateFailHTLC_clone(uint32_t orig) {
28545         LDKUpdateFailHTLC orig_conv;
28546         orig_conv.inner = (void*)(orig & (~1));
28547         orig_conv.is_owned = false;
28548         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28549         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
28550         uint32_t ret_ref = 0;
28551         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28552         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28553         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28554         ret_ref = (uintptr_t)ret_var.inner;
28555         if (ret_var.is_owned) {
28556                 ret_ref |= 1;
28557         }
28558         return ret_ref;
28559 }
28560
28561 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_free"))) TS_UpdateFailMalformedHTLC_free(uint32_t this_obj) {
28562         LDKUpdateFailMalformedHTLC this_obj_conv;
28563         this_obj_conv.inner = (void*)(this_obj & (~1));
28564         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28566         UpdateFailMalformedHTLC_free(this_obj_conv);
28567 }
28568
28569 int8_tArray  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_channel_id"))) TS_UpdateFailMalformedHTLC_get_channel_id(uint32_t this_ptr) {
28570         LDKUpdateFailMalformedHTLC this_ptr_conv;
28571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28572         this_ptr_conv.is_owned = false;
28573         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28574         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28575         memcpy(ret_arr->elems, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv), 32);
28576         return ret_arr;
28577 }
28578
28579 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_channel_id"))) TS_UpdateFailMalformedHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28580         LDKUpdateFailMalformedHTLC this_ptr_conv;
28581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28582         this_ptr_conv.is_owned = false;
28583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28584         LDKThirtyTwoBytes val_ref;
28585         CHECK(val->arr_len == 32);
28586         memcpy(val_ref.data, val->elems, 32); FREE(val);
28587         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
28588 }
28589
28590 int64_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_htlc_id"))) TS_UpdateFailMalformedHTLC_get_htlc_id(uint32_t this_ptr) {
28591         LDKUpdateFailMalformedHTLC this_ptr_conv;
28592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28593         this_ptr_conv.is_owned = false;
28594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28595         int64_t ret_conv = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
28596         return ret_conv;
28597 }
28598
28599 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_htlc_id"))) TS_UpdateFailMalformedHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
28600         LDKUpdateFailMalformedHTLC this_ptr_conv;
28601         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28602         this_ptr_conv.is_owned = false;
28603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28604         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
28605 }
28606
28607 int16_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_get_failure_code"))) TS_UpdateFailMalformedHTLC_get_failure_code(uint32_t this_ptr) {
28608         LDKUpdateFailMalformedHTLC this_ptr_conv;
28609         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28610         this_ptr_conv.is_owned = false;
28611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28612         int16_t ret_conv = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
28613         return ret_conv;
28614 }
28615
28616 void  __attribute__((export_name("TS_UpdateFailMalformedHTLC_set_failure_code"))) TS_UpdateFailMalformedHTLC_set_failure_code(uint32_t this_ptr, int16_t val) {
28617         LDKUpdateFailMalformedHTLC this_ptr_conv;
28618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28619         this_ptr_conv.is_owned = false;
28620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28621         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
28622 }
28623
28624 static inline uintptr_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
28625         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
28626 uint32_t ret_ref = 0;
28627 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28628 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28629 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28630 ret_ref = (uintptr_t)ret_var.inner;
28631 if (ret_var.is_owned) {
28632         ret_ref |= 1;
28633 }
28634         return ret_ref;
28635 }
28636 uint32_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_clone_ptr"))) TS_UpdateFailMalformedHTLC_clone_ptr(uint32_t arg) {
28637         LDKUpdateFailMalformedHTLC arg_conv;
28638         arg_conv.inner = (void*)(arg & (~1));
28639         arg_conv.is_owned = false;
28640         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28641         uint32_t ret_conv = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
28642         return ret_conv;
28643 }
28644
28645 uint32_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_clone"))) TS_UpdateFailMalformedHTLC_clone(uint32_t orig) {
28646         LDKUpdateFailMalformedHTLC orig_conv;
28647         orig_conv.inner = (void*)(orig & (~1));
28648         orig_conv.is_owned = false;
28649         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28650         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
28651         uint32_t ret_ref = 0;
28652         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28653         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28654         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28655         ret_ref = (uintptr_t)ret_var.inner;
28656         if (ret_var.is_owned) {
28657                 ret_ref |= 1;
28658         }
28659         return ret_ref;
28660 }
28661
28662 void  __attribute__((export_name("TS_CommitmentSigned_free"))) TS_CommitmentSigned_free(uint32_t this_obj) {
28663         LDKCommitmentSigned this_obj_conv;
28664         this_obj_conv.inner = (void*)(this_obj & (~1));
28665         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28667         CommitmentSigned_free(this_obj_conv);
28668 }
28669
28670 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_get_channel_id"))) TS_CommitmentSigned_get_channel_id(uint32_t this_ptr) {
28671         LDKCommitmentSigned this_ptr_conv;
28672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28673         this_ptr_conv.is_owned = false;
28674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28675         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28676         memcpy(ret_arr->elems, *CommitmentSigned_get_channel_id(&this_ptr_conv), 32);
28677         return ret_arr;
28678 }
28679
28680 void  __attribute__((export_name("TS_CommitmentSigned_set_channel_id"))) TS_CommitmentSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28681         LDKCommitmentSigned this_ptr_conv;
28682         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28683         this_ptr_conv.is_owned = false;
28684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28685         LDKThirtyTwoBytes val_ref;
28686         CHECK(val->arr_len == 32);
28687         memcpy(val_ref.data, val->elems, 32); FREE(val);
28688         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
28689 }
28690
28691 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_get_signature"))) TS_CommitmentSigned_get_signature(uint32_t this_ptr) {
28692         LDKCommitmentSigned this_ptr_conv;
28693         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28694         this_ptr_conv.is_owned = false;
28695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28696         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
28697         memcpy(ret_arr->elems, CommitmentSigned_get_signature(&this_ptr_conv).compact_form, 64);
28698         return ret_arr;
28699 }
28700
28701 void  __attribute__((export_name("TS_CommitmentSigned_set_signature"))) TS_CommitmentSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
28702         LDKCommitmentSigned this_ptr_conv;
28703         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28704         this_ptr_conv.is_owned = false;
28705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28706         LDKSignature val_ref;
28707         CHECK(val->arr_len == 64);
28708         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
28709         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
28710 }
28711
28712 void  __attribute__((export_name("TS_CommitmentSigned_set_htlc_signatures"))) TS_CommitmentSigned_set_htlc_signatures(uint32_t this_ptr, ptrArray val) {
28713         LDKCommitmentSigned this_ptr_conv;
28714         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28715         this_ptr_conv.is_owned = false;
28716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28717         LDKCVec_SignatureZ val_constr;
28718         val_constr.datalen = val->arr_len;
28719         if (val_constr.datalen > 0)
28720                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
28721         else
28722                 val_constr.data = NULL;
28723         int8_tArray* val_vals = (void*) val->elems /* XXX val leaks */;
28724         for (size_t m = 0; m < val_constr.datalen; m++) {
28725                 int8_tArray val_conv_12 = val_vals[m];
28726                 LDKSignature val_conv_12_ref;
28727                 CHECK(val_conv_12->arr_len == 64);
28728                 memcpy(val_conv_12_ref.compact_form, val_conv_12->elems, 64); FREE(val_conv_12);
28729                 val_constr.data[m] = val_conv_12_ref;
28730         }
28731         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
28732 }
28733
28734 uint32_t  __attribute__((export_name("TS_CommitmentSigned_new"))) TS_CommitmentSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg, ptrArray htlc_signatures_arg) {
28735         LDKThirtyTwoBytes channel_id_arg_ref;
28736         CHECK(channel_id_arg->arr_len == 32);
28737         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28738         LDKSignature signature_arg_ref;
28739         CHECK(signature_arg->arr_len == 64);
28740         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
28741         LDKCVec_SignatureZ htlc_signatures_arg_constr;
28742         htlc_signatures_arg_constr.datalen = htlc_signatures_arg->arr_len;
28743         if (htlc_signatures_arg_constr.datalen > 0)
28744                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
28745         else
28746                 htlc_signatures_arg_constr.data = NULL;
28747         int8_tArray* htlc_signatures_arg_vals = (void*) htlc_signatures_arg->elems /* XXX htlc_signatures_arg leaks */;
28748         for (size_t m = 0; m < htlc_signatures_arg_constr.datalen; m++) {
28749                 int8_tArray htlc_signatures_arg_conv_12 = htlc_signatures_arg_vals[m];
28750                 LDKSignature htlc_signatures_arg_conv_12_ref;
28751                 CHECK(htlc_signatures_arg_conv_12->arr_len == 64);
28752                 memcpy(htlc_signatures_arg_conv_12_ref.compact_form, htlc_signatures_arg_conv_12->elems, 64); FREE(htlc_signatures_arg_conv_12);
28753                 htlc_signatures_arg_constr.data[m] = htlc_signatures_arg_conv_12_ref;
28754         }
28755         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
28756         uint32_t ret_ref = 0;
28757         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28758         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28759         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28760         ret_ref = (uintptr_t)ret_var.inner;
28761         if (ret_var.is_owned) {
28762                 ret_ref |= 1;
28763         }
28764         return ret_ref;
28765 }
28766
28767 static inline uintptr_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
28768         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
28769 uint32_t ret_ref = 0;
28770 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28771 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28772 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28773 ret_ref = (uintptr_t)ret_var.inner;
28774 if (ret_var.is_owned) {
28775         ret_ref |= 1;
28776 }
28777         return ret_ref;
28778 }
28779 uint32_t  __attribute__((export_name("TS_CommitmentSigned_clone_ptr"))) TS_CommitmentSigned_clone_ptr(uint32_t arg) {
28780         LDKCommitmentSigned arg_conv;
28781         arg_conv.inner = (void*)(arg & (~1));
28782         arg_conv.is_owned = false;
28783         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28784         uint32_t ret_conv = CommitmentSigned_clone_ptr(&arg_conv);
28785         return ret_conv;
28786 }
28787
28788 uint32_t  __attribute__((export_name("TS_CommitmentSigned_clone"))) TS_CommitmentSigned_clone(uint32_t orig) {
28789         LDKCommitmentSigned orig_conv;
28790         orig_conv.inner = (void*)(orig & (~1));
28791         orig_conv.is_owned = false;
28792         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28793         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
28794         uint32_t ret_ref = 0;
28795         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28796         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28797         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28798         ret_ref = (uintptr_t)ret_var.inner;
28799         if (ret_var.is_owned) {
28800                 ret_ref |= 1;
28801         }
28802         return ret_ref;
28803 }
28804
28805 void  __attribute__((export_name("TS_RevokeAndACK_free"))) TS_RevokeAndACK_free(uint32_t this_obj) {
28806         LDKRevokeAndACK this_obj_conv;
28807         this_obj_conv.inner = (void*)(this_obj & (~1));
28808         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28810         RevokeAndACK_free(this_obj_conv);
28811 }
28812
28813 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_channel_id"))) TS_RevokeAndACK_get_channel_id(uint32_t this_ptr) {
28814         LDKRevokeAndACK this_ptr_conv;
28815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28816         this_ptr_conv.is_owned = false;
28817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28818         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28819         memcpy(ret_arr->elems, *RevokeAndACK_get_channel_id(&this_ptr_conv), 32);
28820         return ret_arr;
28821 }
28822
28823 void  __attribute__((export_name("TS_RevokeAndACK_set_channel_id"))) TS_RevokeAndACK_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28824         LDKRevokeAndACK this_ptr_conv;
28825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28826         this_ptr_conv.is_owned = false;
28827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28828         LDKThirtyTwoBytes val_ref;
28829         CHECK(val->arr_len == 32);
28830         memcpy(val_ref.data, val->elems, 32); FREE(val);
28831         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
28832 }
28833
28834 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_per_commitment_secret"))) TS_RevokeAndACK_get_per_commitment_secret(uint32_t this_ptr) {
28835         LDKRevokeAndACK this_ptr_conv;
28836         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28837         this_ptr_conv.is_owned = false;
28838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28839         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28840         memcpy(ret_arr->elems, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv), 32);
28841         return ret_arr;
28842 }
28843
28844 void  __attribute__((export_name("TS_RevokeAndACK_set_per_commitment_secret"))) TS_RevokeAndACK_set_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
28845         LDKRevokeAndACK this_ptr_conv;
28846         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28847         this_ptr_conv.is_owned = false;
28848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28849         LDKThirtyTwoBytes val_ref;
28850         CHECK(val->arr_len == 32);
28851         memcpy(val_ref.data, val->elems, 32); FREE(val);
28852         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
28853 }
28854
28855 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_get_next_per_commitment_point"))) TS_RevokeAndACK_get_next_per_commitment_point(uint32_t this_ptr) {
28856         LDKRevokeAndACK this_ptr_conv;
28857         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28858         this_ptr_conv.is_owned = false;
28859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28860         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
28861         memcpy(ret_arr->elems, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
28862         return ret_arr;
28863 }
28864
28865 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) {
28866         LDKRevokeAndACK this_ptr_conv;
28867         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28868         this_ptr_conv.is_owned = false;
28869         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28870         LDKPublicKey val_ref;
28871         CHECK(val->arr_len == 33);
28872         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
28873         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
28874 }
28875
28876 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) {
28877         LDKThirtyTwoBytes channel_id_arg_ref;
28878         CHECK(channel_id_arg->arr_len == 32);
28879         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28880         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
28881         CHECK(per_commitment_secret_arg->arr_len == 32);
28882         memcpy(per_commitment_secret_arg_ref.data, per_commitment_secret_arg->elems, 32); FREE(per_commitment_secret_arg);
28883         LDKPublicKey next_per_commitment_point_arg_ref;
28884         CHECK(next_per_commitment_point_arg->arr_len == 33);
28885         memcpy(next_per_commitment_point_arg_ref.compressed_form, next_per_commitment_point_arg->elems, 33); FREE(next_per_commitment_point_arg);
28886         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
28887         uint32_t ret_ref = 0;
28888         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28889         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28890         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28891         ret_ref = (uintptr_t)ret_var.inner;
28892         if (ret_var.is_owned) {
28893                 ret_ref |= 1;
28894         }
28895         return ret_ref;
28896 }
28897
28898 static inline uintptr_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
28899         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
28900 uint32_t ret_ref = 0;
28901 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28902 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28903 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28904 ret_ref = (uintptr_t)ret_var.inner;
28905 if (ret_var.is_owned) {
28906         ret_ref |= 1;
28907 }
28908         return ret_ref;
28909 }
28910 uint32_t  __attribute__((export_name("TS_RevokeAndACK_clone_ptr"))) TS_RevokeAndACK_clone_ptr(uint32_t arg) {
28911         LDKRevokeAndACK arg_conv;
28912         arg_conv.inner = (void*)(arg & (~1));
28913         arg_conv.is_owned = false;
28914         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28915         uint32_t ret_conv = RevokeAndACK_clone_ptr(&arg_conv);
28916         return ret_conv;
28917 }
28918
28919 uint32_t  __attribute__((export_name("TS_RevokeAndACK_clone"))) TS_RevokeAndACK_clone(uint32_t orig) {
28920         LDKRevokeAndACK orig_conv;
28921         orig_conv.inner = (void*)(orig & (~1));
28922         orig_conv.is_owned = false;
28923         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28924         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
28925         uint32_t ret_ref = 0;
28926         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28927         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28928         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28929         ret_ref = (uintptr_t)ret_var.inner;
28930         if (ret_var.is_owned) {
28931                 ret_ref |= 1;
28932         }
28933         return ret_ref;
28934 }
28935
28936 void  __attribute__((export_name("TS_UpdateFee_free"))) TS_UpdateFee_free(uint32_t this_obj) {
28937         LDKUpdateFee this_obj_conv;
28938         this_obj_conv.inner = (void*)(this_obj & (~1));
28939         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28941         UpdateFee_free(this_obj_conv);
28942 }
28943
28944 int8_tArray  __attribute__((export_name("TS_UpdateFee_get_channel_id"))) TS_UpdateFee_get_channel_id(uint32_t this_ptr) {
28945         LDKUpdateFee this_ptr_conv;
28946         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28947         this_ptr_conv.is_owned = false;
28948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28949         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
28950         memcpy(ret_arr->elems, *UpdateFee_get_channel_id(&this_ptr_conv), 32);
28951         return ret_arr;
28952 }
28953
28954 void  __attribute__((export_name("TS_UpdateFee_set_channel_id"))) TS_UpdateFee_set_channel_id(uint32_t this_ptr, int8_tArray val) {
28955         LDKUpdateFee this_ptr_conv;
28956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28957         this_ptr_conv.is_owned = false;
28958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28959         LDKThirtyTwoBytes val_ref;
28960         CHECK(val->arr_len == 32);
28961         memcpy(val_ref.data, val->elems, 32); FREE(val);
28962         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
28963 }
28964
28965 int32_t  __attribute__((export_name("TS_UpdateFee_get_feerate_per_kw"))) TS_UpdateFee_get_feerate_per_kw(uint32_t this_ptr) {
28966         LDKUpdateFee this_ptr_conv;
28967         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28968         this_ptr_conv.is_owned = false;
28969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28970         int32_t ret_conv = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
28971         return ret_conv;
28972 }
28973
28974 void  __attribute__((export_name("TS_UpdateFee_set_feerate_per_kw"))) TS_UpdateFee_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
28975         LDKUpdateFee this_ptr_conv;
28976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28977         this_ptr_conv.is_owned = false;
28978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28979         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
28980 }
28981
28982 uint32_t  __attribute__((export_name("TS_UpdateFee_new"))) TS_UpdateFee_new(int8_tArray channel_id_arg, int32_t feerate_per_kw_arg) {
28983         LDKThirtyTwoBytes channel_id_arg_ref;
28984         CHECK(channel_id_arg->arr_len == 32);
28985         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
28986         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
28987         uint32_t ret_ref = 0;
28988         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28989         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28990         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28991         ret_ref = (uintptr_t)ret_var.inner;
28992         if (ret_var.is_owned) {
28993                 ret_ref |= 1;
28994         }
28995         return ret_ref;
28996 }
28997
28998 static inline uintptr_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
28999         LDKUpdateFee ret_var = UpdateFee_clone(arg);
29000 uint32_t ret_ref = 0;
29001 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29002 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29003 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29004 ret_ref = (uintptr_t)ret_var.inner;
29005 if (ret_var.is_owned) {
29006         ret_ref |= 1;
29007 }
29008         return ret_ref;
29009 }
29010 uint32_t  __attribute__((export_name("TS_UpdateFee_clone_ptr"))) TS_UpdateFee_clone_ptr(uint32_t arg) {
29011         LDKUpdateFee arg_conv;
29012         arg_conv.inner = (void*)(arg & (~1));
29013         arg_conv.is_owned = false;
29014         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29015         uint32_t ret_conv = UpdateFee_clone_ptr(&arg_conv);
29016         return ret_conv;
29017 }
29018
29019 uint32_t  __attribute__((export_name("TS_UpdateFee_clone"))) TS_UpdateFee_clone(uint32_t orig) {
29020         LDKUpdateFee orig_conv;
29021         orig_conv.inner = (void*)(orig & (~1));
29022         orig_conv.is_owned = false;
29023         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29024         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
29025         uint32_t ret_ref = 0;
29026         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29027         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29028         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29029         ret_ref = (uintptr_t)ret_var.inner;
29030         if (ret_var.is_owned) {
29031                 ret_ref |= 1;
29032         }
29033         return ret_ref;
29034 }
29035
29036 void  __attribute__((export_name("TS_DataLossProtect_free"))) TS_DataLossProtect_free(uint32_t this_obj) {
29037         LDKDataLossProtect this_obj_conv;
29038         this_obj_conv.inner = (void*)(this_obj & (~1));
29039         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29041         DataLossProtect_free(this_obj_conv);
29042 }
29043
29044 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) {
29045         LDKDataLossProtect this_ptr_conv;
29046         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29047         this_ptr_conv.is_owned = false;
29048         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29049         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29050         memcpy(ret_arr->elems, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv), 32);
29051         return ret_arr;
29052 }
29053
29054 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) {
29055         LDKDataLossProtect this_ptr_conv;
29056         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29057         this_ptr_conv.is_owned = false;
29058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29059         LDKThirtyTwoBytes val_ref;
29060         CHECK(val->arr_len == 32);
29061         memcpy(val_ref.data, val->elems, 32); FREE(val);
29062         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
29063 }
29064
29065 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) {
29066         LDKDataLossProtect this_ptr_conv;
29067         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29068         this_ptr_conv.is_owned = false;
29069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29070         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29071         memcpy(ret_arr->elems, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form, 33);
29072         return ret_arr;
29073 }
29074
29075 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) {
29076         LDKDataLossProtect this_ptr_conv;
29077         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29078         this_ptr_conv.is_owned = false;
29079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29080         LDKPublicKey val_ref;
29081         CHECK(val->arr_len == 33);
29082         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29083         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
29084 }
29085
29086 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) {
29087         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
29088         CHECK(your_last_per_commitment_secret_arg->arr_len == 32);
29089         memcpy(your_last_per_commitment_secret_arg_ref.data, your_last_per_commitment_secret_arg->elems, 32); FREE(your_last_per_commitment_secret_arg);
29090         LDKPublicKey my_current_per_commitment_point_arg_ref;
29091         CHECK(my_current_per_commitment_point_arg->arr_len == 33);
29092         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);
29093         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
29094         uint32_t ret_ref = 0;
29095         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29096         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29097         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29098         ret_ref = (uintptr_t)ret_var.inner;
29099         if (ret_var.is_owned) {
29100                 ret_ref |= 1;
29101         }
29102         return ret_ref;
29103 }
29104
29105 static inline uintptr_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
29106         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
29107 uint32_t ret_ref = 0;
29108 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29109 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29110 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29111 ret_ref = (uintptr_t)ret_var.inner;
29112 if (ret_var.is_owned) {
29113         ret_ref |= 1;
29114 }
29115         return ret_ref;
29116 }
29117 uint32_t  __attribute__((export_name("TS_DataLossProtect_clone_ptr"))) TS_DataLossProtect_clone_ptr(uint32_t arg) {
29118         LDKDataLossProtect arg_conv;
29119         arg_conv.inner = (void*)(arg & (~1));
29120         arg_conv.is_owned = false;
29121         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29122         uint32_t ret_conv = DataLossProtect_clone_ptr(&arg_conv);
29123         return ret_conv;
29124 }
29125
29126 uint32_t  __attribute__((export_name("TS_DataLossProtect_clone"))) TS_DataLossProtect_clone(uint32_t orig) {
29127         LDKDataLossProtect orig_conv;
29128         orig_conv.inner = (void*)(orig & (~1));
29129         orig_conv.is_owned = false;
29130         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29131         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
29132         uint32_t ret_ref = 0;
29133         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29134         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29135         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29136         ret_ref = (uintptr_t)ret_var.inner;
29137         if (ret_var.is_owned) {
29138                 ret_ref |= 1;
29139         }
29140         return ret_ref;
29141 }
29142
29143 void  __attribute__((export_name("TS_ChannelReestablish_free"))) TS_ChannelReestablish_free(uint32_t this_obj) {
29144         LDKChannelReestablish this_obj_conv;
29145         this_obj_conv.inner = (void*)(this_obj & (~1));
29146         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29148         ChannelReestablish_free(this_obj_conv);
29149 }
29150
29151 int8_tArray  __attribute__((export_name("TS_ChannelReestablish_get_channel_id"))) TS_ChannelReestablish_get_channel_id(uint32_t this_ptr) {
29152         LDKChannelReestablish this_ptr_conv;
29153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29154         this_ptr_conv.is_owned = false;
29155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29156         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29157         memcpy(ret_arr->elems, *ChannelReestablish_get_channel_id(&this_ptr_conv), 32);
29158         return ret_arr;
29159 }
29160
29161 void  __attribute__((export_name("TS_ChannelReestablish_set_channel_id"))) TS_ChannelReestablish_set_channel_id(uint32_t this_ptr, int8_tArray val) {
29162         LDKChannelReestablish this_ptr_conv;
29163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29164         this_ptr_conv.is_owned = false;
29165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29166         LDKThirtyTwoBytes val_ref;
29167         CHECK(val->arr_len == 32);
29168         memcpy(val_ref.data, val->elems, 32); FREE(val);
29169         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
29170 }
29171
29172 int64_t  __attribute__((export_name("TS_ChannelReestablish_get_next_local_commitment_number"))) TS_ChannelReestablish_get_next_local_commitment_number(uint32_t this_ptr) {
29173         LDKChannelReestablish this_ptr_conv;
29174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29175         this_ptr_conv.is_owned = false;
29176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29177         int64_t ret_conv = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
29178         return ret_conv;
29179 }
29180
29181 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) {
29182         LDKChannelReestablish this_ptr_conv;
29183         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29184         this_ptr_conv.is_owned = false;
29185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29186         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
29187 }
29188
29189 int64_t  __attribute__((export_name("TS_ChannelReestablish_get_next_remote_commitment_number"))) TS_ChannelReestablish_get_next_remote_commitment_number(uint32_t this_ptr) {
29190         LDKChannelReestablish this_ptr_conv;
29191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29192         this_ptr_conv.is_owned = false;
29193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29194         int64_t ret_conv = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
29195         return ret_conv;
29196 }
29197
29198 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) {
29199         LDKChannelReestablish this_ptr_conv;
29200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29201         this_ptr_conv.is_owned = false;
29202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29203         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
29204 }
29205
29206 static inline uintptr_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
29207         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
29208 uint32_t ret_ref = 0;
29209 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29210 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29211 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29212 ret_ref = (uintptr_t)ret_var.inner;
29213 if (ret_var.is_owned) {
29214         ret_ref |= 1;
29215 }
29216         return ret_ref;
29217 }
29218 uint32_t  __attribute__((export_name("TS_ChannelReestablish_clone_ptr"))) TS_ChannelReestablish_clone_ptr(uint32_t arg) {
29219         LDKChannelReestablish arg_conv;
29220         arg_conv.inner = (void*)(arg & (~1));
29221         arg_conv.is_owned = false;
29222         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29223         uint32_t ret_conv = ChannelReestablish_clone_ptr(&arg_conv);
29224         return ret_conv;
29225 }
29226
29227 uint32_t  __attribute__((export_name("TS_ChannelReestablish_clone"))) TS_ChannelReestablish_clone(uint32_t orig) {
29228         LDKChannelReestablish orig_conv;
29229         orig_conv.inner = (void*)(orig & (~1));
29230         orig_conv.is_owned = false;
29231         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29232         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
29233         uint32_t ret_ref = 0;
29234         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29235         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29236         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29237         ret_ref = (uintptr_t)ret_var.inner;
29238         if (ret_var.is_owned) {
29239                 ret_ref |= 1;
29240         }
29241         return ret_ref;
29242 }
29243
29244 void  __attribute__((export_name("TS_AnnouncementSignatures_free"))) TS_AnnouncementSignatures_free(uint32_t this_obj) {
29245         LDKAnnouncementSignatures this_obj_conv;
29246         this_obj_conv.inner = (void*)(this_obj & (~1));
29247         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29249         AnnouncementSignatures_free(this_obj_conv);
29250 }
29251
29252 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_channel_id"))) TS_AnnouncementSignatures_get_channel_id(uint32_t this_ptr) {
29253         LDKAnnouncementSignatures this_ptr_conv;
29254         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29255         this_ptr_conv.is_owned = false;
29256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29257         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29258         memcpy(ret_arr->elems, *AnnouncementSignatures_get_channel_id(&this_ptr_conv), 32);
29259         return ret_arr;
29260 }
29261
29262 void  __attribute__((export_name("TS_AnnouncementSignatures_set_channel_id"))) TS_AnnouncementSignatures_set_channel_id(uint32_t this_ptr, int8_tArray val) {
29263         LDKAnnouncementSignatures this_ptr_conv;
29264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29265         this_ptr_conv.is_owned = false;
29266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29267         LDKThirtyTwoBytes val_ref;
29268         CHECK(val->arr_len == 32);
29269         memcpy(val_ref.data, val->elems, 32); FREE(val);
29270         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
29271 }
29272
29273 int64_t  __attribute__((export_name("TS_AnnouncementSignatures_get_short_channel_id"))) TS_AnnouncementSignatures_get_short_channel_id(uint32_t this_ptr) {
29274         LDKAnnouncementSignatures this_ptr_conv;
29275         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29276         this_ptr_conv.is_owned = false;
29277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29278         int64_t ret_conv = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
29279         return ret_conv;
29280 }
29281
29282 void  __attribute__((export_name("TS_AnnouncementSignatures_set_short_channel_id"))) TS_AnnouncementSignatures_set_short_channel_id(uint32_t this_ptr, int64_t val) {
29283         LDKAnnouncementSignatures this_ptr_conv;
29284         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29285         this_ptr_conv.is_owned = false;
29286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29287         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
29288 }
29289
29290 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_node_signature"))) TS_AnnouncementSignatures_get_node_signature(uint32_t this_ptr) {
29291         LDKAnnouncementSignatures this_ptr_conv;
29292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29293         this_ptr_conv.is_owned = false;
29294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29295         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29296         memcpy(ret_arr->elems, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form, 64);
29297         return ret_arr;
29298 }
29299
29300 void  __attribute__((export_name("TS_AnnouncementSignatures_set_node_signature"))) TS_AnnouncementSignatures_set_node_signature(uint32_t this_ptr, int8_tArray val) {
29301         LDKAnnouncementSignatures this_ptr_conv;
29302         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29303         this_ptr_conv.is_owned = false;
29304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29305         LDKSignature val_ref;
29306         CHECK(val->arr_len == 64);
29307         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29308         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
29309 }
29310
29311 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_get_bitcoin_signature"))) TS_AnnouncementSignatures_get_bitcoin_signature(uint32_t this_ptr) {
29312         LDKAnnouncementSignatures this_ptr_conv;
29313         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29314         this_ptr_conv.is_owned = false;
29315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29316         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29317         memcpy(ret_arr->elems, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form, 64);
29318         return ret_arr;
29319 }
29320
29321 void  __attribute__((export_name("TS_AnnouncementSignatures_set_bitcoin_signature"))) TS_AnnouncementSignatures_set_bitcoin_signature(uint32_t this_ptr, int8_tArray val) {
29322         LDKAnnouncementSignatures this_ptr_conv;
29323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29324         this_ptr_conv.is_owned = false;
29325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29326         LDKSignature val_ref;
29327         CHECK(val->arr_len == 64);
29328         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29329         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
29330 }
29331
29332 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) {
29333         LDKThirtyTwoBytes channel_id_arg_ref;
29334         CHECK(channel_id_arg->arr_len == 32);
29335         memcpy(channel_id_arg_ref.data, channel_id_arg->elems, 32); FREE(channel_id_arg);
29336         LDKSignature node_signature_arg_ref;
29337         CHECK(node_signature_arg->arr_len == 64);
29338         memcpy(node_signature_arg_ref.compact_form, node_signature_arg->elems, 64); FREE(node_signature_arg);
29339         LDKSignature bitcoin_signature_arg_ref;
29340         CHECK(bitcoin_signature_arg->arr_len == 64);
29341         memcpy(bitcoin_signature_arg_ref.compact_form, bitcoin_signature_arg->elems, 64); FREE(bitcoin_signature_arg);
29342         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
29343         uint32_t ret_ref = 0;
29344         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29345         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29346         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29347         ret_ref = (uintptr_t)ret_var.inner;
29348         if (ret_var.is_owned) {
29349                 ret_ref |= 1;
29350         }
29351         return ret_ref;
29352 }
29353
29354 static inline uintptr_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
29355         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
29356 uint32_t ret_ref = 0;
29357 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29358 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29359 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29360 ret_ref = (uintptr_t)ret_var.inner;
29361 if (ret_var.is_owned) {
29362         ret_ref |= 1;
29363 }
29364         return ret_ref;
29365 }
29366 uint32_t  __attribute__((export_name("TS_AnnouncementSignatures_clone_ptr"))) TS_AnnouncementSignatures_clone_ptr(uint32_t arg) {
29367         LDKAnnouncementSignatures arg_conv;
29368         arg_conv.inner = (void*)(arg & (~1));
29369         arg_conv.is_owned = false;
29370         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29371         uint32_t ret_conv = AnnouncementSignatures_clone_ptr(&arg_conv);
29372         return ret_conv;
29373 }
29374
29375 uint32_t  __attribute__((export_name("TS_AnnouncementSignatures_clone"))) TS_AnnouncementSignatures_clone(uint32_t orig) {
29376         LDKAnnouncementSignatures orig_conv;
29377         orig_conv.inner = (void*)(orig & (~1));
29378         orig_conv.is_owned = false;
29379         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29380         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
29381         uint32_t ret_ref = 0;
29382         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29383         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29384         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29385         ret_ref = (uintptr_t)ret_var.inner;
29386         if (ret_var.is_owned) {
29387                 ret_ref |= 1;
29388         }
29389         return ret_ref;
29390 }
29391
29392 void  __attribute__((export_name("TS_NetAddress_free"))) TS_NetAddress_free(uint32_t this_ptr) {
29393         if ((this_ptr & 1) != 0) return;
29394         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
29395         CHECK_ACCESS(this_ptr_ptr);
29396         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
29397         FREE((void*)this_ptr);
29398         NetAddress_free(this_ptr_conv);
29399 }
29400
29401 static inline uintptr_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
29402         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
29403         *ret_copy = NetAddress_clone(arg);
29404 uint32_t ret_ref = (uintptr_t)ret_copy;
29405         return ret_ref;
29406 }
29407 uint32_t  __attribute__((export_name("TS_NetAddress_clone_ptr"))) TS_NetAddress_clone_ptr(uint32_t arg) {
29408         LDKNetAddress* arg_conv = (LDKNetAddress*)arg;
29409         uint32_t ret_conv = NetAddress_clone_ptr(arg_conv);
29410         return ret_conv;
29411 }
29412
29413 uint32_t  __attribute__((export_name("TS_NetAddress_clone"))) TS_NetAddress_clone(uint32_t orig) {
29414         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
29415         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
29416         *ret_copy = NetAddress_clone(orig_conv);
29417         uint32_t ret_ref = (uintptr_t)ret_copy;
29418         return ret_ref;
29419 }
29420
29421 uint32_t  __attribute__((export_name("TS_NetAddress_ipv4"))) TS_NetAddress_ipv4(int8_tArray addr, int16_t port) {
29422         LDKFourBytes addr_ref;
29423         CHECK(addr->arr_len == 4);
29424         memcpy(addr_ref.data, addr->elems, 4); FREE(addr);
29425         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
29426         *ret_copy = NetAddress_ipv4(addr_ref, port);
29427         uint32_t ret_ref = (uintptr_t)ret_copy;
29428         return ret_ref;
29429 }
29430
29431 uint32_t  __attribute__((export_name("TS_NetAddress_ipv6"))) TS_NetAddress_ipv6(int8_tArray addr, int16_t port) {
29432         LDKSixteenBytes addr_ref;
29433         CHECK(addr->arr_len == 16);
29434         memcpy(addr_ref.data, addr->elems, 16); FREE(addr);
29435         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
29436         *ret_copy = NetAddress_ipv6(addr_ref, port);
29437         uint32_t ret_ref = (uintptr_t)ret_copy;
29438         return ret_ref;
29439 }
29440
29441 uint32_t  __attribute__((export_name("TS_NetAddress_onion_v2"))) TS_NetAddress_onion_v2(int8_tArray a) {
29442         LDKTwelveBytes a_ref;
29443         CHECK(a->arr_len == 12);
29444         memcpy(a_ref.data, a->elems, 12); FREE(a);
29445         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
29446         *ret_copy = NetAddress_onion_v2(a_ref);
29447         uint32_t ret_ref = (uintptr_t)ret_copy;
29448         return ret_ref;
29449 }
29450
29451 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) {
29452         LDKThirtyTwoBytes ed25519_pubkey_ref;
29453         CHECK(ed25519_pubkey->arr_len == 32);
29454         memcpy(ed25519_pubkey_ref.data, ed25519_pubkey->elems, 32); FREE(ed25519_pubkey);
29455         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
29456         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
29457         uint32_t ret_ref = (uintptr_t)ret_copy;
29458         return ret_ref;
29459 }
29460
29461 int8_tArray  __attribute__((export_name("TS_NetAddress_write"))) TS_NetAddress_write(uint32_t obj) {
29462         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
29463         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
29464         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
29465         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
29466         CVec_u8Z_free(ret_var);
29467         return ret_arr;
29468 }
29469
29470 uint32_t  __attribute__((export_name("TS_NetAddress_read"))) TS_NetAddress_read(int8_tArray ser) {
29471         LDKu8slice ser_ref;
29472         ser_ref.datalen = ser->arr_len;
29473         ser_ref.data = ser->elems /* XXX ser leaks */;
29474         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
29475         *ret_conv = NetAddress_read(ser_ref);
29476         return (uint32_t)ret_conv;
29477 }
29478
29479 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_free"))) TS_UnsignedNodeAnnouncement_free(uint32_t this_obj) {
29480         LDKUnsignedNodeAnnouncement this_obj_conv;
29481         this_obj_conv.inner = (void*)(this_obj & (~1));
29482         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29484         UnsignedNodeAnnouncement_free(this_obj_conv);
29485 }
29486
29487 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_features"))) TS_UnsignedNodeAnnouncement_get_features(uint32_t this_ptr) {
29488         LDKUnsignedNodeAnnouncement this_ptr_conv;
29489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29490         this_ptr_conv.is_owned = false;
29491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29492         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
29493         uint32_t ret_ref = 0;
29494         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29495         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29496         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29497         ret_ref = (uintptr_t)ret_var.inner;
29498         if (ret_var.is_owned) {
29499                 ret_ref |= 1;
29500         }
29501         return ret_ref;
29502 }
29503
29504 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_features"))) TS_UnsignedNodeAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
29505         LDKUnsignedNodeAnnouncement this_ptr_conv;
29506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29507         this_ptr_conv.is_owned = false;
29508         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29509         LDKNodeFeatures val_conv;
29510         val_conv.inner = (void*)(val & (~1));
29511         val_conv.is_owned = (val & 1) || (val == 0);
29512         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29513         val_conv = NodeFeatures_clone(&val_conv);
29514         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
29515 }
29516
29517 int32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_timestamp"))) TS_UnsignedNodeAnnouncement_get_timestamp(uint32_t this_ptr) {
29518         LDKUnsignedNodeAnnouncement this_ptr_conv;
29519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29520         this_ptr_conv.is_owned = false;
29521         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29522         int32_t ret_conv = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
29523         return ret_conv;
29524 }
29525
29526 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_timestamp"))) TS_UnsignedNodeAnnouncement_set_timestamp(uint32_t this_ptr, int32_t val) {
29527         LDKUnsignedNodeAnnouncement this_ptr_conv;
29528         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29529         this_ptr_conv.is_owned = false;
29530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29531         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
29532 }
29533
29534 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_node_id"))) TS_UnsignedNodeAnnouncement_get_node_id(uint32_t this_ptr) {
29535         LDKUnsignedNodeAnnouncement this_ptr_conv;
29536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29537         this_ptr_conv.is_owned = false;
29538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29539         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29540         memcpy(ret_arr->elems, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form, 33);
29541         return ret_arr;
29542 }
29543
29544 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_node_id"))) TS_UnsignedNodeAnnouncement_set_node_id(uint32_t this_ptr, int8_tArray val) {
29545         LDKUnsignedNodeAnnouncement this_ptr_conv;
29546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29547         this_ptr_conv.is_owned = false;
29548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29549         LDKPublicKey val_ref;
29550         CHECK(val->arr_len == 33);
29551         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29552         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
29553 }
29554
29555 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_rgb"))) TS_UnsignedNodeAnnouncement_get_rgb(uint32_t this_ptr) {
29556         LDKUnsignedNodeAnnouncement this_ptr_conv;
29557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29558         this_ptr_conv.is_owned = false;
29559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29560         int8_tArray ret_arr = init_int8_tArray(3, __LINE__);
29561         memcpy(ret_arr->elems, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv), 3);
29562         return ret_arr;
29563 }
29564
29565 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_rgb"))) TS_UnsignedNodeAnnouncement_set_rgb(uint32_t this_ptr, int8_tArray val) {
29566         LDKUnsignedNodeAnnouncement this_ptr_conv;
29567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29568         this_ptr_conv.is_owned = false;
29569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29570         LDKThreeBytes val_ref;
29571         CHECK(val->arr_len == 3);
29572         memcpy(val_ref.data, val->elems, 3); FREE(val);
29573         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
29574 }
29575
29576 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_get_alias"))) TS_UnsignedNodeAnnouncement_get_alias(uint32_t this_ptr) {
29577         LDKUnsignedNodeAnnouncement this_ptr_conv;
29578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29579         this_ptr_conv.is_owned = false;
29580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29581         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29582         memcpy(ret_arr->elems, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv), 32);
29583         return ret_arr;
29584 }
29585
29586 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_alias"))) TS_UnsignedNodeAnnouncement_set_alias(uint32_t this_ptr, int8_tArray val) {
29587         LDKUnsignedNodeAnnouncement this_ptr_conv;
29588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29589         this_ptr_conv.is_owned = false;
29590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29591         LDKThirtyTwoBytes val_ref;
29592         CHECK(val->arr_len == 32);
29593         memcpy(val_ref.data, val->elems, 32); FREE(val);
29594         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
29595 }
29596
29597 void  __attribute__((export_name("TS_UnsignedNodeAnnouncement_set_addresses"))) TS_UnsignedNodeAnnouncement_set_addresses(uint32_t this_ptr, uint32_tArray val) {
29598         LDKUnsignedNodeAnnouncement this_ptr_conv;
29599         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29600         this_ptr_conv.is_owned = false;
29601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29602         LDKCVec_NetAddressZ val_constr;
29603         val_constr.datalen = val->arr_len;
29604         if (val_constr.datalen > 0)
29605                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
29606         else
29607                 val_constr.data = NULL;
29608         uint32_t* val_vals = val->elems /* XXX val leaks */;
29609         for (size_t m = 0; m < val_constr.datalen; m++) {
29610                 uint32_t val_conv_12 = val_vals[m];
29611                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
29612                 CHECK_ACCESS(val_conv_12_ptr);
29613                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
29614                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
29615                 val_constr.data[m] = val_conv_12_conv;
29616         }
29617         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
29618 }
29619
29620 static inline uintptr_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
29621         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
29622 uint32_t ret_ref = 0;
29623 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29624 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29625 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29626 ret_ref = (uintptr_t)ret_var.inner;
29627 if (ret_var.is_owned) {
29628         ret_ref |= 1;
29629 }
29630         return ret_ref;
29631 }
29632 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_clone_ptr"))) TS_UnsignedNodeAnnouncement_clone_ptr(uint32_t arg) {
29633         LDKUnsignedNodeAnnouncement arg_conv;
29634         arg_conv.inner = (void*)(arg & (~1));
29635         arg_conv.is_owned = false;
29636         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29637         uint32_t ret_conv = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
29638         return ret_conv;
29639 }
29640
29641 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_clone"))) TS_UnsignedNodeAnnouncement_clone(uint32_t orig) {
29642         LDKUnsignedNodeAnnouncement orig_conv;
29643         orig_conv.inner = (void*)(orig & (~1));
29644         orig_conv.is_owned = false;
29645         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29646         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
29647         uint32_t ret_ref = 0;
29648         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29649         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29650         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29651         ret_ref = (uintptr_t)ret_var.inner;
29652         if (ret_var.is_owned) {
29653                 ret_ref |= 1;
29654         }
29655         return ret_ref;
29656 }
29657
29658 void  __attribute__((export_name("TS_NodeAnnouncement_free"))) TS_NodeAnnouncement_free(uint32_t this_obj) {
29659         LDKNodeAnnouncement this_obj_conv;
29660         this_obj_conv.inner = (void*)(this_obj & (~1));
29661         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29663         NodeAnnouncement_free(this_obj_conv);
29664 }
29665
29666 int8_tArray  __attribute__((export_name("TS_NodeAnnouncement_get_signature"))) TS_NodeAnnouncement_get_signature(uint32_t this_ptr) {
29667         LDKNodeAnnouncement this_ptr_conv;
29668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29669         this_ptr_conv.is_owned = false;
29670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29671         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29672         memcpy(ret_arr->elems, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form, 64);
29673         return ret_arr;
29674 }
29675
29676 void  __attribute__((export_name("TS_NodeAnnouncement_set_signature"))) TS_NodeAnnouncement_set_signature(uint32_t this_ptr, int8_tArray val) {
29677         LDKNodeAnnouncement this_ptr_conv;
29678         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29679         this_ptr_conv.is_owned = false;
29680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29681         LDKSignature val_ref;
29682         CHECK(val->arr_len == 64);
29683         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
29684         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
29685 }
29686
29687 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_get_contents"))) TS_NodeAnnouncement_get_contents(uint32_t this_ptr) {
29688         LDKNodeAnnouncement this_ptr_conv;
29689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29690         this_ptr_conv.is_owned = false;
29691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29692         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
29693         uint32_t ret_ref = 0;
29694         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29695         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29696         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29697         ret_ref = (uintptr_t)ret_var.inner;
29698         if (ret_var.is_owned) {
29699                 ret_ref |= 1;
29700         }
29701         return ret_ref;
29702 }
29703
29704 void  __attribute__((export_name("TS_NodeAnnouncement_set_contents"))) TS_NodeAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
29705         LDKNodeAnnouncement this_ptr_conv;
29706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29707         this_ptr_conv.is_owned = false;
29708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29709         LDKUnsignedNodeAnnouncement val_conv;
29710         val_conv.inner = (void*)(val & (~1));
29711         val_conv.is_owned = (val & 1) || (val == 0);
29712         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29713         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
29714         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
29715 }
29716
29717 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_new"))) TS_NodeAnnouncement_new(int8_tArray signature_arg, uint32_t contents_arg) {
29718         LDKSignature signature_arg_ref;
29719         CHECK(signature_arg->arr_len == 64);
29720         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
29721         LDKUnsignedNodeAnnouncement contents_arg_conv;
29722         contents_arg_conv.inner = (void*)(contents_arg & (~1));
29723         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
29724         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
29725         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
29726         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
29727         uint32_t ret_ref = 0;
29728         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29729         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29730         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29731         ret_ref = (uintptr_t)ret_var.inner;
29732         if (ret_var.is_owned) {
29733                 ret_ref |= 1;
29734         }
29735         return ret_ref;
29736 }
29737
29738 static inline uintptr_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
29739         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
29740 uint32_t ret_ref = 0;
29741 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29742 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29743 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29744 ret_ref = (uintptr_t)ret_var.inner;
29745 if (ret_var.is_owned) {
29746         ret_ref |= 1;
29747 }
29748         return ret_ref;
29749 }
29750 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_clone_ptr"))) TS_NodeAnnouncement_clone_ptr(uint32_t arg) {
29751         LDKNodeAnnouncement arg_conv;
29752         arg_conv.inner = (void*)(arg & (~1));
29753         arg_conv.is_owned = false;
29754         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29755         uint32_t ret_conv = NodeAnnouncement_clone_ptr(&arg_conv);
29756         return ret_conv;
29757 }
29758
29759 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_clone"))) TS_NodeAnnouncement_clone(uint32_t orig) {
29760         LDKNodeAnnouncement orig_conv;
29761         orig_conv.inner = (void*)(orig & (~1));
29762         orig_conv.is_owned = false;
29763         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29764         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
29765         uint32_t ret_ref = 0;
29766         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29767         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29768         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29769         ret_ref = (uintptr_t)ret_var.inner;
29770         if (ret_var.is_owned) {
29771                 ret_ref |= 1;
29772         }
29773         return ret_ref;
29774 }
29775
29776 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_free"))) TS_UnsignedChannelAnnouncement_free(uint32_t this_obj) {
29777         LDKUnsignedChannelAnnouncement this_obj_conv;
29778         this_obj_conv.inner = (void*)(this_obj & (~1));
29779         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29780         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29781         UnsignedChannelAnnouncement_free(this_obj_conv);
29782 }
29783
29784 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_features"))) TS_UnsignedChannelAnnouncement_get_features(uint32_t this_ptr) {
29785         LDKUnsignedChannelAnnouncement this_ptr_conv;
29786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29787         this_ptr_conv.is_owned = false;
29788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29789         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
29790         uint32_t ret_ref = 0;
29791         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29792         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29793         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29794         ret_ref = (uintptr_t)ret_var.inner;
29795         if (ret_var.is_owned) {
29796                 ret_ref |= 1;
29797         }
29798         return ret_ref;
29799 }
29800
29801 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_features"))) TS_UnsignedChannelAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
29802         LDKUnsignedChannelAnnouncement this_ptr_conv;
29803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29804         this_ptr_conv.is_owned = false;
29805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29806         LDKChannelFeatures val_conv;
29807         val_conv.inner = (void*)(val & (~1));
29808         val_conv.is_owned = (val & 1) || (val == 0);
29809         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29810         val_conv = ChannelFeatures_clone(&val_conv);
29811         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
29812 }
29813
29814 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_chain_hash"))) TS_UnsignedChannelAnnouncement_get_chain_hash(uint32_t this_ptr) {
29815         LDKUnsignedChannelAnnouncement this_ptr_conv;
29816         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29817         this_ptr_conv.is_owned = false;
29818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29819         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
29820         memcpy(ret_arr->elems, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv), 32);
29821         return ret_arr;
29822 }
29823
29824 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_chain_hash"))) TS_UnsignedChannelAnnouncement_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
29825         LDKUnsignedChannelAnnouncement this_ptr_conv;
29826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29827         this_ptr_conv.is_owned = false;
29828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29829         LDKThirtyTwoBytes val_ref;
29830         CHECK(val->arr_len == 32);
29831         memcpy(val_ref.data, val->elems, 32); FREE(val);
29832         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
29833 }
29834
29835 int64_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_short_channel_id"))) TS_UnsignedChannelAnnouncement_get_short_channel_id(uint32_t this_ptr) {
29836         LDKUnsignedChannelAnnouncement this_ptr_conv;
29837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29838         this_ptr_conv.is_owned = false;
29839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29840         int64_t ret_conv = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
29841         return ret_conv;
29842 }
29843
29844 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_short_channel_id"))) TS_UnsignedChannelAnnouncement_set_short_channel_id(uint32_t this_ptr, int64_t val) {
29845         LDKUnsignedChannelAnnouncement this_ptr_conv;
29846         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29847         this_ptr_conv.is_owned = false;
29848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29849         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
29850 }
29851
29852 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_node_id_1"))) TS_UnsignedChannelAnnouncement_get_node_id_1(uint32_t this_ptr) {
29853         LDKUnsignedChannelAnnouncement this_ptr_conv;
29854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29855         this_ptr_conv.is_owned = false;
29856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29857         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29858         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form, 33);
29859         return ret_arr;
29860 }
29861
29862 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_node_id_1"))) TS_UnsignedChannelAnnouncement_set_node_id_1(uint32_t this_ptr, int8_tArray val) {
29863         LDKUnsignedChannelAnnouncement this_ptr_conv;
29864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29865         this_ptr_conv.is_owned = false;
29866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29867         LDKPublicKey val_ref;
29868         CHECK(val->arr_len == 33);
29869         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29870         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
29871 }
29872
29873 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_node_id_2"))) TS_UnsignedChannelAnnouncement_get_node_id_2(uint32_t this_ptr) {
29874         LDKUnsignedChannelAnnouncement this_ptr_conv;
29875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29876         this_ptr_conv.is_owned = false;
29877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29878         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29879         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form, 33);
29880         return ret_arr;
29881 }
29882
29883 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_node_id_2"))) TS_UnsignedChannelAnnouncement_set_node_id_2(uint32_t this_ptr, int8_tArray val) {
29884         LDKUnsignedChannelAnnouncement this_ptr_conv;
29885         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29886         this_ptr_conv.is_owned = false;
29887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29888         LDKPublicKey val_ref;
29889         CHECK(val->arr_len == 33);
29890         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29891         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
29892 }
29893
29894 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_bitcoin_key_1"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_1(uint32_t this_ptr) {
29895         LDKUnsignedChannelAnnouncement this_ptr_conv;
29896         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29897         this_ptr_conv.is_owned = false;
29898         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29899         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29900         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form, 33);
29901         return ret_arr;
29902 }
29903
29904 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_bitcoin_key_1"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_1(uint32_t this_ptr, int8_tArray val) {
29905         LDKUnsignedChannelAnnouncement this_ptr_conv;
29906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29907         this_ptr_conv.is_owned = false;
29908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29909         LDKPublicKey val_ref;
29910         CHECK(val->arr_len == 33);
29911         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29912         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
29913 }
29914
29915 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_get_bitcoin_key_2"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_2(uint32_t this_ptr) {
29916         LDKUnsignedChannelAnnouncement this_ptr_conv;
29917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29918         this_ptr_conv.is_owned = false;
29919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29920         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
29921         memcpy(ret_arr->elems, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form, 33);
29922         return ret_arr;
29923 }
29924
29925 void  __attribute__((export_name("TS_UnsignedChannelAnnouncement_set_bitcoin_key_2"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_2(uint32_t this_ptr, int8_tArray val) {
29926         LDKUnsignedChannelAnnouncement this_ptr_conv;
29927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29928         this_ptr_conv.is_owned = false;
29929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29930         LDKPublicKey val_ref;
29931         CHECK(val->arr_len == 33);
29932         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
29933         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
29934 }
29935
29936 static inline uintptr_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
29937         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
29938 uint32_t ret_ref = 0;
29939 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29940 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29941 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29942 ret_ref = (uintptr_t)ret_var.inner;
29943 if (ret_var.is_owned) {
29944         ret_ref |= 1;
29945 }
29946         return ret_ref;
29947 }
29948 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_clone_ptr"))) TS_UnsignedChannelAnnouncement_clone_ptr(uint32_t arg) {
29949         LDKUnsignedChannelAnnouncement arg_conv;
29950         arg_conv.inner = (void*)(arg & (~1));
29951         arg_conv.is_owned = false;
29952         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29953         uint32_t ret_conv = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
29954         return ret_conv;
29955 }
29956
29957 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_clone"))) TS_UnsignedChannelAnnouncement_clone(uint32_t orig) {
29958         LDKUnsignedChannelAnnouncement orig_conv;
29959         orig_conv.inner = (void*)(orig & (~1));
29960         orig_conv.is_owned = false;
29961         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29962         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
29963         uint32_t ret_ref = 0;
29964         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29965         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29966         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29967         ret_ref = (uintptr_t)ret_var.inner;
29968         if (ret_var.is_owned) {
29969                 ret_ref |= 1;
29970         }
29971         return ret_ref;
29972 }
29973
29974 void  __attribute__((export_name("TS_ChannelAnnouncement_free"))) TS_ChannelAnnouncement_free(uint32_t this_obj) {
29975         LDKChannelAnnouncement this_obj_conv;
29976         this_obj_conv.inner = (void*)(this_obj & (~1));
29977         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29979         ChannelAnnouncement_free(this_obj_conv);
29980 }
29981
29982 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_node_signature_1"))) TS_ChannelAnnouncement_get_node_signature_1(uint32_t this_ptr) {
29983         LDKChannelAnnouncement this_ptr_conv;
29984         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29985         this_ptr_conv.is_owned = false;
29986         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29987         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
29988         memcpy(ret_arr->elems, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form, 64);
29989         return ret_arr;
29990 }
29991
29992 void  __attribute__((export_name("TS_ChannelAnnouncement_set_node_signature_1"))) TS_ChannelAnnouncement_set_node_signature_1(uint32_t this_ptr, int8_tArray val) {
29993         LDKChannelAnnouncement this_ptr_conv;
29994         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29995         this_ptr_conv.is_owned = false;
29996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29997         LDKSignature val_ref;
29998         CHECK(val->arr_len == 64);
29999         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
30000         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
30001 }
30002
30003 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_node_signature_2"))) TS_ChannelAnnouncement_get_node_signature_2(uint32_t this_ptr) {
30004         LDKChannelAnnouncement this_ptr_conv;
30005         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30006         this_ptr_conv.is_owned = false;
30007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30008         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
30009         memcpy(ret_arr->elems, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form, 64);
30010         return ret_arr;
30011 }
30012
30013 void  __attribute__((export_name("TS_ChannelAnnouncement_set_node_signature_2"))) TS_ChannelAnnouncement_set_node_signature_2(uint32_t this_ptr, int8_tArray val) {
30014         LDKChannelAnnouncement this_ptr_conv;
30015         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30016         this_ptr_conv.is_owned = false;
30017         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30018         LDKSignature val_ref;
30019         CHECK(val->arr_len == 64);
30020         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
30021         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
30022 }
30023
30024 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_bitcoin_signature_1"))) TS_ChannelAnnouncement_get_bitcoin_signature_1(uint32_t this_ptr) {
30025         LDKChannelAnnouncement this_ptr_conv;
30026         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30027         this_ptr_conv.is_owned = false;
30028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30029         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
30030         memcpy(ret_arr->elems, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form, 64);
30031         return ret_arr;
30032 }
30033
30034 void  __attribute__((export_name("TS_ChannelAnnouncement_set_bitcoin_signature_1"))) TS_ChannelAnnouncement_set_bitcoin_signature_1(uint32_t this_ptr, int8_tArray val) {
30035         LDKChannelAnnouncement this_ptr_conv;
30036         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30037         this_ptr_conv.is_owned = false;
30038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30039         LDKSignature val_ref;
30040         CHECK(val->arr_len == 64);
30041         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
30042         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
30043 }
30044
30045 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_get_bitcoin_signature_2"))) TS_ChannelAnnouncement_get_bitcoin_signature_2(uint32_t this_ptr) {
30046         LDKChannelAnnouncement this_ptr_conv;
30047         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30048         this_ptr_conv.is_owned = false;
30049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30050         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
30051         memcpy(ret_arr->elems, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form, 64);
30052         return ret_arr;
30053 }
30054
30055 void  __attribute__((export_name("TS_ChannelAnnouncement_set_bitcoin_signature_2"))) TS_ChannelAnnouncement_set_bitcoin_signature_2(uint32_t this_ptr, int8_tArray val) {
30056         LDKChannelAnnouncement this_ptr_conv;
30057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30058         this_ptr_conv.is_owned = false;
30059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30060         LDKSignature val_ref;
30061         CHECK(val->arr_len == 64);
30062         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
30063         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
30064 }
30065
30066 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_get_contents"))) TS_ChannelAnnouncement_get_contents(uint32_t this_ptr) {
30067         LDKChannelAnnouncement this_ptr_conv;
30068         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30069         this_ptr_conv.is_owned = false;
30070         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30071         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
30072         uint32_t ret_ref = 0;
30073         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30074         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30075         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30076         ret_ref = (uintptr_t)ret_var.inner;
30077         if (ret_var.is_owned) {
30078                 ret_ref |= 1;
30079         }
30080         return ret_ref;
30081 }
30082
30083 void  __attribute__((export_name("TS_ChannelAnnouncement_set_contents"))) TS_ChannelAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
30084         LDKChannelAnnouncement this_ptr_conv;
30085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30086         this_ptr_conv.is_owned = false;
30087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30088         LDKUnsignedChannelAnnouncement val_conv;
30089         val_conv.inner = (void*)(val & (~1));
30090         val_conv.is_owned = (val & 1) || (val == 0);
30091         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30092         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
30093         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
30094 }
30095
30096 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) {
30097         LDKSignature node_signature_1_arg_ref;
30098         CHECK(node_signature_1_arg->arr_len == 64);
30099         memcpy(node_signature_1_arg_ref.compact_form, node_signature_1_arg->elems, 64); FREE(node_signature_1_arg);
30100         LDKSignature node_signature_2_arg_ref;
30101         CHECK(node_signature_2_arg->arr_len == 64);
30102         memcpy(node_signature_2_arg_ref.compact_form, node_signature_2_arg->elems, 64); FREE(node_signature_2_arg);
30103         LDKSignature bitcoin_signature_1_arg_ref;
30104         CHECK(bitcoin_signature_1_arg->arr_len == 64);
30105         memcpy(bitcoin_signature_1_arg_ref.compact_form, bitcoin_signature_1_arg->elems, 64); FREE(bitcoin_signature_1_arg);
30106         LDKSignature bitcoin_signature_2_arg_ref;
30107         CHECK(bitcoin_signature_2_arg->arr_len == 64);
30108         memcpy(bitcoin_signature_2_arg_ref.compact_form, bitcoin_signature_2_arg->elems, 64); FREE(bitcoin_signature_2_arg);
30109         LDKUnsignedChannelAnnouncement contents_arg_conv;
30110         contents_arg_conv.inner = (void*)(contents_arg & (~1));
30111         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
30112         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
30113         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
30114         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);
30115         uint32_t ret_ref = 0;
30116         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30117         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30118         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30119         ret_ref = (uintptr_t)ret_var.inner;
30120         if (ret_var.is_owned) {
30121                 ret_ref |= 1;
30122         }
30123         return ret_ref;
30124 }
30125
30126 static inline uintptr_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
30127         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
30128 uint32_t ret_ref = 0;
30129 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30130 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30131 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30132 ret_ref = (uintptr_t)ret_var.inner;
30133 if (ret_var.is_owned) {
30134         ret_ref |= 1;
30135 }
30136         return ret_ref;
30137 }
30138 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_clone_ptr"))) TS_ChannelAnnouncement_clone_ptr(uint32_t arg) {
30139         LDKChannelAnnouncement arg_conv;
30140         arg_conv.inner = (void*)(arg & (~1));
30141         arg_conv.is_owned = false;
30142         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30143         uint32_t ret_conv = ChannelAnnouncement_clone_ptr(&arg_conv);
30144         return ret_conv;
30145 }
30146
30147 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_clone"))) TS_ChannelAnnouncement_clone(uint32_t orig) {
30148         LDKChannelAnnouncement orig_conv;
30149         orig_conv.inner = (void*)(orig & (~1));
30150         orig_conv.is_owned = false;
30151         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30152         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
30153         uint32_t ret_ref = 0;
30154         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30155         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30156         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30157         ret_ref = (uintptr_t)ret_var.inner;
30158         if (ret_var.is_owned) {
30159                 ret_ref |= 1;
30160         }
30161         return ret_ref;
30162 }
30163
30164 void  __attribute__((export_name("TS_UnsignedChannelUpdate_free"))) TS_UnsignedChannelUpdate_free(uint32_t this_obj) {
30165         LDKUnsignedChannelUpdate this_obj_conv;
30166         this_obj_conv.inner = (void*)(this_obj & (~1));
30167         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30169         UnsignedChannelUpdate_free(this_obj_conv);
30170 }
30171
30172 int8_tArray  __attribute__((export_name("TS_UnsignedChannelUpdate_get_chain_hash"))) TS_UnsignedChannelUpdate_get_chain_hash(uint32_t this_ptr) {
30173         LDKUnsignedChannelUpdate this_ptr_conv;
30174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30175         this_ptr_conv.is_owned = false;
30176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30177         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30178         memcpy(ret_arr->elems, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv), 32);
30179         return ret_arr;
30180 }
30181
30182 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_chain_hash"))) TS_UnsignedChannelUpdate_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
30183         LDKUnsignedChannelUpdate this_ptr_conv;
30184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30185         this_ptr_conv.is_owned = false;
30186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30187         LDKThirtyTwoBytes val_ref;
30188         CHECK(val->arr_len == 32);
30189         memcpy(val_ref.data, val->elems, 32); FREE(val);
30190         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
30191 }
30192
30193 int64_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_short_channel_id"))) TS_UnsignedChannelUpdate_get_short_channel_id(uint32_t this_ptr) {
30194         LDKUnsignedChannelUpdate this_ptr_conv;
30195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30196         this_ptr_conv.is_owned = false;
30197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30198         int64_t ret_conv = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
30199         return ret_conv;
30200 }
30201
30202 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_short_channel_id"))) TS_UnsignedChannelUpdate_set_short_channel_id(uint32_t this_ptr, int64_t val) {
30203         LDKUnsignedChannelUpdate this_ptr_conv;
30204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30205         this_ptr_conv.is_owned = false;
30206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30207         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
30208 }
30209
30210 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_timestamp"))) TS_UnsignedChannelUpdate_get_timestamp(uint32_t this_ptr) {
30211         LDKUnsignedChannelUpdate this_ptr_conv;
30212         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30213         this_ptr_conv.is_owned = false;
30214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30215         int32_t ret_conv = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
30216         return ret_conv;
30217 }
30218
30219 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_timestamp"))) TS_UnsignedChannelUpdate_set_timestamp(uint32_t this_ptr, int32_t val) {
30220         LDKUnsignedChannelUpdate this_ptr_conv;
30221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30222         this_ptr_conv.is_owned = false;
30223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30224         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
30225 }
30226
30227 int8_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_flags"))) TS_UnsignedChannelUpdate_get_flags(uint32_t this_ptr) {
30228         LDKUnsignedChannelUpdate this_ptr_conv;
30229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30230         this_ptr_conv.is_owned = false;
30231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30232         int8_t ret_conv = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
30233         return ret_conv;
30234 }
30235
30236 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_flags"))) TS_UnsignedChannelUpdate_set_flags(uint32_t this_ptr, int8_t val) {
30237         LDKUnsignedChannelUpdate this_ptr_conv;
30238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30239         this_ptr_conv.is_owned = false;
30240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30241         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
30242 }
30243
30244 int16_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_cltv_expiry_delta"))) TS_UnsignedChannelUpdate_get_cltv_expiry_delta(uint32_t this_ptr) {
30245         LDKUnsignedChannelUpdate this_ptr_conv;
30246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30247         this_ptr_conv.is_owned = false;
30248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30249         int16_t ret_conv = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
30250         return ret_conv;
30251 }
30252
30253 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_cltv_expiry_delta"))) TS_UnsignedChannelUpdate_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
30254         LDKUnsignedChannelUpdate this_ptr_conv;
30255         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30256         this_ptr_conv.is_owned = false;
30257         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30258         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
30259 }
30260
30261 int64_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_htlc_minimum_msat"))) TS_UnsignedChannelUpdate_get_htlc_minimum_msat(uint32_t this_ptr) {
30262         LDKUnsignedChannelUpdate this_ptr_conv;
30263         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30264         this_ptr_conv.is_owned = false;
30265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30266         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
30267         return ret_conv;
30268 }
30269
30270 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_htlc_minimum_msat"))) TS_UnsignedChannelUpdate_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
30271         LDKUnsignedChannelUpdate this_ptr_conv;
30272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30273         this_ptr_conv.is_owned = false;
30274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30275         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
30276 }
30277
30278 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_fee_base_msat"))) TS_UnsignedChannelUpdate_get_fee_base_msat(uint32_t this_ptr) {
30279         LDKUnsignedChannelUpdate this_ptr_conv;
30280         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30281         this_ptr_conv.is_owned = false;
30282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30283         int32_t ret_conv = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
30284         return ret_conv;
30285 }
30286
30287 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_fee_base_msat"))) TS_UnsignedChannelUpdate_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
30288         LDKUnsignedChannelUpdate this_ptr_conv;
30289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30290         this_ptr_conv.is_owned = false;
30291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30292         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
30293 }
30294
30295 int32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_get_fee_proportional_millionths"))) TS_UnsignedChannelUpdate_get_fee_proportional_millionths(uint32_t this_ptr) {
30296         LDKUnsignedChannelUpdate this_ptr_conv;
30297         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30298         this_ptr_conv.is_owned = false;
30299         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30300         int32_t ret_conv = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
30301         return ret_conv;
30302 }
30303
30304 void  __attribute__((export_name("TS_UnsignedChannelUpdate_set_fee_proportional_millionths"))) TS_UnsignedChannelUpdate_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
30305         LDKUnsignedChannelUpdate this_ptr_conv;
30306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30307         this_ptr_conv.is_owned = false;
30308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30309         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
30310 }
30311
30312 static inline uintptr_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
30313         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
30314 uint32_t ret_ref = 0;
30315 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30316 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30317 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30318 ret_ref = (uintptr_t)ret_var.inner;
30319 if (ret_var.is_owned) {
30320         ret_ref |= 1;
30321 }
30322         return ret_ref;
30323 }
30324 uint32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_clone_ptr"))) TS_UnsignedChannelUpdate_clone_ptr(uint32_t arg) {
30325         LDKUnsignedChannelUpdate arg_conv;
30326         arg_conv.inner = (void*)(arg & (~1));
30327         arg_conv.is_owned = false;
30328         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30329         uint32_t ret_conv = UnsignedChannelUpdate_clone_ptr(&arg_conv);
30330         return ret_conv;
30331 }
30332
30333 uint32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_clone"))) TS_UnsignedChannelUpdate_clone(uint32_t orig) {
30334         LDKUnsignedChannelUpdate orig_conv;
30335         orig_conv.inner = (void*)(orig & (~1));
30336         orig_conv.is_owned = false;
30337         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30338         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
30339         uint32_t ret_ref = 0;
30340         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30341         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30342         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30343         ret_ref = (uintptr_t)ret_var.inner;
30344         if (ret_var.is_owned) {
30345                 ret_ref |= 1;
30346         }
30347         return ret_ref;
30348 }
30349
30350 void  __attribute__((export_name("TS_ChannelUpdate_free"))) TS_ChannelUpdate_free(uint32_t this_obj) {
30351         LDKChannelUpdate this_obj_conv;
30352         this_obj_conv.inner = (void*)(this_obj & (~1));
30353         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30355         ChannelUpdate_free(this_obj_conv);
30356 }
30357
30358 int8_tArray  __attribute__((export_name("TS_ChannelUpdate_get_signature"))) TS_ChannelUpdate_get_signature(uint32_t this_ptr) {
30359         LDKChannelUpdate this_ptr_conv;
30360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30361         this_ptr_conv.is_owned = false;
30362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30363         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
30364         memcpy(ret_arr->elems, ChannelUpdate_get_signature(&this_ptr_conv).compact_form, 64);
30365         return ret_arr;
30366 }
30367
30368 void  __attribute__((export_name("TS_ChannelUpdate_set_signature"))) TS_ChannelUpdate_set_signature(uint32_t this_ptr, int8_tArray val) {
30369         LDKChannelUpdate this_ptr_conv;
30370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30371         this_ptr_conv.is_owned = false;
30372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30373         LDKSignature val_ref;
30374         CHECK(val->arr_len == 64);
30375         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
30376         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
30377 }
30378
30379 uint32_t  __attribute__((export_name("TS_ChannelUpdate_get_contents"))) TS_ChannelUpdate_get_contents(uint32_t this_ptr) {
30380         LDKChannelUpdate this_ptr_conv;
30381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30382         this_ptr_conv.is_owned = false;
30383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30384         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
30385         uint32_t ret_ref = 0;
30386         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30387         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30388         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30389         ret_ref = (uintptr_t)ret_var.inner;
30390         if (ret_var.is_owned) {
30391                 ret_ref |= 1;
30392         }
30393         return ret_ref;
30394 }
30395
30396 void  __attribute__((export_name("TS_ChannelUpdate_set_contents"))) TS_ChannelUpdate_set_contents(uint32_t this_ptr, uint32_t val) {
30397         LDKChannelUpdate this_ptr_conv;
30398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30399         this_ptr_conv.is_owned = false;
30400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30401         LDKUnsignedChannelUpdate val_conv;
30402         val_conv.inner = (void*)(val & (~1));
30403         val_conv.is_owned = (val & 1) || (val == 0);
30404         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30405         val_conv = UnsignedChannelUpdate_clone(&val_conv);
30406         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
30407 }
30408
30409 uint32_t  __attribute__((export_name("TS_ChannelUpdate_new"))) TS_ChannelUpdate_new(int8_tArray signature_arg, uint32_t contents_arg) {
30410         LDKSignature signature_arg_ref;
30411         CHECK(signature_arg->arr_len == 64);
30412         memcpy(signature_arg_ref.compact_form, signature_arg->elems, 64); FREE(signature_arg);
30413         LDKUnsignedChannelUpdate contents_arg_conv;
30414         contents_arg_conv.inner = (void*)(contents_arg & (~1));
30415         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
30416         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
30417         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
30418         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
30419         uint32_t ret_ref = 0;
30420         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30421         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30422         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30423         ret_ref = (uintptr_t)ret_var.inner;
30424         if (ret_var.is_owned) {
30425                 ret_ref |= 1;
30426         }
30427         return ret_ref;
30428 }
30429
30430 static inline uintptr_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
30431         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
30432 uint32_t ret_ref = 0;
30433 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30434 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30435 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30436 ret_ref = (uintptr_t)ret_var.inner;
30437 if (ret_var.is_owned) {
30438         ret_ref |= 1;
30439 }
30440         return ret_ref;
30441 }
30442 uint32_t  __attribute__((export_name("TS_ChannelUpdate_clone_ptr"))) TS_ChannelUpdate_clone_ptr(uint32_t arg) {
30443         LDKChannelUpdate arg_conv;
30444         arg_conv.inner = (void*)(arg & (~1));
30445         arg_conv.is_owned = false;
30446         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30447         uint32_t ret_conv = ChannelUpdate_clone_ptr(&arg_conv);
30448         return ret_conv;
30449 }
30450
30451 uint32_t  __attribute__((export_name("TS_ChannelUpdate_clone"))) TS_ChannelUpdate_clone(uint32_t orig) {
30452         LDKChannelUpdate orig_conv;
30453         orig_conv.inner = (void*)(orig & (~1));
30454         orig_conv.is_owned = false;
30455         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30456         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
30457         uint32_t ret_ref = 0;
30458         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30459         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30460         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30461         ret_ref = (uintptr_t)ret_var.inner;
30462         if (ret_var.is_owned) {
30463                 ret_ref |= 1;
30464         }
30465         return ret_ref;
30466 }
30467
30468 void  __attribute__((export_name("TS_QueryChannelRange_free"))) TS_QueryChannelRange_free(uint32_t this_obj) {
30469         LDKQueryChannelRange this_obj_conv;
30470         this_obj_conv.inner = (void*)(this_obj & (~1));
30471         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30473         QueryChannelRange_free(this_obj_conv);
30474 }
30475
30476 int8_tArray  __attribute__((export_name("TS_QueryChannelRange_get_chain_hash"))) TS_QueryChannelRange_get_chain_hash(uint32_t this_ptr) {
30477         LDKQueryChannelRange this_ptr_conv;
30478         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30479         this_ptr_conv.is_owned = false;
30480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30481         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30482         memcpy(ret_arr->elems, *QueryChannelRange_get_chain_hash(&this_ptr_conv), 32);
30483         return ret_arr;
30484 }
30485
30486 void  __attribute__((export_name("TS_QueryChannelRange_set_chain_hash"))) TS_QueryChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
30487         LDKQueryChannelRange this_ptr_conv;
30488         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30489         this_ptr_conv.is_owned = false;
30490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30491         LDKThirtyTwoBytes val_ref;
30492         CHECK(val->arr_len == 32);
30493         memcpy(val_ref.data, val->elems, 32); FREE(val);
30494         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
30495 }
30496
30497 int32_t  __attribute__((export_name("TS_QueryChannelRange_get_first_blocknum"))) TS_QueryChannelRange_get_first_blocknum(uint32_t this_ptr) {
30498         LDKQueryChannelRange this_ptr_conv;
30499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30500         this_ptr_conv.is_owned = false;
30501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30502         int32_t ret_conv = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
30503         return ret_conv;
30504 }
30505
30506 void  __attribute__((export_name("TS_QueryChannelRange_set_first_blocknum"))) TS_QueryChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
30507         LDKQueryChannelRange this_ptr_conv;
30508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30509         this_ptr_conv.is_owned = false;
30510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30511         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
30512 }
30513
30514 int32_t  __attribute__((export_name("TS_QueryChannelRange_get_number_of_blocks"))) TS_QueryChannelRange_get_number_of_blocks(uint32_t this_ptr) {
30515         LDKQueryChannelRange this_ptr_conv;
30516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30517         this_ptr_conv.is_owned = false;
30518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30519         int32_t ret_conv = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
30520         return ret_conv;
30521 }
30522
30523 void  __attribute__((export_name("TS_QueryChannelRange_set_number_of_blocks"))) TS_QueryChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
30524         LDKQueryChannelRange this_ptr_conv;
30525         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30526         this_ptr_conv.is_owned = false;
30527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30528         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
30529 }
30530
30531 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) {
30532         LDKThirtyTwoBytes chain_hash_arg_ref;
30533         CHECK(chain_hash_arg->arr_len == 32);
30534         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
30535         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
30536         uint32_t ret_ref = 0;
30537         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30538         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30539         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30540         ret_ref = (uintptr_t)ret_var.inner;
30541         if (ret_var.is_owned) {
30542                 ret_ref |= 1;
30543         }
30544         return ret_ref;
30545 }
30546
30547 static inline uintptr_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
30548         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
30549 uint32_t ret_ref = 0;
30550 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30551 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30552 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30553 ret_ref = (uintptr_t)ret_var.inner;
30554 if (ret_var.is_owned) {
30555         ret_ref |= 1;
30556 }
30557         return ret_ref;
30558 }
30559 uint32_t  __attribute__((export_name("TS_QueryChannelRange_clone_ptr"))) TS_QueryChannelRange_clone_ptr(uint32_t arg) {
30560         LDKQueryChannelRange arg_conv;
30561         arg_conv.inner = (void*)(arg & (~1));
30562         arg_conv.is_owned = false;
30563         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30564         uint32_t ret_conv = QueryChannelRange_clone_ptr(&arg_conv);
30565         return ret_conv;
30566 }
30567
30568 uint32_t  __attribute__((export_name("TS_QueryChannelRange_clone"))) TS_QueryChannelRange_clone(uint32_t orig) {
30569         LDKQueryChannelRange orig_conv;
30570         orig_conv.inner = (void*)(orig & (~1));
30571         orig_conv.is_owned = false;
30572         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30573         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
30574         uint32_t ret_ref = 0;
30575         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30576         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30577         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30578         ret_ref = (uintptr_t)ret_var.inner;
30579         if (ret_var.is_owned) {
30580                 ret_ref |= 1;
30581         }
30582         return ret_ref;
30583 }
30584
30585 void  __attribute__((export_name("TS_ReplyChannelRange_free"))) TS_ReplyChannelRange_free(uint32_t this_obj) {
30586         LDKReplyChannelRange this_obj_conv;
30587         this_obj_conv.inner = (void*)(this_obj & (~1));
30588         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30590         ReplyChannelRange_free(this_obj_conv);
30591 }
30592
30593 int8_tArray  __attribute__((export_name("TS_ReplyChannelRange_get_chain_hash"))) TS_ReplyChannelRange_get_chain_hash(uint32_t this_ptr) {
30594         LDKReplyChannelRange this_ptr_conv;
30595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30596         this_ptr_conv.is_owned = false;
30597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30598         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30599         memcpy(ret_arr->elems, *ReplyChannelRange_get_chain_hash(&this_ptr_conv), 32);
30600         return ret_arr;
30601 }
30602
30603 void  __attribute__((export_name("TS_ReplyChannelRange_set_chain_hash"))) TS_ReplyChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
30604         LDKReplyChannelRange this_ptr_conv;
30605         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30606         this_ptr_conv.is_owned = false;
30607         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30608         LDKThirtyTwoBytes val_ref;
30609         CHECK(val->arr_len == 32);
30610         memcpy(val_ref.data, val->elems, 32); FREE(val);
30611         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
30612 }
30613
30614 int32_t  __attribute__((export_name("TS_ReplyChannelRange_get_first_blocknum"))) TS_ReplyChannelRange_get_first_blocknum(uint32_t this_ptr) {
30615         LDKReplyChannelRange this_ptr_conv;
30616         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30617         this_ptr_conv.is_owned = false;
30618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30619         int32_t ret_conv = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
30620         return ret_conv;
30621 }
30622
30623 void  __attribute__((export_name("TS_ReplyChannelRange_set_first_blocknum"))) TS_ReplyChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
30624         LDKReplyChannelRange this_ptr_conv;
30625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30626         this_ptr_conv.is_owned = false;
30627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30628         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
30629 }
30630
30631 int32_t  __attribute__((export_name("TS_ReplyChannelRange_get_number_of_blocks"))) TS_ReplyChannelRange_get_number_of_blocks(uint32_t this_ptr) {
30632         LDKReplyChannelRange this_ptr_conv;
30633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30634         this_ptr_conv.is_owned = false;
30635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30636         int32_t ret_conv = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
30637         return ret_conv;
30638 }
30639
30640 void  __attribute__((export_name("TS_ReplyChannelRange_set_number_of_blocks"))) TS_ReplyChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
30641         LDKReplyChannelRange this_ptr_conv;
30642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30643         this_ptr_conv.is_owned = false;
30644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30645         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
30646 }
30647
30648 jboolean  __attribute__((export_name("TS_ReplyChannelRange_get_sync_complete"))) TS_ReplyChannelRange_get_sync_complete(uint32_t this_ptr) {
30649         LDKReplyChannelRange this_ptr_conv;
30650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30651         this_ptr_conv.is_owned = false;
30652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30653         jboolean ret_conv = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
30654         return ret_conv;
30655 }
30656
30657 void  __attribute__((export_name("TS_ReplyChannelRange_set_sync_complete"))) TS_ReplyChannelRange_set_sync_complete(uint32_t this_ptr, jboolean val) {
30658         LDKReplyChannelRange this_ptr_conv;
30659         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30660         this_ptr_conv.is_owned = false;
30661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30662         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
30663 }
30664
30665 void  __attribute__((export_name("TS_ReplyChannelRange_set_short_channel_ids"))) TS_ReplyChannelRange_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
30666         LDKReplyChannelRange this_ptr_conv;
30667         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30668         this_ptr_conv.is_owned = false;
30669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30670         LDKCVec_u64Z val_constr;
30671         val_constr.datalen = val->arr_len;
30672         if (val_constr.datalen > 0)
30673                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
30674         else
30675                 val_constr.data = NULL;
30676         int64_t* val_vals = val->elems /* XXX val leaks */;
30677         for (size_t i = 0; i < val_constr.datalen; i++) {
30678                 int64_t val_conv_8 = val_vals[i];
30679                 val_constr.data[i] = val_conv_8;
30680         }
30681         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
30682 }
30683
30684 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) {
30685         LDKThirtyTwoBytes chain_hash_arg_ref;
30686         CHECK(chain_hash_arg->arr_len == 32);
30687         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
30688         LDKCVec_u64Z short_channel_ids_arg_constr;
30689         short_channel_ids_arg_constr.datalen = short_channel_ids_arg->arr_len;
30690         if (short_channel_ids_arg_constr.datalen > 0)
30691                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
30692         else
30693                 short_channel_ids_arg_constr.data = NULL;
30694         int64_t* short_channel_ids_arg_vals = short_channel_ids_arg->elems /* XXX short_channel_ids_arg leaks */;
30695         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
30696                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
30697                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
30698         }
30699         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
30700         uint32_t ret_ref = 0;
30701         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30702         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30703         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30704         ret_ref = (uintptr_t)ret_var.inner;
30705         if (ret_var.is_owned) {
30706                 ret_ref |= 1;
30707         }
30708         return ret_ref;
30709 }
30710
30711 static inline uintptr_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
30712         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
30713 uint32_t ret_ref = 0;
30714 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30715 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30716 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30717 ret_ref = (uintptr_t)ret_var.inner;
30718 if (ret_var.is_owned) {
30719         ret_ref |= 1;
30720 }
30721         return ret_ref;
30722 }
30723 uint32_t  __attribute__((export_name("TS_ReplyChannelRange_clone_ptr"))) TS_ReplyChannelRange_clone_ptr(uint32_t arg) {
30724         LDKReplyChannelRange arg_conv;
30725         arg_conv.inner = (void*)(arg & (~1));
30726         arg_conv.is_owned = false;
30727         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30728         uint32_t ret_conv = ReplyChannelRange_clone_ptr(&arg_conv);
30729         return ret_conv;
30730 }
30731
30732 uint32_t  __attribute__((export_name("TS_ReplyChannelRange_clone"))) TS_ReplyChannelRange_clone(uint32_t orig) {
30733         LDKReplyChannelRange orig_conv;
30734         orig_conv.inner = (void*)(orig & (~1));
30735         orig_conv.is_owned = false;
30736         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30737         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
30738         uint32_t ret_ref = 0;
30739         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30740         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30741         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30742         ret_ref = (uintptr_t)ret_var.inner;
30743         if (ret_var.is_owned) {
30744                 ret_ref |= 1;
30745         }
30746         return ret_ref;
30747 }
30748
30749 void  __attribute__((export_name("TS_QueryShortChannelIds_free"))) TS_QueryShortChannelIds_free(uint32_t this_obj) {
30750         LDKQueryShortChannelIds this_obj_conv;
30751         this_obj_conv.inner = (void*)(this_obj & (~1));
30752         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30754         QueryShortChannelIds_free(this_obj_conv);
30755 }
30756
30757 int8_tArray  __attribute__((export_name("TS_QueryShortChannelIds_get_chain_hash"))) TS_QueryShortChannelIds_get_chain_hash(uint32_t this_ptr) {
30758         LDKQueryShortChannelIds this_ptr_conv;
30759         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30760         this_ptr_conv.is_owned = false;
30761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30762         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30763         memcpy(ret_arr->elems, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv), 32);
30764         return ret_arr;
30765 }
30766
30767 void  __attribute__((export_name("TS_QueryShortChannelIds_set_chain_hash"))) TS_QueryShortChannelIds_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
30768         LDKQueryShortChannelIds this_ptr_conv;
30769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30770         this_ptr_conv.is_owned = false;
30771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30772         LDKThirtyTwoBytes val_ref;
30773         CHECK(val->arr_len == 32);
30774         memcpy(val_ref.data, val->elems, 32); FREE(val);
30775         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
30776 }
30777
30778 void  __attribute__((export_name("TS_QueryShortChannelIds_set_short_channel_ids"))) TS_QueryShortChannelIds_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
30779         LDKQueryShortChannelIds this_ptr_conv;
30780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30781         this_ptr_conv.is_owned = false;
30782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30783         LDKCVec_u64Z val_constr;
30784         val_constr.datalen = val->arr_len;
30785         if (val_constr.datalen > 0)
30786                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
30787         else
30788                 val_constr.data = NULL;
30789         int64_t* val_vals = val->elems /* XXX val leaks */;
30790         for (size_t i = 0; i < val_constr.datalen; i++) {
30791                 int64_t val_conv_8 = val_vals[i];
30792                 val_constr.data[i] = val_conv_8;
30793         }
30794         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
30795 }
30796
30797 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_new"))) TS_QueryShortChannelIds_new(int8_tArray chain_hash_arg, int64_tArray short_channel_ids_arg) {
30798         LDKThirtyTwoBytes chain_hash_arg_ref;
30799         CHECK(chain_hash_arg->arr_len == 32);
30800         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
30801         LDKCVec_u64Z short_channel_ids_arg_constr;
30802         short_channel_ids_arg_constr.datalen = short_channel_ids_arg->arr_len;
30803         if (short_channel_ids_arg_constr.datalen > 0)
30804                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
30805         else
30806                 short_channel_ids_arg_constr.data = NULL;
30807         int64_t* short_channel_ids_arg_vals = short_channel_ids_arg->elems /* XXX short_channel_ids_arg leaks */;
30808         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
30809                 int64_t short_channel_ids_arg_conv_8 = short_channel_ids_arg_vals[i];
30810                 short_channel_ids_arg_constr.data[i] = short_channel_ids_arg_conv_8;
30811         }
30812         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
30813         uint32_t ret_ref = 0;
30814         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30815         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30816         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30817         ret_ref = (uintptr_t)ret_var.inner;
30818         if (ret_var.is_owned) {
30819                 ret_ref |= 1;
30820         }
30821         return ret_ref;
30822 }
30823
30824 static inline uintptr_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
30825         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
30826 uint32_t ret_ref = 0;
30827 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30828 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30829 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30830 ret_ref = (uintptr_t)ret_var.inner;
30831 if (ret_var.is_owned) {
30832         ret_ref |= 1;
30833 }
30834         return ret_ref;
30835 }
30836 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_clone_ptr"))) TS_QueryShortChannelIds_clone_ptr(uint32_t arg) {
30837         LDKQueryShortChannelIds arg_conv;
30838         arg_conv.inner = (void*)(arg & (~1));
30839         arg_conv.is_owned = false;
30840         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30841         uint32_t ret_conv = QueryShortChannelIds_clone_ptr(&arg_conv);
30842         return ret_conv;
30843 }
30844
30845 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_clone"))) TS_QueryShortChannelIds_clone(uint32_t orig) {
30846         LDKQueryShortChannelIds orig_conv;
30847         orig_conv.inner = (void*)(orig & (~1));
30848         orig_conv.is_owned = false;
30849         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30850         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
30851         uint32_t ret_ref = 0;
30852         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30853         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30854         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30855         ret_ref = (uintptr_t)ret_var.inner;
30856         if (ret_var.is_owned) {
30857                 ret_ref |= 1;
30858         }
30859         return ret_ref;
30860 }
30861
30862 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_free"))) TS_ReplyShortChannelIdsEnd_free(uint32_t this_obj) {
30863         LDKReplyShortChannelIdsEnd this_obj_conv;
30864         this_obj_conv.inner = (void*)(this_obj & (~1));
30865         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30867         ReplyShortChannelIdsEnd_free(this_obj_conv);
30868 }
30869
30870 int8_tArray  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_get_chain_hash"))) TS_ReplyShortChannelIdsEnd_get_chain_hash(uint32_t this_ptr) {
30871         LDKReplyShortChannelIdsEnd this_ptr_conv;
30872         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30873         this_ptr_conv.is_owned = false;
30874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30875         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30876         memcpy(ret_arr->elems, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv), 32);
30877         return ret_arr;
30878 }
30879
30880 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_set_chain_hash"))) TS_ReplyShortChannelIdsEnd_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
30881         LDKReplyShortChannelIdsEnd this_ptr_conv;
30882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30883         this_ptr_conv.is_owned = false;
30884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30885         LDKThirtyTwoBytes val_ref;
30886         CHECK(val->arr_len == 32);
30887         memcpy(val_ref.data, val->elems, 32); FREE(val);
30888         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
30889 }
30890
30891 jboolean  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_get_full_information"))) TS_ReplyShortChannelIdsEnd_get_full_information(uint32_t this_ptr) {
30892         LDKReplyShortChannelIdsEnd this_ptr_conv;
30893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30894         this_ptr_conv.is_owned = false;
30895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30896         jboolean ret_conv = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
30897         return ret_conv;
30898 }
30899
30900 void  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_set_full_information"))) TS_ReplyShortChannelIdsEnd_set_full_information(uint32_t this_ptr, jboolean val) {
30901         LDKReplyShortChannelIdsEnd this_ptr_conv;
30902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30903         this_ptr_conv.is_owned = false;
30904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30905         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
30906 }
30907
30908 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_new"))) TS_ReplyShortChannelIdsEnd_new(int8_tArray chain_hash_arg, jboolean full_information_arg) {
30909         LDKThirtyTwoBytes chain_hash_arg_ref;
30910         CHECK(chain_hash_arg->arr_len == 32);
30911         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
30912         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
30913         uint32_t ret_ref = 0;
30914         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30915         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30916         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30917         ret_ref = (uintptr_t)ret_var.inner;
30918         if (ret_var.is_owned) {
30919                 ret_ref |= 1;
30920         }
30921         return ret_ref;
30922 }
30923
30924 static inline uintptr_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
30925         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
30926 uint32_t ret_ref = 0;
30927 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30928 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30929 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30930 ret_ref = (uintptr_t)ret_var.inner;
30931 if (ret_var.is_owned) {
30932         ret_ref |= 1;
30933 }
30934         return ret_ref;
30935 }
30936 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_clone_ptr"))) TS_ReplyShortChannelIdsEnd_clone_ptr(uint32_t arg) {
30937         LDKReplyShortChannelIdsEnd arg_conv;
30938         arg_conv.inner = (void*)(arg & (~1));
30939         arg_conv.is_owned = false;
30940         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30941         uint32_t ret_conv = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
30942         return ret_conv;
30943 }
30944
30945 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_clone"))) TS_ReplyShortChannelIdsEnd_clone(uint32_t orig) {
30946         LDKReplyShortChannelIdsEnd orig_conv;
30947         orig_conv.inner = (void*)(orig & (~1));
30948         orig_conv.is_owned = false;
30949         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30950         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
30951         uint32_t ret_ref = 0;
30952         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30953         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30954         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30955         ret_ref = (uintptr_t)ret_var.inner;
30956         if (ret_var.is_owned) {
30957                 ret_ref |= 1;
30958         }
30959         return ret_ref;
30960 }
30961
30962 void  __attribute__((export_name("TS_GossipTimestampFilter_free"))) TS_GossipTimestampFilter_free(uint32_t this_obj) {
30963         LDKGossipTimestampFilter this_obj_conv;
30964         this_obj_conv.inner = (void*)(this_obj & (~1));
30965         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30967         GossipTimestampFilter_free(this_obj_conv);
30968 }
30969
30970 int8_tArray  __attribute__((export_name("TS_GossipTimestampFilter_get_chain_hash"))) TS_GossipTimestampFilter_get_chain_hash(uint32_t this_ptr) {
30971         LDKGossipTimestampFilter this_ptr_conv;
30972         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30973         this_ptr_conv.is_owned = false;
30974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30975         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
30976         memcpy(ret_arr->elems, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv), 32);
30977         return ret_arr;
30978 }
30979
30980 void  __attribute__((export_name("TS_GossipTimestampFilter_set_chain_hash"))) TS_GossipTimestampFilter_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
30981         LDKGossipTimestampFilter this_ptr_conv;
30982         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30983         this_ptr_conv.is_owned = false;
30984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30985         LDKThirtyTwoBytes val_ref;
30986         CHECK(val->arr_len == 32);
30987         memcpy(val_ref.data, val->elems, 32); FREE(val);
30988         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
30989 }
30990
30991 int32_t  __attribute__((export_name("TS_GossipTimestampFilter_get_first_timestamp"))) TS_GossipTimestampFilter_get_first_timestamp(uint32_t this_ptr) {
30992         LDKGossipTimestampFilter this_ptr_conv;
30993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30994         this_ptr_conv.is_owned = false;
30995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30996         int32_t ret_conv = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
30997         return ret_conv;
30998 }
30999
31000 void  __attribute__((export_name("TS_GossipTimestampFilter_set_first_timestamp"))) TS_GossipTimestampFilter_set_first_timestamp(uint32_t this_ptr, int32_t val) {
31001         LDKGossipTimestampFilter this_ptr_conv;
31002         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31003         this_ptr_conv.is_owned = false;
31004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31005         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
31006 }
31007
31008 int32_t  __attribute__((export_name("TS_GossipTimestampFilter_get_timestamp_range"))) TS_GossipTimestampFilter_get_timestamp_range(uint32_t this_ptr) {
31009         LDKGossipTimestampFilter this_ptr_conv;
31010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31011         this_ptr_conv.is_owned = false;
31012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31013         int32_t ret_conv = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
31014         return ret_conv;
31015 }
31016
31017 void  __attribute__((export_name("TS_GossipTimestampFilter_set_timestamp_range"))) TS_GossipTimestampFilter_set_timestamp_range(uint32_t this_ptr, int32_t val) {
31018         LDKGossipTimestampFilter this_ptr_conv;
31019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31020         this_ptr_conv.is_owned = false;
31021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31022         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
31023 }
31024
31025 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) {
31026         LDKThirtyTwoBytes chain_hash_arg_ref;
31027         CHECK(chain_hash_arg->arr_len == 32);
31028         memcpy(chain_hash_arg_ref.data, chain_hash_arg->elems, 32); FREE(chain_hash_arg);
31029         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
31030         uint32_t ret_ref = 0;
31031         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31032         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31033         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31034         ret_ref = (uintptr_t)ret_var.inner;
31035         if (ret_var.is_owned) {
31036                 ret_ref |= 1;
31037         }
31038         return ret_ref;
31039 }
31040
31041 static inline uintptr_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
31042         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
31043 uint32_t ret_ref = 0;
31044 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31045 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31046 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31047 ret_ref = (uintptr_t)ret_var.inner;
31048 if (ret_var.is_owned) {
31049         ret_ref |= 1;
31050 }
31051         return ret_ref;
31052 }
31053 uint32_t  __attribute__((export_name("TS_GossipTimestampFilter_clone_ptr"))) TS_GossipTimestampFilter_clone_ptr(uint32_t arg) {
31054         LDKGossipTimestampFilter arg_conv;
31055         arg_conv.inner = (void*)(arg & (~1));
31056         arg_conv.is_owned = false;
31057         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31058         uint32_t ret_conv = GossipTimestampFilter_clone_ptr(&arg_conv);
31059         return ret_conv;
31060 }
31061
31062 uint32_t  __attribute__((export_name("TS_GossipTimestampFilter_clone"))) TS_GossipTimestampFilter_clone(uint32_t orig) {
31063         LDKGossipTimestampFilter orig_conv;
31064         orig_conv.inner = (void*)(orig & (~1));
31065         orig_conv.is_owned = false;
31066         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31067         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
31068         uint32_t ret_ref = 0;
31069         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31070         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31071         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31072         ret_ref = (uintptr_t)ret_var.inner;
31073         if (ret_var.is_owned) {
31074                 ret_ref |= 1;
31075         }
31076         return ret_ref;
31077 }
31078
31079 void  __attribute__((export_name("TS_ErrorAction_free"))) TS_ErrorAction_free(uint32_t this_ptr) {
31080         if ((this_ptr & 1) != 0) return;
31081         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
31082         CHECK_ACCESS(this_ptr_ptr);
31083         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
31084         FREE((void*)this_ptr);
31085         ErrorAction_free(this_ptr_conv);
31086 }
31087
31088 static inline uintptr_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
31089         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
31090         *ret_copy = ErrorAction_clone(arg);
31091 uint32_t ret_ref = (uintptr_t)ret_copy;
31092         return ret_ref;
31093 }
31094 uint32_t  __attribute__((export_name("TS_ErrorAction_clone_ptr"))) TS_ErrorAction_clone_ptr(uint32_t arg) {
31095         LDKErrorAction* arg_conv = (LDKErrorAction*)arg;
31096         uint32_t ret_conv = ErrorAction_clone_ptr(arg_conv);
31097         return ret_conv;
31098 }
31099
31100 uint32_t  __attribute__((export_name("TS_ErrorAction_clone"))) TS_ErrorAction_clone(uint32_t orig) {
31101         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
31102         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
31103         *ret_copy = ErrorAction_clone(orig_conv);
31104         uint32_t ret_ref = (uintptr_t)ret_copy;
31105         return ret_ref;
31106 }
31107
31108 uint32_t  __attribute__((export_name("TS_ErrorAction_disconnect_peer"))) TS_ErrorAction_disconnect_peer(uint32_t msg) {
31109         LDKErrorMessage msg_conv;
31110         msg_conv.inner = (void*)(msg & (~1));
31111         msg_conv.is_owned = (msg & 1) || (msg == 0);
31112         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
31113         msg_conv = ErrorMessage_clone(&msg_conv);
31114         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
31115         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
31116         uint32_t ret_ref = (uintptr_t)ret_copy;
31117         return ret_ref;
31118 }
31119
31120 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_error"))) TS_ErrorAction_ignore_error() {
31121         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
31122         *ret_copy = ErrorAction_ignore_error();
31123         uint32_t ret_ref = (uintptr_t)ret_copy;
31124         return ret_ref;
31125 }
31126
31127 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_and_log"))) TS_ErrorAction_ignore_and_log(uint32_t a) {
31128         LDKLevel a_conv = LDKLevel_from_js(a);
31129         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
31130         *ret_copy = ErrorAction_ignore_and_log(a_conv);
31131         uint32_t ret_ref = (uintptr_t)ret_copy;
31132         return ret_ref;
31133 }
31134
31135 uint32_t  __attribute__((export_name("TS_ErrorAction_ignore_duplicate_gossip"))) TS_ErrorAction_ignore_duplicate_gossip() {
31136         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
31137         *ret_copy = ErrorAction_ignore_duplicate_gossip();
31138         uint32_t ret_ref = (uintptr_t)ret_copy;
31139         return ret_ref;
31140 }
31141
31142 uint32_t  __attribute__((export_name("TS_ErrorAction_send_error_message"))) TS_ErrorAction_send_error_message(uint32_t msg) {
31143         LDKErrorMessage msg_conv;
31144         msg_conv.inner = (void*)(msg & (~1));
31145         msg_conv.is_owned = (msg & 1) || (msg == 0);
31146         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
31147         msg_conv = ErrorMessage_clone(&msg_conv);
31148         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
31149         *ret_copy = ErrorAction_send_error_message(msg_conv);
31150         uint32_t ret_ref = (uintptr_t)ret_copy;
31151         return ret_ref;
31152 }
31153
31154 uint32_t  __attribute__((export_name("TS_ErrorAction_send_warning_message"))) TS_ErrorAction_send_warning_message(uint32_t msg, uint32_t log_level) {
31155         LDKWarningMessage msg_conv;
31156         msg_conv.inner = (void*)(msg & (~1));
31157         msg_conv.is_owned = (msg & 1) || (msg == 0);
31158         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
31159         msg_conv = WarningMessage_clone(&msg_conv);
31160         LDKLevel log_level_conv = LDKLevel_from_js(log_level);
31161         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
31162         *ret_copy = ErrorAction_send_warning_message(msg_conv, log_level_conv);
31163         uint32_t ret_ref = (uintptr_t)ret_copy;
31164         return ret_ref;
31165 }
31166
31167 void  __attribute__((export_name("TS_LightningError_free"))) TS_LightningError_free(uint32_t this_obj) {
31168         LDKLightningError this_obj_conv;
31169         this_obj_conv.inner = (void*)(this_obj & (~1));
31170         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31172         LightningError_free(this_obj_conv);
31173 }
31174
31175 jstring  __attribute__((export_name("TS_LightningError_get_err"))) TS_LightningError_get_err(uint32_t this_ptr) {
31176         LDKLightningError this_ptr_conv;
31177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31178         this_ptr_conv.is_owned = false;
31179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31180         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
31181         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
31182         Str_free(ret_str);
31183         return ret_conv;
31184 }
31185
31186 void  __attribute__((export_name("TS_LightningError_set_err"))) TS_LightningError_set_err(uint32_t this_ptr, jstring val) {
31187         LDKLightningError this_ptr_conv;
31188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31189         this_ptr_conv.is_owned = false;
31190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31191         LDKStr val_conv = str_ref_to_owned_c(val);
31192         LightningError_set_err(&this_ptr_conv, val_conv);
31193 }
31194
31195 uint32_t  __attribute__((export_name("TS_LightningError_get_action"))) TS_LightningError_get_action(uint32_t this_ptr) {
31196         LDKLightningError this_ptr_conv;
31197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31198         this_ptr_conv.is_owned = false;
31199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31200         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
31201         *ret_copy = LightningError_get_action(&this_ptr_conv);
31202         uint32_t ret_ref = (uintptr_t)ret_copy;
31203         return ret_ref;
31204 }
31205
31206 void  __attribute__((export_name("TS_LightningError_set_action"))) TS_LightningError_set_action(uint32_t this_ptr, uint32_t val) {
31207         LDKLightningError this_ptr_conv;
31208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31209         this_ptr_conv.is_owned = false;
31210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31211         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
31212         CHECK_ACCESS(val_ptr);
31213         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
31214         val_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)val) & ~1));
31215         LightningError_set_action(&this_ptr_conv, val_conv);
31216 }
31217
31218 uint32_t  __attribute__((export_name("TS_LightningError_new"))) TS_LightningError_new(jstring err_arg, uint32_t action_arg) {
31219         LDKStr err_arg_conv = str_ref_to_owned_c(err_arg);
31220         void* action_arg_ptr = (void*)(((uintptr_t)action_arg) & ~1);
31221         CHECK_ACCESS(action_arg_ptr);
31222         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
31223         action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uintptr_t)action_arg) & ~1));
31224         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
31225         uint32_t ret_ref = 0;
31226         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31227         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31228         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31229         ret_ref = (uintptr_t)ret_var.inner;
31230         if (ret_var.is_owned) {
31231                 ret_ref |= 1;
31232         }
31233         return ret_ref;
31234 }
31235
31236 static inline uintptr_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
31237         LDKLightningError ret_var = LightningError_clone(arg);
31238 uint32_t ret_ref = 0;
31239 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31240 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31241 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31242 ret_ref = (uintptr_t)ret_var.inner;
31243 if (ret_var.is_owned) {
31244         ret_ref |= 1;
31245 }
31246         return ret_ref;
31247 }
31248 uint32_t  __attribute__((export_name("TS_LightningError_clone_ptr"))) TS_LightningError_clone_ptr(uint32_t arg) {
31249         LDKLightningError arg_conv;
31250         arg_conv.inner = (void*)(arg & (~1));
31251         arg_conv.is_owned = false;
31252         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31253         uint32_t ret_conv = LightningError_clone_ptr(&arg_conv);
31254         return ret_conv;
31255 }
31256
31257 uint32_t  __attribute__((export_name("TS_LightningError_clone"))) TS_LightningError_clone(uint32_t orig) {
31258         LDKLightningError orig_conv;
31259         orig_conv.inner = (void*)(orig & (~1));
31260         orig_conv.is_owned = false;
31261         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31262         LDKLightningError ret_var = LightningError_clone(&orig_conv);
31263         uint32_t ret_ref = 0;
31264         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31265         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31266         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31267         ret_ref = (uintptr_t)ret_var.inner;
31268         if (ret_var.is_owned) {
31269                 ret_ref |= 1;
31270         }
31271         return ret_ref;
31272 }
31273
31274 void  __attribute__((export_name("TS_CommitmentUpdate_free"))) TS_CommitmentUpdate_free(uint32_t this_obj) {
31275         LDKCommitmentUpdate this_obj_conv;
31276         this_obj_conv.inner = (void*)(this_obj & (~1));
31277         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31278         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31279         CommitmentUpdate_free(this_obj_conv);
31280 }
31281
31282 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_add_htlcs"))) TS_CommitmentUpdate_get_update_add_htlcs(uint32_t this_ptr) {
31283         LDKCommitmentUpdate this_ptr_conv;
31284         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31285         this_ptr_conv.is_owned = false;
31286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31287         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
31288         uint32_tArray ret_arr = NULL;
31289         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
31290         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
31291         for (size_t p = 0; p < ret_var.datalen; p++) {
31292                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
31293                 uint32_t ret_conv_15_ref = 0;
31294                 CHECK((((uintptr_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31295                 CHECK((((uintptr_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31296                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
31297                 ret_conv_15_ref = (uintptr_t)ret_conv_15_var.inner;
31298                 if (ret_conv_15_var.is_owned) {
31299                         ret_conv_15_ref |= 1;
31300                 }
31301                 ret_arr_ptr[p] = ret_conv_15_ref;
31302         }
31303         
31304         FREE(ret_var.data);
31305         return ret_arr;
31306 }
31307
31308 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_add_htlcs"))) TS_CommitmentUpdate_set_update_add_htlcs(uint32_t this_ptr, uint32_tArray val) {
31309         LDKCommitmentUpdate this_ptr_conv;
31310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31311         this_ptr_conv.is_owned = false;
31312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31313         LDKCVec_UpdateAddHTLCZ val_constr;
31314         val_constr.datalen = val->arr_len;
31315         if (val_constr.datalen > 0)
31316                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
31317         else
31318                 val_constr.data = NULL;
31319         uint32_t* val_vals = val->elems /* XXX val leaks */;
31320         for (size_t p = 0; p < val_constr.datalen; p++) {
31321                 uint32_t val_conv_15 = val_vals[p];
31322                 LDKUpdateAddHTLC val_conv_15_conv;
31323                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
31324                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
31325                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
31326                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
31327                 val_constr.data[p] = val_conv_15_conv;
31328         }
31329         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
31330 }
31331
31332 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fulfill_htlcs"))) TS_CommitmentUpdate_get_update_fulfill_htlcs(uint32_t this_ptr) {
31333         LDKCommitmentUpdate this_ptr_conv;
31334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31335         this_ptr_conv.is_owned = false;
31336         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31337         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
31338         uint32_tArray ret_arr = NULL;
31339         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
31340         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
31341         for (size_t t = 0; t < ret_var.datalen; t++) {
31342                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
31343                 uint32_t ret_conv_19_ref = 0;
31344                 CHECK((((uintptr_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31345                 CHECK((((uintptr_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31346                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
31347                 ret_conv_19_ref = (uintptr_t)ret_conv_19_var.inner;
31348                 if (ret_conv_19_var.is_owned) {
31349                         ret_conv_19_ref |= 1;
31350                 }
31351                 ret_arr_ptr[t] = ret_conv_19_ref;
31352         }
31353         
31354         FREE(ret_var.data);
31355         return ret_arr;
31356 }
31357
31358 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fulfill_htlcs"))) TS_CommitmentUpdate_set_update_fulfill_htlcs(uint32_t this_ptr, uint32_tArray val) {
31359         LDKCommitmentUpdate this_ptr_conv;
31360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31361         this_ptr_conv.is_owned = false;
31362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31363         LDKCVec_UpdateFulfillHTLCZ val_constr;
31364         val_constr.datalen = val->arr_len;
31365         if (val_constr.datalen > 0)
31366                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
31367         else
31368                 val_constr.data = NULL;
31369         uint32_t* val_vals = val->elems /* XXX val leaks */;
31370         for (size_t t = 0; t < val_constr.datalen; t++) {
31371                 uint32_t val_conv_19 = val_vals[t];
31372                 LDKUpdateFulfillHTLC val_conv_19_conv;
31373                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
31374                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
31375                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
31376                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
31377                 val_constr.data[t] = val_conv_19_conv;
31378         }
31379         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
31380 }
31381
31382 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fail_htlcs"))) TS_CommitmentUpdate_get_update_fail_htlcs(uint32_t this_ptr) {
31383         LDKCommitmentUpdate this_ptr_conv;
31384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31385         this_ptr_conv.is_owned = false;
31386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31387         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
31388         uint32_tArray ret_arr = NULL;
31389         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
31390         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
31391         for (size_t q = 0; q < ret_var.datalen; q++) {
31392                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
31393                 uint32_t ret_conv_16_ref = 0;
31394                 CHECK((((uintptr_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31395                 CHECK((((uintptr_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31396                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
31397                 ret_conv_16_ref = (uintptr_t)ret_conv_16_var.inner;
31398                 if (ret_conv_16_var.is_owned) {
31399                         ret_conv_16_ref |= 1;
31400                 }
31401                 ret_arr_ptr[q] = ret_conv_16_ref;
31402         }
31403         
31404         FREE(ret_var.data);
31405         return ret_arr;
31406 }
31407
31408 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fail_htlcs"))) TS_CommitmentUpdate_set_update_fail_htlcs(uint32_t this_ptr, uint32_tArray val) {
31409         LDKCommitmentUpdate this_ptr_conv;
31410         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31411         this_ptr_conv.is_owned = false;
31412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31413         LDKCVec_UpdateFailHTLCZ val_constr;
31414         val_constr.datalen = val->arr_len;
31415         if (val_constr.datalen > 0)
31416                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
31417         else
31418                 val_constr.data = NULL;
31419         uint32_t* val_vals = val->elems /* XXX val leaks */;
31420         for (size_t q = 0; q < val_constr.datalen; q++) {
31421                 uint32_t val_conv_16 = val_vals[q];
31422                 LDKUpdateFailHTLC val_conv_16_conv;
31423                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
31424                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
31425                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
31426                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
31427                 val_constr.data[q] = val_conv_16_conv;
31428         }
31429         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
31430 }
31431
31432 uint32_tArray  __attribute__((export_name("TS_CommitmentUpdate_get_update_fail_malformed_htlcs"))) TS_CommitmentUpdate_get_update_fail_malformed_htlcs(uint32_t this_ptr) {
31433         LDKCommitmentUpdate this_ptr_conv;
31434         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31435         this_ptr_conv.is_owned = false;
31436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31437         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
31438         uint32_tArray ret_arr = NULL;
31439         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
31440         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
31441         for (size_t z = 0; z < ret_var.datalen; z++) {
31442                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
31443                 uint32_t ret_conv_25_ref = 0;
31444                 CHECK((((uintptr_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31445                 CHECK((((uintptr_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31446                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
31447                 ret_conv_25_ref = (uintptr_t)ret_conv_25_var.inner;
31448                 if (ret_conv_25_var.is_owned) {
31449                         ret_conv_25_ref |= 1;
31450                 }
31451                 ret_arr_ptr[z] = ret_conv_25_ref;
31452         }
31453         
31454         FREE(ret_var.data);
31455         return ret_arr;
31456 }
31457
31458 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) {
31459         LDKCommitmentUpdate this_ptr_conv;
31460         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31461         this_ptr_conv.is_owned = false;
31462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31463         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
31464         val_constr.datalen = val->arr_len;
31465         if (val_constr.datalen > 0)
31466                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
31467         else
31468                 val_constr.data = NULL;
31469         uint32_t* val_vals = val->elems /* XXX val leaks */;
31470         for (size_t z = 0; z < val_constr.datalen; z++) {
31471                 uint32_t val_conv_25 = val_vals[z];
31472                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
31473                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
31474                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
31475                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
31476                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
31477                 val_constr.data[z] = val_conv_25_conv;
31478         }
31479         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
31480 }
31481
31482 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_get_update_fee"))) TS_CommitmentUpdate_get_update_fee(uint32_t this_ptr) {
31483         LDKCommitmentUpdate this_ptr_conv;
31484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31485         this_ptr_conv.is_owned = false;
31486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31487         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
31488         uint32_t ret_ref = 0;
31489         if ((uintptr_t)ret_var.inner > 4096) {
31490                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31491                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31492         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31493                 ret_ref = (uintptr_t)ret_var.inner;
31494                 if (ret_var.is_owned) {
31495                         ret_ref |= 1;
31496                 }
31497         }
31498         return ret_ref;
31499 }
31500
31501 void  __attribute__((export_name("TS_CommitmentUpdate_set_update_fee"))) TS_CommitmentUpdate_set_update_fee(uint32_t this_ptr, uint32_t val) {
31502         LDKCommitmentUpdate this_ptr_conv;
31503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31504         this_ptr_conv.is_owned = false;
31505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31506         LDKUpdateFee val_conv;
31507         val_conv.inner = (void*)(val & (~1));
31508         val_conv.is_owned = (val & 1) || (val == 0);
31509         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31510         val_conv = UpdateFee_clone(&val_conv);
31511         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
31512 }
31513
31514 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_get_commitment_signed"))) TS_CommitmentUpdate_get_commitment_signed(uint32_t this_ptr) {
31515         LDKCommitmentUpdate this_ptr_conv;
31516         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31517         this_ptr_conv.is_owned = false;
31518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31519         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
31520         uint32_t ret_ref = 0;
31521         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31522         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31523         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31524         ret_ref = (uintptr_t)ret_var.inner;
31525         if (ret_var.is_owned) {
31526                 ret_ref |= 1;
31527         }
31528         return ret_ref;
31529 }
31530
31531 void  __attribute__((export_name("TS_CommitmentUpdate_set_commitment_signed"))) TS_CommitmentUpdate_set_commitment_signed(uint32_t this_ptr, uint32_t val) {
31532         LDKCommitmentUpdate this_ptr_conv;
31533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31534         this_ptr_conv.is_owned = false;
31535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31536         LDKCommitmentSigned val_conv;
31537         val_conv.inner = (void*)(val & (~1));
31538         val_conv.is_owned = (val & 1) || (val == 0);
31539         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31540         val_conv = CommitmentSigned_clone(&val_conv);
31541         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
31542 }
31543
31544 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) {
31545         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
31546         update_add_htlcs_arg_constr.datalen = update_add_htlcs_arg->arr_len;
31547         if (update_add_htlcs_arg_constr.datalen > 0)
31548                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
31549         else
31550                 update_add_htlcs_arg_constr.data = NULL;
31551         uint32_t* update_add_htlcs_arg_vals = update_add_htlcs_arg->elems /* XXX update_add_htlcs_arg leaks */;
31552         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
31553                 uint32_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
31554                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
31555                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
31556                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
31557                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
31558                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
31559                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
31560         }
31561         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
31562         update_fulfill_htlcs_arg_constr.datalen = update_fulfill_htlcs_arg->arr_len;
31563         if (update_fulfill_htlcs_arg_constr.datalen > 0)
31564                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
31565         else
31566                 update_fulfill_htlcs_arg_constr.data = NULL;
31567         uint32_t* update_fulfill_htlcs_arg_vals = update_fulfill_htlcs_arg->elems /* XXX update_fulfill_htlcs_arg leaks */;
31568         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
31569                 uint32_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
31570                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
31571                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
31572                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
31573                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
31574                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
31575                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
31576         }
31577         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
31578         update_fail_htlcs_arg_constr.datalen = update_fail_htlcs_arg->arr_len;
31579         if (update_fail_htlcs_arg_constr.datalen > 0)
31580                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
31581         else
31582                 update_fail_htlcs_arg_constr.data = NULL;
31583         uint32_t* update_fail_htlcs_arg_vals = update_fail_htlcs_arg->elems /* XXX update_fail_htlcs_arg leaks */;
31584         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
31585                 uint32_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
31586                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
31587                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
31588                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
31589                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
31590                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
31591                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
31592         }
31593         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
31594         update_fail_malformed_htlcs_arg_constr.datalen = update_fail_malformed_htlcs_arg->arr_len;
31595         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
31596                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
31597         else
31598                 update_fail_malformed_htlcs_arg_constr.data = NULL;
31599         uint32_t* update_fail_malformed_htlcs_arg_vals = update_fail_malformed_htlcs_arg->elems /* XXX update_fail_malformed_htlcs_arg leaks */;
31600         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
31601                 uint32_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
31602                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
31603                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
31604                 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);
31605                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
31606                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
31607                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
31608         }
31609         LDKUpdateFee update_fee_arg_conv;
31610         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
31611         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
31612         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
31613         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
31614         LDKCommitmentSigned commitment_signed_arg_conv;
31615         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
31616         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
31617         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
31618         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
31619         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);
31620         uint32_t ret_ref = 0;
31621         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31622         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31623         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31624         ret_ref = (uintptr_t)ret_var.inner;
31625         if (ret_var.is_owned) {
31626                 ret_ref |= 1;
31627         }
31628         return ret_ref;
31629 }
31630
31631 static inline uintptr_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
31632         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
31633 uint32_t ret_ref = 0;
31634 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31635 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31636 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31637 ret_ref = (uintptr_t)ret_var.inner;
31638 if (ret_var.is_owned) {
31639         ret_ref |= 1;
31640 }
31641         return ret_ref;
31642 }
31643 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_clone_ptr"))) TS_CommitmentUpdate_clone_ptr(uint32_t arg) {
31644         LDKCommitmentUpdate arg_conv;
31645         arg_conv.inner = (void*)(arg & (~1));
31646         arg_conv.is_owned = false;
31647         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31648         uint32_t ret_conv = CommitmentUpdate_clone_ptr(&arg_conv);
31649         return ret_conv;
31650 }
31651
31652 uint32_t  __attribute__((export_name("TS_CommitmentUpdate_clone"))) TS_CommitmentUpdate_clone(uint32_t orig) {
31653         LDKCommitmentUpdate orig_conv;
31654         orig_conv.inner = (void*)(orig & (~1));
31655         orig_conv.is_owned = false;
31656         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31657         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
31658         uint32_t ret_ref = 0;
31659         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31660         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31661         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31662         ret_ref = (uintptr_t)ret_var.inner;
31663         if (ret_var.is_owned) {
31664                 ret_ref |= 1;
31665         }
31666         return ret_ref;
31667 }
31668
31669 void  __attribute__((export_name("TS_ChannelMessageHandler_free"))) TS_ChannelMessageHandler_free(uint32_t this_ptr) {
31670         if ((this_ptr & 1) != 0) return;
31671         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
31672         CHECK_ACCESS(this_ptr_ptr);
31673         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
31674         FREE((void*)this_ptr);
31675         ChannelMessageHandler_free(this_ptr_conv);
31676 }
31677
31678 void  __attribute__((export_name("TS_RoutingMessageHandler_free"))) TS_RoutingMessageHandler_free(uint32_t this_ptr) {
31679         if ((this_ptr & 1) != 0) return;
31680         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
31681         CHECK_ACCESS(this_ptr_ptr);
31682         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
31683         FREE((void*)this_ptr);
31684         RoutingMessageHandler_free(this_ptr_conv);
31685 }
31686
31687 int8_tArray  __attribute__((export_name("TS_AcceptChannel_write"))) TS_AcceptChannel_write(uint32_t obj) {
31688         LDKAcceptChannel obj_conv;
31689         obj_conv.inner = (void*)(obj & (~1));
31690         obj_conv.is_owned = false;
31691         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31692         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
31693         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31694         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31695         CVec_u8Z_free(ret_var);
31696         return ret_arr;
31697 }
31698
31699 uint32_t  __attribute__((export_name("TS_AcceptChannel_read"))) TS_AcceptChannel_read(int8_tArray ser) {
31700         LDKu8slice ser_ref;
31701         ser_ref.datalen = ser->arr_len;
31702         ser_ref.data = ser->elems /* XXX ser leaks */;
31703         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
31704         *ret_conv = AcceptChannel_read(ser_ref);
31705         return (uint32_t)ret_conv;
31706 }
31707
31708 int8_tArray  __attribute__((export_name("TS_AnnouncementSignatures_write"))) TS_AnnouncementSignatures_write(uint32_t obj) {
31709         LDKAnnouncementSignatures obj_conv;
31710         obj_conv.inner = (void*)(obj & (~1));
31711         obj_conv.is_owned = false;
31712         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31713         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
31714         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31715         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31716         CVec_u8Z_free(ret_var);
31717         return ret_arr;
31718 }
31719
31720 uint32_t  __attribute__((export_name("TS_AnnouncementSignatures_read"))) TS_AnnouncementSignatures_read(int8_tArray ser) {
31721         LDKu8slice ser_ref;
31722         ser_ref.datalen = ser->arr_len;
31723         ser_ref.data = ser->elems /* XXX ser leaks */;
31724         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
31725         *ret_conv = AnnouncementSignatures_read(ser_ref);
31726         return (uint32_t)ret_conv;
31727 }
31728
31729 int8_tArray  __attribute__((export_name("TS_ChannelReestablish_write"))) TS_ChannelReestablish_write(uint32_t obj) {
31730         LDKChannelReestablish obj_conv;
31731         obj_conv.inner = (void*)(obj & (~1));
31732         obj_conv.is_owned = false;
31733         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31734         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
31735         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31736         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31737         CVec_u8Z_free(ret_var);
31738         return ret_arr;
31739 }
31740
31741 uint32_t  __attribute__((export_name("TS_ChannelReestablish_read"))) TS_ChannelReestablish_read(int8_tArray ser) {
31742         LDKu8slice ser_ref;
31743         ser_ref.datalen = ser->arr_len;
31744         ser_ref.data = ser->elems /* XXX ser leaks */;
31745         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
31746         *ret_conv = ChannelReestablish_read(ser_ref);
31747         return (uint32_t)ret_conv;
31748 }
31749
31750 int8_tArray  __attribute__((export_name("TS_ClosingSigned_write"))) TS_ClosingSigned_write(uint32_t obj) {
31751         LDKClosingSigned obj_conv;
31752         obj_conv.inner = (void*)(obj & (~1));
31753         obj_conv.is_owned = false;
31754         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31755         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
31756         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31757         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31758         CVec_u8Z_free(ret_var);
31759         return ret_arr;
31760 }
31761
31762 uint32_t  __attribute__((export_name("TS_ClosingSigned_read"))) TS_ClosingSigned_read(int8_tArray ser) {
31763         LDKu8slice ser_ref;
31764         ser_ref.datalen = ser->arr_len;
31765         ser_ref.data = ser->elems /* XXX ser leaks */;
31766         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
31767         *ret_conv = ClosingSigned_read(ser_ref);
31768         return (uint32_t)ret_conv;
31769 }
31770
31771 int8_tArray  __attribute__((export_name("TS_ClosingSignedFeeRange_write"))) TS_ClosingSignedFeeRange_write(uint32_t obj) {
31772         LDKClosingSignedFeeRange obj_conv;
31773         obj_conv.inner = (void*)(obj & (~1));
31774         obj_conv.is_owned = false;
31775         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31776         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
31777         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31778         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31779         CVec_u8Z_free(ret_var);
31780         return ret_arr;
31781 }
31782
31783 uint32_t  __attribute__((export_name("TS_ClosingSignedFeeRange_read"))) TS_ClosingSignedFeeRange_read(int8_tArray ser) {
31784         LDKu8slice ser_ref;
31785         ser_ref.datalen = ser->arr_len;
31786         ser_ref.data = ser->elems /* XXX ser leaks */;
31787         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
31788         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
31789         return (uint32_t)ret_conv;
31790 }
31791
31792 int8_tArray  __attribute__((export_name("TS_CommitmentSigned_write"))) TS_CommitmentSigned_write(uint32_t obj) {
31793         LDKCommitmentSigned obj_conv;
31794         obj_conv.inner = (void*)(obj & (~1));
31795         obj_conv.is_owned = false;
31796         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31797         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
31798         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31799         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31800         CVec_u8Z_free(ret_var);
31801         return ret_arr;
31802 }
31803
31804 uint32_t  __attribute__((export_name("TS_CommitmentSigned_read"))) TS_CommitmentSigned_read(int8_tArray ser) {
31805         LDKu8slice ser_ref;
31806         ser_ref.datalen = ser->arr_len;
31807         ser_ref.data = ser->elems /* XXX ser leaks */;
31808         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
31809         *ret_conv = CommitmentSigned_read(ser_ref);
31810         return (uint32_t)ret_conv;
31811 }
31812
31813 int8_tArray  __attribute__((export_name("TS_FundingCreated_write"))) TS_FundingCreated_write(uint32_t obj) {
31814         LDKFundingCreated obj_conv;
31815         obj_conv.inner = (void*)(obj & (~1));
31816         obj_conv.is_owned = false;
31817         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31818         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
31819         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31820         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31821         CVec_u8Z_free(ret_var);
31822         return ret_arr;
31823 }
31824
31825 uint32_t  __attribute__((export_name("TS_FundingCreated_read"))) TS_FundingCreated_read(int8_tArray ser) {
31826         LDKu8slice ser_ref;
31827         ser_ref.datalen = ser->arr_len;
31828         ser_ref.data = ser->elems /* XXX ser leaks */;
31829         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
31830         *ret_conv = FundingCreated_read(ser_ref);
31831         return (uint32_t)ret_conv;
31832 }
31833
31834 int8_tArray  __attribute__((export_name("TS_FundingSigned_write"))) TS_FundingSigned_write(uint32_t obj) {
31835         LDKFundingSigned obj_conv;
31836         obj_conv.inner = (void*)(obj & (~1));
31837         obj_conv.is_owned = false;
31838         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31839         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
31840         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31841         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31842         CVec_u8Z_free(ret_var);
31843         return ret_arr;
31844 }
31845
31846 uint32_t  __attribute__((export_name("TS_FundingSigned_read"))) TS_FundingSigned_read(int8_tArray ser) {
31847         LDKu8slice ser_ref;
31848         ser_ref.datalen = ser->arr_len;
31849         ser_ref.data = ser->elems /* XXX ser leaks */;
31850         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
31851         *ret_conv = FundingSigned_read(ser_ref);
31852         return (uint32_t)ret_conv;
31853 }
31854
31855 int8_tArray  __attribute__((export_name("TS_FundingLocked_write"))) TS_FundingLocked_write(uint32_t obj) {
31856         LDKFundingLocked obj_conv;
31857         obj_conv.inner = (void*)(obj & (~1));
31858         obj_conv.is_owned = false;
31859         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31860         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
31861         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31862         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31863         CVec_u8Z_free(ret_var);
31864         return ret_arr;
31865 }
31866
31867 uint32_t  __attribute__((export_name("TS_FundingLocked_read"))) TS_FundingLocked_read(int8_tArray ser) {
31868         LDKu8slice ser_ref;
31869         ser_ref.datalen = ser->arr_len;
31870         ser_ref.data = ser->elems /* XXX ser leaks */;
31871         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
31872         *ret_conv = FundingLocked_read(ser_ref);
31873         return (uint32_t)ret_conv;
31874 }
31875
31876 int8_tArray  __attribute__((export_name("TS_Init_write"))) TS_Init_write(uint32_t obj) {
31877         LDKInit obj_conv;
31878         obj_conv.inner = (void*)(obj & (~1));
31879         obj_conv.is_owned = false;
31880         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31881         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
31882         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31883         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31884         CVec_u8Z_free(ret_var);
31885         return ret_arr;
31886 }
31887
31888 uint32_t  __attribute__((export_name("TS_Init_read"))) TS_Init_read(int8_tArray ser) {
31889         LDKu8slice ser_ref;
31890         ser_ref.datalen = ser->arr_len;
31891         ser_ref.data = ser->elems /* XXX ser leaks */;
31892         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
31893         *ret_conv = Init_read(ser_ref);
31894         return (uint32_t)ret_conv;
31895 }
31896
31897 int8_tArray  __attribute__((export_name("TS_OpenChannel_write"))) TS_OpenChannel_write(uint32_t obj) {
31898         LDKOpenChannel obj_conv;
31899         obj_conv.inner = (void*)(obj & (~1));
31900         obj_conv.is_owned = false;
31901         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31902         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
31903         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31904         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31905         CVec_u8Z_free(ret_var);
31906         return ret_arr;
31907 }
31908
31909 uint32_t  __attribute__((export_name("TS_OpenChannel_read"))) TS_OpenChannel_read(int8_tArray ser) {
31910         LDKu8slice ser_ref;
31911         ser_ref.datalen = ser->arr_len;
31912         ser_ref.data = ser->elems /* XXX ser leaks */;
31913         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
31914         *ret_conv = OpenChannel_read(ser_ref);
31915         return (uint32_t)ret_conv;
31916 }
31917
31918 int8_tArray  __attribute__((export_name("TS_RevokeAndACK_write"))) TS_RevokeAndACK_write(uint32_t obj) {
31919         LDKRevokeAndACK obj_conv;
31920         obj_conv.inner = (void*)(obj & (~1));
31921         obj_conv.is_owned = false;
31922         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31923         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
31924         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31925         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31926         CVec_u8Z_free(ret_var);
31927         return ret_arr;
31928 }
31929
31930 uint32_t  __attribute__((export_name("TS_RevokeAndACK_read"))) TS_RevokeAndACK_read(int8_tArray ser) {
31931         LDKu8slice ser_ref;
31932         ser_ref.datalen = ser->arr_len;
31933         ser_ref.data = ser->elems /* XXX ser leaks */;
31934         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
31935         *ret_conv = RevokeAndACK_read(ser_ref);
31936         return (uint32_t)ret_conv;
31937 }
31938
31939 int8_tArray  __attribute__((export_name("TS_Shutdown_write"))) TS_Shutdown_write(uint32_t obj) {
31940         LDKShutdown obj_conv;
31941         obj_conv.inner = (void*)(obj & (~1));
31942         obj_conv.is_owned = false;
31943         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31944         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
31945         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31946         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31947         CVec_u8Z_free(ret_var);
31948         return ret_arr;
31949 }
31950
31951 uint32_t  __attribute__((export_name("TS_Shutdown_read"))) TS_Shutdown_read(int8_tArray ser) {
31952         LDKu8slice ser_ref;
31953         ser_ref.datalen = ser->arr_len;
31954         ser_ref.data = ser->elems /* XXX ser leaks */;
31955         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
31956         *ret_conv = Shutdown_read(ser_ref);
31957         return (uint32_t)ret_conv;
31958 }
31959
31960 int8_tArray  __attribute__((export_name("TS_UpdateFailHTLC_write"))) TS_UpdateFailHTLC_write(uint32_t obj) {
31961         LDKUpdateFailHTLC obj_conv;
31962         obj_conv.inner = (void*)(obj & (~1));
31963         obj_conv.is_owned = false;
31964         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31965         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
31966         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31967         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31968         CVec_u8Z_free(ret_var);
31969         return ret_arr;
31970 }
31971
31972 uint32_t  __attribute__((export_name("TS_UpdateFailHTLC_read"))) TS_UpdateFailHTLC_read(int8_tArray ser) {
31973         LDKu8slice ser_ref;
31974         ser_ref.datalen = ser->arr_len;
31975         ser_ref.data = ser->elems /* XXX ser leaks */;
31976         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
31977         *ret_conv = UpdateFailHTLC_read(ser_ref);
31978         return (uint32_t)ret_conv;
31979 }
31980
31981 int8_tArray  __attribute__((export_name("TS_UpdateFailMalformedHTLC_write"))) TS_UpdateFailMalformedHTLC_write(uint32_t obj) {
31982         LDKUpdateFailMalformedHTLC obj_conv;
31983         obj_conv.inner = (void*)(obj & (~1));
31984         obj_conv.is_owned = false;
31985         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31986         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
31987         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
31988         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
31989         CVec_u8Z_free(ret_var);
31990         return ret_arr;
31991 }
31992
31993 uint32_t  __attribute__((export_name("TS_UpdateFailMalformedHTLC_read"))) TS_UpdateFailMalformedHTLC_read(int8_tArray ser) {
31994         LDKu8slice ser_ref;
31995         ser_ref.datalen = ser->arr_len;
31996         ser_ref.data = ser->elems /* XXX ser leaks */;
31997         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
31998         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
31999         return (uint32_t)ret_conv;
32000 }
32001
32002 int8_tArray  __attribute__((export_name("TS_UpdateFee_write"))) TS_UpdateFee_write(uint32_t obj) {
32003         LDKUpdateFee obj_conv;
32004         obj_conv.inner = (void*)(obj & (~1));
32005         obj_conv.is_owned = false;
32006         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32007         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
32008         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32009         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32010         CVec_u8Z_free(ret_var);
32011         return ret_arr;
32012 }
32013
32014 uint32_t  __attribute__((export_name("TS_UpdateFee_read"))) TS_UpdateFee_read(int8_tArray ser) {
32015         LDKu8slice ser_ref;
32016         ser_ref.datalen = ser->arr_len;
32017         ser_ref.data = ser->elems /* XXX ser leaks */;
32018         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
32019         *ret_conv = UpdateFee_read(ser_ref);
32020         return (uint32_t)ret_conv;
32021 }
32022
32023 int8_tArray  __attribute__((export_name("TS_UpdateFulfillHTLC_write"))) TS_UpdateFulfillHTLC_write(uint32_t obj) {
32024         LDKUpdateFulfillHTLC obj_conv;
32025         obj_conv.inner = (void*)(obj & (~1));
32026         obj_conv.is_owned = false;
32027         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32028         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
32029         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32030         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32031         CVec_u8Z_free(ret_var);
32032         return ret_arr;
32033 }
32034
32035 uint32_t  __attribute__((export_name("TS_UpdateFulfillHTLC_read"))) TS_UpdateFulfillHTLC_read(int8_tArray ser) {
32036         LDKu8slice ser_ref;
32037         ser_ref.datalen = ser->arr_len;
32038         ser_ref.data = ser->elems /* XXX ser leaks */;
32039         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
32040         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
32041         return (uint32_t)ret_conv;
32042 }
32043
32044 int8_tArray  __attribute__((export_name("TS_UpdateAddHTLC_write"))) TS_UpdateAddHTLC_write(uint32_t obj) {
32045         LDKUpdateAddHTLC obj_conv;
32046         obj_conv.inner = (void*)(obj & (~1));
32047         obj_conv.is_owned = false;
32048         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32049         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
32050         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32051         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32052         CVec_u8Z_free(ret_var);
32053         return ret_arr;
32054 }
32055
32056 uint32_t  __attribute__((export_name("TS_UpdateAddHTLC_read"))) TS_UpdateAddHTLC_read(int8_tArray ser) {
32057         LDKu8slice ser_ref;
32058         ser_ref.datalen = ser->arr_len;
32059         ser_ref.data = ser->elems /* XXX ser leaks */;
32060         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
32061         *ret_conv = UpdateAddHTLC_read(ser_ref);
32062         return (uint32_t)ret_conv;
32063 }
32064
32065 int8_tArray  __attribute__((export_name("TS_Ping_write"))) TS_Ping_write(uint32_t obj) {
32066         LDKPing obj_conv;
32067         obj_conv.inner = (void*)(obj & (~1));
32068         obj_conv.is_owned = false;
32069         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32070         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
32071         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32072         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32073         CVec_u8Z_free(ret_var);
32074         return ret_arr;
32075 }
32076
32077 uint32_t  __attribute__((export_name("TS_Ping_read"))) TS_Ping_read(int8_tArray ser) {
32078         LDKu8slice ser_ref;
32079         ser_ref.datalen = ser->arr_len;
32080         ser_ref.data = ser->elems /* XXX ser leaks */;
32081         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
32082         *ret_conv = Ping_read(ser_ref);
32083         return (uint32_t)ret_conv;
32084 }
32085
32086 int8_tArray  __attribute__((export_name("TS_Pong_write"))) TS_Pong_write(uint32_t obj) {
32087         LDKPong obj_conv;
32088         obj_conv.inner = (void*)(obj & (~1));
32089         obj_conv.is_owned = false;
32090         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32091         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
32092         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32093         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32094         CVec_u8Z_free(ret_var);
32095         return ret_arr;
32096 }
32097
32098 uint32_t  __attribute__((export_name("TS_Pong_read"))) TS_Pong_read(int8_tArray ser) {
32099         LDKu8slice ser_ref;
32100         ser_ref.datalen = ser->arr_len;
32101         ser_ref.data = ser->elems /* XXX ser leaks */;
32102         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
32103         *ret_conv = Pong_read(ser_ref);
32104         return (uint32_t)ret_conv;
32105 }
32106
32107 int8_tArray  __attribute__((export_name("TS_UnsignedChannelAnnouncement_write"))) TS_UnsignedChannelAnnouncement_write(uint32_t obj) {
32108         LDKUnsignedChannelAnnouncement obj_conv;
32109         obj_conv.inner = (void*)(obj & (~1));
32110         obj_conv.is_owned = false;
32111         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32112         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
32113         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32114         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32115         CVec_u8Z_free(ret_var);
32116         return ret_arr;
32117 }
32118
32119 uint32_t  __attribute__((export_name("TS_UnsignedChannelAnnouncement_read"))) TS_UnsignedChannelAnnouncement_read(int8_tArray ser) {
32120         LDKu8slice ser_ref;
32121         ser_ref.datalen = ser->arr_len;
32122         ser_ref.data = ser->elems /* XXX ser leaks */;
32123         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
32124         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
32125         return (uint32_t)ret_conv;
32126 }
32127
32128 int8_tArray  __attribute__((export_name("TS_ChannelAnnouncement_write"))) TS_ChannelAnnouncement_write(uint32_t obj) {
32129         LDKChannelAnnouncement obj_conv;
32130         obj_conv.inner = (void*)(obj & (~1));
32131         obj_conv.is_owned = false;
32132         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32133         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
32134         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32135         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32136         CVec_u8Z_free(ret_var);
32137         return ret_arr;
32138 }
32139
32140 uint32_t  __attribute__((export_name("TS_ChannelAnnouncement_read"))) TS_ChannelAnnouncement_read(int8_tArray ser) {
32141         LDKu8slice ser_ref;
32142         ser_ref.datalen = ser->arr_len;
32143         ser_ref.data = ser->elems /* XXX ser leaks */;
32144         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
32145         *ret_conv = ChannelAnnouncement_read(ser_ref);
32146         return (uint32_t)ret_conv;
32147 }
32148
32149 int8_tArray  __attribute__((export_name("TS_UnsignedChannelUpdate_write"))) TS_UnsignedChannelUpdate_write(uint32_t obj) {
32150         LDKUnsignedChannelUpdate obj_conv;
32151         obj_conv.inner = (void*)(obj & (~1));
32152         obj_conv.is_owned = false;
32153         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32154         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
32155         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32156         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32157         CVec_u8Z_free(ret_var);
32158         return ret_arr;
32159 }
32160
32161 uint32_t  __attribute__((export_name("TS_UnsignedChannelUpdate_read"))) TS_UnsignedChannelUpdate_read(int8_tArray ser) {
32162         LDKu8slice ser_ref;
32163         ser_ref.datalen = ser->arr_len;
32164         ser_ref.data = ser->elems /* XXX ser leaks */;
32165         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
32166         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
32167         return (uint32_t)ret_conv;
32168 }
32169
32170 int8_tArray  __attribute__((export_name("TS_ChannelUpdate_write"))) TS_ChannelUpdate_write(uint32_t obj) {
32171         LDKChannelUpdate obj_conv;
32172         obj_conv.inner = (void*)(obj & (~1));
32173         obj_conv.is_owned = false;
32174         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32175         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
32176         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32177         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32178         CVec_u8Z_free(ret_var);
32179         return ret_arr;
32180 }
32181
32182 uint32_t  __attribute__((export_name("TS_ChannelUpdate_read"))) TS_ChannelUpdate_read(int8_tArray ser) {
32183         LDKu8slice ser_ref;
32184         ser_ref.datalen = ser->arr_len;
32185         ser_ref.data = ser->elems /* XXX ser leaks */;
32186         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
32187         *ret_conv = ChannelUpdate_read(ser_ref);
32188         return (uint32_t)ret_conv;
32189 }
32190
32191 int8_tArray  __attribute__((export_name("TS_ErrorMessage_write"))) TS_ErrorMessage_write(uint32_t obj) {
32192         LDKErrorMessage obj_conv;
32193         obj_conv.inner = (void*)(obj & (~1));
32194         obj_conv.is_owned = false;
32195         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32196         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
32197         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32198         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32199         CVec_u8Z_free(ret_var);
32200         return ret_arr;
32201 }
32202
32203 uint32_t  __attribute__((export_name("TS_ErrorMessage_read"))) TS_ErrorMessage_read(int8_tArray ser) {
32204         LDKu8slice ser_ref;
32205         ser_ref.datalen = ser->arr_len;
32206         ser_ref.data = ser->elems /* XXX ser leaks */;
32207         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
32208         *ret_conv = ErrorMessage_read(ser_ref);
32209         return (uint32_t)ret_conv;
32210 }
32211
32212 int8_tArray  __attribute__((export_name("TS_WarningMessage_write"))) TS_WarningMessage_write(uint32_t obj) {
32213         LDKWarningMessage obj_conv;
32214         obj_conv.inner = (void*)(obj & (~1));
32215         obj_conv.is_owned = false;
32216         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32217         LDKCVec_u8Z ret_var = WarningMessage_write(&obj_conv);
32218         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32219         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32220         CVec_u8Z_free(ret_var);
32221         return ret_arr;
32222 }
32223
32224 uint32_t  __attribute__((export_name("TS_WarningMessage_read"))) TS_WarningMessage_read(int8_tArray ser) {
32225         LDKu8slice ser_ref;
32226         ser_ref.datalen = ser->arr_len;
32227         ser_ref.data = ser->elems /* XXX ser leaks */;
32228         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
32229         *ret_conv = WarningMessage_read(ser_ref);
32230         return (uint32_t)ret_conv;
32231 }
32232
32233 int8_tArray  __attribute__((export_name("TS_UnsignedNodeAnnouncement_write"))) TS_UnsignedNodeAnnouncement_write(uint32_t obj) {
32234         LDKUnsignedNodeAnnouncement obj_conv;
32235         obj_conv.inner = (void*)(obj & (~1));
32236         obj_conv.is_owned = false;
32237         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32238         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
32239         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32240         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32241         CVec_u8Z_free(ret_var);
32242         return ret_arr;
32243 }
32244
32245 uint32_t  __attribute__((export_name("TS_UnsignedNodeAnnouncement_read"))) TS_UnsignedNodeAnnouncement_read(int8_tArray ser) {
32246         LDKu8slice ser_ref;
32247         ser_ref.datalen = ser->arr_len;
32248         ser_ref.data = ser->elems /* XXX ser leaks */;
32249         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
32250         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
32251         return (uint32_t)ret_conv;
32252 }
32253
32254 int8_tArray  __attribute__((export_name("TS_NodeAnnouncement_write"))) TS_NodeAnnouncement_write(uint32_t obj) {
32255         LDKNodeAnnouncement obj_conv;
32256         obj_conv.inner = (void*)(obj & (~1));
32257         obj_conv.is_owned = false;
32258         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32259         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
32260         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32261         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32262         CVec_u8Z_free(ret_var);
32263         return ret_arr;
32264 }
32265
32266 uint32_t  __attribute__((export_name("TS_NodeAnnouncement_read"))) TS_NodeAnnouncement_read(int8_tArray ser) {
32267         LDKu8slice ser_ref;
32268         ser_ref.datalen = ser->arr_len;
32269         ser_ref.data = ser->elems /* XXX ser leaks */;
32270         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
32271         *ret_conv = NodeAnnouncement_read(ser_ref);
32272         return (uint32_t)ret_conv;
32273 }
32274
32275 uint32_t  __attribute__((export_name("TS_QueryShortChannelIds_read"))) TS_QueryShortChannelIds_read(int8_tArray ser) {
32276         LDKu8slice ser_ref;
32277         ser_ref.datalen = ser->arr_len;
32278         ser_ref.data = ser->elems /* XXX ser leaks */;
32279         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
32280         *ret_conv = QueryShortChannelIds_read(ser_ref);
32281         return (uint32_t)ret_conv;
32282 }
32283
32284 int8_tArray  __attribute__((export_name("TS_QueryShortChannelIds_write"))) TS_QueryShortChannelIds_write(uint32_t obj) {
32285         LDKQueryShortChannelIds obj_conv;
32286         obj_conv.inner = (void*)(obj & (~1));
32287         obj_conv.is_owned = false;
32288         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32289         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
32290         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32291         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32292         CVec_u8Z_free(ret_var);
32293         return ret_arr;
32294 }
32295
32296 int8_tArray  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_write"))) TS_ReplyShortChannelIdsEnd_write(uint32_t obj) {
32297         LDKReplyShortChannelIdsEnd obj_conv;
32298         obj_conv.inner = (void*)(obj & (~1));
32299         obj_conv.is_owned = false;
32300         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32301         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
32302         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32303         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32304         CVec_u8Z_free(ret_var);
32305         return ret_arr;
32306 }
32307
32308 uint32_t  __attribute__((export_name("TS_ReplyShortChannelIdsEnd_read"))) TS_ReplyShortChannelIdsEnd_read(int8_tArray ser) {
32309         LDKu8slice ser_ref;
32310         ser_ref.datalen = ser->arr_len;
32311         ser_ref.data = ser->elems /* XXX ser leaks */;
32312         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
32313         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
32314         return (uint32_t)ret_conv;
32315 }
32316
32317 int32_t  __attribute__((export_name("TS_QueryChannelRange_end_blocknum"))) TS_QueryChannelRange_end_blocknum(uint32_t this_arg) {
32318         LDKQueryChannelRange this_arg_conv;
32319         this_arg_conv.inner = (void*)(this_arg & (~1));
32320         this_arg_conv.is_owned = false;
32321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32322         int32_t ret_conv = QueryChannelRange_end_blocknum(&this_arg_conv);
32323         return ret_conv;
32324 }
32325
32326 int8_tArray  __attribute__((export_name("TS_QueryChannelRange_write"))) TS_QueryChannelRange_write(uint32_t obj) {
32327         LDKQueryChannelRange obj_conv;
32328         obj_conv.inner = (void*)(obj & (~1));
32329         obj_conv.is_owned = false;
32330         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32331         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
32332         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32333         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32334         CVec_u8Z_free(ret_var);
32335         return ret_arr;
32336 }
32337
32338 uint32_t  __attribute__((export_name("TS_QueryChannelRange_read"))) TS_QueryChannelRange_read(int8_tArray ser) {
32339         LDKu8slice ser_ref;
32340         ser_ref.datalen = ser->arr_len;
32341         ser_ref.data = ser->elems /* XXX ser leaks */;
32342         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
32343         *ret_conv = QueryChannelRange_read(ser_ref);
32344         return (uint32_t)ret_conv;
32345 }
32346
32347 uint32_t  __attribute__((export_name("TS_ReplyChannelRange_read"))) TS_ReplyChannelRange_read(int8_tArray ser) {
32348         LDKu8slice ser_ref;
32349         ser_ref.datalen = ser->arr_len;
32350         ser_ref.data = ser->elems /* XXX ser leaks */;
32351         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
32352         *ret_conv = ReplyChannelRange_read(ser_ref);
32353         return (uint32_t)ret_conv;
32354 }
32355
32356 int8_tArray  __attribute__((export_name("TS_ReplyChannelRange_write"))) TS_ReplyChannelRange_write(uint32_t obj) {
32357         LDKReplyChannelRange obj_conv;
32358         obj_conv.inner = (void*)(obj & (~1));
32359         obj_conv.is_owned = false;
32360         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32361         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
32362         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32363         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32364         CVec_u8Z_free(ret_var);
32365         return ret_arr;
32366 }
32367
32368 int8_tArray  __attribute__((export_name("TS_GossipTimestampFilter_write"))) TS_GossipTimestampFilter_write(uint32_t obj) {
32369         LDKGossipTimestampFilter obj_conv;
32370         obj_conv.inner = (void*)(obj & (~1));
32371         obj_conv.is_owned = false;
32372         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32373         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
32374         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32375         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32376         CVec_u8Z_free(ret_var);
32377         return ret_arr;
32378 }
32379
32380 uint32_t  __attribute__((export_name("TS_GossipTimestampFilter_read"))) TS_GossipTimestampFilter_read(int8_tArray ser) {
32381         LDKu8slice ser_ref;
32382         ser_ref.datalen = ser->arr_len;
32383         ser_ref.data = ser->elems /* XXX ser leaks */;
32384         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
32385         *ret_conv = GossipTimestampFilter_read(ser_ref);
32386         return (uint32_t)ret_conv;
32387 }
32388
32389 void  __attribute__((export_name("TS_CustomMessageHandler_free"))) TS_CustomMessageHandler_free(uint32_t this_ptr) {
32390         if ((this_ptr & 1) != 0) return;
32391         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
32392         CHECK_ACCESS(this_ptr_ptr);
32393         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
32394         FREE((void*)this_ptr);
32395         CustomMessageHandler_free(this_ptr_conv);
32396 }
32397
32398 void  __attribute__((export_name("TS_IgnoringMessageHandler_free"))) TS_IgnoringMessageHandler_free(uint32_t this_obj) {
32399         LDKIgnoringMessageHandler this_obj_conv;
32400         this_obj_conv.inner = (void*)(this_obj & (~1));
32401         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32403         IgnoringMessageHandler_free(this_obj_conv);
32404 }
32405
32406 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_new"))) TS_IgnoringMessageHandler_new() {
32407         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
32408         uint32_t ret_ref = 0;
32409         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32410         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32411         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32412         ret_ref = (uintptr_t)ret_var.inner;
32413         if (ret_var.is_owned) {
32414                 ret_ref |= 1;
32415         }
32416         return ret_ref;
32417 }
32418
32419 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_MessageSendEventsProvider"))) TS_IgnoringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
32420         LDKIgnoringMessageHandler this_arg_conv;
32421         this_arg_conv.inner = (void*)(this_arg & (~1));
32422         this_arg_conv.is_owned = false;
32423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32424         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
32425         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
32426         return (uint32_t)ret_ret;
32427 }
32428
32429 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_RoutingMessageHandler"))) TS_IgnoringMessageHandler_as_RoutingMessageHandler(uint32_t this_arg) {
32430         LDKIgnoringMessageHandler this_arg_conv;
32431         this_arg_conv.inner = (void*)(this_arg & (~1));
32432         this_arg_conv.is_owned = false;
32433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32434         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
32435         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
32436         return (uint32_t)ret_ret;
32437 }
32438
32439 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_CustomMessageReader"))) TS_IgnoringMessageHandler_as_CustomMessageReader(uint32_t this_arg) {
32440         LDKIgnoringMessageHandler this_arg_conv;
32441         this_arg_conv.inner = (void*)(this_arg & (~1));
32442         this_arg_conv.is_owned = false;
32443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32444         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
32445         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
32446         return (uint32_t)ret_ret;
32447 }
32448
32449 uint32_t  __attribute__((export_name("TS_IgnoringMessageHandler_as_CustomMessageHandler"))) TS_IgnoringMessageHandler_as_CustomMessageHandler(uint32_t this_arg) {
32450         LDKIgnoringMessageHandler this_arg_conv;
32451         this_arg_conv.inner = (void*)(this_arg & (~1));
32452         this_arg_conv.is_owned = false;
32453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32454         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
32455         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
32456         return (uint32_t)ret_ret;
32457 }
32458
32459 void  __attribute__((export_name("TS_ErroringMessageHandler_free"))) TS_ErroringMessageHandler_free(uint32_t this_obj) {
32460         LDKErroringMessageHandler this_obj_conv;
32461         this_obj_conv.inner = (void*)(this_obj & (~1));
32462         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32464         ErroringMessageHandler_free(this_obj_conv);
32465 }
32466
32467 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_new"))) TS_ErroringMessageHandler_new() {
32468         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
32469         uint32_t ret_ref = 0;
32470         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32471         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32472         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32473         ret_ref = (uintptr_t)ret_var.inner;
32474         if (ret_var.is_owned) {
32475                 ret_ref |= 1;
32476         }
32477         return ret_ref;
32478 }
32479
32480 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_as_MessageSendEventsProvider"))) TS_ErroringMessageHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
32481         LDKErroringMessageHandler this_arg_conv;
32482         this_arg_conv.inner = (void*)(this_arg & (~1));
32483         this_arg_conv.is_owned = false;
32484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32485         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
32486         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
32487         return (uint32_t)ret_ret;
32488 }
32489
32490 uint32_t  __attribute__((export_name("TS_ErroringMessageHandler_as_ChannelMessageHandler"))) TS_ErroringMessageHandler_as_ChannelMessageHandler(uint32_t this_arg) {
32491         LDKErroringMessageHandler this_arg_conv;
32492         this_arg_conv.inner = (void*)(this_arg & (~1));
32493         this_arg_conv.is_owned = false;
32494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32495         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
32496         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
32497         return (uint32_t)ret_ret;
32498 }
32499
32500 void  __attribute__((export_name("TS_MessageHandler_free"))) TS_MessageHandler_free(uint32_t this_obj) {
32501         LDKMessageHandler this_obj_conv;
32502         this_obj_conv.inner = (void*)(this_obj & (~1));
32503         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32505         MessageHandler_free(this_obj_conv);
32506 }
32507
32508 uint32_t  __attribute__((export_name("TS_MessageHandler_get_chan_handler"))) TS_MessageHandler_get_chan_handler(uint32_t this_ptr) {
32509         LDKMessageHandler this_ptr_conv;
32510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32511         this_ptr_conv.is_owned = false;
32512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32513         // WARNING: This object doesn't live past this scope, needs clone!
32514         uint32_t ret_ret = ((uintptr_t)MessageHandler_get_chan_handler(&this_ptr_conv)) | 1;
32515         return ret_ret;
32516 }
32517
32518 void  __attribute__((export_name("TS_MessageHandler_set_chan_handler"))) TS_MessageHandler_set_chan_handler(uint32_t this_ptr, uint32_t val) {
32519         LDKMessageHandler this_ptr_conv;
32520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32521         this_ptr_conv.is_owned = false;
32522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32523         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
32524         CHECK_ACCESS(val_ptr);
32525         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
32526         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
32527                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32528                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
32529         }
32530         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
32531 }
32532
32533 uint32_t  __attribute__((export_name("TS_MessageHandler_get_route_handler"))) TS_MessageHandler_get_route_handler(uint32_t this_ptr) {
32534         LDKMessageHandler this_ptr_conv;
32535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32536         this_ptr_conv.is_owned = false;
32537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32538         // WARNING: This object doesn't live past this scope, needs clone!
32539         uint32_t ret_ret = ((uintptr_t)MessageHandler_get_route_handler(&this_ptr_conv)) | 1;
32540         return ret_ret;
32541 }
32542
32543 void  __attribute__((export_name("TS_MessageHandler_set_route_handler"))) TS_MessageHandler_set_route_handler(uint32_t this_ptr, uint32_t val) {
32544         LDKMessageHandler this_ptr_conv;
32545         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32546         this_ptr_conv.is_owned = false;
32547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32548         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
32549         CHECK_ACCESS(val_ptr);
32550         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
32551         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
32552                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32553                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
32554         }
32555         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
32556 }
32557
32558 uint32_t  __attribute__((export_name("TS_MessageHandler_new"))) TS_MessageHandler_new(uint32_t chan_handler_arg, uint32_t route_handler_arg) {
32559         void* chan_handler_arg_ptr = (void*)(((uintptr_t)chan_handler_arg) & ~1);
32560         CHECK_ACCESS(chan_handler_arg_ptr);
32561         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
32562         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
32563                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32564                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
32565         }
32566         void* route_handler_arg_ptr = (void*)(((uintptr_t)route_handler_arg) & ~1);
32567         CHECK_ACCESS(route_handler_arg_ptr);
32568         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
32569         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
32570                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32571                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
32572         }
32573         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
32574         uint32_t ret_ref = 0;
32575         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32576         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32577         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32578         ret_ref = (uintptr_t)ret_var.inner;
32579         if (ret_var.is_owned) {
32580                 ret_ref |= 1;
32581         }
32582         return ret_ref;
32583 }
32584
32585 static inline uintptr_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
32586         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
32587         *ret_ret = SocketDescriptor_clone(arg);
32588         return (uint32_t)ret_ret;
32589 }
32590 uint32_t  __attribute__((export_name("TS_SocketDescriptor_clone_ptr"))) TS_SocketDescriptor_clone_ptr(uint32_t arg) {
32591         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
32592         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
32593         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
32594         uint32_t ret_conv = SocketDescriptor_clone_ptr(arg_conv);
32595         return ret_conv;
32596 }
32597
32598 uint32_t  __attribute__((export_name("TS_SocketDescriptor_clone"))) TS_SocketDescriptor_clone(uint32_t orig) {
32599         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
32600         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
32601         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
32602         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
32603         *ret_ret = SocketDescriptor_clone(orig_conv);
32604         return (uint32_t)ret_ret;
32605 }
32606
32607 void  __attribute__((export_name("TS_SocketDescriptor_free"))) TS_SocketDescriptor_free(uint32_t this_ptr) {
32608         if ((this_ptr & 1) != 0) return;
32609         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
32610         CHECK_ACCESS(this_ptr_ptr);
32611         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
32612         FREE((void*)this_ptr);
32613         SocketDescriptor_free(this_ptr_conv);
32614 }
32615
32616 void  __attribute__((export_name("TS_PeerHandleError_free"))) TS_PeerHandleError_free(uint32_t this_obj) {
32617         LDKPeerHandleError this_obj_conv;
32618         this_obj_conv.inner = (void*)(this_obj & (~1));
32619         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32621         PeerHandleError_free(this_obj_conv);
32622 }
32623
32624 jboolean  __attribute__((export_name("TS_PeerHandleError_get_no_connection_possible"))) TS_PeerHandleError_get_no_connection_possible(uint32_t this_ptr) {
32625         LDKPeerHandleError this_ptr_conv;
32626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32627         this_ptr_conv.is_owned = false;
32628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32629         jboolean ret_conv = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
32630         return ret_conv;
32631 }
32632
32633 void  __attribute__((export_name("TS_PeerHandleError_set_no_connection_possible"))) TS_PeerHandleError_set_no_connection_possible(uint32_t this_ptr, jboolean val) {
32634         LDKPeerHandleError this_ptr_conv;
32635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32636         this_ptr_conv.is_owned = false;
32637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32638         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
32639 }
32640
32641 uint32_t  __attribute__((export_name("TS_PeerHandleError_new"))) TS_PeerHandleError_new(jboolean no_connection_possible_arg) {
32642         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
32643         uint32_t ret_ref = 0;
32644         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32645         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32646         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32647         ret_ref = (uintptr_t)ret_var.inner;
32648         if (ret_var.is_owned) {
32649                 ret_ref |= 1;
32650         }
32651         return ret_ref;
32652 }
32653
32654 static inline uintptr_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
32655         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
32656 uint32_t ret_ref = 0;
32657 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32658 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32659 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32660 ret_ref = (uintptr_t)ret_var.inner;
32661 if (ret_var.is_owned) {
32662         ret_ref |= 1;
32663 }
32664         return ret_ref;
32665 }
32666 uint32_t  __attribute__((export_name("TS_PeerHandleError_clone_ptr"))) TS_PeerHandleError_clone_ptr(uint32_t arg) {
32667         LDKPeerHandleError arg_conv;
32668         arg_conv.inner = (void*)(arg & (~1));
32669         arg_conv.is_owned = false;
32670         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32671         uint32_t ret_conv = PeerHandleError_clone_ptr(&arg_conv);
32672         return ret_conv;
32673 }
32674
32675 uint32_t  __attribute__((export_name("TS_PeerHandleError_clone"))) TS_PeerHandleError_clone(uint32_t orig) {
32676         LDKPeerHandleError orig_conv;
32677         orig_conv.inner = (void*)(orig & (~1));
32678         orig_conv.is_owned = false;
32679         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32680         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
32681         uint32_t ret_ref = 0;
32682         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32683         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32684         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32685         ret_ref = (uintptr_t)ret_var.inner;
32686         if (ret_var.is_owned) {
32687                 ret_ref |= 1;
32688         }
32689         return ret_ref;
32690 }
32691
32692 void  __attribute__((export_name("TS_PeerManager_free"))) TS_PeerManager_free(uint32_t this_obj) {
32693         LDKPeerManager this_obj_conv;
32694         this_obj_conv.inner = (void*)(this_obj & (~1));
32695         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32697         PeerManager_free(this_obj_conv);
32698 }
32699
32700 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) {
32701         LDKMessageHandler message_handler_conv;
32702         message_handler_conv.inner = (void*)(message_handler & (~1));
32703         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
32704         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
32705         // WARNING: we need a move here but no clone is available for LDKMessageHandler
32706         LDKSecretKey our_node_secret_ref;
32707         CHECK(our_node_secret->arr_len == 32);
32708         memcpy(our_node_secret_ref.bytes, our_node_secret->elems, 32); FREE(our_node_secret);
32709         unsigned char ephemeral_random_data_arr[32];
32710         CHECK(ephemeral_random_data->arr_len == 32);
32711         memcpy(ephemeral_random_data_arr, ephemeral_random_data->elems, 32); FREE(ephemeral_random_data);
32712         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
32713         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
32714         CHECK_ACCESS(logger_ptr);
32715         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
32716         if (logger_conv.free == LDKLogger_JCalls_free) {
32717                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32718                 LDKLogger_JCalls_cloned(&logger_conv);
32719         }
32720         void* custom_message_handler_ptr = (void*)(((uintptr_t)custom_message_handler) & ~1);
32721         CHECK_ACCESS(custom_message_handler_ptr);
32722         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
32723         if (custom_message_handler_conv.free == LDKCustomMessageHandler_JCalls_free) {
32724                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32725                 LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_conv);
32726         }
32727         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
32728         uint32_t ret_ref = 0;
32729         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32730         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32731         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32732         ret_ref = (uintptr_t)ret_var.inner;
32733         if (ret_var.is_owned) {
32734                 ret_ref |= 1;
32735         }
32736         return ret_ref;
32737 }
32738
32739 ptrArray  __attribute__((export_name("TS_PeerManager_get_peer_node_ids"))) TS_PeerManager_get_peer_node_ids(uint32_t this_arg) {
32740         LDKPeerManager this_arg_conv;
32741         this_arg_conv.inner = (void*)(this_arg & (~1));
32742         this_arg_conv.is_owned = false;
32743         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32744         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
32745         ptrArray ret_arr = NULL;
32746         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
32747         int8_tArray *ret_arr_ptr = (int8_tArray*)(((uint8_t*)ret_arr) + 4);
32748         for (size_t m = 0; m < ret_var.datalen; m++) {
32749                 int8_tArray ret_conv_12_arr = init_int8_tArray(33, __LINE__);
32750                 memcpy(ret_conv_12_arr->elems, ret_var.data[m].compressed_form, 33);
32751                 ret_arr_ptr[m] = ret_conv_12_arr;
32752         }
32753         
32754         FREE(ret_var.data);
32755         return ret_arr;
32756 }
32757
32758 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) {
32759         LDKPeerManager this_arg_conv;
32760         this_arg_conv.inner = (void*)(this_arg & (~1));
32761         this_arg_conv.is_owned = false;
32762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32763         LDKPublicKey their_node_id_ref;
32764         CHECK(their_node_id->arr_len == 33);
32765         memcpy(their_node_id_ref.compressed_form, their_node_id->elems, 33); FREE(their_node_id);
32766         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
32767         CHECK_ACCESS(descriptor_ptr);
32768         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
32769         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
32770                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32771                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
32772         }
32773         void* remote_network_address_ptr = (void*)(((uintptr_t)remote_network_address) & ~1);
32774         CHECK_ACCESS(remote_network_address_ptr);
32775         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
32776         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
32777         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv, remote_network_address_conv);
32778         return (uint32_t)ret_conv;
32779 }
32780
32781 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) {
32782         LDKPeerManager this_arg_conv;
32783         this_arg_conv.inner = (void*)(this_arg & (~1));
32784         this_arg_conv.is_owned = false;
32785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32786         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
32787         CHECK_ACCESS(descriptor_ptr);
32788         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
32789         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
32790                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32791                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
32792         }
32793         void* remote_network_address_ptr = (void*)(((uintptr_t)remote_network_address) & ~1);
32794         CHECK_ACCESS(remote_network_address_ptr);
32795         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
32796         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
32797         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv, remote_network_address_conv);
32798         return (uint32_t)ret_conv;
32799 }
32800
32801 uint32_t  __attribute__((export_name("TS_PeerManager_write_buffer_space_avail"))) TS_PeerManager_write_buffer_space_avail(uint32_t this_arg, uint32_t descriptor) {
32802         LDKPeerManager this_arg_conv;
32803         this_arg_conv.inner = (void*)(this_arg & (~1));
32804         this_arg_conv.is_owned = false;
32805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32806         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
32807         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
32808         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
32809         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
32810         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
32811         return (uint32_t)ret_conv;
32812 }
32813
32814 uint32_t  __attribute__((export_name("TS_PeerManager_read_event"))) TS_PeerManager_read_event(uint32_t this_arg, uint32_t peer_descriptor, int8_tArray data) {
32815         LDKPeerManager this_arg_conv;
32816         this_arg_conv.inner = (void*)(this_arg & (~1));
32817         this_arg_conv.is_owned = false;
32818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32819         void* peer_descriptor_ptr = (void*)(((uintptr_t)peer_descriptor) & ~1);
32820         if (!(peer_descriptor & 1)) { CHECK_ACCESS(peer_descriptor_ptr); }
32821         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
32822         LDKu8slice data_ref;
32823         data_ref.datalen = data->arr_len;
32824         data_ref.data = data->elems /* XXX data leaks */;
32825         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
32826         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
32827         return (uint32_t)ret_conv;
32828 }
32829
32830 void  __attribute__((export_name("TS_PeerManager_process_events"))) TS_PeerManager_process_events(uint32_t this_arg) {
32831         LDKPeerManager this_arg_conv;
32832         this_arg_conv.inner = (void*)(this_arg & (~1));
32833         this_arg_conv.is_owned = false;
32834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32835         PeerManager_process_events(&this_arg_conv);
32836 }
32837
32838 void  __attribute__((export_name("TS_PeerManager_socket_disconnected"))) TS_PeerManager_socket_disconnected(uint32_t this_arg, uint32_t descriptor) {
32839         LDKPeerManager this_arg_conv;
32840         this_arg_conv.inner = (void*)(this_arg & (~1));
32841         this_arg_conv.is_owned = false;
32842         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32843         void* descriptor_ptr = (void*)(((uintptr_t)descriptor) & ~1);
32844         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
32845         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
32846         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
32847 }
32848
32849 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) {
32850         LDKPeerManager this_arg_conv;
32851         this_arg_conv.inner = (void*)(this_arg & (~1));
32852         this_arg_conv.is_owned = false;
32853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32854         LDKPublicKey node_id_ref;
32855         CHECK(node_id->arr_len == 33);
32856         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
32857         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
32858 }
32859
32860 void  __attribute__((export_name("TS_PeerManager_disconnect_all_peers"))) TS_PeerManager_disconnect_all_peers(uint32_t this_arg) {
32861         LDKPeerManager this_arg_conv;
32862         this_arg_conv.inner = (void*)(this_arg & (~1));
32863         this_arg_conv.is_owned = false;
32864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32865         PeerManager_disconnect_all_peers(&this_arg_conv);
32866 }
32867
32868 void  __attribute__((export_name("TS_PeerManager_timer_tick_occurred"))) TS_PeerManager_timer_tick_occurred(uint32_t this_arg) {
32869         LDKPeerManager this_arg_conv;
32870         this_arg_conv.inner = (void*)(this_arg & (~1));
32871         this_arg_conv.is_owned = false;
32872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32873         PeerManager_timer_tick_occurred(&this_arg_conv);
32874 }
32875
32876 int64_t  __attribute__((export_name("TS_htlc_success_tx_weight"))) TS_htlc_success_tx_weight(jboolean opt_anchors) {
32877         int64_t ret_conv = htlc_success_tx_weight(opt_anchors);
32878         return ret_conv;
32879 }
32880
32881 int64_t  __attribute__((export_name("TS_htlc_timeout_tx_weight"))) TS_htlc_timeout_tx_weight(jboolean opt_anchors) {
32882         int64_t ret_conv = htlc_timeout_tx_weight(opt_anchors);
32883         return ret_conv;
32884 }
32885
32886 int8_tArray  __attribute__((export_name("TS_build_commitment_secret"))) TS_build_commitment_secret(int8_tArray commitment_seed, int64_t idx) {
32887         unsigned char commitment_seed_arr[32];
32888         CHECK(commitment_seed->arr_len == 32);
32889         memcpy(commitment_seed_arr, commitment_seed->elems, 32); FREE(commitment_seed);
32890         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
32891         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
32892         memcpy(ret_arr->elems, build_commitment_secret(commitment_seed_ref, idx).data, 32);
32893         return ret_arr;
32894 }
32895
32896 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) {
32897         LDKCVec_u8Z to_holder_script_ref;
32898         to_holder_script_ref.datalen = to_holder_script->arr_len;
32899         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
32900         memcpy(to_holder_script_ref.data, to_holder_script->elems, to_holder_script_ref.datalen); FREE(to_holder_script);
32901         LDKCVec_u8Z to_counterparty_script_ref;
32902         to_counterparty_script_ref.datalen = to_counterparty_script->arr_len;
32903         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
32904         memcpy(to_counterparty_script_ref.data, to_counterparty_script->elems, to_counterparty_script_ref.datalen); FREE(to_counterparty_script);
32905         LDKOutPoint funding_outpoint_conv;
32906         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
32907         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
32908         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
32909         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
32910         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);
32911         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
32912         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
32913         Transaction_free(ret_var);
32914         return ret_arr;
32915 }
32916
32917 void  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_free"))) TS_CounterpartyCommitmentSecrets_free(uint32_t this_obj) {
32918         LDKCounterpartyCommitmentSecrets this_obj_conv;
32919         this_obj_conv.inner = (void*)(this_obj & (~1));
32920         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32922         CounterpartyCommitmentSecrets_free(this_obj_conv);
32923 }
32924
32925 static inline uintptr_t CounterpartyCommitmentSecrets_clone_ptr(LDKCounterpartyCommitmentSecrets *NONNULL_PTR arg) {
32926         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(arg);
32927 uint32_t ret_ref = 0;
32928 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32929 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32930 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32931 ret_ref = (uintptr_t)ret_var.inner;
32932 if (ret_var.is_owned) {
32933         ret_ref |= 1;
32934 }
32935         return ret_ref;
32936 }
32937 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_clone_ptr"))) TS_CounterpartyCommitmentSecrets_clone_ptr(uint32_t arg) {
32938         LDKCounterpartyCommitmentSecrets arg_conv;
32939         arg_conv.inner = (void*)(arg & (~1));
32940         arg_conv.is_owned = false;
32941         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32942         uint32_t ret_conv = CounterpartyCommitmentSecrets_clone_ptr(&arg_conv);
32943         return ret_conv;
32944 }
32945
32946 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_clone"))) TS_CounterpartyCommitmentSecrets_clone(uint32_t orig) {
32947         LDKCounterpartyCommitmentSecrets orig_conv;
32948         orig_conv.inner = (void*)(orig & (~1));
32949         orig_conv.is_owned = false;
32950         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32951         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(&orig_conv);
32952         uint32_t ret_ref = 0;
32953         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32954         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32955         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32956         ret_ref = (uintptr_t)ret_var.inner;
32957         if (ret_var.is_owned) {
32958                 ret_ref |= 1;
32959         }
32960         return ret_ref;
32961 }
32962
32963 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_new"))) TS_CounterpartyCommitmentSecrets_new() {
32964         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_new();
32965         uint32_t ret_ref = 0;
32966         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32967         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32968         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32969         ret_ref = (uintptr_t)ret_var.inner;
32970         if (ret_var.is_owned) {
32971                 ret_ref |= 1;
32972         }
32973         return ret_ref;
32974 }
32975
32976 int64_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_get_min_seen_secret"))) TS_CounterpartyCommitmentSecrets_get_min_seen_secret(uint32_t this_arg) {
32977         LDKCounterpartyCommitmentSecrets this_arg_conv;
32978         this_arg_conv.inner = (void*)(this_arg & (~1));
32979         this_arg_conv.is_owned = false;
32980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32981         int64_t ret_conv = CounterpartyCommitmentSecrets_get_min_seen_secret(&this_arg_conv);
32982         return ret_conv;
32983 }
32984
32985 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_provide_secret"))) TS_CounterpartyCommitmentSecrets_provide_secret(uint32_t this_arg, int64_t idx, int8_tArray secret) {
32986         LDKCounterpartyCommitmentSecrets this_arg_conv;
32987         this_arg_conv.inner = (void*)(this_arg & (~1));
32988         this_arg_conv.is_owned = false;
32989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32990         LDKThirtyTwoBytes secret_ref;
32991         CHECK(secret->arr_len == 32);
32992         memcpy(secret_ref.data, secret->elems, 32); FREE(secret);
32993         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
32994         *ret_conv = CounterpartyCommitmentSecrets_provide_secret(&this_arg_conv, idx, secret_ref);
32995         return (uint32_t)ret_conv;
32996 }
32997
32998 int8_tArray  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_get_secret"))) TS_CounterpartyCommitmentSecrets_get_secret(uint32_t this_arg, int64_t idx) {
32999         LDKCounterpartyCommitmentSecrets this_arg_conv;
33000         this_arg_conv.inner = (void*)(this_arg & (~1));
33001         this_arg_conv.is_owned = false;
33002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33003         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
33004         memcpy(ret_arr->elems, CounterpartyCommitmentSecrets_get_secret(&this_arg_conv, idx).data, 32);
33005         return ret_arr;
33006 }
33007
33008 int8_tArray  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_write"))) TS_CounterpartyCommitmentSecrets_write(uint32_t obj) {
33009         LDKCounterpartyCommitmentSecrets obj_conv;
33010         obj_conv.inner = (void*)(obj & (~1));
33011         obj_conv.is_owned = false;
33012         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33013         LDKCVec_u8Z ret_var = CounterpartyCommitmentSecrets_write(&obj_conv);
33014         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33015         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33016         CVec_u8Z_free(ret_var);
33017         return ret_arr;
33018 }
33019
33020 uint32_t  __attribute__((export_name("TS_CounterpartyCommitmentSecrets_read"))) TS_CounterpartyCommitmentSecrets_read(int8_tArray ser) {
33021         LDKu8slice ser_ref;
33022         ser_ref.datalen = ser->arr_len;
33023         ser_ref.data = ser->elems /* XXX ser leaks */;
33024         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
33025         *ret_conv = CounterpartyCommitmentSecrets_read(ser_ref);
33026         return (uint32_t)ret_conv;
33027 }
33028
33029 uint32_t  __attribute__((export_name("TS_derive_private_key"))) TS_derive_private_key(int8_tArray per_commitment_point, int8_tArray base_secret) {
33030         LDKPublicKey per_commitment_point_ref;
33031         CHECK(per_commitment_point->arr_len == 33);
33032         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
33033         unsigned char base_secret_arr[32];
33034         CHECK(base_secret->arr_len == 32);
33035         memcpy(base_secret_arr, base_secret->elems, 32); FREE(base_secret);
33036         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
33037         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
33038         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
33039         return (uint32_t)ret_conv;
33040 }
33041
33042 uint32_t  __attribute__((export_name("TS_derive_public_key"))) TS_derive_public_key(int8_tArray per_commitment_point, int8_tArray base_point) {
33043         LDKPublicKey per_commitment_point_ref;
33044         CHECK(per_commitment_point->arr_len == 33);
33045         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
33046         LDKPublicKey base_point_ref;
33047         CHECK(base_point->arr_len == 33);
33048         memcpy(base_point_ref.compressed_form, base_point->elems, 33); FREE(base_point);
33049         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
33050         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
33051         return (uint32_t)ret_conv;
33052 }
33053
33054 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) {
33055         unsigned char per_commitment_secret_arr[32];
33056         CHECK(per_commitment_secret->arr_len == 32);
33057         memcpy(per_commitment_secret_arr, per_commitment_secret->elems, 32); FREE(per_commitment_secret);
33058         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
33059         unsigned char countersignatory_revocation_base_secret_arr[32];
33060         CHECK(countersignatory_revocation_base_secret->arr_len == 32);
33061         memcpy(countersignatory_revocation_base_secret_arr, countersignatory_revocation_base_secret->elems, 32); FREE(countersignatory_revocation_base_secret);
33062         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
33063         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
33064         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
33065         return (uint32_t)ret_conv;
33066 }
33067
33068 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) {
33069         LDKPublicKey per_commitment_point_ref;
33070         CHECK(per_commitment_point->arr_len == 33);
33071         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
33072         LDKPublicKey countersignatory_revocation_base_point_ref;
33073         CHECK(countersignatory_revocation_base_point->arr_len == 33);
33074         memcpy(countersignatory_revocation_base_point_ref.compressed_form, countersignatory_revocation_base_point->elems, 33); FREE(countersignatory_revocation_base_point);
33075         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
33076         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
33077         return (uint32_t)ret_conv;
33078 }
33079
33080 void  __attribute__((export_name("TS_TxCreationKeys_free"))) TS_TxCreationKeys_free(uint32_t this_obj) {
33081         LDKTxCreationKeys this_obj_conv;
33082         this_obj_conv.inner = (void*)(this_obj & (~1));
33083         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33085         TxCreationKeys_free(this_obj_conv);
33086 }
33087
33088 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_per_commitment_point"))) TS_TxCreationKeys_get_per_commitment_point(uint32_t this_ptr) {
33089         LDKTxCreationKeys this_ptr_conv;
33090         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33091         this_ptr_conv.is_owned = false;
33092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33093         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
33094         memcpy(ret_arr->elems, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
33095         return ret_arr;
33096 }
33097
33098 void  __attribute__((export_name("TS_TxCreationKeys_set_per_commitment_point"))) TS_TxCreationKeys_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
33099         LDKTxCreationKeys this_ptr_conv;
33100         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33101         this_ptr_conv.is_owned = false;
33102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33103         LDKPublicKey val_ref;
33104         CHECK(val->arr_len == 33);
33105         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
33106         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
33107 }
33108
33109 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_revocation_key"))) TS_TxCreationKeys_get_revocation_key(uint32_t this_ptr) {
33110         LDKTxCreationKeys this_ptr_conv;
33111         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33112         this_ptr_conv.is_owned = false;
33113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33114         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
33115         memcpy(ret_arr->elems, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form, 33);
33116         return ret_arr;
33117 }
33118
33119 void  __attribute__((export_name("TS_TxCreationKeys_set_revocation_key"))) TS_TxCreationKeys_set_revocation_key(uint32_t this_ptr, int8_tArray val) {
33120         LDKTxCreationKeys this_ptr_conv;
33121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33122         this_ptr_conv.is_owned = false;
33123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33124         LDKPublicKey val_ref;
33125         CHECK(val->arr_len == 33);
33126         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
33127         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
33128 }
33129
33130 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_broadcaster_htlc_key"))) TS_TxCreationKeys_get_broadcaster_htlc_key(uint32_t this_ptr) {
33131         LDKTxCreationKeys this_ptr_conv;
33132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33133         this_ptr_conv.is_owned = false;
33134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33135         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
33136         memcpy(ret_arr->elems, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form, 33);
33137         return ret_arr;
33138 }
33139
33140 void  __attribute__((export_name("TS_TxCreationKeys_set_broadcaster_htlc_key"))) TS_TxCreationKeys_set_broadcaster_htlc_key(uint32_t this_ptr, int8_tArray val) {
33141         LDKTxCreationKeys this_ptr_conv;
33142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33143         this_ptr_conv.is_owned = false;
33144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33145         LDKPublicKey val_ref;
33146         CHECK(val->arr_len == 33);
33147         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
33148         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
33149 }
33150
33151 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_countersignatory_htlc_key"))) TS_TxCreationKeys_get_countersignatory_htlc_key(uint32_t this_ptr) {
33152         LDKTxCreationKeys this_ptr_conv;
33153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33154         this_ptr_conv.is_owned = false;
33155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33156         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
33157         memcpy(ret_arr->elems, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form, 33);
33158         return ret_arr;
33159 }
33160
33161 void  __attribute__((export_name("TS_TxCreationKeys_set_countersignatory_htlc_key"))) TS_TxCreationKeys_set_countersignatory_htlc_key(uint32_t this_ptr, int8_tArray val) {
33162         LDKTxCreationKeys this_ptr_conv;
33163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33164         this_ptr_conv.is_owned = false;
33165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33166         LDKPublicKey val_ref;
33167         CHECK(val->arr_len == 33);
33168         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
33169         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
33170 }
33171
33172 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_get_broadcaster_delayed_payment_key"))) TS_TxCreationKeys_get_broadcaster_delayed_payment_key(uint32_t this_ptr) {
33173         LDKTxCreationKeys this_ptr_conv;
33174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33175         this_ptr_conv.is_owned = false;
33176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33177         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
33178         memcpy(ret_arr->elems, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form, 33);
33179         return ret_arr;
33180 }
33181
33182 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) {
33183         LDKTxCreationKeys this_ptr_conv;
33184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33185         this_ptr_conv.is_owned = false;
33186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33187         LDKPublicKey val_ref;
33188         CHECK(val->arr_len == 33);
33189         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
33190         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
33191 }
33192
33193 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) {
33194         LDKPublicKey per_commitment_point_arg_ref;
33195         CHECK(per_commitment_point_arg->arr_len == 33);
33196         memcpy(per_commitment_point_arg_ref.compressed_form, per_commitment_point_arg->elems, 33); FREE(per_commitment_point_arg);
33197         LDKPublicKey revocation_key_arg_ref;
33198         CHECK(revocation_key_arg->arr_len == 33);
33199         memcpy(revocation_key_arg_ref.compressed_form, revocation_key_arg->elems, 33); FREE(revocation_key_arg);
33200         LDKPublicKey broadcaster_htlc_key_arg_ref;
33201         CHECK(broadcaster_htlc_key_arg->arr_len == 33);
33202         memcpy(broadcaster_htlc_key_arg_ref.compressed_form, broadcaster_htlc_key_arg->elems, 33); FREE(broadcaster_htlc_key_arg);
33203         LDKPublicKey countersignatory_htlc_key_arg_ref;
33204         CHECK(countersignatory_htlc_key_arg->arr_len == 33);
33205         memcpy(countersignatory_htlc_key_arg_ref.compressed_form, countersignatory_htlc_key_arg->elems, 33); FREE(countersignatory_htlc_key_arg);
33206         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
33207         CHECK(broadcaster_delayed_payment_key_arg->arr_len == 33);
33208         memcpy(broadcaster_delayed_payment_key_arg_ref.compressed_form, broadcaster_delayed_payment_key_arg->elems, 33); FREE(broadcaster_delayed_payment_key_arg);
33209         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);
33210         uint32_t ret_ref = 0;
33211         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33212         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33213         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33214         ret_ref = (uintptr_t)ret_var.inner;
33215         if (ret_var.is_owned) {
33216                 ret_ref |= 1;
33217         }
33218         return ret_ref;
33219 }
33220
33221 static inline uintptr_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
33222         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
33223 uint32_t ret_ref = 0;
33224 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33225 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33226 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33227 ret_ref = (uintptr_t)ret_var.inner;
33228 if (ret_var.is_owned) {
33229         ret_ref |= 1;
33230 }
33231         return ret_ref;
33232 }
33233 uint32_t  __attribute__((export_name("TS_TxCreationKeys_clone_ptr"))) TS_TxCreationKeys_clone_ptr(uint32_t arg) {
33234         LDKTxCreationKeys arg_conv;
33235         arg_conv.inner = (void*)(arg & (~1));
33236         arg_conv.is_owned = false;
33237         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33238         uint32_t ret_conv = TxCreationKeys_clone_ptr(&arg_conv);
33239         return ret_conv;
33240 }
33241
33242 uint32_t  __attribute__((export_name("TS_TxCreationKeys_clone"))) TS_TxCreationKeys_clone(uint32_t orig) {
33243         LDKTxCreationKeys orig_conv;
33244         orig_conv.inner = (void*)(orig & (~1));
33245         orig_conv.is_owned = false;
33246         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33247         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
33248         uint32_t ret_ref = 0;
33249         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33250         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33251         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33252         ret_ref = (uintptr_t)ret_var.inner;
33253         if (ret_var.is_owned) {
33254                 ret_ref |= 1;
33255         }
33256         return ret_ref;
33257 }
33258
33259 int8_tArray  __attribute__((export_name("TS_TxCreationKeys_write"))) TS_TxCreationKeys_write(uint32_t obj) {
33260         LDKTxCreationKeys obj_conv;
33261         obj_conv.inner = (void*)(obj & (~1));
33262         obj_conv.is_owned = false;
33263         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33264         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
33265         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33266         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33267         CVec_u8Z_free(ret_var);
33268         return ret_arr;
33269 }
33270
33271 uint32_t  __attribute__((export_name("TS_TxCreationKeys_read"))) TS_TxCreationKeys_read(int8_tArray ser) {
33272         LDKu8slice ser_ref;
33273         ser_ref.datalen = ser->arr_len;
33274         ser_ref.data = ser->elems /* XXX ser leaks */;
33275         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
33276         *ret_conv = TxCreationKeys_read(ser_ref);
33277         return (uint32_t)ret_conv;
33278 }
33279
33280 void  __attribute__((export_name("TS_ChannelPublicKeys_free"))) TS_ChannelPublicKeys_free(uint32_t this_obj) {
33281         LDKChannelPublicKeys this_obj_conv;
33282         this_obj_conv.inner = (void*)(this_obj & (~1));
33283         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33285         ChannelPublicKeys_free(this_obj_conv);
33286 }
33287
33288 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_funding_pubkey"))) TS_ChannelPublicKeys_get_funding_pubkey(uint32_t this_ptr) {
33289         LDKChannelPublicKeys this_ptr_conv;
33290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33291         this_ptr_conv.is_owned = false;
33292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33293         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
33294         memcpy(ret_arr->elems, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
33295         return ret_arr;
33296 }
33297
33298 void  __attribute__((export_name("TS_ChannelPublicKeys_set_funding_pubkey"))) TS_ChannelPublicKeys_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
33299         LDKChannelPublicKeys this_ptr_conv;
33300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33301         this_ptr_conv.is_owned = false;
33302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33303         LDKPublicKey val_ref;
33304         CHECK(val->arr_len == 33);
33305         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
33306         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
33307 }
33308
33309 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_revocation_basepoint"))) TS_ChannelPublicKeys_get_revocation_basepoint(uint32_t this_ptr) {
33310         LDKChannelPublicKeys this_ptr_conv;
33311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33312         this_ptr_conv.is_owned = false;
33313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33314         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
33315         memcpy(ret_arr->elems, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
33316         return ret_arr;
33317 }
33318
33319 void  __attribute__((export_name("TS_ChannelPublicKeys_set_revocation_basepoint"))) TS_ChannelPublicKeys_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
33320         LDKChannelPublicKeys this_ptr_conv;
33321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33322         this_ptr_conv.is_owned = false;
33323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33324         LDKPublicKey val_ref;
33325         CHECK(val->arr_len == 33);
33326         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
33327         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
33328 }
33329
33330 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_payment_point"))) TS_ChannelPublicKeys_get_payment_point(uint32_t this_ptr) {
33331         LDKChannelPublicKeys this_ptr_conv;
33332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33333         this_ptr_conv.is_owned = false;
33334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33335         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
33336         memcpy(ret_arr->elems, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form, 33);
33337         return ret_arr;
33338 }
33339
33340 void  __attribute__((export_name("TS_ChannelPublicKeys_set_payment_point"))) TS_ChannelPublicKeys_set_payment_point(uint32_t this_ptr, int8_tArray val) {
33341         LDKChannelPublicKeys this_ptr_conv;
33342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33343         this_ptr_conv.is_owned = false;
33344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33345         LDKPublicKey val_ref;
33346         CHECK(val->arr_len == 33);
33347         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
33348         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
33349 }
33350
33351 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_delayed_payment_basepoint"))) TS_ChannelPublicKeys_get_delayed_payment_basepoint(uint32_t this_ptr) {
33352         LDKChannelPublicKeys this_ptr_conv;
33353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33354         this_ptr_conv.is_owned = false;
33355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33356         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
33357         memcpy(ret_arr->elems, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
33358         return ret_arr;
33359 }
33360
33361 void  __attribute__((export_name("TS_ChannelPublicKeys_set_delayed_payment_basepoint"))) TS_ChannelPublicKeys_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
33362         LDKChannelPublicKeys this_ptr_conv;
33363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33364         this_ptr_conv.is_owned = false;
33365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33366         LDKPublicKey val_ref;
33367         CHECK(val->arr_len == 33);
33368         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
33369         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
33370 }
33371
33372 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_get_htlc_basepoint"))) TS_ChannelPublicKeys_get_htlc_basepoint(uint32_t this_ptr) {
33373         LDKChannelPublicKeys this_ptr_conv;
33374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33375         this_ptr_conv.is_owned = false;
33376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33377         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
33378         memcpy(ret_arr->elems, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
33379         return ret_arr;
33380 }
33381
33382 void  __attribute__((export_name("TS_ChannelPublicKeys_set_htlc_basepoint"))) TS_ChannelPublicKeys_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
33383         LDKChannelPublicKeys this_ptr_conv;
33384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33385         this_ptr_conv.is_owned = false;
33386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33387         LDKPublicKey val_ref;
33388         CHECK(val->arr_len == 33);
33389         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
33390         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
33391 }
33392
33393 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) {
33394         LDKPublicKey funding_pubkey_arg_ref;
33395         CHECK(funding_pubkey_arg->arr_len == 33);
33396         memcpy(funding_pubkey_arg_ref.compressed_form, funding_pubkey_arg->elems, 33); FREE(funding_pubkey_arg);
33397         LDKPublicKey revocation_basepoint_arg_ref;
33398         CHECK(revocation_basepoint_arg->arr_len == 33);
33399         memcpy(revocation_basepoint_arg_ref.compressed_form, revocation_basepoint_arg->elems, 33); FREE(revocation_basepoint_arg);
33400         LDKPublicKey payment_point_arg_ref;
33401         CHECK(payment_point_arg->arr_len == 33);
33402         memcpy(payment_point_arg_ref.compressed_form, payment_point_arg->elems, 33); FREE(payment_point_arg);
33403         LDKPublicKey delayed_payment_basepoint_arg_ref;
33404         CHECK(delayed_payment_basepoint_arg->arr_len == 33);
33405         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, delayed_payment_basepoint_arg->elems, 33); FREE(delayed_payment_basepoint_arg);
33406         LDKPublicKey htlc_basepoint_arg_ref;
33407         CHECK(htlc_basepoint_arg->arr_len == 33);
33408         memcpy(htlc_basepoint_arg_ref.compressed_form, htlc_basepoint_arg->elems, 33); FREE(htlc_basepoint_arg);
33409         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);
33410         uint32_t ret_ref = 0;
33411         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33412         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33413         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33414         ret_ref = (uintptr_t)ret_var.inner;
33415         if (ret_var.is_owned) {
33416                 ret_ref |= 1;
33417         }
33418         return ret_ref;
33419 }
33420
33421 static inline uintptr_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
33422         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
33423 uint32_t ret_ref = 0;
33424 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33425 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33426 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33427 ret_ref = (uintptr_t)ret_var.inner;
33428 if (ret_var.is_owned) {
33429         ret_ref |= 1;
33430 }
33431         return ret_ref;
33432 }
33433 uint32_t  __attribute__((export_name("TS_ChannelPublicKeys_clone_ptr"))) TS_ChannelPublicKeys_clone_ptr(uint32_t arg) {
33434         LDKChannelPublicKeys arg_conv;
33435         arg_conv.inner = (void*)(arg & (~1));
33436         arg_conv.is_owned = false;
33437         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33438         uint32_t ret_conv = ChannelPublicKeys_clone_ptr(&arg_conv);
33439         return ret_conv;
33440 }
33441
33442 uint32_t  __attribute__((export_name("TS_ChannelPublicKeys_clone"))) TS_ChannelPublicKeys_clone(uint32_t orig) {
33443         LDKChannelPublicKeys orig_conv;
33444         orig_conv.inner = (void*)(orig & (~1));
33445         orig_conv.is_owned = false;
33446         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33447         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
33448         uint32_t ret_ref = 0;
33449         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33450         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33451         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33452         ret_ref = (uintptr_t)ret_var.inner;
33453         if (ret_var.is_owned) {
33454                 ret_ref |= 1;
33455         }
33456         return ret_ref;
33457 }
33458
33459 int8_tArray  __attribute__((export_name("TS_ChannelPublicKeys_write"))) TS_ChannelPublicKeys_write(uint32_t obj) {
33460         LDKChannelPublicKeys obj_conv;
33461         obj_conv.inner = (void*)(obj & (~1));
33462         obj_conv.is_owned = false;
33463         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33464         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
33465         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33466         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33467         CVec_u8Z_free(ret_var);
33468         return ret_arr;
33469 }
33470
33471 uint32_t  __attribute__((export_name("TS_ChannelPublicKeys_read"))) TS_ChannelPublicKeys_read(int8_tArray ser) {
33472         LDKu8slice ser_ref;
33473         ser_ref.datalen = ser->arr_len;
33474         ser_ref.data = ser->elems /* XXX ser leaks */;
33475         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
33476         *ret_conv = ChannelPublicKeys_read(ser_ref);
33477         return (uint32_t)ret_conv;
33478 }
33479
33480 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) {
33481         LDKPublicKey per_commitment_point_ref;
33482         CHECK(per_commitment_point->arr_len == 33);
33483         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
33484         LDKPublicKey broadcaster_delayed_payment_base_ref;
33485         CHECK(broadcaster_delayed_payment_base->arr_len == 33);
33486         memcpy(broadcaster_delayed_payment_base_ref.compressed_form, broadcaster_delayed_payment_base->elems, 33); FREE(broadcaster_delayed_payment_base);
33487         LDKPublicKey broadcaster_htlc_base_ref;
33488         CHECK(broadcaster_htlc_base->arr_len == 33);
33489         memcpy(broadcaster_htlc_base_ref.compressed_form, broadcaster_htlc_base->elems, 33); FREE(broadcaster_htlc_base);
33490         LDKPublicKey countersignatory_revocation_base_ref;
33491         CHECK(countersignatory_revocation_base->arr_len == 33);
33492         memcpy(countersignatory_revocation_base_ref.compressed_form, countersignatory_revocation_base->elems, 33); FREE(countersignatory_revocation_base);
33493         LDKPublicKey countersignatory_htlc_base_ref;
33494         CHECK(countersignatory_htlc_base->arr_len == 33);
33495         memcpy(countersignatory_htlc_base_ref.compressed_form, countersignatory_htlc_base->elems, 33); FREE(countersignatory_htlc_base);
33496         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
33497         *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);
33498         return (uint32_t)ret_conv;
33499 }
33500
33501 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) {
33502         LDKPublicKey per_commitment_point_ref;
33503         CHECK(per_commitment_point->arr_len == 33);
33504         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point->elems, 33); FREE(per_commitment_point);
33505         LDKChannelPublicKeys broadcaster_keys_conv;
33506         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
33507         broadcaster_keys_conv.is_owned = false;
33508         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
33509         LDKChannelPublicKeys countersignatory_keys_conv;
33510         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
33511         countersignatory_keys_conv.is_owned = false;
33512         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
33513         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
33514         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
33515         return (uint32_t)ret_conv;
33516 }
33517
33518 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) {
33519         LDKPublicKey revocation_key_ref;
33520         CHECK(revocation_key->arr_len == 33);
33521         memcpy(revocation_key_ref.compressed_form, revocation_key->elems, 33); FREE(revocation_key);
33522         LDKPublicKey broadcaster_delayed_payment_key_ref;
33523         CHECK(broadcaster_delayed_payment_key->arr_len == 33);
33524         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, broadcaster_delayed_payment_key->elems, 33); FREE(broadcaster_delayed_payment_key);
33525         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
33526         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33527         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33528         CVec_u8Z_free(ret_var);
33529         return ret_arr;
33530 }
33531
33532 void  __attribute__((export_name("TS_HTLCOutputInCommitment_free"))) TS_HTLCOutputInCommitment_free(uint32_t this_obj) {
33533         LDKHTLCOutputInCommitment this_obj_conv;
33534         this_obj_conv.inner = (void*)(this_obj & (~1));
33535         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33537         HTLCOutputInCommitment_free(this_obj_conv);
33538 }
33539
33540 jboolean  __attribute__((export_name("TS_HTLCOutputInCommitment_get_offered"))) TS_HTLCOutputInCommitment_get_offered(uint32_t this_ptr) {
33541         LDKHTLCOutputInCommitment this_ptr_conv;
33542         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33543         this_ptr_conv.is_owned = false;
33544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33545         jboolean ret_conv = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
33546         return ret_conv;
33547 }
33548
33549 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_offered"))) TS_HTLCOutputInCommitment_set_offered(uint32_t this_ptr, jboolean val) {
33550         LDKHTLCOutputInCommitment this_ptr_conv;
33551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33552         this_ptr_conv.is_owned = false;
33553         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33554         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
33555 }
33556
33557 int64_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_amount_msat"))) TS_HTLCOutputInCommitment_get_amount_msat(uint32_t this_ptr) {
33558         LDKHTLCOutputInCommitment this_ptr_conv;
33559         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33560         this_ptr_conv.is_owned = false;
33561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33562         int64_t ret_conv = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
33563         return ret_conv;
33564 }
33565
33566 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_amount_msat"))) TS_HTLCOutputInCommitment_set_amount_msat(uint32_t this_ptr, int64_t val) {
33567         LDKHTLCOutputInCommitment this_ptr_conv;
33568         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33569         this_ptr_conv.is_owned = false;
33570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33571         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
33572 }
33573
33574 int32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_cltv_expiry"))) TS_HTLCOutputInCommitment_get_cltv_expiry(uint32_t this_ptr) {
33575         LDKHTLCOutputInCommitment this_ptr_conv;
33576         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33577         this_ptr_conv.is_owned = false;
33578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33579         int32_t ret_conv = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
33580         return ret_conv;
33581 }
33582
33583 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_cltv_expiry"))) TS_HTLCOutputInCommitment_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
33584         LDKHTLCOutputInCommitment this_ptr_conv;
33585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33586         this_ptr_conv.is_owned = false;
33587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33588         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
33589 }
33590
33591 int8_tArray  __attribute__((export_name("TS_HTLCOutputInCommitment_get_payment_hash"))) TS_HTLCOutputInCommitment_get_payment_hash(uint32_t this_ptr) {
33592         LDKHTLCOutputInCommitment this_ptr_conv;
33593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33594         this_ptr_conv.is_owned = false;
33595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33596         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
33597         memcpy(ret_arr->elems, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv), 32);
33598         return ret_arr;
33599 }
33600
33601 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_payment_hash"))) TS_HTLCOutputInCommitment_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
33602         LDKHTLCOutputInCommitment this_ptr_conv;
33603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33604         this_ptr_conv.is_owned = false;
33605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33606         LDKThirtyTwoBytes val_ref;
33607         CHECK(val->arr_len == 32);
33608         memcpy(val_ref.data, val->elems, 32); FREE(val);
33609         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
33610 }
33611
33612 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_get_transaction_output_index"))) TS_HTLCOutputInCommitment_get_transaction_output_index(uint32_t this_ptr) {
33613         LDKHTLCOutputInCommitment this_ptr_conv;
33614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33615         this_ptr_conv.is_owned = false;
33616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33617         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
33618         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
33619         uint32_t ret_ref = (uintptr_t)ret_copy;
33620         return ret_ref;
33621 }
33622
33623 void  __attribute__((export_name("TS_HTLCOutputInCommitment_set_transaction_output_index"))) TS_HTLCOutputInCommitment_set_transaction_output_index(uint32_t this_ptr, uint32_t val) {
33624         LDKHTLCOutputInCommitment this_ptr_conv;
33625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33626         this_ptr_conv.is_owned = false;
33627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33628         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
33629         CHECK_ACCESS(val_ptr);
33630         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
33631         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)val) & ~1));
33632         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
33633 }
33634
33635 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) {
33636         LDKThirtyTwoBytes payment_hash_arg_ref;
33637         CHECK(payment_hash_arg->arr_len == 32);
33638         memcpy(payment_hash_arg_ref.data, payment_hash_arg->elems, 32); FREE(payment_hash_arg);
33639         void* transaction_output_index_arg_ptr = (void*)(((uintptr_t)transaction_output_index_arg) & ~1);
33640         CHECK_ACCESS(transaction_output_index_arg_ptr);
33641         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
33642         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uintptr_t)transaction_output_index_arg) & ~1));
33643         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
33644         uint32_t ret_ref = 0;
33645         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33646         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33647         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33648         ret_ref = (uintptr_t)ret_var.inner;
33649         if (ret_var.is_owned) {
33650                 ret_ref |= 1;
33651         }
33652         return ret_ref;
33653 }
33654
33655 static inline uintptr_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
33656         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
33657 uint32_t ret_ref = 0;
33658 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33659 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33660 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33661 ret_ref = (uintptr_t)ret_var.inner;
33662 if (ret_var.is_owned) {
33663         ret_ref |= 1;
33664 }
33665         return ret_ref;
33666 }
33667 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_clone_ptr"))) TS_HTLCOutputInCommitment_clone_ptr(uint32_t arg) {
33668         LDKHTLCOutputInCommitment arg_conv;
33669         arg_conv.inner = (void*)(arg & (~1));
33670         arg_conv.is_owned = false;
33671         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33672         uint32_t ret_conv = HTLCOutputInCommitment_clone_ptr(&arg_conv);
33673         return ret_conv;
33674 }
33675
33676 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_clone"))) TS_HTLCOutputInCommitment_clone(uint32_t orig) {
33677         LDKHTLCOutputInCommitment orig_conv;
33678         orig_conv.inner = (void*)(orig & (~1));
33679         orig_conv.is_owned = false;
33680         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33681         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
33682         uint32_t ret_ref = 0;
33683         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33684         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33685         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33686         ret_ref = (uintptr_t)ret_var.inner;
33687         if (ret_var.is_owned) {
33688                 ret_ref |= 1;
33689         }
33690         return ret_ref;
33691 }
33692
33693 int8_tArray  __attribute__((export_name("TS_HTLCOutputInCommitment_write"))) TS_HTLCOutputInCommitment_write(uint32_t obj) {
33694         LDKHTLCOutputInCommitment obj_conv;
33695         obj_conv.inner = (void*)(obj & (~1));
33696         obj_conv.is_owned = false;
33697         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33698         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
33699         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33700         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33701         CVec_u8Z_free(ret_var);
33702         return ret_arr;
33703 }
33704
33705 uint32_t  __attribute__((export_name("TS_HTLCOutputInCommitment_read"))) TS_HTLCOutputInCommitment_read(int8_tArray ser) {
33706         LDKu8slice ser_ref;
33707         ser_ref.datalen = ser->arr_len;
33708         ser_ref.data = ser->elems /* XXX ser leaks */;
33709         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
33710         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
33711         return (uint32_t)ret_conv;
33712 }
33713
33714 int8_tArray  __attribute__((export_name("TS_get_htlc_redeemscript"))) TS_get_htlc_redeemscript(uint32_t htlc, jboolean opt_anchors, uint32_t keys) {
33715         LDKHTLCOutputInCommitment htlc_conv;
33716         htlc_conv.inner = (void*)(htlc & (~1));
33717         htlc_conv.is_owned = false;
33718         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
33719         LDKTxCreationKeys keys_conv;
33720         keys_conv.inner = (void*)(keys & (~1));
33721         keys_conv.is_owned = false;
33722         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
33723         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, opt_anchors, &keys_conv);
33724         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33725         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33726         CVec_u8Z_free(ret_var);
33727         return ret_arr;
33728 }
33729
33730 int8_tArray  __attribute__((export_name("TS_make_funding_redeemscript"))) TS_make_funding_redeemscript(int8_tArray broadcaster, int8_tArray countersignatory) {
33731         LDKPublicKey broadcaster_ref;
33732         CHECK(broadcaster->arr_len == 33);
33733         memcpy(broadcaster_ref.compressed_form, broadcaster->elems, 33); FREE(broadcaster);
33734         LDKPublicKey countersignatory_ref;
33735         CHECK(countersignatory->arr_len == 33);
33736         memcpy(countersignatory_ref.compressed_form, countersignatory->elems, 33); FREE(countersignatory);
33737         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
33738         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33739         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33740         CVec_u8Z_free(ret_var);
33741         return ret_arr;
33742 }
33743
33744 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) {
33745         unsigned char commitment_txid_arr[32];
33746         CHECK(commitment_txid->arr_len == 32);
33747         memcpy(commitment_txid_arr, commitment_txid->elems, 32); FREE(commitment_txid);
33748         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
33749         LDKHTLCOutputInCommitment htlc_conv;
33750         htlc_conv.inner = (void*)(htlc & (~1));
33751         htlc_conv.is_owned = false;
33752         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
33753         LDKPublicKey broadcaster_delayed_payment_key_ref;
33754         CHECK(broadcaster_delayed_payment_key->arr_len == 33);
33755         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, broadcaster_delayed_payment_key->elems, 33); FREE(broadcaster_delayed_payment_key);
33756         LDKPublicKey revocation_key_ref;
33757         CHECK(revocation_key->arr_len == 33);
33758         memcpy(revocation_key_ref.compressed_form, revocation_key->elems, 33); FREE(revocation_key);
33759         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);
33760         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33761         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33762         Transaction_free(ret_var);
33763         return ret_arr;
33764 }
33765
33766 int8_tArray  __attribute__((export_name("TS_get_anchor_redeemscript"))) TS_get_anchor_redeemscript(int8_tArray funding_pubkey) {
33767         LDKPublicKey funding_pubkey_ref;
33768         CHECK(funding_pubkey->arr_len == 33);
33769         memcpy(funding_pubkey_ref.compressed_form, funding_pubkey->elems, 33); FREE(funding_pubkey);
33770         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
33771         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
33772         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
33773         CVec_u8Z_free(ret_var);
33774         return ret_arr;
33775 }
33776
33777 void  __attribute__((export_name("TS_ChannelTransactionParameters_free"))) TS_ChannelTransactionParameters_free(uint32_t this_obj) {
33778         LDKChannelTransactionParameters this_obj_conv;
33779         this_obj_conv.inner = (void*)(this_obj & (~1));
33780         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33782         ChannelTransactionParameters_free(this_obj_conv);
33783 }
33784
33785 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_holder_pubkeys"))) TS_ChannelTransactionParameters_get_holder_pubkeys(uint32_t this_ptr) {
33786         LDKChannelTransactionParameters this_ptr_conv;
33787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33788         this_ptr_conv.is_owned = false;
33789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33790         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
33791         uint32_t ret_ref = 0;
33792         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33793         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33794         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33795         ret_ref = (uintptr_t)ret_var.inner;
33796         if (ret_var.is_owned) {
33797                 ret_ref |= 1;
33798         }
33799         return ret_ref;
33800 }
33801
33802 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_holder_pubkeys"))) TS_ChannelTransactionParameters_set_holder_pubkeys(uint32_t this_ptr, uint32_t val) {
33803         LDKChannelTransactionParameters this_ptr_conv;
33804         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33805         this_ptr_conv.is_owned = false;
33806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33807         LDKChannelPublicKeys val_conv;
33808         val_conv.inner = (void*)(val & (~1));
33809         val_conv.is_owned = (val & 1) || (val == 0);
33810         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33811         val_conv = ChannelPublicKeys_clone(&val_conv);
33812         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
33813 }
33814
33815 int16_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_holder_selected_contest_delay"))) TS_ChannelTransactionParameters_get_holder_selected_contest_delay(uint32_t this_ptr) {
33816         LDKChannelTransactionParameters this_ptr_conv;
33817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33818         this_ptr_conv.is_owned = false;
33819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33820         int16_t ret_conv = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
33821         return ret_conv;
33822 }
33823
33824 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) {
33825         LDKChannelTransactionParameters this_ptr_conv;
33826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33827         this_ptr_conv.is_owned = false;
33828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33829         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
33830 }
33831
33832 jboolean  __attribute__((export_name("TS_ChannelTransactionParameters_get_is_outbound_from_holder"))) TS_ChannelTransactionParameters_get_is_outbound_from_holder(uint32_t this_ptr) {
33833         LDKChannelTransactionParameters this_ptr_conv;
33834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33835         this_ptr_conv.is_owned = false;
33836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33837         jboolean ret_conv = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
33838         return ret_conv;
33839 }
33840
33841 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_is_outbound_from_holder"))) TS_ChannelTransactionParameters_set_is_outbound_from_holder(uint32_t this_ptr, jboolean val) {
33842         LDKChannelTransactionParameters this_ptr_conv;
33843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33844         this_ptr_conv.is_owned = false;
33845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33846         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
33847 }
33848
33849 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_counterparty_parameters"))) TS_ChannelTransactionParameters_get_counterparty_parameters(uint32_t this_ptr) {
33850         LDKChannelTransactionParameters this_ptr_conv;
33851         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33852         this_ptr_conv.is_owned = false;
33853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33854         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
33855         uint32_t ret_ref = 0;
33856         if ((uintptr_t)ret_var.inner > 4096) {
33857                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33858                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33859         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33860                 ret_ref = (uintptr_t)ret_var.inner;
33861                 if (ret_var.is_owned) {
33862                         ret_ref |= 1;
33863                 }
33864         }
33865         return ret_ref;
33866 }
33867
33868 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_counterparty_parameters"))) TS_ChannelTransactionParameters_set_counterparty_parameters(uint32_t this_ptr, uint32_t val) {
33869         LDKChannelTransactionParameters this_ptr_conv;
33870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33871         this_ptr_conv.is_owned = false;
33872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33873         LDKCounterpartyChannelTransactionParameters val_conv;
33874         val_conv.inner = (void*)(val & (~1));
33875         val_conv.is_owned = (val & 1) || (val == 0);
33876         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33877         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
33878         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
33879 }
33880
33881 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_funding_outpoint"))) TS_ChannelTransactionParameters_get_funding_outpoint(uint32_t this_ptr) {
33882         LDKChannelTransactionParameters this_ptr_conv;
33883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33884         this_ptr_conv.is_owned = false;
33885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33886         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
33887         uint32_t ret_ref = 0;
33888         if ((uintptr_t)ret_var.inner > 4096) {
33889                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33890                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33891         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33892                 ret_ref = (uintptr_t)ret_var.inner;
33893                 if (ret_var.is_owned) {
33894                         ret_ref |= 1;
33895                 }
33896         }
33897         return ret_ref;
33898 }
33899
33900 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_funding_outpoint"))) TS_ChannelTransactionParameters_set_funding_outpoint(uint32_t this_ptr, uint32_t val) {
33901         LDKChannelTransactionParameters this_ptr_conv;
33902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33903         this_ptr_conv.is_owned = false;
33904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33905         LDKOutPoint val_conv;
33906         val_conv.inner = (void*)(val & (~1));
33907         val_conv.is_owned = (val & 1) || (val == 0);
33908         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33909         val_conv = OutPoint_clone(&val_conv);
33910         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
33911 }
33912
33913 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_get_opt_anchors"))) TS_ChannelTransactionParameters_get_opt_anchors(uint32_t this_ptr) {
33914         LDKChannelTransactionParameters this_ptr_conv;
33915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33916         this_ptr_conv.is_owned = false;
33917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33918         uint32_t ret_conv = LDKCOption_NoneZ_to_js(ChannelTransactionParameters_get_opt_anchors(&this_ptr_conv));
33919         return ret_conv;
33920 }
33921
33922 void  __attribute__((export_name("TS_ChannelTransactionParameters_set_opt_anchors"))) TS_ChannelTransactionParameters_set_opt_anchors(uint32_t this_ptr, uint32_t val) {
33923         LDKChannelTransactionParameters this_ptr_conv;
33924         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33925         this_ptr_conv.is_owned = false;
33926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33927         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_js(val);
33928         ChannelTransactionParameters_set_opt_anchors(&this_ptr_conv, val_conv);
33929 }
33930
33931 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) {
33932         LDKChannelPublicKeys holder_pubkeys_arg_conv;
33933         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
33934         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
33935         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
33936         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
33937         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
33938         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
33939         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
33940         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
33941         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
33942         LDKOutPoint funding_outpoint_arg_conv;
33943         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
33944         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
33945         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
33946         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
33947         LDKCOption_NoneZ opt_anchors_arg_conv = LDKCOption_NoneZ_from_js(opt_anchors_arg);
33948         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);
33949         uint32_t ret_ref = 0;
33950         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33951         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33952         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33953         ret_ref = (uintptr_t)ret_var.inner;
33954         if (ret_var.is_owned) {
33955                 ret_ref |= 1;
33956         }
33957         return ret_ref;
33958 }
33959
33960 static inline uintptr_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
33961         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
33962 uint32_t ret_ref = 0;
33963 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33964 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33965 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33966 ret_ref = (uintptr_t)ret_var.inner;
33967 if (ret_var.is_owned) {
33968         ret_ref |= 1;
33969 }
33970         return ret_ref;
33971 }
33972 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_clone_ptr"))) TS_ChannelTransactionParameters_clone_ptr(uint32_t arg) {
33973         LDKChannelTransactionParameters arg_conv;
33974         arg_conv.inner = (void*)(arg & (~1));
33975         arg_conv.is_owned = false;
33976         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33977         uint32_t ret_conv = ChannelTransactionParameters_clone_ptr(&arg_conv);
33978         return ret_conv;
33979 }
33980
33981 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_clone"))) TS_ChannelTransactionParameters_clone(uint32_t orig) {
33982         LDKChannelTransactionParameters orig_conv;
33983         orig_conv.inner = (void*)(orig & (~1));
33984         orig_conv.is_owned = false;
33985         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33986         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
33987         uint32_t ret_ref = 0;
33988         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33989         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33990         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33991         ret_ref = (uintptr_t)ret_var.inner;
33992         if (ret_var.is_owned) {
33993                 ret_ref |= 1;
33994         }
33995         return ret_ref;
33996 }
33997
33998 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_free"))) TS_CounterpartyChannelTransactionParameters_free(uint32_t this_obj) {
33999         LDKCounterpartyChannelTransactionParameters this_obj_conv;
34000         this_obj_conv.inner = (void*)(this_obj & (~1));
34001         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34003         CounterpartyChannelTransactionParameters_free(this_obj_conv);
34004 }
34005
34006 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_get_pubkeys"))) TS_CounterpartyChannelTransactionParameters_get_pubkeys(uint32_t this_ptr) {
34007         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
34008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34009         this_ptr_conv.is_owned = false;
34010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34011         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
34012         uint32_t ret_ref = 0;
34013         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34014         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34015         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34016         ret_ref = (uintptr_t)ret_var.inner;
34017         if (ret_var.is_owned) {
34018                 ret_ref |= 1;
34019         }
34020         return ret_ref;
34021 }
34022
34023 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_set_pubkeys"))) TS_CounterpartyChannelTransactionParameters_set_pubkeys(uint32_t this_ptr, uint32_t val) {
34024         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
34025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34026         this_ptr_conv.is_owned = false;
34027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34028         LDKChannelPublicKeys val_conv;
34029         val_conv.inner = (void*)(val & (~1));
34030         val_conv.is_owned = (val & 1) || (val == 0);
34031         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34032         val_conv = ChannelPublicKeys_clone(&val_conv);
34033         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
34034 }
34035
34036 int16_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay"))) TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay(uint32_t this_ptr) {
34037         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
34038         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34039         this_ptr_conv.is_owned = false;
34040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34041         int16_t ret_conv = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
34042         return ret_conv;
34043 }
34044
34045 void  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay"))) TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay(uint32_t this_ptr, int16_t val) {
34046         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
34047         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34048         this_ptr_conv.is_owned = false;
34049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34050         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
34051 }
34052
34053 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_new"))) TS_CounterpartyChannelTransactionParameters_new(uint32_t pubkeys_arg, int16_t selected_contest_delay_arg) {
34054         LDKChannelPublicKeys pubkeys_arg_conv;
34055         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
34056         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
34057         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
34058         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
34059         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
34060         uint32_t ret_ref = 0;
34061         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34062         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34063         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34064         ret_ref = (uintptr_t)ret_var.inner;
34065         if (ret_var.is_owned) {
34066                 ret_ref |= 1;
34067         }
34068         return ret_ref;
34069 }
34070
34071 static inline uintptr_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
34072         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
34073 uint32_t ret_ref = 0;
34074 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34075 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34076 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34077 ret_ref = (uintptr_t)ret_var.inner;
34078 if (ret_var.is_owned) {
34079         ret_ref |= 1;
34080 }
34081         return ret_ref;
34082 }
34083 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_clone_ptr"))) TS_CounterpartyChannelTransactionParameters_clone_ptr(uint32_t arg) {
34084         LDKCounterpartyChannelTransactionParameters arg_conv;
34085         arg_conv.inner = (void*)(arg & (~1));
34086         arg_conv.is_owned = false;
34087         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34088         uint32_t ret_conv = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
34089         return ret_conv;
34090 }
34091
34092 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_clone"))) TS_CounterpartyChannelTransactionParameters_clone(uint32_t orig) {
34093         LDKCounterpartyChannelTransactionParameters orig_conv;
34094         orig_conv.inner = (void*)(orig & (~1));
34095         orig_conv.is_owned = false;
34096         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34097         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
34098         uint32_t ret_ref = 0;
34099         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34100         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34101         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34102         ret_ref = (uintptr_t)ret_var.inner;
34103         if (ret_var.is_owned) {
34104                 ret_ref |= 1;
34105         }
34106         return ret_ref;
34107 }
34108
34109 jboolean  __attribute__((export_name("TS_ChannelTransactionParameters_is_populated"))) TS_ChannelTransactionParameters_is_populated(uint32_t this_arg) {
34110         LDKChannelTransactionParameters this_arg_conv;
34111         this_arg_conv.inner = (void*)(this_arg & (~1));
34112         this_arg_conv.is_owned = false;
34113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34114         jboolean ret_conv = ChannelTransactionParameters_is_populated(&this_arg_conv);
34115         return ret_conv;
34116 }
34117
34118 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_as_holder_broadcastable"))) TS_ChannelTransactionParameters_as_holder_broadcastable(uint32_t this_arg) {
34119         LDKChannelTransactionParameters this_arg_conv;
34120         this_arg_conv.inner = (void*)(this_arg & (~1));
34121         this_arg_conv.is_owned = false;
34122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34123         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
34124         uint32_t ret_ref = 0;
34125         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34126         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34127         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34128         ret_ref = (uintptr_t)ret_var.inner;
34129         if (ret_var.is_owned) {
34130                 ret_ref |= 1;
34131         }
34132         return ret_ref;
34133 }
34134
34135 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_as_counterparty_broadcastable"))) TS_ChannelTransactionParameters_as_counterparty_broadcastable(uint32_t this_arg) {
34136         LDKChannelTransactionParameters this_arg_conv;
34137         this_arg_conv.inner = (void*)(this_arg & (~1));
34138         this_arg_conv.is_owned = false;
34139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34140         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
34141         uint32_t ret_ref = 0;
34142         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34143         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34144         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34145         ret_ref = (uintptr_t)ret_var.inner;
34146         if (ret_var.is_owned) {
34147                 ret_ref |= 1;
34148         }
34149         return ret_ref;
34150 }
34151
34152 int8_tArray  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_write"))) TS_CounterpartyChannelTransactionParameters_write(uint32_t obj) {
34153         LDKCounterpartyChannelTransactionParameters obj_conv;
34154         obj_conv.inner = (void*)(obj & (~1));
34155         obj_conv.is_owned = false;
34156         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34157         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
34158         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34159         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34160         CVec_u8Z_free(ret_var);
34161         return ret_arr;
34162 }
34163
34164 uint32_t  __attribute__((export_name("TS_CounterpartyChannelTransactionParameters_read"))) TS_CounterpartyChannelTransactionParameters_read(int8_tArray ser) {
34165         LDKu8slice ser_ref;
34166         ser_ref.datalen = ser->arr_len;
34167         ser_ref.data = ser->elems /* XXX ser leaks */;
34168         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
34169         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
34170         return (uint32_t)ret_conv;
34171 }
34172
34173 int8_tArray  __attribute__((export_name("TS_ChannelTransactionParameters_write"))) TS_ChannelTransactionParameters_write(uint32_t obj) {
34174         LDKChannelTransactionParameters obj_conv;
34175         obj_conv.inner = (void*)(obj & (~1));
34176         obj_conv.is_owned = false;
34177         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34178         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
34179         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34180         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34181         CVec_u8Z_free(ret_var);
34182         return ret_arr;
34183 }
34184
34185 uint32_t  __attribute__((export_name("TS_ChannelTransactionParameters_read"))) TS_ChannelTransactionParameters_read(int8_tArray ser) {
34186         LDKu8slice ser_ref;
34187         ser_ref.datalen = ser->arr_len;
34188         ser_ref.data = ser->elems /* XXX ser leaks */;
34189         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
34190         *ret_conv = ChannelTransactionParameters_read(ser_ref);
34191         return (uint32_t)ret_conv;
34192 }
34193
34194 void  __attribute__((export_name("TS_DirectedChannelTransactionParameters_free"))) TS_DirectedChannelTransactionParameters_free(uint32_t this_obj) {
34195         LDKDirectedChannelTransactionParameters this_obj_conv;
34196         this_obj_conv.inner = (void*)(this_obj & (~1));
34197         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34199         DirectedChannelTransactionParameters_free(this_obj_conv);
34200 }
34201
34202 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_broadcaster_pubkeys"))) TS_DirectedChannelTransactionParameters_broadcaster_pubkeys(uint32_t this_arg) {
34203         LDKDirectedChannelTransactionParameters this_arg_conv;
34204         this_arg_conv.inner = (void*)(this_arg & (~1));
34205         this_arg_conv.is_owned = false;
34206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34207         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
34208         uint32_t ret_ref = 0;
34209         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34210         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34211         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34212         ret_ref = (uintptr_t)ret_var.inner;
34213         if (ret_var.is_owned) {
34214                 ret_ref |= 1;
34215         }
34216         return ret_ref;
34217 }
34218
34219 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_countersignatory_pubkeys"))) TS_DirectedChannelTransactionParameters_countersignatory_pubkeys(uint32_t this_arg) {
34220         LDKDirectedChannelTransactionParameters this_arg_conv;
34221         this_arg_conv.inner = (void*)(this_arg & (~1));
34222         this_arg_conv.is_owned = false;
34223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34224         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
34225         uint32_t ret_ref = 0;
34226         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34227         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34228         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34229         ret_ref = (uintptr_t)ret_var.inner;
34230         if (ret_var.is_owned) {
34231                 ret_ref |= 1;
34232         }
34233         return ret_ref;
34234 }
34235
34236 int16_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_contest_delay"))) TS_DirectedChannelTransactionParameters_contest_delay(uint32_t this_arg) {
34237         LDKDirectedChannelTransactionParameters this_arg_conv;
34238         this_arg_conv.inner = (void*)(this_arg & (~1));
34239         this_arg_conv.is_owned = false;
34240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34241         int16_t ret_conv = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
34242         return ret_conv;
34243 }
34244
34245 jboolean  __attribute__((export_name("TS_DirectedChannelTransactionParameters_is_outbound"))) TS_DirectedChannelTransactionParameters_is_outbound(uint32_t this_arg) {
34246         LDKDirectedChannelTransactionParameters this_arg_conv;
34247         this_arg_conv.inner = (void*)(this_arg & (~1));
34248         this_arg_conv.is_owned = false;
34249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34250         jboolean ret_conv = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
34251         return ret_conv;
34252 }
34253
34254 uint32_t  __attribute__((export_name("TS_DirectedChannelTransactionParameters_funding_outpoint"))) TS_DirectedChannelTransactionParameters_funding_outpoint(uint32_t this_arg) {
34255         LDKDirectedChannelTransactionParameters this_arg_conv;
34256         this_arg_conv.inner = (void*)(this_arg & (~1));
34257         this_arg_conv.is_owned = false;
34258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34259         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
34260         uint32_t ret_ref = 0;
34261         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34262         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34263         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34264         ret_ref = (uintptr_t)ret_var.inner;
34265         if (ret_var.is_owned) {
34266                 ret_ref |= 1;
34267         }
34268         return ret_ref;
34269 }
34270
34271 jboolean  __attribute__((export_name("TS_DirectedChannelTransactionParameters_opt_anchors"))) TS_DirectedChannelTransactionParameters_opt_anchors(uint32_t this_arg) {
34272         LDKDirectedChannelTransactionParameters this_arg_conv;
34273         this_arg_conv.inner = (void*)(this_arg & (~1));
34274         this_arg_conv.is_owned = false;
34275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34276         jboolean ret_conv = DirectedChannelTransactionParameters_opt_anchors(&this_arg_conv);
34277         return ret_conv;
34278 }
34279
34280 void  __attribute__((export_name("TS_HolderCommitmentTransaction_free"))) TS_HolderCommitmentTransaction_free(uint32_t this_obj) {
34281         LDKHolderCommitmentTransaction this_obj_conv;
34282         this_obj_conv.inner = (void*)(this_obj & (~1));
34283         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34285         HolderCommitmentTransaction_free(this_obj_conv);
34286 }
34287
34288 int8_tArray  __attribute__((export_name("TS_HolderCommitmentTransaction_get_counterparty_sig"))) TS_HolderCommitmentTransaction_get_counterparty_sig(uint32_t this_ptr) {
34289         LDKHolderCommitmentTransaction this_ptr_conv;
34290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34291         this_ptr_conv.is_owned = false;
34292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34293         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
34294         memcpy(ret_arr->elems, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form, 64);
34295         return ret_arr;
34296 }
34297
34298 void  __attribute__((export_name("TS_HolderCommitmentTransaction_set_counterparty_sig"))) TS_HolderCommitmentTransaction_set_counterparty_sig(uint32_t this_ptr, int8_tArray val) {
34299         LDKHolderCommitmentTransaction this_ptr_conv;
34300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34301         this_ptr_conv.is_owned = false;
34302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34303         LDKSignature val_ref;
34304         CHECK(val->arr_len == 64);
34305         memcpy(val_ref.compact_form, val->elems, 64); FREE(val);
34306         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
34307 }
34308
34309 void  __attribute__((export_name("TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs"))) TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs(uint32_t this_ptr, ptrArray val) {
34310         LDKHolderCommitmentTransaction this_ptr_conv;
34311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34312         this_ptr_conv.is_owned = false;
34313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34314         LDKCVec_SignatureZ val_constr;
34315         val_constr.datalen = val->arr_len;
34316         if (val_constr.datalen > 0)
34317                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
34318         else
34319                 val_constr.data = NULL;
34320         int8_tArray* val_vals = (void*) val->elems /* XXX val leaks */;
34321         for (size_t m = 0; m < val_constr.datalen; m++) {
34322                 int8_tArray val_conv_12 = val_vals[m];
34323                 LDKSignature val_conv_12_ref;
34324                 CHECK(val_conv_12->arr_len == 64);
34325                 memcpy(val_conv_12_ref.compact_form, val_conv_12->elems, 64); FREE(val_conv_12);
34326                 val_constr.data[m] = val_conv_12_ref;
34327         }
34328         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
34329 }
34330
34331 static inline uintptr_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
34332         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
34333 uint32_t ret_ref = 0;
34334 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34335 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34336 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34337 ret_ref = (uintptr_t)ret_var.inner;
34338 if (ret_var.is_owned) {
34339         ret_ref |= 1;
34340 }
34341         return ret_ref;
34342 }
34343 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_clone_ptr"))) TS_HolderCommitmentTransaction_clone_ptr(uint32_t arg) {
34344         LDKHolderCommitmentTransaction arg_conv;
34345         arg_conv.inner = (void*)(arg & (~1));
34346         arg_conv.is_owned = false;
34347         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34348         uint32_t ret_conv = HolderCommitmentTransaction_clone_ptr(&arg_conv);
34349         return ret_conv;
34350 }
34351
34352 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_clone"))) TS_HolderCommitmentTransaction_clone(uint32_t orig) {
34353         LDKHolderCommitmentTransaction orig_conv;
34354         orig_conv.inner = (void*)(orig & (~1));
34355         orig_conv.is_owned = false;
34356         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34357         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
34358         uint32_t ret_ref = 0;
34359         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34360         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34361         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34362         ret_ref = (uintptr_t)ret_var.inner;
34363         if (ret_var.is_owned) {
34364                 ret_ref |= 1;
34365         }
34366         return ret_ref;
34367 }
34368
34369 int8_tArray  __attribute__((export_name("TS_HolderCommitmentTransaction_write"))) TS_HolderCommitmentTransaction_write(uint32_t obj) {
34370         LDKHolderCommitmentTransaction obj_conv;
34371         obj_conv.inner = (void*)(obj & (~1));
34372         obj_conv.is_owned = false;
34373         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34374         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
34375         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34376         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34377         CVec_u8Z_free(ret_var);
34378         return ret_arr;
34379 }
34380
34381 uint32_t  __attribute__((export_name("TS_HolderCommitmentTransaction_read"))) TS_HolderCommitmentTransaction_read(int8_tArray ser) {
34382         LDKu8slice ser_ref;
34383         ser_ref.datalen = ser->arr_len;
34384         ser_ref.data = ser->elems /* XXX ser leaks */;
34385         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
34386         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
34387         return (uint32_t)ret_conv;
34388 }
34389
34390 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) {
34391         LDKCommitmentTransaction commitment_tx_conv;
34392         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
34393         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
34394         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
34395         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
34396         LDKSignature counterparty_sig_ref;
34397         CHECK(counterparty_sig->arr_len == 64);
34398         memcpy(counterparty_sig_ref.compact_form, counterparty_sig->elems, 64); FREE(counterparty_sig);
34399         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
34400         counterparty_htlc_sigs_constr.datalen = counterparty_htlc_sigs->arr_len;
34401         if (counterparty_htlc_sigs_constr.datalen > 0)
34402                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
34403         else
34404                 counterparty_htlc_sigs_constr.data = NULL;
34405         int8_tArray* counterparty_htlc_sigs_vals = (void*) counterparty_htlc_sigs->elems /* XXX counterparty_htlc_sigs leaks */;
34406         for (size_t m = 0; m < counterparty_htlc_sigs_constr.datalen; m++) {
34407                 int8_tArray counterparty_htlc_sigs_conv_12 = counterparty_htlc_sigs_vals[m];
34408                 LDKSignature counterparty_htlc_sigs_conv_12_ref;
34409                 CHECK(counterparty_htlc_sigs_conv_12->arr_len == 64);
34410                 memcpy(counterparty_htlc_sigs_conv_12_ref.compact_form, counterparty_htlc_sigs_conv_12->elems, 64); FREE(counterparty_htlc_sigs_conv_12);
34411                 counterparty_htlc_sigs_constr.data[m] = counterparty_htlc_sigs_conv_12_ref;
34412         }
34413         LDKPublicKey holder_funding_key_ref;
34414         CHECK(holder_funding_key->arr_len == 33);
34415         memcpy(holder_funding_key_ref.compressed_form, holder_funding_key->elems, 33); FREE(holder_funding_key);
34416         LDKPublicKey counterparty_funding_key_ref;
34417         CHECK(counterparty_funding_key->arr_len == 33);
34418         memcpy(counterparty_funding_key_ref.compressed_form, counterparty_funding_key->elems, 33); FREE(counterparty_funding_key);
34419         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
34420         uint32_t ret_ref = 0;
34421         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34422         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34423         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34424         ret_ref = (uintptr_t)ret_var.inner;
34425         if (ret_var.is_owned) {
34426                 ret_ref |= 1;
34427         }
34428         return ret_ref;
34429 }
34430
34431 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_free"))) TS_BuiltCommitmentTransaction_free(uint32_t this_obj) {
34432         LDKBuiltCommitmentTransaction this_obj_conv;
34433         this_obj_conv.inner = (void*)(this_obj & (~1));
34434         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34436         BuiltCommitmentTransaction_free(this_obj_conv);
34437 }
34438
34439 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_get_transaction"))) TS_BuiltCommitmentTransaction_get_transaction(uint32_t this_ptr) {
34440         LDKBuiltCommitmentTransaction this_ptr_conv;
34441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34442         this_ptr_conv.is_owned = false;
34443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34444         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
34445         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34446         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34447         Transaction_free(ret_var);
34448         return ret_arr;
34449 }
34450
34451 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_set_transaction"))) TS_BuiltCommitmentTransaction_set_transaction(uint32_t this_ptr, int8_tArray val) {
34452         LDKBuiltCommitmentTransaction this_ptr_conv;
34453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34454         this_ptr_conv.is_owned = false;
34455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34456         LDKTransaction val_ref;
34457         val_ref.datalen = val->arr_len;
34458         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
34459         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
34460         val_ref.data_is_owned = true;
34461         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
34462 }
34463
34464 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_get_txid"))) TS_BuiltCommitmentTransaction_get_txid(uint32_t this_ptr) {
34465         LDKBuiltCommitmentTransaction this_ptr_conv;
34466         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34467         this_ptr_conv.is_owned = false;
34468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34469         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
34470         memcpy(ret_arr->elems, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv), 32);
34471         return ret_arr;
34472 }
34473
34474 void  __attribute__((export_name("TS_BuiltCommitmentTransaction_set_txid"))) TS_BuiltCommitmentTransaction_set_txid(uint32_t this_ptr, int8_tArray val) {
34475         LDKBuiltCommitmentTransaction this_ptr_conv;
34476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34477         this_ptr_conv.is_owned = false;
34478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34479         LDKThirtyTwoBytes val_ref;
34480         CHECK(val->arr_len == 32);
34481         memcpy(val_ref.data, val->elems, 32); FREE(val);
34482         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
34483 }
34484
34485 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_new"))) TS_BuiltCommitmentTransaction_new(int8_tArray transaction_arg, int8_tArray txid_arg) {
34486         LDKTransaction transaction_arg_ref;
34487         transaction_arg_ref.datalen = transaction_arg->arr_len;
34488         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
34489         memcpy(transaction_arg_ref.data, transaction_arg->elems, transaction_arg_ref.datalen); FREE(transaction_arg);
34490         transaction_arg_ref.data_is_owned = true;
34491         LDKThirtyTwoBytes txid_arg_ref;
34492         CHECK(txid_arg->arr_len == 32);
34493         memcpy(txid_arg_ref.data, txid_arg->elems, 32); FREE(txid_arg);
34494         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
34495         uint32_t ret_ref = 0;
34496         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34497         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34498         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34499         ret_ref = (uintptr_t)ret_var.inner;
34500         if (ret_var.is_owned) {
34501                 ret_ref |= 1;
34502         }
34503         return ret_ref;
34504 }
34505
34506 static inline uintptr_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
34507         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
34508 uint32_t ret_ref = 0;
34509 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34510 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34511 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34512 ret_ref = (uintptr_t)ret_var.inner;
34513 if (ret_var.is_owned) {
34514         ret_ref |= 1;
34515 }
34516         return ret_ref;
34517 }
34518 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_clone_ptr"))) TS_BuiltCommitmentTransaction_clone_ptr(uint32_t arg) {
34519         LDKBuiltCommitmentTransaction arg_conv;
34520         arg_conv.inner = (void*)(arg & (~1));
34521         arg_conv.is_owned = false;
34522         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34523         uint32_t ret_conv = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
34524         return ret_conv;
34525 }
34526
34527 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_clone"))) TS_BuiltCommitmentTransaction_clone(uint32_t orig) {
34528         LDKBuiltCommitmentTransaction orig_conv;
34529         orig_conv.inner = (void*)(orig & (~1));
34530         orig_conv.is_owned = false;
34531         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34532         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
34533         uint32_t ret_ref = 0;
34534         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34535         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34536         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34537         ret_ref = (uintptr_t)ret_var.inner;
34538         if (ret_var.is_owned) {
34539                 ret_ref |= 1;
34540         }
34541         return ret_ref;
34542 }
34543
34544 int8_tArray  __attribute__((export_name("TS_BuiltCommitmentTransaction_write"))) TS_BuiltCommitmentTransaction_write(uint32_t obj) {
34545         LDKBuiltCommitmentTransaction obj_conv;
34546         obj_conv.inner = (void*)(obj & (~1));
34547         obj_conv.is_owned = false;
34548         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34549         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
34550         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34551         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34552         CVec_u8Z_free(ret_var);
34553         return ret_arr;
34554 }
34555
34556 uint32_t  __attribute__((export_name("TS_BuiltCommitmentTransaction_read"))) TS_BuiltCommitmentTransaction_read(int8_tArray ser) {
34557         LDKu8slice ser_ref;
34558         ser_ref.datalen = ser->arr_len;
34559         ser_ref.data = ser->elems /* XXX ser leaks */;
34560         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
34561         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
34562         return (uint32_t)ret_conv;
34563 }
34564
34565 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) {
34566         LDKBuiltCommitmentTransaction this_arg_conv;
34567         this_arg_conv.inner = (void*)(this_arg & (~1));
34568         this_arg_conv.is_owned = false;
34569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34570         LDKu8slice funding_redeemscript_ref;
34571         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
34572         funding_redeemscript_ref.data = funding_redeemscript->elems /* XXX funding_redeemscript leaks */;
34573         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
34574         memcpy(ret_arr->elems, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
34575         return ret_arr;
34576 }
34577
34578 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) {
34579         LDKBuiltCommitmentTransaction this_arg_conv;
34580         this_arg_conv.inner = (void*)(this_arg & (~1));
34581         this_arg_conv.is_owned = false;
34582         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34583         unsigned char funding_key_arr[32];
34584         CHECK(funding_key->arr_len == 32);
34585         memcpy(funding_key_arr, funding_key->elems, 32); FREE(funding_key);
34586         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
34587         LDKu8slice funding_redeemscript_ref;
34588         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
34589         funding_redeemscript_ref.data = funding_redeemscript->elems /* XXX funding_redeemscript leaks */;
34590         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
34591         memcpy(ret_arr->elems, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
34592         return ret_arr;
34593 }
34594
34595 void  __attribute__((export_name("TS_ClosingTransaction_free"))) TS_ClosingTransaction_free(uint32_t this_obj) {
34596         LDKClosingTransaction this_obj_conv;
34597         this_obj_conv.inner = (void*)(this_obj & (~1));
34598         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34600         ClosingTransaction_free(this_obj_conv);
34601 }
34602
34603 static inline uintptr_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
34604         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
34605 uint32_t ret_ref = 0;
34606 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34607 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34608 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34609 ret_ref = (uintptr_t)ret_var.inner;
34610 if (ret_var.is_owned) {
34611         ret_ref |= 1;
34612 }
34613         return ret_ref;
34614 }
34615 uint32_t  __attribute__((export_name("TS_ClosingTransaction_clone_ptr"))) TS_ClosingTransaction_clone_ptr(uint32_t arg) {
34616         LDKClosingTransaction arg_conv;
34617         arg_conv.inner = (void*)(arg & (~1));
34618         arg_conv.is_owned = false;
34619         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34620         uint32_t ret_conv = ClosingTransaction_clone_ptr(&arg_conv);
34621         return ret_conv;
34622 }
34623
34624 uint32_t  __attribute__((export_name("TS_ClosingTransaction_clone"))) TS_ClosingTransaction_clone(uint32_t orig) {
34625         LDKClosingTransaction orig_conv;
34626         orig_conv.inner = (void*)(orig & (~1));
34627         orig_conv.is_owned = false;
34628         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34629         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
34630         uint32_t ret_ref = 0;
34631         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34632         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34633         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34634         ret_ref = (uintptr_t)ret_var.inner;
34635         if (ret_var.is_owned) {
34636                 ret_ref |= 1;
34637         }
34638         return ret_ref;
34639 }
34640
34641 int64_t  __attribute__((export_name("TS_ClosingTransaction_hash"))) TS_ClosingTransaction_hash(uint32_t o) {
34642         LDKClosingTransaction o_conv;
34643         o_conv.inner = (void*)(o & (~1));
34644         o_conv.is_owned = false;
34645         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
34646         int64_t ret_conv = ClosingTransaction_hash(&o_conv);
34647         return ret_conv;
34648 }
34649
34650 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) {
34651         LDKCVec_u8Z to_holder_script_ref;
34652         to_holder_script_ref.datalen = to_holder_script->arr_len;
34653         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
34654         memcpy(to_holder_script_ref.data, to_holder_script->elems, to_holder_script_ref.datalen); FREE(to_holder_script);
34655         LDKCVec_u8Z to_counterparty_script_ref;
34656         to_counterparty_script_ref.datalen = to_counterparty_script->arr_len;
34657         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
34658         memcpy(to_counterparty_script_ref.data, to_counterparty_script->elems, to_counterparty_script_ref.datalen); FREE(to_counterparty_script);
34659         LDKOutPoint funding_outpoint_conv;
34660         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
34661         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
34662         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
34663         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
34664         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
34665         uint32_t ret_ref = 0;
34666         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34667         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34668         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34669         ret_ref = (uintptr_t)ret_var.inner;
34670         if (ret_var.is_owned) {
34671                 ret_ref |= 1;
34672         }
34673         return ret_ref;
34674 }
34675
34676 uint32_t  __attribute__((export_name("TS_ClosingTransaction_trust"))) TS_ClosingTransaction_trust(uint32_t this_arg) {
34677         LDKClosingTransaction this_arg_conv;
34678         this_arg_conv.inner = (void*)(this_arg & (~1));
34679         this_arg_conv.is_owned = false;
34680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34681         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
34682         uint32_t ret_ref = 0;
34683         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34684         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34685         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34686         ret_ref = (uintptr_t)ret_var.inner;
34687         if (ret_var.is_owned) {
34688                 ret_ref |= 1;
34689         }
34690         return ret_ref;
34691 }
34692
34693 uint32_t  __attribute__((export_name("TS_ClosingTransaction_verify"))) TS_ClosingTransaction_verify(uint32_t this_arg, uint32_t funding_outpoint) {
34694         LDKClosingTransaction this_arg_conv;
34695         this_arg_conv.inner = (void*)(this_arg & (~1));
34696         this_arg_conv.is_owned = false;
34697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34698         LDKOutPoint funding_outpoint_conv;
34699         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
34700         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
34701         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
34702         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
34703         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
34704         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
34705         return (uint32_t)ret_conv;
34706 }
34707
34708 int64_t  __attribute__((export_name("TS_ClosingTransaction_to_holder_value_sat"))) TS_ClosingTransaction_to_holder_value_sat(uint32_t this_arg) {
34709         LDKClosingTransaction this_arg_conv;
34710         this_arg_conv.inner = (void*)(this_arg & (~1));
34711         this_arg_conv.is_owned = false;
34712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34713         int64_t ret_conv = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
34714         return ret_conv;
34715 }
34716
34717 int64_t  __attribute__((export_name("TS_ClosingTransaction_to_counterparty_value_sat"))) TS_ClosingTransaction_to_counterparty_value_sat(uint32_t this_arg) {
34718         LDKClosingTransaction this_arg_conv;
34719         this_arg_conv.inner = (void*)(this_arg & (~1));
34720         this_arg_conv.is_owned = false;
34721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34722         int64_t ret_conv = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
34723         return ret_conv;
34724 }
34725
34726 int8_tArray  __attribute__((export_name("TS_ClosingTransaction_to_holder_script"))) TS_ClosingTransaction_to_holder_script(uint32_t this_arg) {
34727         LDKClosingTransaction this_arg_conv;
34728         this_arg_conv.inner = (void*)(this_arg & (~1));
34729         this_arg_conv.is_owned = false;
34730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34731         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
34732         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34733         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34734         return ret_arr;
34735 }
34736
34737 int8_tArray  __attribute__((export_name("TS_ClosingTransaction_to_counterparty_script"))) TS_ClosingTransaction_to_counterparty_script(uint32_t this_arg) {
34738         LDKClosingTransaction this_arg_conv;
34739         this_arg_conv.inner = (void*)(this_arg & (~1));
34740         this_arg_conv.is_owned = false;
34741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34742         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
34743         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34744         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34745         return ret_arr;
34746 }
34747
34748 void  __attribute__((export_name("TS_TrustedClosingTransaction_free"))) TS_TrustedClosingTransaction_free(uint32_t this_obj) {
34749         LDKTrustedClosingTransaction this_obj_conv;
34750         this_obj_conv.inner = (void*)(this_obj & (~1));
34751         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34753         TrustedClosingTransaction_free(this_obj_conv);
34754 }
34755
34756 int8_tArray  __attribute__((export_name("TS_TrustedClosingTransaction_built_transaction"))) TS_TrustedClosingTransaction_built_transaction(uint32_t this_arg) {
34757         LDKTrustedClosingTransaction this_arg_conv;
34758         this_arg_conv.inner = (void*)(this_arg & (~1));
34759         this_arg_conv.is_owned = false;
34760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34761         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
34762         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34763         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34764         Transaction_free(ret_var);
34765         return ret_arr;
34766 }
34767
34768 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) {
34769         LDKTrustedClosingTransaction this_arg_conv;
34770         this_arg_conv.inner = (void*)(this_arg & (~1));
34771         this_arg_conv.is_owned = false;
34772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34773         LDKu8slice funding_redeemscript_ref;
34774         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
34775         funding_redeemscript_ref.data = funding_redeemscript->elems /* XXX funding_redeemscript leaks */;
34776         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
34777         memcpy(ret_arr->elems, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
34778         return ret_arr;
34779 }
34780
34781 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) {
34782         LDKTrustedClosingTransaction this_arg_conv;
34783         this_arg_conv.inner = (void*)(this_arg & (~1));
34784         this_arg_conv.is_owned = false;
34785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34786         unsigned char funding_key_arr[32];
34787         CHECK(funding_key->arr_len == 32);
34788         memcpy(funding_key_arr, funding_key->elems, 32); FREE(funding_key);
34789         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
34790         LDKu8slice funding_redeemscript_ref;
34791         funding_redeemscript_ref.datalen = funding_redeemscript->arr_len;
34792         funding_redeemscript_ref.data = funding_redeemscript->elems /* XXX funding_redeemscript leaks */;
34793         int8_tArray ret_arr = init_int8_tArray(64, __LINE__);
34794         memcpy(ret_arr->elems, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
34795         return ret_arr;
34796 }
34797
34798 void  __attribute__((export_name("TS_CommitmentTransaction_free"))) TS_CommitmentTransaction_free(uint32_t this_obj) {
34799         LDKCommitmentTransaction this_obj_conv;
34800         this_obj_conv.inner = (void*)(this_obj & (~1));
34801         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34803         CommitmentTransaction_free(this_obj_conv);
34804 }
34805
34806 static inline uintptr_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
34807         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
34808 uint32_t ret_ref = 0;
34809 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34810 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34811 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34812 ret_ref = (uintptr_t)ret_var.inner;
34813 if (ret_var.is_owned) {
34814         ret_ref |= 1;
34815 }
34816         return ret_ref;
34817 }
34818 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_clone_ptr"))) TS_CommitmentTransaction_clone_ptr(uint32_t arg) {
34819         LDKCommitmentTransaction arg_conv;
34820         arg_conv.inner = (void*)(arg & (~1));
34821         arg_conv.is_owned = false;
34822         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34823         uint32_t ret_conv = CommitmentTransaction_clone_ptr(&arg_conv);
34824         return ret_conv;
34825 }
34826
34827 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_clone"))) TS_CommitmentTransaction_clone(uint32_t orig) {
34828         LDKCommitmentTransaction orig_conv;
34829         orig_conv.inner = (void*)(orig & (~1));
34830         orig_conv.is_owned = false;
34831         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34832         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
34833         uint32_t ret_ref = 0;
34834         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34835         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34836         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34837         ret_ref = (uintptr_t)ret_var.inner;
34838         if (ret_var.is_owned) {
34839                 ret_ref |= 1;
34840         }
34841         return ret_ref;
34842 }
34843
34844 int8_tArray  __attribute__((export_name("TS_CommitmentTransaction_write"))) TS_CommitmentTransaction_write(uint32_t obj) {
34845         LDKCommitmentTransaction obj_conv;
34846         obj_conv.inner = (void*)(obj & (~1));
34847         obj_conv.is_owned = false;
34848         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34849         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
34850         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
34851         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
34852         CVec_u8Z_free(ret_var);
34853         return ret_arr;
34854 }
34855
34856 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_read"))) TS_CommitmentTransaction_read(int8_tArray ser) {
34857         LDKu8slice ser_ref;
34858         ser_ref.datalen = ser->arr_len;
34859         ser_ref.data = ser->elems /* XXX ser leaks */;
34860         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
34861         *ret_conv = CommitmentTransaction_read(ser_ref);
34862         return (uint32_t)ret_conv;
34863 }
34864
34865 int64_t  __attribute__((export_name("TS_CommitmentTransaction_commitment_number"))) TS_CommitmentTransaction_commitment_number(uint32_t this_arg) {
34866         LDKCommitmentTransaction this_arg_conv;
34867         this_arg_conv.inner = (void*)(this_arg & (~1));
34868         this_arg_conv.is_owned = false;
34869         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34870         int64_t ret_conv = CommitmentTransaction_commitment_number(&this_arg_conv);
34871         return ret_conv;
34872 }
34873
34874 int64_t  __attribute__((export_name("TS_CommitmentTransaction_to_broadcaster_value_sat"))) TS_CommitmentTransaction_to_broadcaster_value_sat(uint32_t this_arg) {
34875         LDKCommitmentTransaction this_arg_conv;
34876         this_arg_conv.inner = (void*)(this_arg & (~1));
34877         this_arg_conv.is_owned = false;
34878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34879         int64_t ret_conv = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
34880         return ret_conv;
34881 }
34882
34883 int64_t  __attribute__((export_name("TS_CommitmentTransaction_to_countersignatory_value_sat"))) TS_CommitmentTransaction_to_countersignatory_value_sat(uint32_t this_arg) {
34884         LDKCommitmentTransaction this_arg_conv;
34885         this_arg_conv.inner = (void*)(this_arg & (~1));
34886         this_arg_conv.is_owned = false;
34887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34888         int64_t ret_conv = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
34889         return ret_conv;
34890 }
34891
34892 int32_t  __attribute__((export_name("TS_CommitmentTransaction_feerate_per_kw"))) TS_CommitmentTransaction_feerate_per_kw(uint32_t this_arg) {
34893         LDKCommitmentTransaction this_arg_conv;
34894         this_arg_conv.inner = (void*)(this_arg & (~1));
34895         this_arg_conv.is_owned = false;
34896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34897         int32_t ret_conv = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
34898         return ret_conv;
34899 }
34900
34901 uint32_t  __attribute__((export_name("TS_CommitmentTransaction_trust"))) TS_CommitmentTransaction_trust(uint32_t this_arg) {
34902         LDKCommitmentTransaction this_arg_conv;
34903         this_arg_conv.inner = (void*)(this_arg & (~1));
34904         this_arg_conv.is_owned = false;
34905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34906         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
34907         uint32_t ret_ref = 0;
34908         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34909         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34910         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34911         ret_ref = (uintptr_t)ret_var.inner;
34912         if (ret_var.is_owned) {
34913                 ret_ref |= 1;
34914         }
34915         return ret_ref;
34916 }
34917
34918 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) {
34919         LDKCommitmentTransaction this_arg_conv;
34920         this_arg_conv.inner = (void*)(this_arg & (~1));
34921         this_arg_conv.is_owned = false;
34922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34923         LDKDirectedChannelTransactionParameters channel_parameters_conv;
34924         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
34925         channel_parameters_conv.is_owned = false;
34926         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
34927         LDKChannelPublicKeys broadcaster_keys_conv;
34928         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
34929         broadcaster_keys_conv.is_owned = false;
34930         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
34931         LDKChannelPublicKeys countersignatory_keys_conv;
34932         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
34933         countersignatory_keys_conv.is_owned = false;
34934         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
34935         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
34936         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
34937         return (uint32_t)ret_conv;
34938 }
34939
34940 void  __attribute__((export_name("TS_TrustedCommitmentTransaction_free"))) TS_TrustedCommitmentTransaction_free(uint32_t this_obj) {
34941         LDKTrustedCommitmentTransaction this_obj_conv;
34942         this_obj_conv.inner = (void*)(this_obj & (~1));
34943         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34944         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34945         TrustedCommitmentTransaction_free(this_obj_conv);
34946 }
34947
34948 int8_tArray  __attribute__((export_name("TS_TrustedCommitmentTransaction_txid"))) TS_TrustedCommitmentTransaction_txid(uint32_t this_arg) {
34949         LDKTrustedCommitmentTransaction this_arg_conv;
34950         this_arg_conv.inner = (void*)(this_arg & (~1));
34951         this_arg_conv.is_owned = false;
34952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34953         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
34954         memcpy(ret_arr->elems, TrustedCommitmentTransaction_txid(&this_arg_conv).data, 32);
34955         return ret_arr;
34956 }
34957
34958 uint32_t  __attribute__((export_name("TS_TrustedCommitmentTransaction_built_transaction"))) TS_TrustedCommitmentTransaction_built_transaction(uint32_t this_arg) {
34959         LDKTrustedCommitmentTransaction this_arg_conv;
34960         this_arg_conv.inner = (void*)(this_arg & (~1));
34961         this_arg_conv.is_owned = false;
34962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34963         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
34964         uint32_t ret_ref = 0;
34965         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34966         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34967         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34968         ret_ref = (uintptr_t)ret_var.inner;
34969         if (ret_var.is_owned) {
34970                 ret_ref |= 1;
34971         }
34972         return ret_ref;
34973 }
34974
34975 uint32_t  __attribute__((export_name("TS_TrustedCommitmentTransaction_keys"))) TS_TrustedCommitmentTransaction_keys(uint32_t this_arg) {
34976         LDKTrustedCommitmentTransaction this_arg_conv;
34977         this_arg_conv.inner = (void*)(this_arg & (~1));
34978         this_arg_conv.is_owned = false;
34979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34980         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
34981         uint32_t ret_ref = 0;
34982         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34983         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34984         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34985         ret_ref = (uintptr_t)ret_var.inner;
34986         if (ret_var.is_owned) {
34987                 ret_ref |= 1;
34988         }
34989         return ret_ref;
34990 }
34991
34992 jboolean  __attribute__((export_name("TS_TrustedCommitmentTransaction_opt_anchors"))) TS_TrustedCommitmentTransaction_opt_anchors(uint32_t this_arg) {
34993         LDKTrustedCommitmentTransaction this_arg_conv;
34994         this_arg_conv.inner = (void*)(this_arg & (~1));
34995         this_arg_conv.is_owned = false;
34996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34997         jboolean ret_conv = TrustedCommitmentTransaction_opt_anchors(&this_arg_conv);
34998         return ret_conv;
34999 }
35000
35001 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) {
35002         LDKTrustedCommitmentTransaction this_arg_conv;
35003         this_arg_conv.inner = (void*)(this_arg & (~1));
35004         this_arg_conv.is_owned = false;
35005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35006         unsigned char htlc_base_key_arr[32];
35007         CHECK(htlc_base_key->arr_len == 32);
35008         memcpy(htlc_base_key_arr, htlc_base_key->elems, 32); FREE(htlc_base_key);
35009         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
35010         LDKDirectedChannelTransactionParameters channel_parameters_conv;
35011         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
35012         channel_parameters_conv.is_owned = false;
35013         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
35014         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
35015         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
35016         return (uint32_t)ret_conv;
35017 }
35018
35019 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) {
35020         LDKPublicKey broadcaster_payment_basepoint_ref;
35021         CHECK(broadcaster_payment_basepoint->arr_len == 33);
35022         memcpy(broadcaster_payment_basepoint_ref.compressed_form, broadcaster_payment_basepoint->elems, 33); FREE(broadcaster_payment_basepoint);
35023         LDKPublicKey countersignatory_payment_basepoint_ref;
35024         CHECK(countersignatory_payment_basepoint->arr_len == 33);
35025         memcpy(countersignatory_payment_basepoint_ref.compressed_form, countersignatory_payment_basepoint->elems, 33); FREE(countersignatory_payment_basepoint);
35026         int64_t ret_conv = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
35027         return ret_conv;
35028 }
35029
35030 jboolean  __attribute__((export_name("TS_InitFeatures_eq"))) TS_InitFeatures_eq(uint32_t a, uint32_t b) {
35031         LDKInitFeatures a_conv;
35032         a_conv.inner = (void*)(a & (~1));
35033         a_conv.is_owned = false;
35034         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35035         LDKInitFeatures b_conv;
35036         b_conv.inner = (void*)(b & (~1));
35037         b_conv.is_owned = false;
35038         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35039         jboolean ret_conv = InitFeatures_eq(&a_conv, &b_conv);
35040         return ret_conv;
35041 }
35042
35043 jboolean  __attribute__((export_name("TS_NodeFeatures_eq"))) TS_NodeFeatures_eq(uint32_t a, uint32_t b) {
35044         LDKNodeFeatures a_conv;
35045         a_conv.inner = (void*)(a & (~1));
35046         a_conv.is_owned = false;
35047         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35048         LDKNodeFeatures b_conv;
35049         b_conv.inner = (void*)(b & (~1));
35050         b_conv.is_owned = false;
35051         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35052         jboolean ret_conv = NodeFeatures_eq(&a_conv, &b_conv);
35053         return ret_conv;
35054 }
35055
35056 jboolean  __attribute__((export_name("TS_ChannelFeatures_eq"))) TS_ChannelFeatures_eq(uint32_t a, uint32_t b) {
35057         LDKChannelFeatures a_conv;
35058         a_conv.inner = (void*)(a & (~1));
35059         a_conv.is_owned = false;
35060         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35061         LDKChannelFeatures b_conv;
35062         b_conv.inner = (void*)(b & (~1));
35063         b_conv.is_owned = false;
35064         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35065         jboolean ret_conv = ChannelFeatures_eq(&a_conv, &b_conv);
35066         return ret_conv;
35067 }
35068
35069 jboolean  __attribute__((export_name("TS_InvoiceFeatures_eq"))) TS_InvoiceFeatures_eq(uint32_t a, uint32_t b) {
35070         LDKInvoiceFeatures a_conv;
35071         a_conv.inner = (void*)(a & (~1));
35072         a_conv.is_owned = false;
35073         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35074         LDKInvoiceFeatures b_conv;
35075         b_conv.inner = (void*)(b & (~1));
35076         b_conv.is_owned = false;
35077         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35078         jboolean ret_conv = InvoiceFeatures_eq(&a_conv, &b_conv);
35079         return ret_conv;
35080 }
35081
35082 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_eq"))) TS_ChannelTypeFeatures_eq(uint32_t a, uint32_t b) {
35083         LDKChannelTypeFeatures a_conv;
35084         a_conv.inner = (void*)(a & (~1));
35085         a_conv.is_owned = false;
35086         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35087         LDKChannelTypeFeatures b_conv;
35088         b_conv.inner = (void*)(b & (~1));
35089         b_conv.is_owned = false;
35090         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35091         jboolean ret_conv = ChannelTypeFeatures_eq(&a_conv, &b_conv);
35092         return ret_conv;
35093 }
35094
35095 static inline uintptr_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
35096         LDKInitFeatures ret_var = InitFeatures_clone(arg);
35097 uint32_t ret_ref = 0;
35098 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35099 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35100 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35101 ret_ref = (uintptr_t)ret_var.inner;
35102 if (ret_var.is_owned) {
35103         ret_ref |= 1;
35104 }
35105         return ret_ref;
35106 }
35107 uint32_t  __attribute__((export_name("TS_InitFeatures_clone_ptr"))) TS_InitFeatures_clone_ptr(uint32_t arg) {
35108         LDKInitFeatures arg_conv;
35109         arg_conv.inner = (void*)(arg & (~1));
35110         arg_conv.is_owned = false;
35111         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35112         uint32_t ret_conv = InitFeatures_clone_ptr(&arg_conv);
35113         return ret_conv;
35114 }
35115
35116 uint32_t  __attribute__((export_name("TS_InitFeatures_clone"))) TS_InitFeatures_clone(uint32_t orig) {
35117         LDKInitFeatures orig_conv;
35118         orig_conv.inner = (void*)(orig & (~1));
35119         orig_conv.is_owned = false;
35120         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35121         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
35122         uint32_t ret_ref = 0;
35123         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35124         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35125         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35126         ret_ref = (uintptr_t)ret_var.inner;
35127         if (ret_var.is_owned) {
35128                 ret_ref |= 1;
35129         }
35130         return ret_ref;
35131 }
35132
35133 static inline uintptr_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
35134         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
35135 uint32_t ret_ref = 0;
35136 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35137 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35138 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35139 ret_ref = (uintptr_t)ret_var.inner;
35140 if (ret_var.is_owned) {
35141         ret_ref |= 1;
35142 }
35143         return ret_ref;
35144 }
35145 uint32_t  __attribute__((export_name("TS_NodeFeatures_clone_ptr"))) TS_NodeFeatures_clone_ptr(uint32_t arg) {
35146         LDKNodeFeatures arg_conv;
35147         arg_conv.inner = (void*)(arg & (~1));
35148         arg_conv.is_owned = false;
35149         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35150         uint32_t ret_conv = NodeFeatures_clone_ptr(&arg_conv);
35151         return ret_conv;
35152 }
35153
35154 uint32_t  __attribute__((export_name("TS_NodeFeatures_clone"))) TS_NodeFeatures_clone(uint32_t orig) {
35155         LDKNodeFeatures orig_conv;
35156         orig_conv.inner = (void*)(orig & (~1));
35157         orig_conv.is_owned = false;
35158         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35159         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
35160         uint32_t ret_ref = 0;
35161         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35162         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35163         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35164         ret_ref = (uintptr_t)ret_var.inner;
35165         if (ret_var.is_owned) {
35166                 ret_ref |= 1;
35167         }
35168         return ret_ref;
35169 }
35170
35171 static inline uintptr_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
35172         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
35173 uint32_t ret_ref = 0;
35174 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35175 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35176 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35177 ret_ref = (uintptr_t)ret_var.inner;
35178 if (ret_var.is_owned) {
35179         ret_ref |= 1;
35180 }
35181         return ret_ref;
35182 }
35183 uint32_t  __attribute__((export_name("TS_ChannelFeatures_clone_ptr"))) TS_ChannelFeatures_clone_ptr(uint32_t arg) {
35184         LDKChannelFeatures arg_conv;
35185         arg_conv.inner = (void*)(arg & (~1));
35186         arg_conv.is_owned = false;
35187         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35188         uint32_t ret_conv = ChannelFeatures_clone_ptr(&arg_conv);
35189         return ret_conv;
35190 }
35191
35192 uint32_t  __attribute__((export_name("TS_ChannelFeatures_clone"))) TS_ChannelFeatures_clone(uint32_t orig) {
35193         LDKChannelFeatures orig_conv;
35194         orig_conv.inner = (void*)(orig & (~1));
35195         orig_conv.is_owned = false;
35196         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35197         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
35198         uint32_t ret_ref = 0;
35199         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35200         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35201         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35202         ret_ref = (uintptr_t)ret_var.inner;
35203         if (ret_var.is_owned) {
35204                 ret_ref |= 1;
35205         }
35206         return ret_ref;
35207 }
35208
35209 static inline uintptr_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
35210         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
35211 uint32_t ret_ref = 0;
35212 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35213 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35214 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35215 ret_ref = (uintptr_t)ret_var.inner;
35216 if (ret_var.is_owned) {
35217         ret_ref |= 1;
35218 }
35219         return ret_ref;
35220 }
35221 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_clone_ptr"))) TS_InvoiceFeatures_clone_ptr(uint32_t arg) {
35222         LDKInvoiceFeatures arg_conv;
35223         arg_conv.inner = (void*)(arg & (~1));
35224         arg_conv.is_owned = false;
35225         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35226         uint32_t ret_conv = InvoiceFeatures_clone_ptr(&arg_conv);
35227         return ret_conv;
35228 }
35229
35230 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_clone"))) TS_InvoiceFeatures_clone(uint32_t orig) {
35231         LDKInvoiceFeatures orig_conv;
35232         orig_conv.inner = (void*)(orig & (~1));
35233         orig_conv.is_owned = false;
35234         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35235         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
35236         uint32_t ret_ref = 0;
35237         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35238         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35239         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35240         ret_ref = (uintptr_t)ret_var.inner;
35241         if (ret_var.is_owned) {
35242                 ret_ref |= 1;
35243         }
35244         return ret_ref;
35245 }
35246
35247 static inline uintptr_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
35248         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
35249 uint32_t ret_ref = 0;
35250 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35251 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35252 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35253 ret_ref = (uintptr_t)ret_var.inner;
35254 if (ret_var.is_owned) {
35255         ret_ref |= 1;
35256 }
35257         return ret_ref;
35258 }
35259 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_clone_ptr"))) TS_ChannelTypeFeatures_clone_ptr(uint32_t arg) {
35260         LDKChannelTypeFeatures arg_conv;
35261         arg_conv.inner = (void*)(arg & (~1));
35262         arg_conv.is_owned = false;
35263         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35264         uint32_t ret_conv = ChannelTypeFeatures_clone_ptr(&arg_conv);
35265         return ret_conv;
35266 }
35267
35268 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_clone"))) TS_ChannelTypeFeatures_clone(uint32_t orig) {
35269         LDKChannelTypeFeatures orig_conv;
35270         orig_conv.inner = (void*)(orig & (~1));
35271         orig_conv.is_owned = false;
35272         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35273         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_conv);
35274         uint32_t ret_ref = 0;
35275         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35276         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35277         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35278         ret_ref = (uintptr_t)ret_var.inner;
35279         if (ret_var.is_owned) {
35280                 ret_ref |= 1;
35281         }
35282         return ret_ref;
35283 }
35284
35285 void  __attribute__((export_name("TS_InitFeatures_free"))) TS_InitFeatures_free(uint32_t this_obj) {
35286         LDKInitFeatures this_obj_conv;
35287         this_obj_conv.inner = (void*)(this_obj & (~1));
35288         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35290         InitFeatures_free(this_obj_conv);
35291 }
35292
35293 void  __attribute__((export_name("TS_NodeFeatures_free"))) TS_NodeFeatures_free(uint32_t this_obj) {
35294         LDKNodeFeatures this_obj_conv;
35295         this_obj_conv.inner = (void*)(this_obj & (~1));
35296         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35297         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35298         NodeFeatures_free(this_obj_conv);
35299 }
35300
35301 void  __attribute__((export_name("TS_ChannelFeatures_free"))) TS_ChannelFeatures_free(uint32_t this_obj) {
35302         LDKChannelFeatures this_obj_conv;
35303         this_obj_conv.inner = (void*)(this_obj & (~1));
35304         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35306         ChannelFeatures_free(this_obj_conv);
35307 }
35308
35309 void  __attribute__((export_name("TS_InvoiceFeatures_free"))) TS_InvoiceFeatures_free(uint32_t this_obj) {
35310         LDKInvoiceFeatures this_obj_conv;
35311         this_obj_conv.inner = (void*)(this_obj & (~1));
35312         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35314         InvoiceFeatures_free(this_obj_conv);
35315 }
35316
35317 void  __attribute__((export_name("TS_ChannelTypeFeatures_free"))) TS_ChannelTypeFeatures_free(uint32_t this_obj) {
35318         LDKChannelTypeFeatures this_obj_conv;
35319         this_obj_conv.inner = (void*)(this_obj & (~1));
35320         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35322         ChannelTypeFeatures_free(this_obj_conv);
35323 }
35324
35325 uint32_t  __attribute__((export_name("TS_InitFeatures_empty"))) TS_InitFeatures_empty() {
35326         LDKInitFeatures ret_var = InitFeatures_empty();
35327         uint32_t ret_ref = 0;
35328         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35329         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35330         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35331         ret_ref = (uintptr_t)ret_var.inner;
35332         if (ret_var.is_owned) {
35333                 ret_ref |= 1;
35334         }
35335         return ret_ref;
35336 }
35337
35338 uint32_t  __attribute__((export_name("TS_InitFeatures_known"))) TS_InitFeatures_known() {
35339         LDKInitFeatures ret_var = InitFeatures_known();
35340         uint32_t ret_ref = 0;
35341         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35342         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35343         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35344         ret_ref = (uintptr_t)ret_var.inner;
35345         if (ret_var.is_owned) {
35346                 ret_ref |= 1;
35347         }
35348         return ret_ref;
35349 }
35350
35351 jboolean  __attribute__((export_name("TS_InitFeatures_requires_unknown_bits"))) TS_InitFeatures_requires_unknown_bits(uint32_t this_arg) {
35352         LDKInitFeatures this_arg_conv;
35353         this_arg_conv.inner = (void*)(this_arg & (~1));
35354         this_arg_conv.is_owned = false;
35355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35356         jboolean ret_conv = InitFeatures_requires_unknown_bits(&this_arg_conv);
35357         return ret_conv;
35358 }
35359
35360 uint32_t  __attribute__((export_name("TS_NodeFeatures_empty"))) TS_NodeFeatures_empty() {
35361         LDKNodeFeatures ret_var = NodeFeatures_empty();
35362         uint32_t ret_ref = 0;
35363         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35364         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35365         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35366         ret_ref = (uintptr_t)ret_var.inner;
35367         if (ret_var.is_owned) {
35368                 ret_ref |= 1;
35369         }
35370         return ret_ref;
35371 }
35372
35373 uint32_t  __attribute__((export_name("TS_NodeFeatures_known"))) TS_NodeFeatures_known() {
35374         LDKNodeFeatures ret_var = NodeFeatures_known();
35375         uint32_t ret_ref = 0;
35376         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35377         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35378         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35379         ret_ref = (uintptr_t)ret_var.inner;
35380         if (ret_var.is_owned) {
35381                 ret_ref |= 1;
35382         }
35383         return ret_ref;
35384 }
35385
35386 jboolean  __attribute__((export_name("TS_NodeFeatures_requires_unknown_bits"))) TS_NodeFeatures_requires_unknown_bits(uint32_t this_arg) {
35387         LDKNodeFeatures this_arg_conv;
35388         this_arg_conv.inner = (void*)(this_arg & (~1));
35389         this_arg_conv.is_owned = false;
35390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35391         jboolean ret_conv = NodeFeatures_requires_unknown_bits(&this_arg_conv);
35392         return ret_conv;
35393 }
35394
35395 uint32_t  __attribute__((export_name("TS_ChannelFeatures_empty"))) TS_ChannelFeatures_empty() {
35396         LDKChannelFeatures ret_var = ChannelFeatures_empty();
35397         uint32_t ret_ref = 0;
35398         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35399         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35400         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35401         ret_ref = (uintptr_t)ret_var.inner;
35402         if (ret_var.is_owned) {
35403                 ret_ref |= 1;
35404         }
35405         return ret_ref;
35406 }
35407
35408 uint32_t  __attribute__((export_name("TS_ChannelFeatures_known"))) TS_ChannelFeatures_known() {
35409         LDKChannelFeatures ret_var = ChannelFeatures_known();
35410         uint32_t ret_ref = 0;
35411         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35412         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35413         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35414         ret_ref = (uintptr_t)ret_var.inner;
35415         if (ret_var.is_owned) {
35416                 ret_ref |= 1;
35417         }
35418         return ret_ref;
35419 }
35420
35421 jboolean  __attribute__((export_name("TS_ChannelFeatures_requires_unknown_bits"))) TS_ChannelFeatures_requires_unknown_bits(uint32_t this_arg) {
35422         LDKChannelFeatures this_arg_conv;
35423         this_arg_conv.inner = (void*)(this_arg & (~1));
35424         this_arg_conv.is_owned = false;
35425         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35426         jboolean ret_conv = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
35427         return ret_conv;
35428 }
35429
35430 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_empty"))) TS_InvoiceFeatures_empty() {
35431         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
35432         uint32_t ret_ref = 0;
35433         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35434         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35435         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35436         ret_ref = (uintptr_t)ret_var.inner;
35437         if (ret_var.is_owned) {
35438                 ret_ref |= 1;
35439         }
35440         return ret_ref;
35441 }
35442
35443 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_known"))) TS_InvoiceFeatures_known() {
35444         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
35445         uint32_t ret_ref = 0;
35446         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35447         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35448         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35449         ret_ref = (uintptr_t)ret_var.inner;
35450         if (ret_var.is_owned) {
35451                 ret_ref |= 1;
35452         }
35453         return ret_ref;
35454 }
35455
35456 jboolean  __attribute__((export_name("TS_InvoiceFeatures_requires_unknown_bits"))) TS_InvoiceFeatures_requires_unknown_bits(uint32_t this_arg) {
35457         LDKInvoiceFeatures this_arg_conv;
35458         this_arg_conv.inner = (void*)(this_arg & (~1));
35459         this_arg_conv.is_owned = false;
35460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35461         jboolean ret_conv = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
35462         return ret_conv;
35463 }
35464
35465 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_empty"))) TS_ChannelTypeFeatures_empty() {
35466         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
35467         uint32_t ret_ref = 0;
35468         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35469         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35470         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35471         ret_ref = (uintptr_t)ret_var.inner;
35472         if (ret_var.is_owned) {
35473                 ret_ref |= 1;
35474         }
35475         return ret_ref;
35476 }
35477
35478 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_known"))) TS_ChannelTypeFeatures_known() {
35479         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_known();
35480         uint32_t ret_ref = 0;
35481         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35482         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35483         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35484         ret_ref = (uintptr_t)ret_var.inner;
35485         if (ret_var.is_owned) {
35486                 ret_ref |= 1;
35487         }
35488         return ret_ref;
35489 }
35490
35491 jboolean  __attribute__((export_name("TS_ChannelTypeFeatures_requires_unknown_bits"))) TS_ChannelTypeFeatures_requires_unknown_bits(uint32_t this_arg) {
35492         LDKChannelTypeFeatures this_arg_conv;
35493         this_arg_conv.inner = (void*)(this_arg & (~1));
35494         this_arg_conv.is_owned = false;
35495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35496         jboolean ret_conv = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
35497         return ret_conv;
35498 }
35499
35500 int8_tArray  __attribute__((export_name("TS_InitFeatures_write"))) TS_InitFeatures_write(uint32_t obj) {
35501         LDKInitFeatures obj_conv;
35502         obj_conv.inner = (void*)(obj & (~1));
35503         obj_conv.is_owned = false;
35504         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35505         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
35506         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35507         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35508         CVec_u8Z_free(ret_var);
35509         return ret_arr;
35510 }
35511
35512 uint32_t  __attribute__((export_name("TS_InitFeatures_read"))) TS_InitFeatures_read(int8_tArray ser) {
35513         LDKu8slice ser_ref;
35514         ser_ref.datalen = ser->arr_len;
35515         ser_ref.data = ser->elems /* XXX ser leaks */;
35516         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
35517         *ret_conv = InitFeatures_read(ser_ref);
35518         return (uint32_t)ret_conv;
35519 }
35520
35521 int8_tArray  __attribute__((export_name("TS_ChannelFeatures_write"))) TS_ChannelFeatures_write(uint32_t obj) {
35522         LDKChannelFeatures obj_conv;
35523         obj_conv.inner = (void*)(obj & (~1));
35524         obj_conv.is_owned = false;
35525         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35526         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
35527         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35528         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35529         CVec_u8Z_free(ret_var);
35530         return ret_arr;
35531 }
35532
35533 uint32_t  __attribute__((export_name("TS_ChannelFeatures_read"))) TS_ChannelFeatures_read(int8_tArray ser) {
35534         LDKu8slice ser_ref;
35535         ser_ref.datalen = ser->arr_len;
35536         ser_ref.data = ser->elems /* XXX ser leaks */;
35537         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
35538         *ret_conv = ChannelFeatures_read(ser_ref);
35539         return (uint32_t)ret_conv;
35540 }
35541
35542 int8_tArray  __attribute__((export_name("TS_NodeFeatures_write"))) TS_NodeFeatures_write(uint32_t obj) {
35543         LDKNodeFeatures obj_conv;
35544         obj_conv.inner = (void*)(obj & (~1));
35545         obj_conv.is_owned = false;
35546         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35547         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
35548         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35549         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35550         CVec_u8Z_free(ret_var);
35551         return ret_arr;
35552 }
35553
35554 uint32_t  __attribute__((export_name("TS_NodeFeatures_read"))) TS_NodeFeatures_read(int8_tArray ser) {
35555         LDKu8slice ser_ref;
35556         ser_ref.datalen = ser->arr_len;
35557         ser_ref.data = ser->elems /* XXX ser leaks */;
35558         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
35559         *ret_conv = NodeFeatures_read(ser_ref);
35560         return (uint32_t)ret_conv;
35561 }
35562
35563 int8_tArray  __attribute__((export_name("TS_InvoiceFeatures_write"))) TS_InvoiceFeatures_write(uint32_t obj) {
35564         LDKInvoiceFeatures obj_conv;
35565         obj_conv.inner = (void*)(obj & (~1));
35566         obj_conv.is_owned = false;
35567         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35568         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
35569         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35570         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35571         CVec_u8Z_free(ret_var);
35572         return ret_arr;
35573 }
35574
35575 uint32_t  __attribute__((export_name("TS_InvoiceFeatures_read"))) TS_InvoiceFeatures_read(int8_tArray ser) {
35576         LDKu8slice ser_ref;
35577         ser_ref.datalen = ser->arr_len;
35578         ser_ref.data = ser->elems /* XXX ser leaks */;
35579         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
35580         *ret_conv = InvoiceFeatures_read(ser_ref);
35581         return (uint32_t)ret_conv;
35582 }
35583
35584 int8_tArray  __attribute__((export_name("TS_ChannelTypeFeatures_write"))) TS_ChannelTypeFeatures_write(uint32_t obj) {
35585         LDKChannelTypeFeatures obj_conv;
35586         obj_conv.inner = (void*)(obj & (~1));
35587         obj_conv.is_owned = false;
35588         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35589         LDKCVec_u8Z ret_var = ChannelTypeFeatures_write(&obj_conv);
35590         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35591         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35592         CVec_u8Z_free(ret_var);
35593         return ret_arr;
35594 }
35595
35596 uint32_t  __attribute__((export_name("TS_ChannelTypeFeatures_read"))) TS_ChannelTypeFeatures_read(int8_tArray ser) {
35597         LDKu8slice ser_ref;
35598         ser_ref.datalen = ser->arr_len;
35599         ser_ref.data = ser->elems /* XXX ser leaks */;
35600         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
35601         *ret_conv = ChannelTypeFeatures_read(ser_ref);
35602         return (uint32_t)ret_conv;
35603 }
35604
35605 void  __attribute__((export_name("TS_ShutdownScript_free"))) TS_ShutdownScript_free(uint32_t this_obj) {
35606         LDKShutdownScript this_obj_conv;
35607         this_obj_conv.inner = (void*)(this_obj & (~1));
35608         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35610         ShutdownScript_free(this_obj_conv);
35611 }
35612
35613 static inline uintptr_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
35614         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
35615 uint32_t ret_ref = 0;
35616 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35617 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35618 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35619 ret_ref = (uintptr_t)ret_var.inner;
35620 if (ret_var.is_owned) {
35621         ret_ref |= 1;
35622 }
35623         return ret_ref;
35624 }
35625 uint32_t  __attribute__((export_name("TS_ShutdownScript_clone_ptr"))) TS_ShutdownScript_clone_ptr(uint32_t arg) {
35626         LDKShutdownScript arg_conv;
35627         arg_conv.inner = (void*)(arg & (~1));
35628         arg_conv.is_owned = false;
35629         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35630         uint32_t ret_conv = ShutdownScript_clone_ptr(&arg_conv);
35631         return ret_conv;
35632 }
35633
35634 uint32_t  __attribute__((export_name("TS_ShutdownScript_clone"))) TS_ShutdownScript_clone(uint32_t orig) {
35635         LDKShutdownScript orig_conv;
35636         orig_conv.inner = (void*)(orig & (~1));
35637         orig_conv.is_owned = false;
35638         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35639         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
35640         uint32_t ret_ref = 0;
35641         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35642         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35643         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35644         ret_ref = (uintptr_t)ret_var.inner;
35645         if (ret_var.is_owned) {
35646                 ret_ref |= 1;
35647         }
35648         return ret_ref;
35649 }
35650
35651 void  __attribute__((export_name("TS_InvalidShutdownScript_free"))) TS_InvalidShutdownScript_free(uint32_t this_obj) {
35652         LDKInvalidShutdownScript this_obj_conv;
35653         this_obj_conv.inner = (void*)(this_obj & (~1));
35654         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35656         InvalidShutdownScript_free(this_obj_conv);
35657 }
35658
35659 int8_tArray  __attribute__((export_name("TS_InvalidShutdownScript_get_script"))) TS_InvalidShutdownScript_get_script(uint32_t this_ptr) {
35660         LDKInvalidShutdownScript this_ptr_conv;
35661         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35662         this_ptr_conv.is_owned = false;
35663         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35664         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
35665         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35666         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35667         return ret_arr;
35668 }
35669
35670 void  __attribute__((export_name("TS_InvalidShutdownScript_set_script"))) TS_InvalidShutdownScript_set_script(uint32_t this_ptr, int8_tArray val) {
35671         LDKInvalidShutdownScript this_ptr_conv;
35672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35673         this_ptr_conv.is_owned = false;
35674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35675         LDKCVec_u8Z val_ref;
35676         val_ref.datalen = val->arr_len;
35677         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
35678         memcpy(val_ref.data, val->elems, val_ref.datalen); FREE(val);
35679         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
35680 }
35681
35682 uint32_t  __attribute__((export_name("TS_InvalidShutdownScript_new"))) TS_InvalidShutdownScript_new(int8_tArray script_arg) {
35683         LDKCVec_u8Z script_arg_ref;
35684         script_arg_ref.datalen = script_arg->arr_len;
35685         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
35686         memcpy(script_arg_ref.data, script_arg->elems, script_arg_ref.datalen); FREE(script_arg);
35687         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
35688         uint32_t ret_ref = 0;
35689         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35690         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35691         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35692         ret_ref = (uintptr_t)ret_var.inner;
35693         if (ret_var.is_owned) {
35694                 ret_ref |= 1;
35695         }
35696         return ret_ref;
35697 }
35698
35699 static inline uintptr_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
35700         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
35701 uint32_t ret_ref = 0;
35702 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35703 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35704 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35705 ret_ref = (uintptr_t)ret_var.inner;
35706 if (ret_var.is_owned) {
35707         ret_ref |= 1;
35708 }
35709         return ret_ref;
35710 }
35711 uint32_t  __attribute__((export_name("TS_InvalidShutdownScript_clone_ptr"))) TS_InvalidShutdownScript_clone_ptr(uint32_t arg) {
35712         LDKInvalidShutdownScript arg_conv;
35713         arg_conv.inner = (void*)(arg & (~1));
35714         arg_conv.is_owned = false;
35715         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35716         uint32_t ret_conv = InvalidShutdownScript_clone_ptr(&arg_conv);
35717         return ret_conv;
35718 }
35719
35720 uint32_t  __attribute__((export_name("TS_InvalidShutdownScript_clone"))) TS_InvalidShutdownScript_clone(uint32_t orig) {
35721         LDKInvalidShutdownScript orig_conv;
35722         orig_conv.inner = (void*)(orig & (~1));
35723         orig_conv.is_owned = false;
35724         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35725         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
35726         uint32_t ret_ref = 0;
35727         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35728         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35729         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35730         ret_ref = (uintptr_t)ret_var.inner;
35731         if (ret_var.is_owned) {
35732                 ret_ref |= 1;
35733         }
35734         return ret_ref;
35735 }
35736
35737 int8_tArray  __attribute__((export_name("TS_ShutdownScript_write"))) TS_ShutdownScript_write(uint32_t obj) {
35738         LDKShutdownScript obj_conv;
35739         obj_conv.inner = (void*)(obj & (~1));
35740         obj_conv.is_owned = false;
35741         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35742         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
35743         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35744         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35745         CVec_u8Z_free(ret_var);
35746         return ret_arr;
35747 }
35748
35749 uint32_t  __attribute__((export_name("TS_ShutdownScript_read"))) TS_ShutdownScript_read(int8_tArray ser) {
35750         LDKu8slice ser_ref;
35751         ser_ref.datalen = ser->arr_len;
35752         ser_ref.data = ser->elems /* XXX ser leaks */;
35753         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
35754         *ret_conv = ShutdownScript_read(ser_ref);
35755         return (uint32_t)ret_conv;
35756 }
35757
35758 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_p2wpkh"))) TS_ShutdownScript_new_p2wpkh(int8_tArray pubkey_hash) {
35759         unsigned char pubkey_hash_arr[20];
35760         CHECK(pubkey_hash->arr_len == 20);
35761         memcpy(pubkey_hash_arr, pubkey_hash->elems, 20); FREE(pubkey_hash);
35762         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
35763         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
35764         uint32_t ret_ref = 0;
35765         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35766         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35767         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35768         ret_ref = (uintptr_t)ret_var.inner;
35769         if (ret_var.is_owned) {
35770                 ret_ref |= 1;
35771         }
35772         return ret_ref;
35773 }
35774
35775 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_p2wsh"))) TS_ShutdownScript_new_p2wsh(int8_tArray script_hash) {
35776         unsigned char script_hash_arr[32];
35777         CHECK(script_hash->arr_len == 32);
35778         memcpy(script_hash_arr, script_hash->elems, 32); FREE(script_hash);
35779         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
35780         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
35781         uint32_t ret_ref = 0;
35782         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35783         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35784         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35785         ret_ref = (uintptr_t)ret_var.inner;
35786         if (ret_var.is_owned) {
35787                 ret_ref |= 1;
35788         }
35789         return ret_ref;
35790 }
35791
35792 uint32_t  __attribute__((export_name("TS_ShutdownScript_new_witness_program"))) TS_ShutdownScript_new_witness_program(int8_t version, int8_tArray program) {
35793         LDKu8slice program_ref;
35794         program_ref.datalen = program->arr_len;
35795         program_ref.data = program->elems /* XXX program leaks */;
35796         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
35797         *ret_conv = ShutdownScript_new_witness_program(version, program_ref);
35798         return (uint32_t)ret_conv;
35799 }
35800
35801 int8_tArray  __attribute__((export_name("TS_ShutdownScript_into_inner"))) TS_ShutdownScript_into_inner(uint32_t this_arg) {
35802         LDKShutdownScript this_arg_conv;
35803         this_arg_conv.inner = (void*)(this_arg & (~1));
35804         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
35805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35806         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
35807         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
35808         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35809         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35810         CVec_u8Z_free(ret_var);
35811         return ret_arr;
35812 }
35813
35814 int8_tArray  __attribute__((export_name("TS_ShutdownScript_as_legacy_pubkey"))) TS_ShutdownScript_as_legacy_pubkey(uint32_t this_arg) {
35815         LDKShutdownScript this_arg_conv;
35816         this_arg_conv.inner = (void*)(this_arg & (~1));
35817         this_arg_conv.is_owned = false;
35818         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35819         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
35820         memcpy(ret_arr->elems, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form, 33);
35821         return ret_arr;
35822 }
35823
35824 jboolean  __attribute__((export_name("TS_ShutdownScript_is_compatible"))) TS_ShutdownScript_is_compatible(uint32_t this_arg, uint32_t features) {
35825         LDKShutdownScript this_arg_conv;
35826         this_arg_conv.inner = (void*)(this_arg & (~1));
35827         this_arg_conv.is_owned = false;
35828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35829         LDKInitFeatures features_conv;
35830         features_conv.inner = (void*)(features & (~1));
35831         features_conv.is_owned = false;
35832         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
35833         jboolean ret_conv = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
35834         return ret_conv;
35835 }
35836
35837 void  __attribute__((export_name("TS_CustomMessageReader_free"))) TS_CustomMessageReader_free(uint32_t this_ptr) {
35838         if ((this_ptr & 1) != 0) return;
35839         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
35840         CHECK_ACCESS(this_ptr_ptr);
35841         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
35842         FREE((void*)this_ptr);
35843         CustomMessageReader_free(this_ptr_conv);
35844 }
35845
35846 static inline uintptr_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
35847         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
35848         *ret_ret = Type_clone(arg);
35849         return (uint32_t)ret_ret;
35850 }
35851 uint32_t  __attribute__((export_name("TS_Type_clone_ptr"))) TS_Type_clone_ptr(uint32_t arg) {
35852         void* arg_ptr = (void*)(((uintptr_t)arg) & ~1);
35853         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
35854         LDKType* arg_conv = (LDKType*)arg_ptr;
35855         uint32_t ret_conv = Type_clone_ptr(arg_conv);
35856         return ret_conv;
35857 }
35858
35859 uint32_t  __attribute__((export_name("TS_Type_clone"))) TS_Type_clone(uint32_t orig) {
35860         void* orig_ptr = (void*)(((uintptr_t)orig) & ~1);
35861         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
35862         LDKType* orig_conv = (LDKType*)orig_ptr;
35863         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
35864         *ret_ret = Type_clone(orig_conv);
35865         return (uint32_t)ret_ret;
35866 }
35867
35868 void  __attribute__((export_name("TS_Type_free"))) TS_Type_free(uint32_t this_ptr) {
35869         if ((this_ptr & 1) != 0) return;
35870         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
35871         CHECK_ACCESS(this_ptr_ptr);
35872         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
35873         FREE((void*)this_ptr);
35874         Type_free(this_ptr_conv);
35875 }
35876
35877 void  __attribute__((export_name("TS_NodeId_free"))) TS_NodeId_free(uint32_t this_obj) {
35878         LDKNodeId this_obj_conv;
35879         this_obj_conv.inner = (void*)(this_obj & (~1));
35880         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35882         NodeId_free(this_obj_conv);
35883 }
35884
35885 static inline uintptr_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
35886         LDKNodeId ret_var = NodeId_clone(arg);
35887 uint32_t ret_ref = 0;
35888 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35889 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35890 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35891 ret_ref = (uintptr_t)ret_var.inner;
35892 if (ret_var.is_owned) {
35893         ret_ref |= 1;
35894 }
35895         return ret_ref;
35896 }
35897 uint32_t  __attribute__((export_name("TS_NodeId_clone_ptr"))) TS_NodeId_clone_ptr(uint32_t arg) {
35898         LDKNodeId arg_conv;
35899         arg_conv.inner = (void*)(arg & (~1));
35900         arg_conv.is_owned = false;
35901         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35902         uint32_t ret_conv = NodeId_clone_ptr(&arg_conv);
35903         return ret_conv;
35904 }
35905
35906 uint32_t  __attribute__((export_name("TS_NodeId_clone"))) TS_NodeId_clone(uint32_t orig) {
35907         LDKNodeId orig_conv;
35908         orig_conv.inner = (void*)(orig & (~1));
35909         orig_conv.is_owned = false;
35910         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35911         LDKNodeId ret_var = NodeId_clone(&orig_conv);
35912         uint32_t ret_ref = 0;
35913         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35914         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35915         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35916         ret_ref = (uintptr_t)ret_var.inner;
35917         if (ret_var.is_owned) {
35918                 ret_ref |= 1;
35919         }
35920         return ret_ref;
35921 }
35922
35923 uint32_t  __attribute__((export_name("TS_NodeId_from_pubkey"))) TS_NodeId_from_pubkey(int8_tArray pubkey) {
35924         LDKPublicKey pubkey_ref;
35925         CHECK(pubkey->arr_len == 33);
35926         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
35927         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
35928         uint32_t ret_ref = 0;
35929         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35930         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35931         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35932         ret_ref = (uintptr_t)ret_var.inner;
35933         if (ret_var.is_owned) {
35934                 ret_ref |= 1;
35935         }
35936         return ret_ref;
35937 }
35938
35939 int8_tArray  __attribute__((export_name("TS_NodeId_as_slice"))) TS_NodeId_as_slice(uint32_t this_arg) {
35940         LDKNodeId this_arg_conv;
35941         this_arg_conv.inner = (void*)(this_arg & (~1));
35942         this_arg_conv.is_owned = false;
35943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
35944         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
35945         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35946         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35947         return ret_arr;
35948 }
35949
35950 int64_t  __attribute__((export_name("TS_NodeId_hash"))) TS_NodeId_hash(uint32_t o) {
35951         LDKNodeId o_conv;
35952         o_conv.inner = (void*)(o & (~1));
35953         o_conv.is_owned = false;
35954         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
35955         int64_t ret_conv = NodeId_hash(&o_conv);
35956         return ret_conv;
35957 }
35958
35959 int8_tArray  __attribute__((export_name("TS_NodeId_write"))) TS_NodeId_write(uint32_t obj) {
35960         LDKNodeId obj_conv;
35961         obj_conv.inner = (void*)(obj & (~1));
35962         obj_conv.is_owned = false;
35963         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35964         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
35965         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
35966         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
35967         CVec_u8Z_free(ret_var);
35968         return ret_arr;
35969 }
35970
35971 uint32_t  __attribute__((export_name("TS_NodeId_read"))) TS_NodeId_read(int8_tArray ser) {
35972         LDKu8slice ser_ref;
35973         ser_ref.datalen = ser->arr_len;
35974         ser_ref.data = ser->elems /* XXX ser leaks */;
35975         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
35976         *ret_conv = NodeId_read(ser_ref);
35977         return (uint32_t)ret_conv;
35978 }
35979
35980 void  __attribute__((export_name("TS_NetworkGraph_free"))) TS_NetworkGraph_free(uint32_t this_obj) {
35981         LDKNetworkGraph this_obj_conv;
35982         this_obj_conv.inner = (void*)(this_obj & (~1));
35983         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35984         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35985         NetworkGraph_free(this_obj_conv);
35986 }
35987
35988 static inline uintptr_t NetworkGraph_clone_ptr(LDKNetworkGraph *NONNULL_PTR arg) {
35989         LDKNetworkGraph ret_var = NetworkGraph_clone(arg);
35990 uint32_t ret_ref = 0;
35991 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35992 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35993 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35994 ret_ref = (uintptr_t)ret_var.inner;
35995 if (ret_var.is_owned) {
35996         ret_ref |= 1;
35997 }
35998         return ret_ref;
35999 }
36000 uint32_t  __attribute__((export_name("TS_NetworkGraph_clone_ptr"))) TS_NetworkGraph_clone_ptr(uint32_t arg) {
36001         LDKNetworkGraph arg_conv;
36002         arg_conv.inner = (void*)(arg & (~1));
36003         arg_conv.is_owned = false;
36004         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36005         uint32_t ret_conv = NetworkGraph_clone_ptr(&arg_conv);
36006         return ret_conv;
36007 }
36008
36009 uint32_t  __attribute__((export_name("TS_NetworkGraph_clone"))) TS_NetworkGraph_clone(uint32_t orig) {
36010         LDKNetworkGraph orig_conv;
36011         orig_conv.inner = (void*)(orig & (~1));
36012         orig_conv.is_owned = false;
36013         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36014         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
36015         uint32_t ret_ref = 0;
36016         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36017         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36018         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36019         ret_ref = (uintptr_t)ret_var.inner;
36020         if (ret_var.is_owned) {
36021                 ret_ref |= 1;
36022         }
36023         return ret_ref;
36024 }
36025
36026 void  __attribute__((export_name("TS_ReadOnlyNetworkGraph_free"))) TS_ReadOnlyNetworkGraph_free(uint32_t this_obj) {
36027         LDKReadOnlyNetworkGraph this_obj_conv;
36028         this_obj_conv.inner = (void*)(this_obj & (~1));
36029         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36030         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36031         ReadOnlyNetworkGraph_free(this_obj_conv);
36032 }
36033
36034 void  __attribute__((export_name("TS_NetworkUpdate_free"))) TS_NetworkUpdate_free(uint32_t this_ptr) {
36035         if ((this_ptr & 1) != 0) return;
36036         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
36037         CHECK_ACCESS(this_ptr_ptr);
36038         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
36039         FREE((void*)this_ptr);
36040         NetworkUpdate_free(this_ptr_conv);
36041 }
36042
36043 static inline uintptr_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
36044         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
36045         *ret_copy = NetworkUpdate_clone(arg);
36046 uint32_t ret_ref = (uintptr_t)ret_copy;
36047         return ret_ref;
36048 }
36049 uint32_t  __attribute__((export_name("TS_NetworkUpdate_clone_ptr"))) TS_NetworkUpdate_clone_ptr(uint32_t arg) {
36050         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)arg;
36051         uint32_t ret_conv = NetworkUpdate_clone_ptr(arg_conv);
36052         return ret_conv;
36053 }
36054
36055 uint32_t  __attribute__((export_name("TS_NetworkUpdate_clone"))) TS_NetworkUpdate_clone(uint32_t orig) {
36056         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig;
36057         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
36058         *ret_copy = NetworkUpdate_clone(orig_conv);
36059         uint32_t ret_ref = (uintptr_t)ret_copy;
36060         return ret_ref;
36061 }
36062
36063 uint32_t  __attribute__((export_name("TS_NetworkUpdate_channel_update_message"))) TS_NetworkUpdate_channel_update_message(uint32_t msg) {
36064         LDKChannelUpdate msg_conv;
36065         msg_conv.inner = (void*)(msg & (~1));
36066         msg_conv.is_owned = (msg & 1) || (msg == 0);
36067         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36068         msg_conv = ChannelUpdate_clone(&msg_conv);
36069         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
36070         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
36071         uint32_t ret_ref = (uintptr_t)ret_copy;
36072         return ret_ref;
36073 }
36074
36075 uint32_t  __attribute__((export_name("TS_NetworkUpdate_channel_closed"))) TS_NetworkUpdate_channel_closed(int64_t short_channel_id, jboolean is_permanent) {
36076         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
36077         *ret_copy = NetworkUpdate_channel_closed(short_channel_id, is_permanent);
36078         uint32_t ret_ref = (uintptr_t)ret_copy;
36079         return ret_ref;
36080 }
36081
36082 uint32_t  __attribute__((export_name("TS_NetworkUpdate_node_failure"))) TS_NetworkUpdate_node_failure(int8_tArray node_id, jboolean is_permanent) {
36083         LDKPublicKey node_id_ref;
36084         CHECK(node_id->arr_len == 33);
36085         memcpy(node_id_ref.compressed_form, node_id->elems, 33); FREE(node_id);
36086         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
36087         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
36088         uint32_t ret_ref = (uintptr_t)ret_copy;
36089         return ret_ref;
36090 }
36091
36092 int8_tArray  __attribute__((export_name("TS_NetworkUpdate_write"))) TS_NetworkUpdate_write(uint32_t obj) {
36093         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj;
36094         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
36095         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36096         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36097         CVec_u8Z_free(ret_var);
36098         return ret_arr;
36099 }
36100
36101 uint32_t  __attribute__((export_name("TS_NetworkUpdate_read"))) TS_NetworkUpdate_read(int8_tArray ser) {
36102         LDKu8slice ser_ref;
36103         ser_ref.datalen = ser->arr_len;
36104         ser_ref.data = ser->elems /* XXX ser leaks */;
36105         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
36106         *ret_conv = NetworkUpdate_read(ser_ref);
36107         return (uint32_t)ret_conv;
36108 }
36109
36110 uint32_t  __attribute__((export_name("TS_NetGraphMsgHandler_as_EventHandler"))) TS_NetGraphMsgHandler_as_EventHandler(uint32_t this_arg) {
36111         LDKNetGraphMsgHandler this_arg_conv;
36112         this_arg_conv.inner = (void*)(this_arg & (~1));
36113         this_arg_conv.is_owned = false;
36114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36115         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
36116         *ret_ret = NetGraphMsgHandler_as_EventHandler(&this_arg_conv);
36117         return (uint32_t)ret_ret;
36118 }
36119
36120 void  __attribute__((export_name("TS_NetGraphMsgHandler_free"))) TS_NetGraphMsgHandler_free(uint32_t this_obj) {
36121         LDKNetGraphMsgHandler this_obj_conv;
36122         this_obj_conv.inner = (void*)(this_obj & (~1));
36123         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36125         NetGraphMsgHandler_free(this_obj_conv);
36126 }
36127
36128 uint32_t  __attribute__((export_name("TS_NetGraphMsgHandler_new"))) TS_NetGraphMsgHandler_new(uint32_t network_graph, uint32_t chain_access, uint32_t logger) {
36129         LDKNetworkGraph network_graph_conv;
36130         network_graph_conv.inner = (void*)(network_graph & (~1));
36131         network_graph_conv.is_owned = false;
36132         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
36133         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
36134         CHECK_ACCESS(chain_access_ptr);
36135         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
36136         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
36137         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
36138                 // Manually implement clone for Java trait instances
36139                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
36140                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36141                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
36142                 }
36143         }
36144         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
36145         CHECK_ACCESS(logger_ptr);
36146         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
36147         if (logger_conv.free == LDKLogger_JCalls_free) {
36148                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36149                 LDKLogger_JCalls_cloned(&logger_conv);
36150         }
36151         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(&network_graph_conv, chain_access_conv, logger_conv);
36152         uint32_t ret_ref = 0;
36153         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36154         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36155         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36156         ret_ref = (uintptr_t)ret_var.inner;
36157         if (ret_var.is_owned) {
36158                 ret_ref |= 1;
36159         }
36160         return ret_ref;
36161 }
36162
36163 void  __attribute__((export_name("TS_NetGraphMsgHandler_add_chain_access"))) TS_NetGraphMsgHandler_add_chain_access(uint32_t this_arg, uint32_t chain_access) {
36164         LDKNetGraphMsgHandler this_arg_conv;
36165         this_arg_conv.inner = (void*)(this_arg & (~1));
36166         this_arg_conv.is_owned = false;
36167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36168         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
36169         CHECK_ACCESS(chain_access_ptr);
36170         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
36171         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
36172         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
36173                 // Manually implement clone for Java trait instances
36174                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
36175                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36176                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
36177                 }
36178         }
36179         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv);
36180 }
36181
36182 uint32_t  __attribute__((export_name("TS_NetGraphMsgHandler_as_RoutingMessageHandler"))) TS_NetGraphMsgHandler_as_RoutingMessageHandler(uint32_t this_arg) {
36183         LDKNetGraphMsgHandler this_arg_conv;
36184         this_arg_conv.inner = (void*)(this_arg & (~1));
36185         this_arg_conv.is_owned = false;
36186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36187         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
36188         *ret_ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
36189         return (uint32_t)ret_ret;
36190 }
36191
36192 uint32_t  __attribute__((export_name("TS_NetGraphMsgHandler_as_MessageSendEventsProvider"))) TS_NetGraphMsgHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
36193         LDKNetGraphMsgHandler this_arg_conv;
36194         this_arg_conv.inner = (void*)(this_arg & (~1));
36195         this_arg_conv.is_owned = false;
36196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36197         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
36198         *ret_ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
36199         return (uint32_t)ret_ret;
36200 }
36201
36202 void  __attribute__((export_name("TS_ChannelUpdateInfo_free"))) TS_ChannelUpdateInfo_free(uint32_t this_obj) {
36203         LDKChannelUpdateInfo this_obj_conv;
36204         this_obj_conv.inner = (void*)(this_obj & (~1));
36205         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36207         ChannelUpdateInfo_free(this_obj_conv);
36208 }
36209
36210 int32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_last_update"))) TS_ChannelUpdateInfo_get_last_update(uint32_t this_ptr) {
36211         LDKChannelUpdateInfo this_ptr_conv;
36212         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36213         this_ptr_conv.is_owned = false;
36214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36215         int32_t ret_conv = ChannelUpdateInfo_get_last_update(&this_ptr_conv);
36216         return ret_conv;
36217 }
36218
36219 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_last_update"))) TS_ChannelUpdateInfo_set_last_update(uint32_t this_ptr, int32_t val) {
36220         LDKChannelUpdateInfo this_ptr_conv;
36221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36222         this_ptr_conv.is_owned = false;
36223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36224         ChannelUpdateInfo_set_last_update(&this_ptr_conv, val);
36225 }
36226
36227 jboolean  __attribute__((export_name("TS_ChannelUpdateInfo_get_enabled"))) TS_ChannelUpdateInfo_get_enabled(uint32_t this_ptr) {
36228         LDKChannelUpdateInfo this_ptr_conv;
36229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36230         this_ptr_conv.is_owned = false;
36231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36232         jboolean ret_conv = ChannelUpdateInfo_get_enabled(&this_ptr_conv);
36233         return ret_conv;
36234 }
36235
36236 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_enabled"))) TS_ChannelUpdateInfo_set_enabled(uint32_t this_ptr, jboolean val) {
36237         LDKChannelUpdateInfo this_ptr_conv;
36238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36239         this_ptr_conv.is_owned = false;
36240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36241         ChannelUpdateInfo_set_enabled(&this_ptr_conv, val);
36242 }
36243
36244 int16_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_cltv_expiry_delta"))) TS_ChannelUpdateInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
36245         LDKChannelUpdateInfo this_ptr_conv;
36246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36247         this_ptr_conv.is_owned = false;
36248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36249         int16_t ret_conv = ChannelUpdateInfo_get_cltv_expiry_delta(&this_ptr_conv);
36250         return ret_conv;
36251 }
36252
36253 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_cltv_expiry_delta"))) TS_ChannelUpdateInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
36254         LDKChannelUpdateInfo this_ptr_conv;
36255         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36256         this_ptr_conv.is_owned = false;
36257         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36258         ChannelUpdateInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
36259 }
36260
36261 int64_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_htlc_minimum_msat"))) TS_ChannelUpdateInfo_get_htlc_minimum_msat(uint32_t this_ptr) {
36262         LDKChannelUpdateInfo this_ptr_conv;
36263         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36264         this_ptr_conv.is_owned = false;
36265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36266         int64_t ret_conv = ChannelUpdateInfo_get_htlc_minimum_msat(&this_ptr_conv);
36267         return ret_conv;
36268 }
36269
36270 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_htlc_minimum_msat"))) TS_ChannelUpdateInfo_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
36271         LDKChannelUpdateInfo this_ptr_conv;
36272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36273         this_ptr_conv.is_owned = false;
36274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36275         ChannelUpdateInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
36276 }
36277
36278 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_htlc_maximum_msat"))) TS_ChannelUpdateInfo_get_htlc_maximum_msat(uint32_t this_ptr) {
36279         LDKChannelUpdateInfo this_ptr_conv;
36280         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36281         this_ptr_conv.is_owned = false;
36282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36283         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
36284         *ret_copy = ChannelUpdateInfo_get_htlc_maximum_msat(&this_ptr_conv);
36285         uint32_t ret_ref = (uintptr_t)ret_copy;
36286         return ret_ref;
36287 }
36288
36289 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_htlc_maximum_msat"))) TS_ChannelUpdateInfo_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
36290         LDKChannelUpdateInfo this_ptr_conv;
36291         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36292         this_ptr_conv.is_owned = false;
36293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36294         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
36295         CHECK_ACCESS(val_ptr);
36296         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
36297         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
36298         ChannelUpdateInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
36299 }
36300
36301 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_fees"))) TS_ChannelUpdateInfo_get_fees(uint32_t this_ptr) {
36302         LDKChannelUpdateInfo this_ptr_conv;
36303         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36304         this_ptr_conv.is_owned = false;
36305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36306         LDKRoutingFees ret_var = ChannelUpdateInfo_get_fees(&this_ptr_conv);
36307         uint32_t ret_ref = 0;
36308         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36309         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36310         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36311         ret_ref = (uintptr_t)ret_var.inner;
36312         if (ret_var.is_owned) {
36313                 ret_ref |= 1;
36314         }
36315         return ret_ref;
36316 }
36317
36318 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_fees"))) TS_ChannelUpdateInfo_set_fees(uint32_t this_ptr, uint32_t val) {
36319         LDKChannelUpdateInfo this_ptr_conv;
36320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36321         this_ptr_conv.is_owned = false;
36322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36323         LDKRoutingFees val_conv;
36324         val_conv.inner = (void*)(val & (~1));
36325         val_conv.is_owned = (val & 1) || (val == 0);
36326         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36327         val_conv = RoutingFees_clone(&val_conv);
36328         ChannelUpdateInfo_set_fees(&this_ptr_conv, val_conv);
36329 }
36330
36331 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_get_last_update_message"))) TS_ChannelUpdateInfo_get_last_update_message(uint32_t this_ptr) {
36332         LDKChannelUpdateInfo this_ptr_conv;
36333         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36334         this_ptr_conv.is_owned = false;
36335         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36336         LDKChannelUpdate ret_var = ChannelUpdateInfo_get_last_update_message(&this_ptr_conv);
36337         uint32_t ret_ref = 0;
36338         if ((uintptr_t)ret_var.inner > 4096) {
36339                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36340                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36341         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36342                 ret_ref = (uintptr_t)ret_var.inner;
36343                 if (ret_var.is_owned) {
36344                         ret_ref |= 1;
36345                 }
36346         }
36347         return ret_ref;
36348 }
36349
36350 void  __attribute__((export_name("TS_ChannelUpdateInfo_set_last_update_message"))) TS_ChannelUpdateInfo_set_last_update_message(uint32_t this_ptr, uint32_t val) {
36351         LDKChannelUpdateInfo this_ptr_conv;
36352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36353         this_ptr_conv.is_owned = false;
36354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36355         LDKChannelUpdate val_conv;
36356         val_conv.inner = (void*)(val & (~1));
36357         val_conv.is_owned = (val & 1) || (val == 0);
36358         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36359         val_conv = ChannelUpdate_clone(&val_conv);
36360         ChannelUpdateInfo_set_last_update_message(&this_ptr_conv, val_conv);
36361 }
36362
36363 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) {
36364         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
36365         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
36366         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
36367         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
36368         LDKRoutingFees fees_arg_conv;
36369         fees_arg_conv.inner = (void*)(fees_arg & (~1));
36370         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
36371         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
36372         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
36373         LDKChannelUpdate last_update_message_arg_conv;
36374         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
36375         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
36376         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
36377         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
36378         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);
36379         uint32_t ret_ref = 0;
36380         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36381         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36382         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36383         ret_ref = (uintptr_t)ret_var.inner;
36384         if (ret_var.is_owned) {
36385                 ret_ref |= 1;
36386         }
36387         return ret_ref;
36388 }
36389
36390 static inline uintptr_t ChannelUpdateInfo_clone_ptr(LDKChannelUpdateInfo *NONNULL_PTR arg) {
36391         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(arg);
36392 uint32_t ret_ref = 0;
36393 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36394 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36395 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36396 ret_ref = (uintptr_t)ret_var.inner;
36397 if (ret_var.is_owned) {
36398         ret_ref |= 1;
36399 }
36400         return ret_ref;
36401 }
36402 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_clone_ptr"))) TS_ChannelUpdateInfo_clone_ptr(uint32_t arg) {
36403         LDKChannelUpdateInfo arg_conv;
36404         arg_conv.inner = (void*)(arg & (~1));
36405         arg_conv.is_owned = false;
36406         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36407         uint32_t ret_conv = ChannelUpdateInfo_clone_ptr(&arg_conv);
36408         return ret_conv;
36409 }
36410
36411 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_clone"))) TS_ChannelUpdateInfo_clone(uint32_t orig) {
36412         LDKChannelUpdateInfo orig_conv;
36413         orig_conv.inner = (void*)(orig & (~1));
36414         orig_conv.is_owned = false;
36415         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36416         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(&orig_conv);
36417         uint32_t ret_ref = 0;
36418         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36419         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36420         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36421         ret_ref = (uintptr_t)ret_var.inner;
36422         if (ret_var.is_owned) {
36423                 ret_ref |= 1;
36424         }
36425         return ret_ref;
36426 }
36427
36428 int8_tArray  __attribute__((export_name("TS_ChannelUpdateInfo_write"))) TS_ChannelUpdateInfo_write(uint32_t obj) {
36429         LDKChannelUpdateInfo obj_conv;
36430         obj_conv.inner = (void*)(obj & (~1));
36431         obj_conv.is_owned = false;
36432         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36433         LDKCVec_u8Z ret_var = ChannelUpdateInfo_write(&obj_conv);
36434         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36435         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36436         CVec_u8Z_free(ret_var);
36437         return ret_arr;
36438 }
36439
36440 uint32_t  __attribute__((export_name("TS_ChannelUpdateInfo_read"))) TS_ChannelUpdateInfo_read(int8_tArray ser) {
36441         LDKu8slice ser_ref;
36442         ser_ref.datalen = ser->arr_len;
36443         ser_ref.data = ser->elems /* XXX ser leaks */;
36444         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
36445         *ret_conv = ChannelUpdateInfo_read(ser_ref);
36446         return (uint32_t)ret_conv;
36447 }
36448
36449 void  __attribute__((export_name("TS_ChannelInfo_free"))) TS_ChannelInfo_free(uint32_t this_obj) {
36450         LDKChannelInfo this_obj_conv;
36451         this_obj_conv.inner = (void*)(this_obj & (~1));
36452         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36454         ChannelInfo_free(this_obj_conv);
36455 }
36456
36457 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_features"))) TS_ChannelInfo_get_features(uint32_t this_ptr) {
36458         LDKChannelInfo this_ptr_conv;
36459         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36460         this_ptr_conv.is_owned = false;
36461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36462         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
36463         uint32_t ret_ref = 0;
36464         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36465         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36466         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36467         ret_ref = (uintptr_t)ret_var.inner;
36468         if (ret_var.is_owned) {
36469                 ret_ref |= 1;
36470         }
36471         return ret_ref;
36472 }
36473
36474 void  __attribute__((export_name("TS_ChannelInfo_set_features"))) TS_ChannelInfo_set_features(uint32_t this_ptr, uint32_t val) {
36475         LDKChannelInfo this_ptr_conv;
36476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36477         this_ptr_conv.is_owned = false;
36478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36479         LDKChannelFeatures val_conv;
36480         val_conv.inner = (void*)(val & (~1));
36481         val_conv.is_owned = (val & 1) || (val == 0);
36482         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36483         val_conv = ChannelFeatures_clone(&val_conv);
36484         ChannelInfo_set_features(&this_ptr_conv, val_conv);
36485 }
36486
36487 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_node_one"))) TS_ChannelInfo_get_node_one(uint32_t this_ptr) {
36488         LDKChannelInfo this_ptr_conv;
36489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36490         this_ptr_conv.is_owned = false;
36491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36492         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
36493         uint32_t ret_ref = 0;
36494         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36495         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36496         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36497         ret_ref = (uintptr_t)ret_var.inner;
36498         if (ret_var.is_owned) {
36499                 ret_ref |= 1;
36500         }
36501         return ret_ref;
36502 }
36503
36504 void  __attribute__((export_name("TS_ChannelInfo_set_node_one"))) TS_ChannelInfo_set_node_one(uint32_t this_ptr, uint32_t val) {
36505         LDKChannelInfo this_ptr_conv;
36506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36507         this_ptr_conv.is_owned = false;
36508         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36509         LDKNodeId val_conv;
36510         val_conv.inner = (void*)(val & (~1));
36511         val_conv.is_owned = (val & 1) || (val == 0);
36512         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36513         val_conv = NodeId_clone(&val_conv);
36514         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
36515 }
36516
36517 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_one_to_two"))) TS_ChannelInfo_get_one_to_two(uint32_t this_ptr) {
36518         LDKChannelInfo this_ptr_conv;
36519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36520         this_ptr_conv.is_owned = false;
36521         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36522         LDKChannelUpdateInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
36523         uint32_t ret_ref = 0;
36524         if ((uintptr_t)ret_var.inner > 4096) {
36525                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36526                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36527         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36528                 ret_ref = (uintptr_t)ret_var.inner;
36529                 if (ret_var.is_owned) {
36530                         ret_ref |= 1;
36531                 }
36532         }
36533         return ret_ref;
36534 }
36535
36536 void  __attribute__((export_name("TS_ChannelInfo_set_one_to_two"))) TS_ChannelInfo_set_one_to_two(uint32_t this_ptr, uint32_t val) {
36537         LDKChannelInfo this_ptr_conv;
36538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36539         this_ptr_conv.is_owned = false;
36540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36541         LDKChannelUpdateInfo val_conv;
36542         val_conv.inner = (void*)(val & (~1));
36543         val_conv.is_owned = (val & 1) || (val == 0);
36544         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36545         val_conv = ChannelUpdateInfo_clone(&val_conv);
36546         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
36547 }
36548
36549 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_node_two"))) TS_ChannelInfo_get_node_two(uint32_t this_ptr) {
36550         LDKChannelInfo this_ptr_conv;
36551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36552         this_ptr_conv.is_owned = false;
36553         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36554         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
36555         uint32_t ret_ref = 0;
36556         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36557         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36558         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36559         ret_ref = (uintptr_t)ret_var.inner;
36560         if (ret_var.is_owned) {
36561                 ret_ref |= 1;
36562         }
36563         return ret_ref;
36564 }
36565
36566 void  __attribute__((export_name("TS_ChannelInfo_set_node_two"))) TS_ChannelInfo_set_node_two(uint32_t this_ptr, uint32_t val) {
36567         LDKChannelInfo this_ptr_conv;
36568         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36569         this_ptr_conv.is_owned = false;
36570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36571         LDKNodeId val_conv;
36572         val_conv.inner = (void*)(val & (~1));
36573         val_conv.is_owned = (val & 1) || (val == 0);
36574         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36575         val_conv = NodeId_clone(&val_conv);
36576         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
36577 }
36578
36579 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_two_to_one"))) TS_ChannelInfo_get_two_to_one(uint32_t this_ptr) {
36580         LDKChannelInfo this_ptr_conv;
36581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36582         this_ptr_conv.is_owned = false;
36583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36584         LDKChannelUpdateInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
36585         uint32_t ret_ref = 0;
36586         if ((uintptr_t)ret_var.inner > 4096) {
36587                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36588                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36589         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36590                 ret_ref = (uintptr_t)ret_var.inner;
36591                 if (ret_var.is_owned) {
36592                         ret_ref |= 1;
36593                 }
36594         }
36595         return ret_ref;
36596 }
36597
36598 void  __attribute__((export_name("TS_ChannelInfo_set_two_to_one"))) TS_ChannelInfo_set_two_to_one(uint32_t this_ptr, uint32_t val) {
36599         LDKChannelInfo this_ptr_conv;
36600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36601         this_ptr_conv.is_owned = false;
36602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36603         LDKChannelUpdateInfo val_conv;
36604         val_conv.inner = (void*)(val & (~1));
36605         val_conv.is_owned = (val & 1) || (val == 0);
36606         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36607         val_conv = ChannelUpdateInfo_clone(&val_conv);
36608         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
36609 }
36610
36611 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_capacity_sats"))) TS_ChannelInfo_get_capacity_sats(uint32_t this_ptr) {
36612         LDKChannelInfo this_ptr_conv;
36613         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36614         this_ptr_conv.is_owned = false;
36615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36616         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
36617         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
36618         uint32_t ret_ref = (uintptr_t)ret_copy;
36619         return ret_ref;
36620 }
36621
36622 void  __attribute__((export_name("TS_ChannelInfo_set_capacity_sats"))) TS_ChannelInfo_set_capacity_sats(uint32_t this_ptr, uint32_t val) {
36623         LDKChannelInfo this_ptr_conv;
36624         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36625         this_ptr_conv.is_owned = false;
36626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36627         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
36628         CHECK_ACCESS(val_ptr);
36629         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
36630         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
36631         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
36632 }
36633
36634 uint32_t  __attribute__((export_name("TS_ChannelInfo_get_announcement_message"))) TS_ChannelInfo_get_announcement_message(uint32_t this_ptr) {
36635         LDKChannelInfo this_ptr_conv;
36636         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36637         this_ptr_conv.is_owned = false;
36638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36639         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
36640         uint32_t ret_ref = 0;
36641         if ((uintptr_t)ret_var.inner > 4096) {
36642                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36643                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36644         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36645                 ret_ref = (uintptr_t)ret_var.inner;
36646                 if (ret_var.is_owned) {
36647                         ret_ref |= 1;
36648                 }
36649         }
36650         return ret_ref;
36651 }
36652
36653 void  __attribute__((export_name("TS_ChannelInfo_set_announcement_message"))) TS_ChannelInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
36654         LDKChannelInfo this_ptr_conv;
36655         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36656         this_ptr_conv.is_owned = false;
36657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36658         LDKChannelAnnouncement val_conv;
36659         val_conv.inner = (void*)(val & (~1));
36660         val_conv.is_owned = (val & 1) || (val == 0);
36661         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36662         val_conv = ChannelAnnouncement_clone(&val_conv);
36663         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
36664 }
36665
36666 static inline uintptr_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
36667         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
36668 uint32_t ret_ref = 0;
36669 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36670 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36671 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36672 ret_ref = (uintptr_t)ret_var.inner;
36673 if (ret_var.is_owned) {
36674         ret_ref |= 1;
36675 }
36676         return ret_ref;
36677 }
36678 uint32_t  __attribute__((export_name("TS_ChannelInfo_clone_ptr"))) TS_ChannelInfo_clone_ptr(uint32_t arg) {
36679         LDKChannelInfo arg_conv;
36680         arg_conv.inner = (void*)(arg & (~1));
36681         arg_conv.is_owned = false;
36682         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36683         uint32_t ret_conv = ChannelInfo_clone_ptr(&arg_conv);
36684         return ret_conv;
36685 }
36686
36687 uint32_t  __attribute__((export_name("TS_ChannelInfo_clone"))) TS_ChannelInfo_clone(uint32_t orig) {
36688         LDKChannelInfo orig_conv;
36689         orig_conv.inner = (void*)(orig & (~1));
36690         orig_conv.is_owned = false;
36691         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36692         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
36693         uint32_t ret_ref = 0;
36694         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36695         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36696         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36697         ret_ref = (uintptr_t)ret_var.inner;
36698         if (ret_var.is_owned) {
36699                 ret_ref |= 1;
36700         }
36701         return ret_ref;
36702 }
36703
36704 int8_tArray  __attribute__((export_name("TS_ChannelInfo_write"))) TS_ChannelInfo_write(uint32_t obj) {
36705         LDKChannelInfo obj_conv;
36706         obj_conv.inner = (void*)(obj & (~1));
36707         obj_conv.is_owned = false;
36708         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36709         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
36710         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
36711         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
36712         CVec_u8Z_free(ret_var);
36713         return ret_arr;
36714 }
36715
36716 uint32_t  __attribute__((export_name("TS_ChannelInfo_read"))) TS_ChannelInfo_read(int8_tArray ser) {
36717         LDKu8slice ser_ref;
36718         ser_ref.datalen = ser->arr_len;
36719         ser_ref.data = ser->elems /* XXX ser leaks */;
36720         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
36721         *ret_conv = ChannelInfo_read(ser_ref);
36722         return (uint32_t)ret_conv;
36723 }
36724
36725 void  __attribute__((export_name("TS_DirectedChannelInfo_free"))) TS_DirectedChannelInfo_free(uint32_t this_obj) {
36726         LDKDirectedChannelInfo this_obj_conv;
36727         this_obj_conv.inner = (void*)(this_obj & (~1));
36728         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36730         DirectedChannelInfo_free(this_obj_conv);
36731 }
36732
36733 static inline uintptr_t DirectedChannelInfo_clone_ptr(LDKDirectedChannelInfo *NONNULL_PTR arg) {
36734         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(arg);
36735 uint32_t ret_ref = 0;
36736 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36737 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36738 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36739 ret_ref = (uintptr_t)ret_var.inner;
36740 if (ret_var.is_owned) {
36741         ret_ref |= 1;
36742 }
36743         return ret_ref;
36744 }
36745 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_clone_ptr"))) TS_DirectedChannelInfo_clone_ptr(uint32_t arg) {
36746         LDKDirectedChannelInfo arg_conv;
36747         arg_conv.inner = (void*)(arg & (~1));
36748         arg_conv.is_owned = false;
36749         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36750         uint32_t ret_conv = DirectedChannelInfo_clone_ptr(&arg_conv);
36751         return ret_conv;
36752 }
36753
36754 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_clone"))) TS_DirectedChannelInfo_clone(uint32_t orig) {
36755         LDKDirectedChannelInfo orig_conv;
36756         orig_conv.inner = (void*)(orig & (~1));
36757         orig_conv.is_owned = false;
36758         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36759         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(&orig_conv);
36760         uint32_t ret_ref = 0;
36761         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36762         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36763         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36764         ret_ref = (uintptr_t)ret_var.inner;
36765         if (ret_var.is_owned) {
36766                 ret_ref |= 1;
36767         }
36768         return ret_ref;
36769 }
36770
36771 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_channel"))) TS_DirectedChannelInfo_channel(uint32_t this_arg) {
36772         LDKDirectedChannelInfo this_arg_conv;
36773         this_arg_conv.inner = (void*)(this_arg & (~1));
36774         this_arg_conv.is_owned = false;
36775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36776         LDKChannelInfo ret_var = DirectedChannelInfo_channel(&this_arg_conv);
36777         uint32_t ret_ref = 0;
36778         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36779         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36780         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36781         ret_ref = (uintptr_t)ret_var.inner;
36782         if (ret_var.is_owned) {
36783                 ret_ref |= 1;
36784         }
36785         return ret_ref;
36786 }
36787
36788 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_direction"))) TS_DirectedChannelInfo_direction(uint32_t this_arg) {
36789         LDKDirectedChannelInfo this_arg_conv;
36790         this_arg_conv.inner = (void*)(this_arg & (~1));
36791         this_arg_conv.is_owned = false;
36792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36793         LDKChannelUpdateInfo ret_var = DirectedChannelInfo_direction(&this_arg_conv);
36794         uint32_t ret_ref = 0;
36795         if ((uintptr_t)ret_var.inner > 4096) {
36796                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36797                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36798         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36799                 ret_ref = (uintptr_t)ret_var.inner;
36800                 if (ret_var.is_owned) {
36801                         ret_ref |= 1;
36802                 }
36803         }
36804         return ret_ref;
36805 }
36806
36807 uint32_t  __attribute__((export_name("TS_DirectedChannelInfo_effective_capacity"))) TS_DirectedChannelInfo_effective_capacity(uint32_t this_arg) {
36808         LDKDirectedChannelInfo this_arg_conv;
36809         this_arg_conv.inner = (void*)(this_arg & (~1));
36810         this_arg_conv.is_owned = false;
36811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36812         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36813         *ret_copy = DirectedChannelInfo_effective_capacity(&this_arg_conv);
36814         uint32_t ret_ref = (uintptr_t)ret_copy;
36815         return ret_ref;
36816 }
36817
36818 void  __attribute__((export_name("TS_EffectiveCapacity_free"))) TS_EffectiveCapacity_free(uint32_t this_ptr) {
36819         if ((this_ptr & 1) != 0) return;
36820         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
36821         CHECK_ACCESS(this_ptr_ptr);
36822         LDKEffectiveCapacity this_ptr_conv = *(LDKEffectiveCapacity*)(this_ptr_ptr);
36823         FREE((void*)this_ptr);
36824         EffectiveCapacity_free(this_ptr_conv);
36825 }
36826
36827 static inline uintptr_t EffectiveCapacity_clone_ptr(LDKEffectiveCapacity *NONNULL_PTR arg) {
36828         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36829         *ret_copy = EffectiveCapacity_clone(arg);
36830 uint32_t ret_ref = (uintptr_t)ret_copy;
36831         return ret_ref;
36832 }
36833 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_clone_ptr"))) TS_EffectiveCapacity_clone_ptr(uint32_t arg) {
36834         LDKEffectiveCapacity* arg_conv = (LDKEffectiveCapacity*)arg;
36835         uint32_t ret_conv = EffectiveCapacity_clone_ptr(arg_conv);
36836         return ret_conv;
36837 }
36838
36839 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_clone"))) TS_EffectiveCapacity_clone(uint32_t orig) {
36840         LDKEffectiveCapacity* orig_conv = (LDKEffectiveCapacity*)orig;
36841         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36842         *ret_copy = EffectiveCapacity_clone(orig_conv);
36843         uint32_t ret_ref = (uintptr_t)ret_copy;
36844         return ret_ref;
36845 }
36846
36847 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_exact_liquidity"))) TS_EffectiveCapacity_exact_liquidity(int64_t liquidity_msat) {
36848         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36849         *ret_copy = EffectiveCapacity_exact_liquidity(liquidity_msat);
36850         uint32_t ret_ref = (uintptr_t)ret_copy;
36851         return ret_ref;
36852 }
36853
36854 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_maximum_htlc"))) TS_EffectiveCapacity_maximum_htlc(int64_t amount_msat) {
36855         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36856         *ret_copy = EffectiveCapacity_maximum_htlc(amount_msat);
36857         uint32_t ret_ref = (uintptr_t)ret_copy;
36858         return ret_ref;
36859 }
36860
36861 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_total"))) TS_EffectiveCapacity_total(int64_t capacity_msat) {
36862         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36863         *ret_copy = EffectiveCapacity_total(capacity_msat);
36864         uint32_t ret_ref = (uintptr_t)ret_copy;
36865         return ret_ref;
36866 }
36867
36868 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_infinite"))) TS_EffectiveCapacity_infinite() {
36869         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36870         *ret_copy = EffectiveCapacity_infinite();
36871         uint32_t ret_ref = (uintptr_t)ret_copy;
36872         return ret_ref;
36873 }
36874
36875 uint32_t  __attribute__((export_name("TS_EffectiveCapacity_unknown"))) TS_EffectiveCapacity_unknown() {
36876         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
36877         *ret_copy = EffectiveCapacity_unknown();
36878         uint32_t ret_ref = (uintptr_t)ret_copy;
36879         return ret_ref;
36880 }
36881
36882 int64_t  __attribute__((export_name("TS_EffectiveCapacity_as_msat"))) TS_EffectiveCapacity_as_msat(uint32_t this_arg) {
36883         LDKEffectiveCapacity* this_arg_conv = (LDKEffectiveCapacity*)this_arg;
36884         int64_t ret_conv = EffectiveCapacity_as_msat(this_arg_conv);
36885         return ret_conv;
36886 }
36887
36888 void  __attribute__((export_name("TS_RoutingFees_free"))) TS_RoutingFees_free(uint32_t this_obj) {
36889         LDKRoutingFees this_obj_conv;
36890         this_obj_conv.inner = (void*)(this_obj & (~1));
36891         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36893         RoutingFees_free(this_obj_conv);
36894 }
36895
36896 int32_t  __attribute__((export_name("TS_RoutingFees_get_base_msat"))) TS_RoutingFees_get_base_msat(uint32_t this_ptr) {
36897         LDKRoutingFees this_ptr_conv;
36898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36899         this_ptr_conv.is_owned = false;
36900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36901         int32_t ret_conv = RoutingFees_get_base_msat(&this_ptr_conv);
36902         return ret_conv;
36903 }
36904
36905 void  __attribute__((export_name("TS_RoutingFees_set_base_msat"))) TS_RoutingFees_set_base_msat(uint32_t this_ptr, int32_t val) {
36906         LDKRoutingFees this_ptr_conv;
36907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36908         this_ptr_conv.is_owned = false;
36909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36910         RoutingFees_set_base_msat(&this_ptr_conv, val);
36911 }
36912
36913 int32_t  __attribute__((export_name("TS_RoutingFees_get_proportional_millionths"))) TS_RoutingFees_get_proportional_millionths(uint32_t this_ptr) {
36914         LDKRoutingFees this_ptr_conv;
36915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36916         this_ptr_conv.is_owned = false;
36917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36918         int32_t ret_conv = RoutingFees_get_proportional_millionths(&this_ptr_conv);
36919         return ret_conv;
36920 }
36921
36922 void  __attribute__((export_name("TS_RoutingFees_set_proportional_millionths"))) TS_RoutingFees_set_proportional_millionths(uint32_t this_ptr, int32_t val) {
36923         LDKRoutingFees this_ptr_conv;
36924         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36925         this_ptr_conv.is_owned = false;
36926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36927         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
36928 }
36929
36930 uint32_t  __attribute__((export_name("TS_RoutingFees_new"))) TS_RoutingFees_new(int32_t base_msat_arg, int32_t proportional_millionths_arg) {
36931         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
36932         uint32_t ret_ref = 0;
36933         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36934         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36935         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36936         ret_ref = (uintptr_t)ret_var.inner;
36937         if (ret_var.is_owned) {
36938                 ret_ref |= 1;
36939         }
36940         return ret_ref;
36941 }
36942
36943 jboolean  __attribute__((export_name("TS_RoutingFees_eq"))) TS_RoutingFees_eq(uint32_t a, uint32_t b) {
36944         LDKRoutingFees a_conv;
36945         a_conv.inner = (void*)(a & (~1));
36946         a_conv.is_owned = false;
36947         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36948         LDKRoutingFees b_conv;
36949         b_conv.inner = (void*)(b & (~1));
36950         b_conv.is_owned = false;
36951         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36952         jboolean ret_conv = RoutingFees_eq(&a_conv, &b_conv);
36953         return ret_conv;
36954 }
36955
36956 static inline uintptr_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
36957         LDKRoutingFees ret_var = RoutingFees_clone(arg);
36958 uint32_t ret_ref = 0;
36959 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36960 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36961 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36962 ret_ref = (uintptr_t)ret_var.inner;
36963 if (ret_var.is_owned) {
36964         ret_ref |= 1;
36965 }
36966         return ret_ref;
36967 }
36968 uint32_t  __attribute__((export_name("TS_RoutingFees_clone_ptr"))) TS_RoutingFees_clone_ptr(uint32_t arg) {
36969         LDKRoutingFees arg_conv;
36970         arg_conv.inner = (void*)(arg & (~1));
36971         arg_conv.is_owned = false;
36972         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36973         uint32_t ret_conv = RoutingFees_clone_ptr(&arg_conv);
36974         return ret_conv;
36975 }
36976
36977 uint32_t  __attribute__((export_name("TS_RoutingFees_clone"))) TS_RoutingFees_clone(uint32_t orig) {
36978         LDKRoutingFees orig_conv;
36979         orig_conv.inner = (void*)(orig & (~1));
36980         orig_conv.is_owned = false;
36981         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36982         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
36983         uint32_t ret_ref = 0;
36984         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36985         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36986         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36987         ret_ref = (uintptr_t)ret_var.inner;
36988         if (ret_var.is_owned) {
36989                 ret_ref |= 1;
36990         }
36991         return ret_ref;
36992 }
36993
36994 int64_t  __attribute__((export_name("TS_RoutingFees_hash"))) TS_RoutingFees_hash(uint32_t o) {
36995         LDKRoutingFees o_conv;
36996         o_conv.inner = (void*)(o & (~1));
36997         o_conv.is_owned = false;
36998         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
36999         int64_t ret_conv = RoutingFees_hash(&o_conv);
37000         return ret_conv;
37001 }
37002
37003 int8_tArray  __attribute__((export_name("TS_RoutingFees_write"))) TS_RoutingFees_write(uint32_t obj) {
37004         LDKRoutingFees obj_conv;
37005         obj_conv.inner = (void*)(obj & (~1));
37006         obj_conv.is_owned = false;
37007         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37008         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
37009         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37010         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37011         CVec_u8Z_free(ret_var);
37012         return ret_arr;
37013 }
37014
37015 uint32_t  __attribute__((export_name("TS_RoutingFees_read"))) TS_RoutingFees_read(int8_tArray ser) {
37016         LDKu8slice ser_ref;
37017         ser_ref.datalen = ser->arr_len;
37018         ser_ref.data = ser->elems /* XXX ser leaks */;
37019         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
37020         *ret_conv = RoutingFees_read(ser_ref);
37021         return (uint32_t)ret_conv;
37022 }
37023
37024 void  __attribute__((export_name("TS_NodeAnnouncementInfo_free"))) TS_NodeAnnouncementInfo_free(uint32_t this_obj) {
37025         LDKNodeAnnouncementInfo this_obj_conv;
37026         this_obj_conv.inner = (void*)(this_obj & (~1));
37027         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37029         NodeAnnouncementInfo_free(this_obj_conv);
37030 }
37031
37032 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_features"))) TS_NodeAnnouncementInfo_get_features(uint32_t this_ptr) {
37033         LDKNodeAnnouncementInfo this_ptr_conv;
37034         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37035         this_ptr_conv.is_owned = false;
37036         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37037         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
37038         uint32_t ret_ref = 0;
37039         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37040         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37041         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37042         ret_ref = (uintptr_t)ret_var.inner;
37043         if (ret_var.is_owned) {
37044                 ret_ref |= 1;
37045         }
37046         return ret_ref;
37047 }
37048
37049 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_features"))) TS_NodeAnnouncementInfo_set_features(uint32_t this_ptr, uint32_t val) {
37050         LDKNodeAnnouncementInfo this_ptr_conv;
37051         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37052         this_ptr_conv.is_owned = false;
37053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37054         LDKNodeFeatures val_conv;
37055         val_conv.inner = (void*)(val & (~1));
37056         val_conv.is_owned = (val & 1) || (val == 0);
37057         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37058         val_conv = NodeFeatures_clone(&val_conv);
37059         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
37060 }
37061
37062 int32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_last_update"))) TS_NodeAnnouncementInfo_get_last_update(uint32_t this_ptr) {
37063         LDKNodeAnnouncementInfo this_ptr_conv;
37064         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37065         this_ptr_conv.is_owned = false;
37066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37067         int32_t ret_conv = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
37068         return ret_conv;
37069 }
37070
37071 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_last_update"))) TS_NodeAnnouncementInfo_set_last_update(uint32_t this_ptr, int32_t val) {
37072         LDKNodeAnnouncementInfo this_ptr_conv;
37073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37074         this_ptr_conv.is_owned = false;
37075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37076         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
37077 }
37078
37079 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_get_rgb"))) TS_NodeAnnouncementInfo_get_rgb(uint32_t this_ptr) {
37080         LDKNodeAnnouncementInfo this_ptr_conv;
37081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37082         this_ptr_conv.is_owned = false;
37083         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37084         int8_tArray ret_arr = init_int8_tArray(3, __LINE__);
37085         memcpy(ret_arr->elems, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv), 3);
37086         return ret_arr;
37087 }
37088
37089 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_rgb"))) TS_NodeAnnouncementInfo_set_rgb(uint32_t this_ptr, int8_tArray val) {
37090         LDKNodeAnnouncementInfo this_ptr_conv;
37091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37092         this_ptr_conv.is_owned = false;
37093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37094         LDKThreeBytes val_ref;
37095         CHECK(val->arr_len == 3);
37096         memcpy(val_ref.data, val->elems, 3); FREE(val);
37097         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
37098 }
37099
37100 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_get_alias"))) TS_NodeAnnouncementInfo_get_alias(uint32_t this_ptr) {
37101         LDKNodeAnnouncementInfo this_ptr_conv;
37102         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37103         this_ptr_conv.is_owned = false;
37104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37105         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
37106         memcpy(ret_arr->elems, *NodeAnnouncementInfo_get_alias(&this_ptr_conv), 32);
37107         return ret_arr;
37108 }
37109
37110 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_alias"))) TS_NodeAnnouncementInfo_set_alias(uint32_t this_ptr, int8_tArray val) {
37111         LDKNodeAnnouncementInfo this_ptr_conv;
37112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37113         this_ptr_conv.is_owned = false;
37114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37115         LDKThirtyTwoBytes val_ref;
37116         CHECK(val->arr_len == 32);
37117         memcpy(val_ref.data, val->elems, 32); FREE(val);
37118         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
37119 }
37120
37121 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_addresses"))) TS_NodeAnnouncementInfo_set_addresses(uint32_t this_ptr, uint32_tArray val) {
37122         LDKNodeAnnouncementInfo this_ptr_conv;
37123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37124         this_ptr_conv.is_owned = false;
37125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37126         LDKCVec_NetAddressZ val_constr;
37127         val_constr.datalen = val->arr_len;
37128         if (val_constr.datalen > 0)
37129                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
37130         else
37131                 val_constr.data = NULL;
37132         uint32_t* val_vals = val->elems /* XXX val leaks */;
37133         for (size_t m = 0; m < val_constr.datalen; m++) {
37134                 uint32_t val_conv_12 = val_vals[m];
37135                 void* val_conv_12_ptr = (void*)(((uintptr_t)val_conv_12) & ~1);
37136                 CHECK_ACCESS(val_conv_12_ptr);
37137                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
37138                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uintptr_t)val_conv_12) & ~1));
37139                 val_constr.data[m] = val_conv_12_conv;
37140         }
37141         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
37142 }
37143
37144 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_get_announcement_message"))) TS_NodeAnnouncementInfo_get_announcement_message(uint32_t this_ptr) {
37145         LDKNodeAnnouncementInfo this_ptr_conv;
37146         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37147         this_ptr_conv.is_owned = false;
37148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37149         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
37150         uint32_t ret_ref = 0;
37151         if ((uintptr_t)ret_var.inner > 4096) {
37152                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37153                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37154         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37155                 ret_ref = (uintptr_t)ret_var.inner;
37156                 if (ret_var.is_owned) {
37157                         ret_ref |= 1;
37158                 }
37159         }
37160         return ret_ref;
37161 }
37162
37163 void  __attribute__((export_name("TS_NodeAnnouncementInfo_set_announcement_message"))) TS_NodeAnnouncementInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
37164         LDKNodeAnnouncementInfo this_ptr_conv;
37165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37166         this_ptr_conv.is_owned = false;
37167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37168         LDKNodeAnnouncement val_conv;
37169         val_conv.inner = (void*)(val & (~1));
37170         val_conv.is_owned = (val & 1) || (val == 0);
37171         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37172         val_conv = NodeAnnouncement_clone(&val_conv);
37173         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
37174 }
37175
37176 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) {
37177         LDKNodeFeatures features_arg_conv;
37178         features_arg_conv.inner = (void*)(features_arg & (~1));
37179         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
37180         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
37181         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
37182         LDKThreeBytes rgb_arg_ref;
37183         CHECK(rgb_arg->arr_len == 3);
37184         memcpy(rgb_arg_ref.data, rgb_arg->elems, 3); FREE(rgb_arg);
37185         LDKThirtyTwoBytes alias_arg_ref;
37186         CHECK(alias_arg->arr_len == 32);
37187         memcpy(alias_arg_ref.data, alias_arg->elems, 32); FREE(alias_arg);
37188         LDKCVec_NetAddressZ addresses_arg_constr;
37189         addresses_arg_constr.datalen = addresses_arg->arr_len;
37190         if (addresses_arg_constr.datalen > 0)
37191                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
37192         else
37193                 addresses_arg_constr.data = NULL;
37194         uint32_t* addresses_arg_vals = addresses_arg->elems /* XXX addresses_arg leaks */;
37195         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
37196                 uint32_t addresses_arg_conv_12 = addresses_arg_vals[m];
37197                 void* addresses_arg_conv_12_ptr = (void*)(((uintptr_t)addresses_arg_conv_12) & ~1);
37198                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
37199                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
37200                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
37201         }
37202         LDKNodeAnnouncement announcement_message_arg_conv;
37203         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
37204         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
37205         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
37206         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
37207         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
37208         uint32_t ret_ref = 0;
37209         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37210         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37211         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37212         ret_ref = (uintptr_t)ret_var.inner;
37213         if (ret_var.is_owned) {
37214                 ret_ref |= 1;
37215         }
37216         return ret_ref;
37217 }
37218
37219 static inline uintptr_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
37220         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
37221 uint32_t ret_ref = 0;
37222 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37223 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37224 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37225 ret_ref = (uintptr_t)ret_var.inner;
37226 if (ret_var.is_owned) {
37227         ret_ref |= 1;
37228 }
37229         return ret_ref;
37230 }
37231 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_clone_ptr"))) TS_NodeAnnouncementInfo_clone_ptr(uint32_t arg) {
37232         LDKNodeAnnouncementInfo arg_conv;
37233         arg_conv.inner = (void*)(arg & (~1));
37234         arg_conv.is_owned = false;
37235         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37236         uint32_t ret_conv = NodeAnnouncementInfo_clone_ptr(&arg_conv);
37237         return ret_conv;
37238 }
37239
37240 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_clone"))) TS_NodeAnnouncementInfo_clone(uint32_t orig) {
37241         LDKNodeAnnouncementInfo orig_conv;
37242         orig_conv.inner = (void*)(orig & (~1));
37243         orig_conv.is_owned = false;
37244         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37245         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
37246         uint32_t ret_ref = 0;
37247         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37248         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37249         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37250         ret_ref = (uintptr_t)ret_var.inner;
37251         if (ret_var.is_owned) {
37252                 ret_ref |= 1;
37253         }
37254         return ret_ref;
37255 }
37256
37257 int8_tArray  __attribute__((export_name("TS_NodeAnnouncementInfo_write"))) TS_NodeAnnouncementInfo_write(uint32_t obj) {
37258         LDKNodeAnnouncementInfo obj_conv;
37259         obj_conv.inner = (void*)(obj & (~1));
37260         obj_conv.is_owned = false;
37261         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37262         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
37263         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37264         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37265         CVec_u8Z_free(ret_var);
37266         return ret_arr;
37267 }
37268
37269 uint32_t  __attribute__((export_name("TS_NodeAnnouncementInfo_read"))) TS_NodeAnnouncementInfo_read(int8_tArray ser) {
37270         LDKu8slice ser_ref;
37271         ser_ref.datalen = ser->arr_len;
37272         ser_ref.data = ser->elems /* XXX ser leaks */;
37273         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
37274         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
37275         return (uint32_t)ret_conv;
37276 }
37277
37278 void  __attribute__((export_name("TS_NodeInfo_free"))) TS_NodeInfo_free(uint32_t this_obj) {
37279         LDKNodeInfo this_obj_conv;
37280         this_obj_conv.inner = (void*)(this_obj & (~1));
37281         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37283         NodeInfo_free(this_obj_conv);
37284 }
37285
37286 void  __attribute__((export_name("TS_NodeInfo_set_channels"))) TS_NodeInfo_set_channels(uint32_t this_ptr, int64_tArray val) {
37287         LDKNodeInfo this_ptr_conv;
37288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37289         this_ptr_conv.is_owned = false;
37290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37291         LDKCVec_u64Z val_constr;
37292         val_constr.datalen = val->arr_len;
37293         if (val_constr.datalen > 0)
37294                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
37295         else
37296                 val_constr.data = NULL;
37297         int64_t* val_vals = val->elems /* XXX val leaks */;
37298         for (size_t i = 0; i < val_constr.datalen; i++) {
37299                 int64_t val_conv_8 = val_vals[i];
37300                 val_constr.data[i] = val_conv_8;
37301         }
37302         NodeInfo_set_channels(&this_ptr_conv, val_constr);
37303 }
37304
37305 uint32_t  __attribute__((export_name("TS_NodeInfo_get_lowest_inbound_channel_fees"))) TS_NodeInfo_get_lowest_inbound_channel_fees(uint32_t this_ptr) {
37306         LDKNodeInfo this_ptr_conv;
37307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37308         this_ptr_conv.is_owned = false;
37309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37310         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
37311         uint32_t ret_ref = 0;
37312         if ((uintptr_t)ret_var.inner > 4096) {
37313                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37314                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37315         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37316                 ret_ref = (uintptr_t)ret_var.inner;
37317                 if (ret_var.is_owned) {
37318                         ret_ref |= 1;
37319                 }
37320         }
37321         return ret_ref;
37322 }
37323
37324 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) {
37325         LDKNodeInfo this_ptr_conv;
37326         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37327         this_ptr_conv.is_owned = false;
37328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37329         LDKRoutingFees val_conv;
37330         val_conv.inner = (void*)(val & (~1));
37331         val_conv.is_owned = (val & 1) || (val == 0);
37332         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37333         val_conv = RoutingFees_clone(&val_conv);
37334         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
37335 }
37336
37337 uint32_t  __attribute__((export_name("TS_NodeInfo_get_announcement_info"))) TS_NodeInfo_get_announcement_info(uint32_t this_ptr) {
37338         LDKNodeInfo this_ptr_conv;
37339         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37340         this_ptr_conv.is_owned = false;
37341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37342         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
37343         uint32_t ret_ref = 0;
37344         if ((uintptr_t)ret_var.inner > 4096) {
37345                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37346                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37347         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37348                 ret_ref = (uintptr_t)ret_var.inner;
37349                 if (ret_var.is_owned) {
37350                         ret_ref |= 1;
37351                 }
37352         }
37353         return ret_ref;
37354 }
37355
37356 void  __attribute__((export_name("TS_NodeInfo_set_announcement_info"))) TS_NodeInfo_set_announcement_info(uint32_t this_ptr, uint32_t val) {
37357         LDKNodeInfo this_ptr_conv;
37358         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37359         this_ptr_conv.is_owned = false;
37360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37361         LDKNodeAnnouncementInfo val_conv;
37362         val_conv.inner = (void*)(val & (~1));
37363         val_conv.is_owned = (val & 1) || (val == 0);
37364         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37365         val_conv = NodeAnnouncementInfo_clone(&val_conv);
37366         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
37367 }
37368
37369 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) {
37370         LDKCVec_u64Z channels_arg_constr;
37371         channels_arg_constr.datalen = channels_arg->arr_len;
37372         if (channels_arg_constr.datalen > 0)
37373                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
37374         else
37375                 channels_arg_constr.data = NULL;
37376         int64_t* channels_arg_vals = channels_arg->elems /* XXX channels_arg leaks */;
37377         for (size_t i = 0; i < channels_arg_constr.datalen; i++) {
37378                 int64_t channels_arg_conv_8 = channels_arg_vals[i];
37379                 channels_arg_constr.data[i] = channels_arg_conv_8;
37380         }
37381         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
37382         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
37383         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
37384         CHECK_INNER_FIELD_ACCESS_OR_NULL(lowest_inbound_channel_fees_arg_conv);
37385         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
37386         LDKNodeAnnouncementInfo announcement_info_arg_conv;
37387         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
37388         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
37389         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
37390         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
37391         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
37392         uint32_t ret_ref = 0;
37393         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37394         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37395         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37396         ret_ref = (uintptr_t)ret_var.inner;
37397         if (ret_var.is_owned) {
37398                 ret_ref |= 1;
37399         }
37400         return ret_ref;
37401 }
37402
37403 static inline uintptr_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
37404         LDKNodeInfo ret_var = NodeInfo_clone(arg);
37405 uint32_t ret_ref = 0;
37406 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37407 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37408 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37409 ret_ref = (uintptr_t)ret_var.inner;
37410 if (ret_var.is_owned) {
37411         ret_ref |= 1;
37412 }
37413         return ret_ref;
37414 }
37415 uint32_t  __attribute__((export_name("TS_NodeInfo_clone_ptr"))) TS_NodeInfo_clone_ptr(uint32_t arg) {
37416         LDKNodeInfo arg_conv;
37417         arg_conv.inner = (void*)(arg & (~1));
37418         arg_conv.is_owned = false;
37419         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37420         uint32_t ret_conv = NodeInfo_clone_ptr(&arg_conv);
37421         return ret_conv;
37422 }
37423
37424 uint32_t  __attribute__((export_name("TS_NodeInfo_clone"))) TS_NodeInfo_clone(uint32_t orig) {
37425         LDKNodeInfo orig_conv;
37426         orig_conv.inner = (void*)(orig & (~1));
37427         orig_conv.is_owned = false;
37428         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37429         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
37430         uint32_t ret_ref = 0;
37431         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37432         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37433         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37434         ret_ref = (uintptr_t)ret_var.inner;
37435         if (ret_var.is_owned) {
37436                 ret_ref |= 1;
37437         }
37438         return ret_ref;
37439 }
37440
37441 int8_tArray  __attribute__((export_name("TS_NodeInfo_write"))) TS_NodeInfo_write(uint32_t obj) {
37442         LDKNodeInfo obj_conv;
37443         obj_conv.inner = (void*)(obj & (~1));
37444         obj_conv.is_owned = false;
37445         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37446         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
37447         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37448         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37449         CVec_u8Z_free(ret_var);
37450         return ret_arr;
37451 }
37452
37453 uint32_t  __attribute__((export_name("TS_NodeInfo_read"))) TS_NodeInfo_read(int8_tArray ser) {
37454         LDKu8slice ser_ref;
37455         ser_ref.datalen = ser->arr_len;
37456         ser_ref.data = ser->elems /* XXX ser leaks */;
37457         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
37458         *ret_conv = NodeInfo_read(ser_ref);
37459         return (uint32_t)ret_conv;
37460 }
37461
37462 int8_tArray  __attribute__((export_name("TS_NetworkGraph_write"))) TS_NetworkGraph_write(uint32_t obj) {
37463         LDKNetworkGraph obj_conv;
37464         obj_conv.inner = (void*)(obj & (~1));
37465         obj_conv.is_owned = false;
37466         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37467         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
37468         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37469         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37470         CVec_u8Z_free(ret_var);
37471         return ret_arr;
37472 }
37473
37474 uint32_t  __attribute__((export_name("TS_NetworkGraph_read"))) TS_NetworkGraph_read(int8_tArray ser) {
37475         LDKu8slice ser_ref;
37476         ser_ref.datalen = ser->arr_len;
37477         ser_ref.data = ser->elems /* XXX ser leaks */;
37478         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
37479         *ret_conv = NetworkGraph_read(ser_ref);
37480         return (uint32_t)ret_conv;
37481 }
37482
37483 uint32_t  __attribute__((export_name("TS_NetworkGraph_new"))) TS_NetworkGraph_new(int8_tArray genesis_hash) {
37484         LDKThirtyTwoBytes genesis_hash_ref;
37485         CHECK(genesis_hash->arr_len == 32);
37486         memcpy(genesis_hash_ref.data, genesis_hash->elems, 32); FREE(genesis_hash);
37487         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
37488         uint32_t ret_ref = 0;
37489         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37490         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37491         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37492         ret_ref = (uintptr_t)ret_var.inner;
37493         if (ret_var.is_owned) {
37494                 ret_ref |= 1;
37495         }
37496         return ret_ref;
37497 }
37498
37499 uint32_t  __attribute__((export_name("TS_NetworkGraph_read_only"))) TS_NetworkGraph_read_only(uint32_t this_arg) {
37500         LDKNetworkGraph this_arg_conv;
37501         this_arg_conv.inner = (void*)(this_arg & (~1));
37502         this_arg_conv.is_owned = false;
37503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37504         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
37505         uint32_t ret_ref = 0;
37506         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37507         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37508         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37509         ret_ref = (uintptr_t)ret_var.inner;
37510         if (ret_var.is_owned) {
37511                 ret_ref |= 1;
37512         }
37513         return ret_ref;
37514 }
37515
37516 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_node_from_announcement"))) TS_NetworkGraph_update_node_from_announcement(uint32_t this_arg, uint32_t msg) {
37517         LDKNetworkGraph this_arg_conv;
37518         this_arg_conv.inner = (void*)(this_arg & (~1));
37519         this_arg_conv.is_owned = false;
37520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37521         LDKNodeAnnouncement msg_conv;
37522         msg_conv.inner = (void*)(msg & (~1));
37523         msg_conv.is_owned = false;
37524         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
37525         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
37526         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
37527         return (uint32_t)ret_conv;
37528 }
37529
37530 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) {
37531         LDKNetworkGraph this_arg_conv;
37532         this_arg_conv.inner = (void*)(this_arg & (~1));
37533         this_arg_conv.is_owned = false;
37534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37535         LDKUnsignedNodeAnnouncement msg_conv;
37536         msg_conv.inner = (void*)(msg & (~1));
37537         msg_conv.is_owned = false;
37538         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
37539         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
37540         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
37541         return (uint32_t)ret_conv;
37542 }
37543
37544 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) {
37545         LDKNetworkGraph this_arg_conv;
37546         this_arg_conv.inner = (void*)(this_arg & (~1));
37547         this_arg_conv.is_owned = false;
37548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37549         LDKChannelAnnouncement msg_conv;
37550         msg_conv.inner = (void*)(msg & (~1));
37551         msg_conv.is_owned = false;
37552         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
37553         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
37554         CHECK_ACCESS(chain_access_ptr);
37555         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
37556         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
37557         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
37558                 // Manually implement clone for Java trait instances
37559                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
37560                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37561                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
37562                 }
37563         }
37564         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
37565         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
37566         return (uint32_t)ret_conv;
37567 }
37568
37569 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) {
37570         LDKNetworkGraph this_arg_conv;
37571         this_arg_conv.inner = (void*)(this_arg & (~1));
37572         this_arg_conv.is_owned = false;
37573         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37574         LDKUnsignedChannelAnnouncement msg_conv;
37575         msg_conv.inner = (void*)(msg & (~1));
37576         msg_conv.is_owned = false;
37577         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
37578         void* chain_access_ptr = (void*)(((uintptr_t)chain_access) & ~1);
37579         CHECK_ACCESS(chain_access_ptr);
37580         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
37581         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
37582         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
37583                 // Manually implement clone for Java trait instances
37584                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
37585                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37586                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
37587                 }
37588         }
37589         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
37590         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
37591         return (uint32_t)ret_conv;
37592 }
37593
37594 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) {
37595         LDKNetworkGraph this_arg_conv;
37596         this_arg_conv.inner = (void*)(this_arg & (~1));
37597         this_arg_conv.is_owned = false;
37598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37599         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
37600 }
37601
37602 void  __attribute__((export_name("TS_NetworkGraph_fail_node"))) TS_NetworkGraph_fail_node(uint32_t this_arg, int8_tArray _node_id, jboolean is_permanent) {
37603         LDKNetworkGraph this_arg_conv;
37604         this_arg_conv.inner = (void*)(this_arg & (~1));
37605         this_arg_conv.is_owned = false;
37606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37607         LDKPublicKey _node_id_ref;
37608         CHECK(_node_id->arr_len == 33);
37609         memcpy(_node_id_ref.compressed_form, _node_id->elems, 33); FREE(_node_id);
37610         NetworkGraph_fail_node(&this_arg_conv, _node_id_ref, is_permanent);
37611 }
37612
37613 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) {
37614         LDKNetworkGraph this_arg_conv;
37615         this_arg_conv.inner = (void*)(this_arg & (~1));
37616         this_arg_conv.is_owned = false;
37617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37618         NetworkGraph_remove_stale_channels_with_time(&this_arg_conv, current_time_unix);
37619 }
37620
37621 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_channel"))) TS_NetworkGraph_update_channel(uint32_t this_arg, uint32_t msg) {
37622         LDKNetworkGraph this_arg_conv;
37623         this_arg_conv.inner = (void*)(this_arg & (~1));
37624         this_arg_conv.is_owned = false;
37625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37626         LDKChannelUpdate msg_conv;
37627         msg_conv.inner = (void*)(msg & (~1));
37628         msg_conv.is_owned = false;
37629         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
37630         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
37631         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
37632         return (uint32_t)ret_conv;
37633 }
37634
37635 uint32_t  __attribute__((export_name("TS_NetworkGraph_update_channel_unsigned"))) TS_NetworkGraph_update_channel_unsigned(uint32_t this_arg, uint32_t msg) {
37636         LDKNetworkGraph this_arg_conv;
37637         this_arg_conv.inner = (void*)(this_arg & (~1));
37638         this_arg_conv.is_owned = false;
37639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37640         LDKUnsignedChannelUpdate msg_conv;
37641         msg_conv.inner = (void*)(msg & (~1));
37642         msg_conv.is_owned = false;
37643         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
37644         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
37645         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
37646         return (uint32_t)ret_conv;
37647 }
37648
37649 uint32_t  __attribute__((export_name("TS_ReadOnlyNetworkGraph_get_addresses"))) TS_ReadOnlyNetworkGraph_get_addresses(uint32_t this_arg, int8_tArray pubkey) {
37650         LDKReadOnlyNetworkGraph this_arg_conv;
37651         this_arg_conv.inner = (void*)(this_arg & (~1));
37652         this_arg_conv.is_owned = false;
37653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37654         LDKPublicKey pubkey_ref;
37655         CHECK(pubkey->arr_len == 33);
37656         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
37657         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
37658         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
37659         uint32_t ret_ref = (uintptr_t)ret_copy;
37660         return ret_ref;
37661 }
37662
37663 void  __attribute__((export_name("TS_RouteHop_free"))) TS_RouteHop_free(uint32_t this_obj) {
37664         LDKRouteHop this_obj_conv;
37665         this_obj_conv.inner = (void*)(this_obj & (~1));
37666         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37668         RouteHop_free(this_obj_conv);
37669 }
37670
37671 int8_tArray  __attribute__((export_name("TS_RouteHop_get_pubkey"))) TS_RouteHop_get_pubkey(uint32_t this_ptr) {
37672         LDKRouteHop this_ptr_conv;
37673         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37674         this_ptr_conv.is_owned = false;
37675         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37676         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
37677         memcpy(ret_arr->elems, RouteHop_get_pubkey(&this_ptr_conv).compressed_form, 33);
37678         return ret_arr;
37679 }
37680
37681 void  __attribute__((export_name("TS_RouteHop_set_pubkey"))) TS_RouteHop_set_pubkey(uint32_t this_ptr, int8_tArray val) {
37682         LDKRouteHop this_ptr_conv;
37683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37684         this_ptr_conv.is_owned = false;
37685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37686         LDKPublicKey val_ref;
37687         CHECK(val->arr_len == 33);
37688         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
37689         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
37690 }
37691
37692 uint32_t  __attribute__((export_name("TS_RouteHop_get_node_features"))) TS_RouteHop_get_node_features(uint32_t this_ptr) {
37693         LDKRouteHop this_ptr_conv;
37694         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37695         this_ptr_conv.is_owned = false;
37696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37697         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
37698         uint32_t ret_ref = 0;
37699         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37700         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37701         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37702         ret_ref = (uintptr_t)ret_var.inner;
37703         if (ret_var.is_owned) {
37704                 ret_ref |= 1;
37705         }
37706         return ret_ref;
37707 }
37708
37709 void  __attribute__((export_name("TS_RouteHop_set_node_features"))) TS_RouteHop_set_node_features(uint32_t this_ptr, uint32_t val) {
37710         LDKRouteHop this_ptr_conv;
37711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37712         this_ptr_conv.is_owned = false;
37713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37714         LDKNodeFeatures val_conv;
37715         val_conv.inner = (void*)(val & (~1));
37716         val_conv.is_owned = (val & 1) || (val == 0);
37717         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37718         val_conv = NodeFeatures_clone(&val_conv);
37719         RouteHop_set_node_features(&this_ptr_conv, val_conv);
37720 }
37721
37722 int64_t  __attribute__((export_name("TS_RouteHop_get_short_channel_id"))) TS_RouteHop_get_short_channel_id(uint32_t this_ptr) {
37723         LDKRouteHop this_ptr_conv;
37724         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37725         this_ptr_conv.is_owned = false;
37726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37727         int64_t ret_conv = RouteHop_get_short_channel_id(&this_ptr_conv);
37728         return ret_conv;
37729 }
37730
37731 void  __attribute__((export_name("TS_RouteHop_set_short_channel_id"))) TS_RouteHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
37732         LDKRouteHop this_ptr_conv;
37733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37734         this_ptr_conv.is_owned = false;
37735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37736         RouteHop_set_short_channel_id(&this_ptr_conv, val);
37737 }
37738
37739 uint32_t  __attribute__((export_name("TS_RouteHop_get_channel_features"))) TS_RouteHop_get_channel_features(uint32_t this_ptr) {
37740         LDKRouteHop this_ptr_conv;
37741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37742         this_ptr_conv.is_owned = false;
37743         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37744         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
37745         uint32_t ret_ref = 0;
37746         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37747         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37748         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37749         ret_ref = (uintptr_t)ret_var.inner;
37750         if (ret_var.is_owned) {
37751                 ret_ref |= 1;
37752         }
37753         return ret_ref;
37754 }
37755
37756 void  __attribute__((export_name("TS_RouteHop_set_channel_features"))) TS_RouteHop_set_channel_features(uint32_t this_ptr, uint32_t val) {
37757         LDKRouteHop this_ptr_conv;
37758         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37759         this_ptr_conv.is_owned = false;
37760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37761         LDKChannelFeatures val_conv;
37762         val_conv.inner = (void*)(val & (~1));
37763         val_conv.is_owned = (val & 1) || (val == 0);
37764         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37765         val_conv = ChannelFeatures_clone(&val_conv);
37766         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
37767 }
37768
37769 int64_t  __attribute__((export_name("TS_RouteHop_get_fee_msat"))) TS_RouteHop_get_fee_msat(uint32_t this_ptr) {
37770         LDKRouteHop this_ptr_conv;
37771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37772         this_ptr_conv.is_owned = false;
37773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37774         int64_t ret_conv = RouteHop_get_fee_msat(&this_ptr_conv);
37775         return ret_conv;
37776 }
37777
37778 void  __attribute__((export_name("TS_RouteHop_set_fee_msat"))) TS_RouteHop_set_fee_msat(uint32_t this_ptr, int64_t val) {
37779         LDKRouteHop this_ptr_conv;
37780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37781         this_ptr_conv.is_owned = false;
37782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37783         RouteHop_set_fee_msat(&this_ptr_conv, val);
37784 }
37785
37786 int32_t  __attribute__((export_name("TS_RouteHop_get_cltv_expiry_delta"))) TS_RouteHop_get_cltv_expiry_delta(uint32_t this_ptr) {
37787         LDKRouteHop this_ptr_conv;
37788         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37789         this_ptr_conv.is_owned = false;
37790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37791         int32_t ret_conv = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
37792         return ret_conv;
37793 }
37794
37795 void  __attribute__((export_name("TS_RouteHop_set_cltv_expiry_delta"))) TS_RouteHop_set_cltv_expiry_delta(uint32_t this_ptr, int32_t val) {
37796         LDKRouteHop this_ptr_conv;
37797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37798         this_ptr_conv.is_owned = false;
37799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37800         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
37801 }
37802
37803 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) {
37804         LDKPublicKey pubkey_arg_ref;
37805         CHECK(pubkey_arg->arr_len == 33);
37806         memcpy(pubkey_arg_ref.compressed_form, pubkey_arg->elems, 33); FREE(pubkey_arg);
37807         LDKNodeFeatures node_features_arg_conv;
37808         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
37809         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
37810         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
37811         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
37812         LDKChannelFeatures channel_features_arg_conv;
37813         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
37814         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
37815         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
37816         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
37817         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);
37818         uint32_t ret_ref = 0;
37819         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37820         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37821         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37822         ret_ref = (uintptr_t)ret_var.inner;
37823         if (ret_var.is_owned) {
37824                 ret_ref |= 1;
37825         }
37826         return ret_ref;
37827 }
37828
37829 static inline uintptr_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
37830         LDKRouteHop ret_var = RouteHop_clone(arg);
37831 uint32_t ret_ref = 0;
37832 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37833 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37834 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37835 ret_ref = (uintptr_t)ret_var.inner;
37836 if (ret_var.is_owned) {
37837         ret_ref |= 1;
37838 }
37839         return ret_ref;
37840 }
37841 uint32_t  __attribute__((export_name("TS_RouteHop_clone_ptr"))) TS_RouteHop_clone_ptr(uint32_t arg) {
37842         LDKRouteHop arg_conv;
37843         arg_conv.inner = (void*)(arg & (~1));
37844         arg_conv.is_owned = false;
37845         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37846         uint32_t ret_conv = RouteHop_clone_ptr(&arg_conv);
37847         return ret_conv;
37848 }
37849
37850 uint32_t  __attribute__((export_name("TS_RouteHop_clone"))) TS_RouteHop_clone(uint32_t orig) {
37851         LDKRouteHop orig_conv;
37852         orig_conv.inner = (void*)(orig & (~1));
37853         orig_conv.is_owned = false;
37854         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37855         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
37856         uint32_t ret_ref = 0;
37857         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37858         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37859         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37860         ret_ref = (uintptr_t)ret_var.inner;
37861         if (ret_var.is_owned) {
37862                 ret_ref |= 1;
37863         }
37864         return ret_ref;
37865 }
37866
37867 int64_t  __attribute__((export_name("TS_RouteHop_hash"))) TS_RouteHop_hash(uint32_t o) {
37868         LDKRouteHop o_conv;
37869         o_conv.inner = (void*)(o & (~1));
37870         o_conv.is_owned = false;
37871         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
37872         int64_t ret_conv = RouteHop_hash(&o_conv);
37873         return ret_conv;
37874 }
37875
37876 jboolean  __attribute__((export_name("TS_RouteHop_eq"))) TS_RouteHop_eq(uint32_t a, uint32_t b) {
37877         LDKRouteHop a_conv;
37878         a_conv.inner = (void*)(a & (~1));
37879         a_conv.is_owned = false;
37880         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37881         LDKRouteHop b_conv;
37882         b_conv.inner = (void*)(b & (~1));
37883         b_conv.is_owned = false;
37884         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37885         jboolean ret_conv = RouteHop_eq(&a_conv, &b_conv);
37886         return ret_conv;
37887 }
37888
37889 int8_tArray  __attribute__((export_name("TS_RouteHop_write"))) TS_RouteHop_write(uint32_t obj) {
37890         LDKRouteHop obj_conv;
37891         obj_conv.inner = (void*)(obj & (~1));
37892         obj_conv.is_owned = false;
37893         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37894         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
37895         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
37896         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
37897         CVec_u8Z_free(ret_var);
37898         return ret_arr;
37899 }
37900
37901 uint32_t  __attribute__((export_name("TS_RouteHop_read"))) TS_RouteHop_read(int8_tArray ser) {
37902         LDKu8slice ser_ref;
37903         ser_ref.datalen = ser->arr_len;
37904         ser_ref.data = ser->elems /* XXX ser leaks */;
37905         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
37906         *ret_conv = RouteHop_read(ser_ref);
37907         return (uint32_t)ret_conv;
37908 }
37909
37910 void  __attribute__((export_name("TS_Route_free"))) TS_Route_free(uint32_t this_obj) {
37911         LDKRoute this_obj_conv;
37912         this_obj_conv.inner = (void*)(this_obj & (~1));
37913         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37915         Route_free(this_obj_conv);
37916 }
37917
37918 ptrArray  __attribute__((export_name("TS_Route_get_paths"))) TS_Route_get_paths(uint32_t this_ptr) {
37919         LDKRoute this_ptr_conv;
37920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37921         this_ptr_conv.is_owned = false;
37922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37923         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
37924         ptrArray ret_arr = NULL;
37925         ret_arr = init_ptrArray(ret_var.datalen, __LINE__);
37926         uint32_tArray *ret_arr_ptr = (uint32_tArray*)(((uint8_t*)ret_arr) + 4);
37927         for (size_t m = 0; m < ret_var.datalen; m++) {
37928                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
37929                 uint32_tArray ret_conv_12_arr = NULL;
37930                 ret_conv_12_arr = init_uint32_tArray(ret_conv_12_var.datalen, __LINE__);
37931                 uint32_t *ret_conv_12_arr_ptr = (uint32_t*)(((uint8_t*)ret_conv_12_arr) + 4);
37932                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
37933                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
37934                         uint32_t ret_conv_12_conv_10_ref = 0;
37935                         CHECK((((uintptr_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37936                         CHECK((((uintptr_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37937                         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_conv_10_var);
37938                         ret_conv_12_conv_10_ref = (uintptr_t)ret_conv_12_conv_10_var.inner;
37939                         if (ret_conv_12_conv_10_var.is_owned) {
37940                                 ret_conv_12_conv_10_ref |= 1;
37941                         }
37942                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
37943                 }
37944                 
37945                 FREE(ret_conv_12_var.data);
37946                 ret_arr_ptr[m] = ret_conv_12_arr;
37947         }
37948         
37949         FREE(ret_var.data);
37950         return ret_arr;
37951 }
37952
37953 void  __attribute__((export_name("TS_Route_set_paths"))) TS_Route_set_paths(uint32_t this_ptr, ptrArray val) {
37954         LDKRoute this_ptr_conv;
37955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37956         this_ptr_conv.is_owned = false;
37957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37958         LDKCVec_CVec_RouteHopZZ val_constr;
37959         val_constr.datalen = val->arr_len;
37960         if (val_constr.datalen > 0)
37961                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
37962         else
37963                 val_constr.data = NULL;
37964         uint32_tArray* val_vals = (void*) val->elems /* XXX val leaks */;
37965         for (size_t m = 0; m < val_constr.datalen; m++) {
37966                 uint32_tArray val_conv_12 = val_vals[m];
37967                 LDKCVec_RouteHopZ val_conv_12_constr;
37968                 val_conv_12_constr.datalen = val_conv_12->arr_len;
37969                 if (val_conv_12_constr.datalen > 0)
37970                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
37971                 else
37972                         val_conv_12_constr.data = NULL;
37973                 uint32_t* val_conv_12_vals = val_conv_12->elems /* XXX val_conv_12 leaks */;
37974                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
37975                         uint32_t val_conv_12_conv_10 = val_conv_12_vals[k];
37976                         LDKRouteHop val_conv_12_conv_10_conv;
37977                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
37978                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
37979                         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv_10_conv);
37980                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
37981                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
37982                 }
37983                 val_constr.data[m] = val_conv_12_constr;
37984         }
37985         Route_set_paths(&this_ptr_conv, val_constr);
37986 }
37987
37988 uint32_t  __attribute__((export_name("TS_Route_get_payment_params"))) TS_Route_get_payment_params(uint32_t this_ptr) {
37989         LDKRoute this_ptr_conv;
37990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37991         this_ptr_conv.is_owned = false;
37992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37993         LDKPaymentParameters ret_var = Route_get_payment_params(&this_ptr_conv);
37994         uint32_t ret_ref = 0;
37995         if ((uintptr_t)ret_var.inner > 4096) {
37996                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37997                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37998         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37999                 ret_ref = (uintptr_t)ret_var.inner;
38000                 if (ret_var.is_owned) {
38001                         ret_ref |= 1;
38002                 }
38003         }
38004         return ret_ref;
38005 }
38006
38007 void  __attribute__((export_name("TS_Route_set_payment_params"))) TS_Route_set_payment_params(uint32_t this_ptr, uint32_t val) {
38008         LDKRoute this_ptr_conv;
38009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38010         this_ptr_conv.is_owned = false;
38011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38012         LDKPaymentParameters val_conv;
38013         val_conv.inner = (void*)(val & (~1));
38014         val_conv.is_owned = (val & 1) || (val == 0);
38015         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38016         val_conv = PaymentParameters_clone(&val_conv);
38017         Route_set_payment_params(&this_ptr_conv, val_conv);
38018 }
38019
38020 uint32_t  __attribute__((export_name("TS_Route_new"))) TS_Route_new(ptrArray paths_arg, uint32_t payment_params_arg) {
38021         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
38022         paths_arg_constr.datalen = paths_arg->arr_len;
38023         if (paths_arg_constr.datalen > 0)
38024                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
38025         else
38026                 paths_arg_constr.data = NULL;
38027         uint32_tArray* paths_arg_vals = (void*) paths_arg->elems /* XXX paths_arg leaks */;
38028         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
38029                 uint32_tArray paths_arg_conv_12 = paths_arg_vals[m];
38030                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
38031                 paths_arg_conv_12_constr.datalen = paths_arg_conv_12->arr_len;
38032                 if (paths_arg_conv_12_constr.datalen > 0)
38033                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
38034                 else
38035                         paths_arg_conv_12_constr.data = NULL;
38036                 uint32_t* paths_arg_conv_12_vals = paths_arg_conv_12->elems /* XXX paths_arg_conv_12 leaks */;
38037                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
38038                         uint32_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
38039                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
38040                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
38041                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
38042                         CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_12_conv_10_conv);
38043                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
38044                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
38045                 }
38046                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
38047         }
38048         LDKPaymentParameters payment_params_arg_conv;
38049         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
38050         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
38051         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
38052         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
38053         LDKRoute ret_var = Route_new(paths_arg_constr, payment_params_arg_conv);
38054         uint32_t ret_ref = 0;
38055         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38056         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38057         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38058         ret_ref = (uintptr_t)ret_var.inner;
38059         if (ret_var.is_owned) {
38060                 ret_ref |= 1;
38061         }
38062         return ret_ref;
38063 }
38064
38065 static inline uintptr_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
38066         LDKRoute ret_var = Route_clone(arg);
38067 uint32_t ret_ref = 0;
38068 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38069 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38070 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38071 ret_ref = (uintptr_t)ret_var.inner;
38072 if (ret_var.is_owned) {
38073         ret_ref |= 1;
38074 }
38075         return ret_ref;
38076 }
38077 uint32_t  __attribute__((export_name("TS_Route_clone_ptr"))) TS_Route_clone_ptr(uint32_t arg) {
38078         LDKRoute arg_conv;
38079         arg_conv.inner = (void*)(arg & (~1));
38080         arg_conv.is_owned = false;
38081         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38082         uint32_t ret_conv = Route_clone_ptr(&arg_conv);
38083         return ret_conv;
38084 }
38085
38086 uint32_t  __attribute__((export_name("TS_Route_clone"))) TS_Route_clone(uint32_t orig) {
38087         LDKRoute orig_conv;
38088         orig_conv.inner = (void*)(orig & (~1));
38089         orig_conv.is_owned = false;
38090         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38091         LDKRoute ret_var = Route_clone(&orig_conv);
38092         uint32_t ret_ref = 0;
38093         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38094         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38095         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38096         ret_ref = (uintptr_t)ret_var.inner;
38097         if (ret_var.is_owned) {
38098                 ret_ref |= 1;
38099         }
38100         return ret_ref;
38101 }
38102
38103 int64_t  __attribute__((export_name("TS_Route_hash"))) TS_Route_hash(uint32_t o) {
38104         LDKRoute o_conv;
38105         o_conv.inner = (void*)(o & (~1));
38106         o_conv.is_owned = false;
38107         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38108         int64_t ret_conv = Route_hash(&o_conv);
38109         return ret_conv;
38110 }
38111
38112 jboolean  __attribute__((export_name("TS_Route_eq"))) TS_Route_eq(uint32_t a, uint32_t b) {
38113         LDKRoute a_conv;
38114         a_conv.inner = (void*)(a & (~1));
38115         a_conv.is_owned = false;
38116         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38117         LDKRoute b_conv;
38118         b_conv.inner = (void*)(b & (~1));
38119         b_conv.is_owned = false;
38120         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38121         jboolean ret_conv = Route_eq(&a_conv, &b_conv);
38122         return ret_conv;
38123 }
38124
38125 int64_t  __attribute__((export_name("TS_Route_get_total_fees"))) TS_Route_get_total_fees(uint32_t this_arg) {
38126         LDKRoute this_arg_conv;
38127         this_arg_conv.inner = (void*)(this_arg & (~1));
38128         this_arg_conv.is_owned = false;
38129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38130         int64_t ret_conv = Route_get_total_fees(&this_arg_conv);
38131         return ret_conv;
38132 }
38133
38134 int64_t  __attribute__((export_name("TS_Route_get_total_amount"))) TS_Route_get_total_amount(uint32_t this_arg) {
38135         LDKRoute this_arg_conv;
38136         this_arg_conv.inner = (void*)(this_arg & (~1));
38137         this_arg_conv.is_owned = false;
38138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38139         int64_t ret_conv = Route_get_total_amount(&this_arg_conv);
38140         return ret_conv;
38141 }
38142
38143 int8_tArray  __attribute__((export_name("TS_Route_write"))) TS_Route_write(uint32_t obj) {
38144         LDKRoute obj_conv;
38145         obj_conv.inner = (void*)(obj & (~1));
38146         obj_conv.is_owned = false;
38147         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38148         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
38149         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38150         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38151         CVec_u8Z_free(ret_var);
38152         return ret_arr;
38153 }
38154
38155 uint32_t  __attribute__((export_name("TS_Route_read"))) TS_Route_read(int8_tArray ser) {
38156         LDKu8slice ser_ref;
38157         ser_ref.datalen = ser->arr_len;
38158         ser_ref.data = ser->elems /* XXX ser leaks */;
38159         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
38160         *ret_conv = Route_read(ser_ref);
38161         return (uint32_t)ret_conv;
38162 }
38163
38164 void  __attribute__((export_name("TS_RouteParameters_free"))) TS_RouteParameters_free(uint32_t this_obj) {
38165         LDKRouteParameters this_obj_conv;
38166         this_obj_conv.inner = (void*)(this_obj & (~1));
38167         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38169         RouteParameters_free(this_obj_conv);
38170 }
38171
38172 uint32_t  __attribute__((export_name("TS_RouteParameters_get_payment_params"))) TS_RouteParameters_get_payment_params(uint32_t this_ptr) {
38173         LDKRouteParameters this_ptr_conv;
38174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38175         this_ptr_conv.is_owned = false;
38176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38177         LDKPaymentParameters ret_var = RouteParameters_get_payment_params(&this_ptr_conv);
38178         uint32_t ret_ref = 0;
38179         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38180         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38181         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38182         ret_ref = (uintptr_t)ret_var.inner;
38183         if (ret_var.is_owned) {
38184                 ret_ref |= 1;
38185         }
38186         return ret_ref;
38187 }
38188
38189 void  __attribute__((export_name("TS_RouteParameters_set_payment_params"))) TS_RouteParameters_set_payment_params(uint32_t this_ptr, uint32_t val) {
38190         LDKRouteParameters this_ptr_conv;
38191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38192         this_ptr_conv.is_owned = false;
38193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38194         LDKPaymentParameters val_conv;
38195         val_conv.inner = (void*)(val & (~1));
38196         val_conv.is_owned = (val & 1) || (val == 0);
38197         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38198         val_conv = PaymentParameters_clone(&val_conv);
38199         RouteParameters_set_payment_params(&this_ptr_conv, val_conv);
38200 }
38201
38202 int64_t  __attribute__((export_name("TS_RouteParameters_get_final_value_msat"))) TS_RouteParameters_get_final_value_msat(uint32_t this_ptr) {
38203         LDKRouteParameters this_ptr_conv;
38204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38205         this_ptr_conv.is_owned = false;
38206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38207         int64_t ret_conv = RouteParameters_get_final_value_msat(&this_ptr_conv);
38208         return ret_conv;
38209 }
38210
38211 void  __attribute__((export_name("TS_RouteParameters_set_final_value_msat"))) TS_RouteParameters_set_final_value_msat(uint32_t this_ptr, int64_t val) {
38212         LDKRouteParameters this_ptr_conv;
38213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38214         this_ptr_conv.is_owned = false;
38215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38216         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
38217 }
38218
38219 int32_t  __attribute__((export_name("TS_RouteParameters_get_final_cltv_expiry_delta"))) TS_RouteParameters_get_final_cltv_expiry_delta(uint32_t this_ptr) {
38220         LDKRouteParameters this_ptr_conv;
38221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38222         this_ptr_conv.is_owned = false;
38223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38224         int32_t ret_conv = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
38225         return ret_conv;
38226 }
38227
38228 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) {
38229         LDKRouteParameters this_ptr_conv;
38230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38231         this_ptr_conv.is_owned = false;
38232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38233         RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
38234 }
38235
38236 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) {
38237         LDKPaymentParameters payment_params_arg_conv;
38238         payment_params_arg_conv.inner = (void*)(payment_params_arg & (~1));
38239         payment_params_arg_conv.is_owned = (payment_params_arg & 1) || (payment_params_arg == 0);
38240         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
38241         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
38242         LDKRouteParameters ret_var = RouteParameters_new(payment_params_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
38243         uint32_t ret_ref = 0;
38244         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38245         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38246         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38247         ret_ref = (uintptr_t)ret_var.inner;
38248         if (ret_var.is_owned) {
38249                 ret_ref |= 1;
38250         }
38251         return ret_ref;
38252 }
38253
38254 static inline uintptr_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
38255         LDKRouteParameters ret_var = RouteParameters_clone(arg);
38256 uint32_t ret_ref = 0;
38257 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38258 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38259 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38260 ret_ref = (uintptr_t)ret_var.inner;
38261 if (ret_var.is_owned) {
38262         ret_ref |= 1;
38263 }
38264         return ret_ref;
38265 }
38266 uint32_t  __attribute__((export_name("TS_RouteParameters_clone_ptr"))) TS_RouteParameters_clone_ptr(uint32_t arg) {
38267         LDKRouteParameters arg_conv;
38268         arg_conv.inner = (void*)(arg & (~1));
38269         arg_conv.is_owned = false;
38270         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38271         uint32_t ret_conv = RouteParameters_clone_ptr(&arg_conv);
38272         return ret_conv;
38273 }
38274
38275 uint32_t  __attribute__((export_name("TS_RouteParameters_clone"))) TS_RouteParameters_clone(uint32_t orig) {
38276         LDKRouteParameters orig_conv;
38277         orig_conv.inner = (void*)(orig & (~1));
38278         orig_conv.is_owned = false;
38279         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38280         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
38281         uint32_t ret_ref = 0;
38282         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38283         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38284         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38285         ret_ref = (uintptr_t)ret_var.inner;
38286         if (ret_var.is_owned) {
38287                 ret_ref |= 1;
38288         }
38289         return ret_ref;
38290 }
38291
38292 int8_tArray  __attribute__((export_name("TS_RouteParameters_write"))) TS_RouteParameters_write(uint32_t obj) {
38293         LDKRouteParameters obj_conv;
38294         obj_conv.inner = (void*)(obj & (~1));
38295         obj_conv.is_owned = false;
38296         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38297         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
38298         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38299         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38300         CVec_u8Z_free(ret_var);
38301         return ret_arr;
38302 }
38303
38304 uint32_t  __attribute__((export_name("TS_RouteParameters_read"))) TS_RouteParameters_read(int8_tArray ser) {
38305         LDKu8slice ser_ref;
38306         ser_ref.datalen = ser->arr_len;
38307         ser_ref.data = ser->elems /* XXX ser leaks */;
38308         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
38309         *ret_conv = RouteParameters_read(ser_ref);
38310         return (uint32_t)ret_conv;
38311 }
38312
38313 void  __attribute__((export_name("TS_PaymentParameters_free"))) TS_PaymentParameters_free(uint32_t this_obj) {
38314         LDKPaymentParameters this_obj_conv;
38315         this_obj_conv.inner = (void*)(this_obj & (~1));
38316         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38318         PaymentParameters_free(this_obj_conv);
38319 }
38320
38321 int8_tArray  __attribute__((export_name("TS_PaymentParameters_get_payee_pubkey"))) TS_PaymentParameters_get_payee_pubkey(uint32_t this_ptr) {
38322         LDKPaymentParameters this_ptr_conv;
38323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38324         this_ptr_conv.is_owned = false;
38325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38326         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
38327         memcpy(ret_arr->elems, PaymentParameters_get_payee_pubkey(&this_ptr_conv).compressed_form, 33);
38328         return ret_arr;
38329 }
38330
38331 void  __attribute__((export_name("TS_PaymentParameters_set_payee_pubkey"))) TS_PaymentParameters_set_payee_pubkey(uint32_t this_ptr, int8_tArray val) {
38332         LDKPaymentParameters this_ptr_conv;
38333         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38334         this_ptr_conv.is_owned = false;
38335         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38336         LDKPublicKey val_ref;
38337         CHECK(val->arr_len == 33);
38338         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
38339         PaymentParameters_set_payee_pubkey(&this_ptr_conv, val_ref);
38340 }
38341
38342 uint32_t  __attribute__((export_name("TS_PaymentParameters_get_features"))) TS_PaymentParameters_get_features(uint32_t this_ptr) {
38343         LDKPaymentParameters this_ptr_conv;
38344         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38345         this_ptr_conv.is_owned = false;
38346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38347         LDKInvoiceFeatures ret_var = PaymentParameters_get_features(&this_ptr_conv);
38348         uint32_t ret_ref = 0;
38349         if ((uintptr_t)ret_var.inner > 4096) {
38350                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38351                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38352         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38353                 ret_ref = (uintptr_t)ret_var.inner;
38354                 if (ret_var.is_owned) {
38355                         ret_ref |= 1;
38356                 }
38357         }
38358         return ret_ref;
38359 }
38360
38361 void  __attribute__((export_name("TS_PaymentParameters_set_features"))) TS_PaymentParameters_set_features(uint32_t this_ptr, uint32_t val) {
38362         LDKPaymentParameters this_ptr_conv;
38363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38364         this_ptr_conv.is_owned = false;
38365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38366         LDKInvoiceFeatures val_conv;
38367         val_conv.inner = (void*)(val & (~1));
38368         val_conv.is_owned = (val & 1) || (val == 0);
38369         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38370         val_conv = InvoiceFeatures_clone(&val_conv);
38371         PaymentParameters_set_features(&this_ptr_conv, val_conv);
38372 }
38373
38374 uint32_tArray  __attribute__((export_name("TS_PaymentParameters_get_route_hints"))) TS_PaymentParameters_get_route_hints(uint32_t this_ptr) {
38375         LDKPaymentParameters this_ptr_conv;
38376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38377         this_ptr_conv.is_owned = false;
38378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38379         LDKCVec_RouteHintZ ret_var = PaymentParameters_get_route_hints(&this_ptr_conv);
38380         uint32_tArray ret_arr = NULL;
38381         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
38382         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
38383         for (size_t l = 0; l < ret_var.datalen; l++) {
38384                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
38385                 uint32_t ret_conv_11_ref = 0;
38386                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38387                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38388                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
38389                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
38390                 if (ret_conv_11_var.is_owned) {
38391                         ret_conv_11_ref |= 1;
38392                 }
38393                 ret_arr_ptr[l] = ret_conv_11_ref;
38394         }
38395         
38396         FREE(ret_var.data);
38397         return ret_arr;
38398 }
38399
38400 void  __attribute__((export_name("TS_PaymentParameters_set_route_hints"))) TS_PaymentParameters_set_route_hints(uint32_t this_ptr, uint32_tArray val) {
38401         LDKPaymentParameters this_ptr_conv;
38402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38403         this_ptr_conv.is_owned = false;
38404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38405         LDKCVec_RouteHintZ val_constr;
38406         val_constr.datalen = val->arr_len;
38407         if (val_constr.datalen > 0)
38408                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
38409         else
38410                 val_constr.data = NULL;
38411         uint32_t* val_vals = val->elems /* XXX val leaks */;
38412         for (size_t l = 0; l < val_constr.datalen; l++) {
38413                 uint32_t val_conv_11 = val_vals[l];
38414                 LDKRouteHint val_conv_11_conv;
38415                 val_conv_11_conv.inner = (void*)(val_conv_11 & (~1));
38416                 val_conv_11_conv.is_owned = (val_conv_11 & 1) || (val_conv_11 == 0);
38417                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_11_conv);
38418                 val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
38419                 val_constr.data[l] = val_conv_11_conv;
38420         }
38421         PaymentParameters_set_route_hints(&this_ptr_conv, val_constr);
38422 }
38423
38424 uint32_t  __attribute__((export_name("TS_PaymentParameters_get_expiry_time"))) TS_PaymentParameters_get_expiry_time(uint32_t this_ptr) {
38425         LDKPaymentParameters this_ptr_conv;
38426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38427         this_ptr_conv.is_owned = false;
38428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38429         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
38430         *ret_copy = PaymentParameters_get_expiry_time(&this_ptr_conv);
38431         uint32_t ret_ref = (uintptr_t)ret_copy;
38432         return ret_ref;
38433 }
38434
38435 void  __attribute__((export_name("TS_PaymentParameters_set_expiry_time"))) TS_PaymentParameters_set_expiry_time(uint32_t this_ptr, uint32_t val) {
38436         LDKPaymentParameters this_ptr_conv;
38437         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38438         this_ptr_conv.is_owned = false;
38439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38440         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
38441         CHECK_ACCESS(val_ptr);
38442         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
38443         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
38444         PaymentParameters_set_expiry_time(&this_ptr_conv, val_conv);
38445 }
38446
38447 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) {
38448         LDKPaymentParameters this_ptr_conv;
38449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38450         this_ptr_conv.is_owned = false;
38451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38452         int32_t ret_conv = PaymentParameters_get_max_total_cltv_expiry_delta(&this_ptr_conv);
38453         return ret_conv;
38454 }
38455
38456 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) {
38457         LDKPaymentParameters this_ptr_conv;
38458         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38459         this_ptr_conv.is_owned = false;
38460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38461         PaymentParameters_set_max_total_cltv_expiry_delta(&this_ptr_conv, val);
38462 }
38463
38464 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) {
38465         LDKPublicKey payee_pubkey_arg_ref;
38466         CHECK(payee_pubkey_arg->arr_len == 33);
38467         memcpy(payee_pubkey_arg_ref.compressed_form, payee_pubkey_arg->elems, 33); FREE(payee_pubkey_arg);
38468         LDKInvoiceFeatures features_arg_conv;
38469         features_arg_conv.inner = (void*)(features_arg & (~1));
38470         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
38471         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
38472         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
38473         LDKCVec_RouteHintZ route_hints_arg_constr;
38474         route_hints_arg_constr.datalen = route_hints_arg->arr_len;
38475         if (route_hints_arg_constr.datalen > 0)
38476                 route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
38477         else
38478                 route_hints_arg_constr.data = NULL;
38479         uint32_t* route_hints_arg_vals = route_hints_arg->elems /* XXX route_hints_arg leaks */;
38480         for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
38481                 uint32_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
38482                 LDKRouteHint route_hints_arg_conv_11_conv;
38483                 route_hints_arg_conv_11_conv.inner = (void*)(route_hints_arg_conv_11 & (~1));
38484                 route_hints_arg_conv_11_conv.is_owned = (route_hints_arg_conv_11 & 1) || (route_hints_arg_conv_11 == 0);
38485                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_arg_conv_11_conv);
38486                 route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
38487                 route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
38488         }
38489         void* expiry_time_arg_ptr = (void*)(((uintptr_t)expiry_time_arg) & ~1);
38490         CHECK_ACCESS(expiry_time_arg_ptr);
38491         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
38492         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)expiry_time_arg) & ~1));
38493         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);
38494         uint32_t ret_ref = 0;
38495         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38496         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38497         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38498         ret_ref = (uintptr_t)ret_var.inner;
38499         if (ret_var.is_owned) {
38500                 ret_ref |= 1;
38501         }
38502         return ret_ref;
38503 }
38504
38505 static inline uintptr_t PaymentParameters_clone_ptr(LDKPaymentParameters *NONNULL_PTR arg) {
38506         LDKPaymentParameters ret_var = PaymentParameters_clone(arg);
38507 uint32_t ret_ref = 0;
38508 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38509 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38510 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38511 ret_ref = (uintptr_t)ret_var.inner;
38512 if (ret_var.is_owned) {
38513         ret_ref |= 1;
38514 }
38515         return ret_ref;
38516 }
38517 uint32_t  __attribute__((export_name("TS_PaymentParameters_clone_ptr"))) TS_PaymentParameters_clone_ptr(uint32_t arg) {
38518         LDKPaymentParameters arg_conv;
38519         arg_conv.inner = (void*)(arg & (~1));
38520         arg_conv.is_owned = false;
38521         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38522         uint32_t ret_conv = PaymentParameters_clone_ptr(&arg_conv);
38523         return ret_conv;
38524 }
38525
38526 uint32_t  __attribute__((export_name("TS_PaymentParameters_clone"))) TS_PaymentParameters_clone(uint32_t orig) {
38527         LDKPaymentParameters orig_conv;
38528         orig_conv.inner = (void*)(orig & (~1));
38529         orig_conv.is_owned = false;
38530         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38531         LDKPaymentParameters ret_var = PaymentParameters_clone(&orig_conv);
38532         uint32_t ret_ref = 0;
38533         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38534         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38535         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38536         ret_ref = (uintptr_t)ret_var.inner;
38537         if (ret_var.is_owned) {
38538                 ret_ref |= 1;
38539         }
38540         return ret_ref;
38541 }
38542
38543 int64_t  __attribute__((export_name("TS_PaymentParameters_hash"))) TS_PaymentParameters_hash(uint32_t o) {
38544         LDKPaymentParameters o_conv;
38545         o_conv.inner = (void*)(o & (~1));
38546         o_conv.is_owned = false;
38547         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38548         int64_t ret_conv = PaymentParameters_hash(&o_conv);
38549         return ret_conv;
38550 }
38551
38552 jboolean  __attribute__((export_name("TS_PaymentParameters_eq"))) TS_PaymentParameters_eq(uint32_t a, uint32_t b) {
38553         LDKPaymentParameters a_conv;
38554         a_conv.inner = (void*)(a & (~1));
38555         a_conv.is_owned = false;
38556         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38557         LDKPaymentParameters b_conv;
38558         b_conv.inner = (void*)(b & (~1));
38559         b_conv.is_owned = false;
38560         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38561         jboolean ret_conv = PaymentParameters_eq(&a_conv, &b_conv);
38562         return ret_conv;
38563 }
38564
38565 int8_tArray  __attribute__((export_name("TS_PaymentParameters_write"))) TS_PaymentParameters_write(uint32_t obj) {
38566         LDKPaymentParameters obj_conv;
38567         obj_conv.inner = (void*)(obj & (~1));
38568         obj_conv.is_owned = false;
38569         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38570         LDKCVec_u8Z ret_var = PaymentParameters_write(&obj_conv);
38571         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38572         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38573         CVec_u8Z_free(ret_var);
38574         return ret_arr;
38575 }
38576
38577 uint32_t  __attribute__((export_name("TS_PaymentParameters_read"))) TS_PaymentParameters_read(int8_tArray ser) {
38578         LDKu8slice ser_ref;
38579         ser_ref.datalen = ser->arr_len;
38580         ser_ref.data = ser->elems /* XXX ser leaks */;
38581         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
38582         *ret_conv = PaymentParameters_read(ser_ref);
38583         return (uint32_t)ret_conv;
38584 }
38585
38586 uint32_t  __attribute__((export_name("TS_PaymentParameters_from_node_id"))) TS_PaymentParameters_from_node_id(int8_tArray payee_pubkey) {
38587         LDKPublicKey payee_pubkey_ref;
38588         CHECK(payee_pubkey->arr_len == 33);
38589         memcpy(payee_pubkey_ref.compressed_form, payee_pubkey->elems, 33); FREE(payee_pubkey);
38590         LDKPaymentParameters ret_var = PaymentParameters_from_node_id(payee_pubkey_ref);
38591         uint32_t ret_ref = 0;
38592         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38593         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38594         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38595         ret_ref = (uintptr_t)ret_var.inner;
38596         if (ret_var.is_owned) {
38597                 ret_ref |= 1;
38598         }
38599         return ret_ref;
38600 }
38601
38602 uint32_t  __attribute__((export_name("TS_PaymentParameters_for_keysend"))) TS_PaymentParameters_for_keysend(int8_tArray payee_pubkey) {
38603         LDKPublicKey payee_pubkey_ref;
38604         CHECK(payee_pubkey->arr_len == 33);
38605         memcpy(payee_pubkey_ref.compressed_form, payee_pubkey->elems, 33); FREE(payee_pubkey);
38606         LDKPaymentParameters ret_var = PaymentParameters_for_keysend(payee_pubkey_ref);
38607         uint32_t ret_ref = 0;
38608         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38609         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38610         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38611         ret_ref = (uintptr_t)ret_var.inner;
38612         if (ret_var.is_owned) {
38613                 ret_ref |= 1;
38614         }
38615         return ret_ref;
38616 }
38617
38618 void  __attribute__((export_name("TS_RouteHint_free"))) TS_RouteHint_free(uint32_t this_obj) {
38619         LDKRouteHint this_obj_conv;
38620         this_obj_conv.inner = (void*)(this_obj & (~1));
38621         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38623         RouteHint_free(this_obj_conv);
38624 }
38625
38626 uint32_tArray  __attribute__((export_name("TS_RouteHint_get_a"))) TS_RouteHint_get_a(uint32_t this_ptr) {
38627         LDKRouteHint this_ptr_conv;
38628         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38629         this_ptr_conv.is_owned = false;
38630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38631         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
38632         uint32_tArray ret_arr = NULL;
38633         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
38634         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
38635         for (size_t o = 0; o < ret_var.datalen; o++) {
38636                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
38637                 uint32_t ret_conv_14_ref = 0;
38638                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38639                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38640                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
38641                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
38642                 if (ret_conv_14_var.is_owned) {
38643                         ret_conv_14_ref |= 1;
38644                 }
38645                 ret_arr_ptr[o] = ret_conv_14_ref;
38646         }
38647         
38648         FREE(ret_var.data);
38649         return ret_arr;
38650 }
38651
38652 void  __attribute__((export_name("TS_RouteHint_set_a"))) TS_RouteHint_set_a(uint32_t this_ptr, uint32_tArray val) {
38653         LDKRouteHint this_ptr_conv;
38654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38655         this_ptr_conv.is_owned = false;
38656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38657         LDKCVec_RouteHintHopZ val_constr;
38658         val_constr.datalen = val->arr_len;
38659         if (val_constr.datalen > 0)
38660                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
38661         else
38662                 val_constr.data = NULL;
38663         uint32_t* val_vals = val->elems /* XXX val leaks */;
38664         for (size_t o = 0; o < val_constr.datalen; o++) {
38665                 uint32_t val_conv_14 = val_vals[o];
38666                 LDKRouteHintHop val_conv_14_conv;
38667                 val_conv_14_conv.inner = (void*)(val_conv_14 & (~1));
38668                 val_conv_14_conv.is_owned = (val_conv_14 & 1) || (val_conv_14 == 0);
38669                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
38670                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
38671                 val_constr.data[o] = val_conv_14_conv;
38672         }
38673         RouteHint_set_a(&this_ptr_conv, val_constr);
38674 }
38675
38676 uint32_t  __attribute__((export_name("TS_RouteHint_new"))) TS_RouteHint_new(uint32_tArray a_arg) {
38677         LDKCVec_RouteHintHopZ a_arg_constr;
38678         a_arg_constr.datalen = a_arg->arr_len;
38679         if (a_arg_constr.datalen > 0)
38680                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
38681         else
38682                 a_arg_constr.data = NULL;
38683         uint32_t* a_arg_vals = a_arg->elems /* XXX a_arg leaks */;
38684         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
38685                 uint32_t a_arg_conv_14 = a_arg_vals[o];
38686                 LDKRouteHintHop a_arg_conv_14_conv;
38687                 a_arg_conv_14_conv.inner = (void*)(a_arg_conv_14 & (~1));
38688                 a_arg_conv_14_conv.is_owned = (a_arg_conv_14 & 1) || (a_arg_conv_14 == 0);
38689                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
38690                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
38691                 a_arg_constr.data[o] = a_arg_conv_14_conv;
38692         }
38693         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
38694         uint32_t ret_ref = 0;
38695         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38696         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38697         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38698         ret_ref = (uintptr_t)ret_var.inner;
38699         if (ret_var.is_owned) {
38700                 ret_ref |= 1;
38701         }
38702         return ret_ref;
38703 }
38704
38705 static inline uintptr_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
38706         LDKRouteHint ret_var = RouteHint_clone(arg);
38707 uint32_t ret_ref = 0;
38708 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38709 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38710 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38711 ret_ref = (uintptr_t)ret_var.inner;
38712 if (ret_var.is_owned) {
38713         ret_ref |= 1;
38714 }
38715         return ret_ref;
38716 }
38717 uint32_t  __attribute__((export_name("TS_RouteHint_clone_ptr"))) TS_RouteHint_clone_ptr(uint32_t arg) {
38718         LDKRouteHint arg_conv;
38719         arg_conv.inner = (void*)(arg & (~1));
38720         arg_conv.is_owned = false;
38721         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38722         uint32_t ret_conv = RouteHint_clone_ptr(&arg_conv);
38723         return ret_conv;
38724 }
38725
38726 uint32_t  __attribute__((export_name("TS_RouteHint_clone"))) TS_RouteHint_clone(uint32_t orig) {
38727         LDKRouteHint orig_conv;
38728         orig_conv.inner = (void*)(orig & (~1));
38729         orig_conv.is_owned = false;
38730         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38731         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
38732         uint32_t ret_ref = 0;
38733         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38734         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38735         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38736         ret_ref = (uintptr_t)ret_var.inner;
38737         if (ret_var.is_owned) {
38738                 ret_ref |= 1;
38739         }
38740         return ret_ref;
38741 }
38742
38743 int64_t  __attribute__((export_name("TS_RouteHint_hash"))) TS_RouteHint_hash(uint32_t o) {
38744         LDKRouteHint o_conv;
38745         o_conv.inner = (void*)(o & (~1));
38746         o_conv.is_owned = false;
38747         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38748         int64_t ret_conv = RouteHint_hash(&o_conv);
38749         return ret_conv;
38750 }
38751
38752 jboolean  __attribute__((export_name("TS_RouteHint_eq"))) TS_RouteHint_eq(uint32_t a, uint32_t b) {
38753         LDKRouteHint a_conv;
38754         a_conv.inner = (void*)(a & (~1));
38755         a_conv.is_owned = false;
38756         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38757         LDKRouteHint b_conv;
38758         b_conv.inner = (void*)(b & (~1));
38759         b_conv.is_owned = false;
38760         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38761         jboolean ret_conv = RouteHint_eq(&a_conv, &b_conv);
38762         return ret_conv;
38763 }
38764
38765 int8_tArray  __attribute__((export_name("TS_RouteHint_write"))) TS_RouteHint_write(uint32_t obj) {
38766         LDKRouteHint obj_conv;
38767         obj_conv.inner = (void*)(obj & (~1));
38768         obj_conv.is_owned = false;
38769         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38770         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
38771         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
38772         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
38773         CVec_u8Z_free(ret_var);
38774         return ret_arr;
38775 }
38776
38777 uint32_t  __attribute__((export_name("TS_RouteHint_read"))) TS_RouteHint_read(int8_tArray ser) {
38778         LDKu8slice ser_ref;
38779         ser_ref.datalen = ser->arr_len;
38780         ser_ref.data = ser->elems /* XXX ser leaks */;
38781         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
38782         *ret_conv = RouteHint_read(ser_ref);
38783         return (uint32_t)ret_conv;
38784 }
38785
38786 void  __attribute__((export_name("TS_RouteHintHop_free"))) TS_RouteHintHop_free(uint32_t this_obj) {
38787         LDKRouteHintHop this_obj_conv;
38788         this_obj_conv.inner = (void*)(this_obj & (~1));
38789         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38790         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38791         RouteHintHop_free(this_obj_conv);
38792 }
38793
38794 int8_tArray  __attribute__((export_name("TS_RouteHintHop_get_src_node_id"))) TS_RouteHintHop_get_src_node_id(uint32_t this_ptr) {
38795         LDKRouteHintHop this_ptr_conv;
38796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38797         this_ptr_conv.is_owned = false;
38798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38799         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
38800         memcpy(ret_arr->elems, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form, 33);
38801         return ret_arr;
38802 }
38803
38804 void  __attribute__((export_name("TS_RouteHintHop_set_src_node_id"))) TS_RouteHintHop_set_src_node_id(uint32_t this_ptr, int8_tArray val) {
38805         LDKRouteHintHop this_ptr_conv;
38806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38807         this_ptr_conv.is_owned = false;
38808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38809         LDKPublicKey val_ref;
38810         CHECK(val->arr_len == 33);
38811         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
38812         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
38813 }
38814
38815 int64_t  __attribute__((export_name("TS_RouteHintHop_get_short_channel_id"))) TS_RouteHintHop_get_short_channel_id(uint32_t this_ptr) {
38816         LDKRouteHintHop this_ptr_conv;
38817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38818         this_ptr_conv.is_owned = false;
38819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38820         int64_t ret_conv = RouteHintHop_get_short_channel_id(&this_ptr_conv);
38821         return ret_conv;
38822 }
38823
38824 void  __attribute__((export_name("TS_RouteHintHop_set_short_channel_id"))) TS_RouteHintHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
38825         LDKRouteHintHop this_ptr_conv;
38826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38827         this_ptr_conv.is_owned = false;
38828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38829         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
38830 }
38831
38832 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_fees"))) TS_RouteHintHop_get_fees(uint32_t this_ptr) {
38833         LDKRouteHintHop this_ptr_conv;
38834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38835         this_ptr_conv.is_owned = false;
38836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38837         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
38838         uint32_t ret_ref = 0;
38839         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38840         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38841         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38842         ret_ref = (uintptr_t)ret_var.inner;
38843         if (ret_var.is_owned) {
38844                 ret_ref |= 1;
38845         }
38846         return ret_ref;
38847 }
38848
38849 void  __attribute__((export_name("TS_RouteHintHop_set_fees"))) TS_RouteHintHop_set_fees(uint32_t this_ptr, uint32_t val) {
38850         LDKRouteHintHop this_ptr_conv;
38851         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38852         this_ptr_conv.is_owned = false;
38853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38854         LDKRoutingFees val_conv;
38855         val_conv.inner = (void*)(val & (~1));
38856         val_conv.is_owned = (val & 1) || (val == 0);
38857         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38858         val_conv = RoutingFees_clone(&val_conv);
38859         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
38860 }
38861
38862 int16_t  __attribute__((export_name("TS_RouteHintHop_get_cltv_expiry_delta"))) TS_RouteHintHop_get_cltv_expiry_delta(uint32_t this_ptr) {
38863         LDKRouteHintHop this_ptr_conv;
38864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38865         this_ptr_conv.is_owned = false;
38866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38867         int16_t ret_conv = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
38868         return ret_conv;
38869 }
38870
38871 void  __attribute__((export_name("TS_RouteHintHop_set_cltv_expiry_delta"))) TS_RouteHintHop_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
38872         LDKRouteHintHop this_ptr_conv;
38873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38874         this_ptr_conv.is_owned = false;
38875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38876         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
38877 }
38878
38879 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_htlc_minimum_msat"))) TS_RouteHintHop_get_htlc_minimum_msat(uint32_t this_ptr) {
38880         LDKRouteHintHop this_ptr_conv;
38881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38882         this_ptr_conv.is_owned = false;
38883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38884         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
38885         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
38886         uint32_t ret_ref = (uintptr_t)ret_copy;
38887         return ret_ref;
38888 }
38889
38890 void  __attribute__((export_name("TS_RouteHintHop_set_htlc_minimum_msat"))) TS_RouteHintHop_set_htlc_minimum_msat(uint32_t this_ptr, uint32_t val) {
38891         LDKRouteHintHop this_ptr_conv;
38892         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38893         this_ptr_conv.is_owned = false;
38894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38895         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
38896         CHECK_ACCESS(val_ptr);
38897         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
38898         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
38899         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
38900 }
38901
38902 uint32_t  __attribute__((export_name("TS_RouteHintHop_get_htlc_maximum_msat"))) TS_RouteHintHop_get_htlc_maximum_msat(uint32_t this_ptr) {
38903         LDKRouteHintHop this_ptr_conv;
38904         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38905         this_ptr_conv.is_owned = false;
38906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38907         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
38908         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
38909         uint32_t ret_ref = (uintptr_t)ret_copy;
38910         return ret_ref;
38911 }
38912
38913 void  __attribute__((export_name("TS_RouteHintHop_set_htlc_maximum_msat"))) TS_RouteHintHop_set_htlc_maximum_msat(uint32_t this_ptr, uint32_t val) {
38914         LDKRouteHintHop this_ptr_conv;
38915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38916         this_ptr_conv.is_owned = false;
38917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38918         void* val_ptr = (void*)(((uintptr_t)val) & ~1);
38919         CHECK_ACCESS(val_ptr);
38920         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
38921         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)val) & ~1));
38922         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
38923 }
38924
38925 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) {
38926         LDKPublicKey src_node_id_arg_ref;
38927         CHECK(src_node_id_arg->arr_len == 33);
38928         memcpy(src_node_id_arg_ref.compressed_form, src_node_id_arg->elems, 33); FREE(src_node_id_arg);
38929         LDKRoutingFees fees_arg_conv;
38930         fees_arg_conv.inner = (void*)(fees_arg & (~1));
38931         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
38932         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
38933         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
38934         void* htlc_minimum_msat_arg_ptr = (void*)(((uintptr_t)htlc_minimum_msat_arg) & ~1);
38935         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
38936         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
38937         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_minimum_msat_arg) & ~1));
38938         void* htlc_maximum_msat_arg_ptr = (void*)(((uintptr_t)htlc_maximum_msat_arg) & ~1);
38939         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
38940         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
38941         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)htlc_maximum_msat_arg) & ~1));
38942         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);
38943         uint32_t ret_ref = 0;
38944         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38945         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38946         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38947         ret_ref = (uintptr_t)ret_var.inner;
38948         if (ret_var.is_owned) {
38949                 ret_ref |= 1;
38950         }
38951         return ret_ref;
38952 }
38953
38954 static inline uintptr_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
38955         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
38956 uint32_t ret_ref = 0;
38957 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38958 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38959 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38960 ret_ref = (uintptr_t)ret_var.inner;
38961 if (ret_var.is_owned) {
38962         ret_ref |= 1;
38963 }
38964         return ret_ref;
38965 }
38966 uint32_t  __attribute__((export_name("TS_RouteHintHop_clone_ptr"))) TS_RouteHintHop_clone_ptr(uint32_t arg) {
38967         LDKRouteHintHop arg_conv;
38968         arg_conv.inner = (void*)(arg & (~1));
38969         arg_conv.is_owned = false;
38970         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38971         uint32_t ret_conv = RouteHintHop_clone_ptr(&arg_conv);
38972         return ret_conv;
38973 }
38974
38975 uint32_t  __attribute__((export_name("TS_RouteHintHop_clone"))) TS_RouteHintHop_clone(uint32_t orig) {
38976         LDKRouteHintHop orig_conv;
38977         orig_conv.inner = (void*)(orig & (~1));
38978         orig_conv.is_owned = false;
38979         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38980         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
38981         uint32_t ret_ref = 0;
38982         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38983         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38984         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38985         ret_ref = (uintptr_t)ret_var.inner;
38986         if (ret_var.is_owned) {
38987                 ret_ref |= 1;
38988         }
38989         return ret_ref;
38990 }
38991
38992 int64_t  __attribute__((export_name("TS_RouteHintHop_hash"))) TS_RouteHintHop_hash(uint32_t o) {
38993         LDKRouteHintHop o_conv;
38994         o_conv.inner = (void*)(o & (~1));
38995         o_conv.is_owned = false;
38996         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38997         int64_t ret_conv = RouteHintHop_hash(&o_conv);
38998         return ret_conv;
38999 }
39000
39001 jboolean  __attribute__((export_name("TS_RouteHintHop_eq"))) TS_RouteHintHop_eq(uint32_t a, uint32_t b) {
39002         LDKRouteHintHop a_conv;
39003         a_conv.inner = (void*)(a & (~1));
39004         a_conv.is_owned = false;
39005         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39006         LDKRouteHintHop b_conv;
39007         b_conv.inner = (void*)(b & (~1));
39008         b_conv.is_owned = false;
39009         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39010         jboolean ret_conv = RouteHintHop_eq(&a_conv, &b_conv);
39011         return ret_conv;
39012 }
39013
39014 int8_tArray  __attribute__((export_name("TS_RouteHintHop_write"))) TS_RouteHintHop_write(uint32_t obj) {
39015         LDKRouteHintHop obj_conv;
39016         obj_conv.inner = (void*)(obj & (~1));
39017         obj_conv.is_owned = false;
39018         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39019         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
39020         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39021         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39022         CVec_u8Z_free(ret_var);
39023         return ret_arr;
39024 }
39025
39026 uint32_t  __attribute__((export_name("TS_RouteHintHop_read"))) TS_RouteHintHop_read(int8_tArray ser) {
39027         LDKu8slice ser_ref;
39028         ser_ref.datalen = ser->arr_len;
39029         ser_ref.data = ser->elems /* XXX ser leaks */;
39030         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
39031         *ret_conv = RouteHintHop_read(ser_ref);
39032         return (uint32_t)ret_conv;
39033 }
39034
39035 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) {
39036         LDKPublicKey our_node_pubkey_ref;
39037         CHECK(our_node_pubkey->arr_len == 33);
39038         memcpy(our_node_pubkey_ref.compressed_form, our_node_pubkey->elems, 33); FREE(our_node_pubkey);
39039         LDKRouteParameters route_params_conv;
39040         route_params_conv.inner = (void*)(route_params & (~1));
39041         route_params_conv.is_owned = false;
39042         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
39043         LDKNetworkGraph network_conv;
39044         network_conv.inner = (void*)(network & (~1));
39045         network_conv.is_owned = false;
39046         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_conv);
39047         LDKCVec_ChannelDetailsZ first_hops_constr;
39048         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
39049         if (first_hops != 0) {
39050                 first_hops_constr.datalen = first_hops->arr_len;
39051                 if (first_hops_constr.datalen > 0)
39052                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
39053                 else
39054                         first_hops_constr.data = NULL;
39055                 uint32_t* first_hops_vals = first_hops->elems /* XXX first_hops leaks */;
39056                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
39057                         uint32_t first_hops_conv_16 = first_hops_vals[q];
39058                         LDKChannelDetails first_hops_conv_16_conv;
39059                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
39060                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
39061                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
39062                         first_hops_constr.data[q] = first_hops_conv_16_conv;
39063                 }
39064                 first_hops_ptr = &first_hops_constr;
39065         }
39066         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
39067         CHECK_ACCESS(logger_ptr);
39068         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
39069         if (logger_conv.free == LDKLogger_JCalls_free) {
39070                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39071                 LDKLogger_JCalls_cloned(&logger_conv);
39072         }
39073         void* scorer_ptr = (void*)(((uintptr_t)scorer) & ~1);
39074         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
39075         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
39076         unsigned char random_seed_bytes_arr[32];
39077         CHECK(random_seed_bytes->arr_len == 32);
39078         memcpy(random_seed_bytes_arr, random_seed_bytes->elems, 32); FREE(random_seed_bytes);
39079         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
39080         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
39081         *ret_conv = find_route(our_node_pubkey_ref, &route_params_conv, &network_conv, first_hops_ptr, logger_conv, scorer_conv, random_seed_bytes_ref);
39082         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
39083         return (uint32_t)ret_conv;
39084 }
39085
39086 void  __attribute__((export_name("TS_Score_free"))) TS_Score_free(uint32_t this_ptr) {
39087         if ((this_ptr & 1) != 0) return;
39088         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39089         CHECK_ACCESS(this_ptr_ptr);
39090         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
39091         FREE((void*)this_ptr);
39092         Score_free(this_ptr_conv);
39093 }
39094
39095 void  __attribute__((export_name("TS_LockableScore_free"))) TS_LockableScore_free(uint32_t this_ptr) {
39096         if ((this_ptr & 1) != 0) return;
39097         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39098         CHECK_ACCESS(this_ptr_ptr);
39099         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
39100         FREE((void*)this_ptr);
39101         LockableScore_free(this_ptr_conv);
39102 }
39103
39104 void  __attribute__((export_name("TS_MultiThreadedLockableScore_free"))) TS_MultiThreadedLockableScore_free(uint32_t this_obj) {
39105         LDKMultiThreadedLockableScore this_obj_conv;
39106         this_obj_conv.inner = (void*)(this_obj & (~1));
39107         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39109         MultiThreadedLockableScore_free(this_obj_conv);
39110 }
39111
39112 uint32_t  __attribute__((export_name("TS_MultiThreadedLockableScore_new"))) TS_MultiThreadedLockableScore_new(uint32_t score) {
39113         void* score_ptr = (void*)(((uintptr_t)score) & ~1);
39114         CHECK_ACCESS(score_ptr);
39115         LDKScore score_conv = *(LDKScore*)(score_ptr);
39116         if (score_conv.free == LDKScore_JCalls_free) {
39117                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39118                 LDKScore_JCalls_cloned(&score_conv);
39119         }
39120         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
39121         uint32_t ret_ref = 0;
39122         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39123         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39124         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39125         ret_ref = (uintptr_t)ret_var.inner;
39126         if (ret_var.is_owned) {
39127                 ret_ref |= 1;
39128         }
39129         return ret_ref;
39130 }
39131
39132 void  __attribute__((export_name("TS_FixedPenaltyScorer_free"))) TS_FixedPenaltyScorer_free(uint32_t this_obj) {
39133         LDKFixedPenaltyScorer this_obj_conv;
39134         this_obj_conv.inner = (void*)(this_obj & (~1));
39135         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39137         FixedPenaltyScorer_free(this_obj_conv);
39138 }
39139
39140 static inline uintptr_t FixedPenaltyScorer_clone_ptr(LDKFixedPenaltyScorer *NONNULL_PTR arg) {
39141         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(arg);
39142 uint32_t ret_ref = 0;
39143 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39144 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39145 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39146 ret_ref = (uintptr_t)ret_var.inner;
39147 if (ret_var.is_owned) {
39148         ret_ref |= 1;
39149 }
39150         return ret_ref;
39151 }
39152 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_clone_ptr"))) TS_FixedPenaltyScorer_clone_ptr(uint32_t arg) {
39153         LDKFixedPenaltyScorer arg_conv;
39154         arg_conv.inner = (void*)(arg & (~1));
39155         arg_conv.is_owned = false;
39156         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39157         uint32_t ret_conv = FixedPenaltyScorer_clone_ptr(&arg_conv);
39158         return ret_conv;
39159 }
39160
39161 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_clone"))) TS_FixedPenaltyScorer_clone(uint32_t orig) {
39162         LDKFixedPenaltyScorer orig_conv;
39163         orig_conv.inner = (void*)(orig & (~1));
39164         orig_conv.is_owned = false;
39165         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39166         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(&orig_conv);
39167         uint32_t ret_ref = 0;
39168         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39169         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39170         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39171         ret_ref = (uintptr_t)ret_var.inner;
39172         if (ret_var.is_owned) {
39173                 ret_ref |= 1;
39174         }
39175         return ret_ref;
39176 }
39177
39178 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_with_penalty"))) TS_FixedPenaltyScorer_with_penalty(int64_t penalty_msat) {
39179         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_with_penalty(penalty_msat);
39180         uint32_t ret_ref = 0;
39181         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39182         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39183         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39184         ret_ref = (uintptr_t)ret_var.inner;
39185         if (ret_var.is_owned) {
39186                 ret_ref |= 1;
39187         }
39188         return ret_ref;
39189 }
39190
39191 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_as_Score"))) TS_FixedPenaltyScorer_as_Score(uint32_t this_arg) {
39192         LDKFixedPenaltyScorer this_arg_conv;
39193         this_arg_conv.inner = (void*)(this_arg & (~1));
39194         this_arg_conv.is_owned = false;
39195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39196         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
39197         *ret_ret = FixedPenaltyScorer_as_Score(&this_arg_conv);
39198         return (uint32_t)ret_ret;
39199 }
39200
39201 int8_tArray  __attribute__((export_name("TS_FixedPenaltyScorer_write"))) TS_FixedPenaltyScorer_write(uint32_t obj) {
39202         LDKFixedPenaltyScorer obj_conv;
39203         obj_conv.inner = (void*)(obj & (~1));
39204         obj_conv.is_owned = false;
39205         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39206         LDKCVec_u8Z ret_var = FixedPenaltyScorer_write(&obj_conv);
39207         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39208         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39209         CVec_u8Z_free(ret_var);
39210         return ret_arr;
39211 }
39212
39213 uint32_t  __attribute__((export_name("TS_FixedPenaltyScorer_read"))) TS_FixedPenaltyScorer_read(int8_tArray ser, int64_t arg) {
39214         LDKu8slice ser_ref;
39215         ser_ref.datalen = ser->arr_len;
39216         ser_ref.data = ser->elems /* XXX ser leaks */;
39217         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
39218         *ret_conv = FixedPenaltyScorer_read(ser_ref, arg);
39219         return (uint32_t)ret_conv;
39220 }
39221
39222 void  __attribute__((export_name("TS_Scorer_free"))) TS_Scorer_free(uint32_t this_obj) {
39223         LDKScorer this_obj_conv;
39224         this_obj_conv.inner = (void*)(this_obj & (~1));
39225         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39227         Scorer_free(this_obj_conv);
39228 }
39229
39230 void  __attribute__((export_name("TS_ScoringParameters_free"))) TS_ScoringParameters_free(uint32_t this_obj) {
39231         LDKScoringParameters this_obj_conv;
39232         this_obj_conv.inner = (void*)(this_obj & (~1));
39233         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39235         ScoringParameters_free(this_obj_conv);
39236 }
39237
39238 int64_t  __attribute__((export_name("TS_ScoringParameters_get_base_penalty_msat"))) TS_ScoringParameters_get_base_penalty_msat(uint32_t this_ptr) {
39239         LDKScoringParameters this_ptr_conv;
39240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39241         this_ptr_conv.is_owned = false;
39242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39243         int64_t ret_conv = ScoringParameters_get_base_penalty_msat(&this_ptr_conv);
39244         return ret_conv;
39245 }
39246
39247 void  __attribute__((export_name("TS_ScoringParameters_set_base_penalty_msat"))) TS_ScoringParameters_set_base_penalty_msat(uint32_t this_ptr, int64_t val) {
39248         LDKScoringParameters this_ptr_conv;
39249         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39250         this_ptr_conv.is_owned = false;
39251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39252         ScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
39253 }
39254
39255 int64_t  __attribute__((export_name("TS_ScoringParameters_get_failure_penalty_msat"))) TS_ScoringParameters_get_failure_penalty_msat(uint32_t this_ptr) {
39256         LDKScoringParameters this_ptr_conv;
39257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39258         this_ptr_conv.is_owned = false;
39259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39260         int64_t ret_conv = ScoringParameters_get_failure_penalty_msat(&this_ptr_conv);
39261         return ret_conv;
39262 }
39263
39264 void  __attribute__((export_name("TS_ScoringParameters_set_failure_penalty_msat"))) TS_ScoringParameters_set_failure_penalty_msat(uint32_t this_ptr, int64_t val) {
39265         LDKScoringParameters this_ptr_conv;
39266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39267         this_ptr_conv.is_owned = false;
39268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39269         ScoringParameters_set_failure_penalty_msat(&this_ptr_conv, val);
39270 }
39271
39272 int16_t  __attribute__((export_name("TS_ScoringParameters_get_overuse_penalty_start_1024th"))) TS_ScoringParameters_get_overuse_penalty_start_1024th(uint32_t this_ptr) {
39273         LDKScoringParameters this_ptr_conv;
39274         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39275         this_ptr_conv.is_owned = false;
39276         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39277         int16_t ret_conv = ScoringParameters_get_overuse_penalty_start_1024th(&this_ptr_conv);
39278         return ret_conv;
39279 }
39280
39281 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) {
39282         LDKScoringParameters this_ptr_conv;
39283         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39284         this_ptr_conv.is_owned = false;
39285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39286         ScoringParameters_set_overuse_penalty_start_1024th(&this_ptr_conv, val);
39287 }
39288
39289 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) {
39290         LDKScoringParameters this_ptr_conv;
39291         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39292         this_ptr_conv.is_owned = false;
39293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39294         int64_t ret_conv = ScoringParameters_get_overuse_penalty_msat_per_1024th(&this_ptr_conv);
39295         return ret_conv;
39296 }
39297
39298 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) {
39299         LDKScoringParameters this_ptr_conv;
39300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39301         this_ptr_conv.is_owned = false;
39302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39303         ScoringParameters_set_overuse_penalty_msat_per_1024th(&this_ptr_conv, val);
39304 }
39305
39306 int64_t  __attribute__((export_name("TS_ScoringParameters_get_failure_penalty_half_life"))) TS_ScoringParameters_get_failure_penalty_half_life(uint32_t this_ptr) {
39307         LDKScoringParameters this_ptr_conv;
39308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39309         this_ptr_conv.is_owned = false;
39310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39311         int64_t ret_conv = ScoringParameters_get_failure_penalty_half_life(&this_ptr_conv);
39312         return ret_conv;
39313 }
39314
39315 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) {
39316         LDKScoringParameters this_ptr_conv;
39317         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39318         this_ptr_conv.is_owned = false;
39319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39320         ScoringParameters_set_failure_penalty_half_life(&this_ptr_conv, val);
39321 }
39322
39323 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) {
39324         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);
39325         uint32_t ret_ref = 0;
39326         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39327         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39328         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39329         ret_ref = (uintptr_t)ret_var.inner;
39330         if (ret_var.is_owned) {
39331                 ret_ref |= 1;
39332         }
39333         return ret_ref;
39334 }
39335
39336 static inline uintptr_t ScoringParameters_clone_ptr(LDKScoringParameters *NONNULL_PTR arg) {
39337         LDKScoringParameters ret_var = ScoringParameters_clone(arg);
39338 uint32_t ret_ref = 0;
39339 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39340 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39341 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39342 ret_ref = (uintptr_t)ret_var.inner;
39343 if (ret_var.is_owned) {
39344         ret_ref |= 1;
39345 }
39346         return ret_ref;
39347 }
39348 uint32_t  __attribute__((export_name("TS_ScoringParameters_clone_ptr"))) TS_ScoringParameters_clone_ptr(uint32_t arg) {
39349         LDKScoringParameters arg_conv;
39350         arg_conv.inner = (void*)(arg & (~1));
39351         arg_conv.is_owned = false;
39352         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39353         uint32_t ret_conv = ScoringParameters_clone_ptr(&arg_conv);
39354         return ret_conv;
39355 }
39356
39357 uint32_t  __attribute__((export_name("TS_ScoringParameters_clone"))) TS_ScoringParameters_clone(uint32_t orig) {
39358         LDKScoringParameters orig_conv;
39359         orig_conv.inner = (void*)(orig & (~1));
39360         orig_conv.is_owned = false;
39361         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39362         LDKScoringParameters ret_var = ScoringParameters_clone(&orig_conv);
39363         uint32_t ret_ref = 0;
39364         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39365         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39366         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39367         ret_ref = (uintptr_t)ret_var.inner;
39368         if (ret_var.is_owned) {
39369                 ret_ref |= 1;
39370         }
39371         return ret_ref;
39372 }
39373
39374 int8_tArray  __attribute__((export_name("TS_ScoringParameters_write"))) TS_ScoringParameters_write(uint32_t obj) {
39375         LDKScoringParameters obj_conv;
39376         obj_conv.inner = (void*)(obj & (~1));
39377         obj_conv.is_owned = false;
39378         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39379         LDKCVec_u8Z ret_var = ScoringParameters_write(&obj_conv);
39380         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39381         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39382         CVec_u8Z_free(ret_var);
39383         return ret_arr;
39384 }
39385
39386 uint32_t  __attribute__((export_name("TS_ScoringParameters_read"))) TS_ScoringParameters_read(int8_tArray ser) {
39387         LDKu8slice ser_ref;
39388         ser_ref.datalen = ser->arr_len;
39389         ser_ref.data = ser->elems /* XXX ser leaks */;
39390         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
39391         *ret_conv = ScoringParameters_read(ser_ref);
39392         return (uint32_t)ret_conv;
39393 }
39394
39395 uint32_t  __attribute__((export_name("TS_Scorer_new"))) TS_Scorer_new(uint32_t params) {
39396         LDKScoringParameters params_conv;
39397         params_conv.inner = (void*)(params & (~1));
39398         params_conv.is_owned = (params & 1) || (params == 0);
39399         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
39400         params_conv = ScoringParameters_clone(&params_conv);
39401         LDKScorer ret_var = Scorer_new(params_conv);
39402         uint32_t ret_ref = 0;
39403         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39404         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39405         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39406         ret_ref = (uintptr_t)ret_var.inner;
39407         if (ret_var.is_owned) {
39408                 ret_ref |= 1;
39409         }
39410         return ret_ref;
39411 }
39412
39413 uint32_t  __attribute__((export_name("TS_Scorer_default"))) TS_Scorer_default() {
39414         LDKScorer ret_var = Scorer_default();
39415         uint32_t ret_ref = 0;
39416         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39417         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39418         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39419         ret_ref = (uintptr_t)ret_var.inner;
39420         if (ret_var.is_owned) {
39421                 ret_ref |= 1;
39422         }
39423         return ret_ref;
39424 }
39425
39426 uint32_t  __attribute__((export_name("TS_ScoringParameters_default"))) TS_ScoringParameters_default() {
39427         LDKScoringParameters ret_var = ScoringParameters_default();
39428         uint32_t ret_ref = 0;
39429         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39430         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39431         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39432         ret_ref = (uintptr_t)ret_var.inner;
39433         if (ret_var.is_owned) {
39434                 ret_ref |= 1;
39435         }
39436         return ret_ref;
39437 }
39438
39439 uint32_t  __attribute__((export_name("TS_Scorer_as_Score"))) TS_Scorer_as_Score(uint32_t this_arg) {
39440         LDKScorer this_arg_conv;
39441         this_arg_conv.inner = (void*)(this_arg & (~1));
39442         this_arg_conv.is_owned = false;
39443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39444         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
39445         *ret_ret = Scorer_as_Score(&this_arg_conv);
39446         return (uint32_t)ret_ret;
39447 }
39448
39449 int8_tArray  __attribute__((export_name("TS_Scorer_write"))) TS_Scorer_write(uint32_t obj) {
39450         LDKScorer obj_conv;
39451         obj_conv.inner = (void*)(obj & (~1));
39452         obj_conv.is_owned = false;
39453         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39454         LDKCVec_u8Z ret_var = Scorer_write(&obj_conv);
39455         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39456         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39457         CVec_u8Z_free(ret_var);
39458         return ret_arr;
39459 }
39460
39461 uint32_t  __attribute__((export_name("TS_Scorer_read"))) TS_Scorer_read(int8_tArray ser) {
39462         LDKu8slice ser_ref;
39463         ser_ref.datalen = ser->arr_len;
39464         ser_ref.data = ser->elems /* XXX ser leaks */;
39465         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
39466         *ret_conv = Scorer_read(ser_ref);
39467         return (uint32_t)ret_conv;
39468 }
39469
39470 void  __attribute__((export_name("TS_ProbabilisticScorer_free"))) TS_ProbabilisticScorer_free(uint32_t this_obj) {
39471         LDKProbabilisticScorer this_obj_conv;
39472         this_obj_conv.inner = (void*)(this_obj & (~1));
39473         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39475         ProbabilisticScorer_free(this_obj_conv);
39476 }
39477
39478 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_free"))) TS_ProbabilisticScoringParameters_free(uint32_t this_obj) {
39479         LDKProbabilisticScoringParameters this_obj_conv;
39480         this_obj_conv.inner = (void*)(this_obj & (~1));
39481         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39483         ProbabilisticScoringParameters_free(this_obj_conv);
39484 }
39485
39486 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_base_penalty_msat"))) TS_ProbabilisticScoringParameters_get_base_penalty_msat(uint32_t this_ptr) {
39487         LDKProbabilisticScoringParameters this_ptr_conv;
39488         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39489         this_ptr_conv.is_owned = false;
39490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39491         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_msat(&this_ptr_conv);
39492         return ret_conv;
39493 }
39494
39495 void  __attribute__((export_name("TS_ProbabilisticScoringParameters_set_base_penalty_msat"))) TS_ProbabilisticScoringParameters_set_base_penalty_msat(uint32_t this_ptr, int64_t val) {
39496         LDKProbabilisticScoringParameters this_ptr_conv;
39497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39498         this_ptr_conv.is_owned = false;
39499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39500         ProbabilisticScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
39501 }
39502
39503 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat"))) TS_ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(uint32_t this_ptr) {
39504         LDKProbabilisticScoringParameters this_ptr_conv;
39505         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39506         this_ptr_conv.is_owned = false;
39507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39508         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(&this_ptr_conv);
39509         return ret_conv;
39510 }
39511
39512 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) {
39513         LDKProbabilisticScoringParameters this_ptr_conv;
39514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39515         this_ptr_conv.is_owned = false;
39516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39517         ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
39518 }
39519
39520 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_liquidity_offset_half_life"))) TS_ProbabilisticScoringParameters_get_liquidity_offset_half_life(uint32_t this_ptr) {
39521         LDKProbabilisticScoringParameters this_ptr_conv;
39522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39523         this_ptr_conv.is_owned = false;
39524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39525         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_offset_half_life(&this_ptr_conv);
39526         return ret_conv;
39527 }
39528
39529 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) {
39530         LDKProbabilisticScoringParameters this_ptr_conv;
39531         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39532         this_ptr_conv.is_owned = false;
39533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39534         ProbabilisticScoringParameters_set_liquidity_offset_half_life(&this_ptr_conv, val);
39535 }
39536
39537 int64_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_get_amount_penalty_multiplier_msat"))) TS_ProbabilisticScoringParameters_get_amount_penalty_multiplier_msat(uint32_t this_ptr) {
39538         LDKProbabilisticScoringParameters this_ptr_conv;
39539         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39540         this_ptr_conv.is_owned = false;
39541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39542         int64_t ret_conv = ProbabilisticScoringParameters_get_amount_penalty_multiplier_msat(&this_ptr_conv);
39543         return ret_conv;
39544 }
39545
39546 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) {
39547         LDKProbabilisticScoringParameters this_ptr_conv;
39548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39549         this_ptr_conv.is_owned = false;
39550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39551         ProbabilisticScoringParameters_set_amount_penalty_multiplier_msat(&this_ptr_conv, val);
39552 }
39553
39554 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) {
39555         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_new(base_penalty_msat_arg, liquidity_penalty_multiplier_msat_arg, liquidity_offset_half_life_arg, amount_penalty_multiplier_msat_arg);
39556         uint32_t ret_ref = 0;
39557         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39558         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39559         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39560         ret_ref = (uintptr_t)ret_var.inner;
39561         if (ret_var.is_owned) {
39562                 ret_ref |= 1;
39563         }
39564         return ret_ref;
39565 }
39566
39567 static inline uintptr_t ProbabilisticScoringParameters_clone_ptr(LDKProbabilisticScoringParameters *NONNULL_PTR arg) {
39568         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(arg);
39569 uint32_t ret_ref = 0;
39570 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39571 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39572 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39573 ret_ref = (uintptr_t)ret_var.inner;
39574 if (ret_var.is_owned) {
39575         ret_ref |= 1;
39576 }
39577         return ret_ref;
39578 }
39579 uint32_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_clone_ptr"))) TS_ProbabilisticScoringParameters_clone_ptr(uint32_t arg) {
39580         LDKProbabilisticScoringParameters arg_conv;
39581         arg_conv.inner = (void*)(arg & (~1));
39582         arg_conv.is_owned = false;
39583         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39584         uint32_t ret_conv = ProbabilisticScoringParameters_clone_ptr(&arg_conv);
39585         return ret_conv;
39586 }
39587
39588 uint32_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_clone"))) TS_ProbabilisticScoringParameters_clone(uint32_t orig) {
39589         LDKProbabilisticScoringParameters orig_conv;
39590         orig_conv.inner = (void*)(orig & (~1));
39591         orig_conv.is_owned = false;
39592         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39593         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(&orig_conv);
39594         uint32_t ret_ref = 0;
39595         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39596         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39597         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39598         ret_ref = (uintptr_t)ret_var.inner;
39599         if (ret_var.is_owned) {
39600                 ret_ref |= 1;
39601         }
39602         return ret_ref;
39603 }
39604
39605 uint32_t  __attribute__((export_name("TS_ProbabilisticScorer_new"))) TS_ProbabilisticScorer_new(uint32_t params, uint32_t network_graph) {
39606         LDKProbabilisticScoringParameters params_conv;
39607         params_conv.inner = (void*)(params & (~1));
39608         params_conv.is_owned = (params & 1) || (params == 0);
39609         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
39610         params_conv = ProbabilisticScoringParameters_clone(&params_conv);
39611         LDKNetworkGraph network_graph_conv;
39612         network_graph_conv.inner = (void*)(network_graph & (~1));
39613         network_graph_conv.is_owned = false;
39614         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
39615         LDKProbabilisticScorer ret_var = ProbabilisticScorer_new(params_conv, &network_graph_conv);
39616         uint32_t ret_ref = 0;
39617         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39618         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39619         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39620         ret_ref = (uintptr_t)ret_var.inner;
39621         if (ret_var.is_owned) {
39622                 ret_ref |= 1;
39623         }
39624         return ret_ref;
39625 }
39626
39627 uint32_t  __attribute__((export_name("TS_ProbabilisticScoringParameters_default"))) TS_ProbabilisticScoringParameters_default() {
39628         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_default();
39629         uint32_t ret_ref = 0;
39630         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39631         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39632         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39633         ret_ref = (uintptr_t)ret_var.inner;
39634         if (ret_var.is_owned) {
39635                 ret_ref |= 1;
39636         }
39637         return ret_ref;
39638 }
39639
39640 uint32_t  __attribute__((export_name("TS_ProbabilisticScorer_as_Score"))) TS_ProbabilisticScorer_as_Score(uint32_t this_arg) {
39641         LDKProbabilisticScorer this_arg_conv;
39642         this_arg_conv.inner = (void*)(this_arg & (~1));
39643         this_arg_conv.is_owned = false;
39644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39645         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
39646         *ret_ret = ProbabilisticScorer_as_Score(&this_arg_conv);
39647         return (uint32_t)ret_ret;
39648 }
39649
39650 int8_tArray  __attribute__((export_name("TS_ProbabilisticScorer_write"))) TS_ProbabilisticScorer_write(uint32_t obj) {
39651         LDKProbabilisticScorer obj_conv;
39652         obj_conv.inner = (void*)(obj & (~1));
39653         obj_conv.is_owned = false;
39654         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39655         LDKCVec_u8Z ret_var = ProbabilisticScorer_write(&obj_conv);
39656         int8_tArray ret_arr = init_int8_tArray(ret_var.datalen, __LINE__);
39657         memcpy(ret_arr->elems, ret_var.data, ret_var.datalen);
39658         CVec_u8Z_free(ret_var);
39659         return ret_arr;
39660 }
39661
39662 uint32_t  __attribute__((export_name("TS_ProbabilisticScorer_read"))) TS_ProbabilisticScorer_read(int8_tArray ser, uint32_t arg_a, uint32_t arg_b) {
39663         LDKu8slice ser_ref;
39664         ser_ref.datalen = ser->arr_len;
39665         ser_ref.data = ser->elems /* XXX ser leaks */;
39666         LDKProbabilisticScoringParameters arg_a_conv;
39667         arg_a_conv.inner = (void*)(arg_a & (~1));
39668         arg_a_conv.is_owned = (arg_a & 1) || (arg_a == 0);
39669         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_a_conv);
39670         arg_a_conv = ProbabilisticScoringParameters_clone(&arg_a_conv);
39671         LDKNetworkGraph arg_b_conv;
39672         arg_b_conv.inner = (void*)(arg_b & (~1));
39673         arg_b_conv.is_owned = false;
39674         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_b_conv);
39675         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
39676         *ret_conv = ProbabilisticScorer_read(ser_ref, arg_a_conv, &arg_b_conv);
39677         return (uint32_t)ret_conv;
39678 }
39679
39680 void  __attribute__((export_name("TS_ParseError_free"))) TS_ParseError_free(uint32_t this_ptr) {
39681         if ((this_ptr & 1) != 0) return;
39682         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39683         CHECK_ACCESS(this_ptr_ptr);
39684         LDKParseError this_ptr_conv = *(LDKParseError*)(this_ptr_ptr);
39685         FREE((void*)this_ptr);
39686         ParseError_free(this_ptr_conv);
39687 }
39688
39689 static inline uintptr_t ParseError_clone_ptr(LDKParseError *NONNULL_PTR arg) {
39690         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39691         *ret_copy = ParseError_clone(arg);
39692 uint32_t ret_ref = (uintptr_t)ret_copy;
39693         return ret_ref;
39694 }
39695 uint32_t  __attribute__((export_name("TS_ParseError_clone_ptr"))) TS_ParseError_clone_ptr(uint32_t arg) {
39696         LDKParseError* arg_conv = (LDKParseError*)arg;
39697         uint32_t ret_conv = ParseError_clone_ptr(arg_conv);
39698         return ret_conv;
39699 }
39700
39701 uint32_t  __attribute__((export_name("TS_ParseError_clone"))) TS_ParseError_clone(uint32_t orig) {
39702         LDKParseError* orig_conv = (LDKParseError*)orig;
39703         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39704         *ret_copy = ParseError_clone(orig_conv);
39705         uint32_t ret_ref = (uintptr_t)ret_copy;
39706         return ret_ref;
39707 }
39708
39709 uint32_t  __attribute__((export_name("TS_ParseError_bech32_error"))) TS_ParseError_bech32_error(uint32_t a) {
39710         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
39711         CHECK_ACCESS(a_ptr);
39712         LDKBech32Error a_conv = *(LDKBech32Error*)(a_ptr);
39713         a_conv = Bech32Error_clone((LDKBech32Error*)(((uintptr_t)a) & ~1));
39714         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39715         *ret_copy = ParseError_bech32_error(a_conv);
39716         uint32_t ret_ref = (uintptr_t)ret_copy;
39717         return ret_ref;
39718 }
39719
39720 uint32_t  __attribute__((export_name("TS_ParseError_parse_amount_error"))) TS_ParseError_parse_amount_error(int32_t a) {
39721         
39722         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39723         *ret_copy = ParseError_parse_amount_error((LDKError){ ._dummy = 0 });
39724         uint32_t ret_ref = (uintptr_t)ret_copy;
39725         return ret_ref;
39726 }
39727
39728 uint32_t  __attribute__((export_name("TS_ParseError_malformed_signature"))) TS_ParseError_malformed_signature(uint32_t a) {
39729         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_js(a);
39730         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39731         *ret_copy = ParseError_malformed_signature(a_conv);
39732         uint32_t ret_ref = (uintptr_t)ret_copy;
39733         return ret_ref;
39734 }
39735
39736 uint32_t  __attribute__((export_name("TS_ParseError_bad_prefix"))) TS_ParseError_bad_prefix() {
39737         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39738         *ret_copy = ParseError_bad_prefix();
39739         uint32_t ret_ref = (uintptr_t)ret_copy;
39740         return ret_ref;
39741 }
39742
39743 uint32_t  __attribute__((export_name("TS_ParseError_unknown_currency"))) TS_ParseError_unknown_currency() {
39744         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39745         *ret_copy = ParseError_unknown_currency();
39746         uint32_t ret_ref = (uintptr_t)ret_copy;
39747         return ret_ref;
39748 }
39749
39750 uint32_t  __attribute__((export_name("TS_ParseError_unknown_si_prefix"))) TS_ParseError_unknown_si_prefix() {
39751         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39752         *ret_copy = ParseError_unknown_si_prefix();
39753         uint32_t ret_ref = (uintptr_t)ret_copy;
39754         return ret_ref;
39755 }
39756
39757 uint32_t  __attribute__((export_name("TS_ParseError_malformed_hrp"))) TS_ParseError_malformed_hrp() {
39758         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39759         *ret_copy = ParseError_malformed_hrp();
39760         uint32_t ret_ref = (uintptr_t)ret_copy;
39761         return ret_ref;
39762 }
39763
39764 uint32_t  __attribute__((export_name("TS_ParseError_too_short_data_part"))) TS_ParseError_too_short_data_part() {
39765         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39766         *ret_copy = ParseError_too_short_data_part();
39767         uint32_t ret_ref = (uintptr_t)ret_copy;
39768         return ret_ref;
39769 }
39770
39771 uint32_t  __attribute__((export_name("TS_ParseError_unexpected_end_of_tagged_fields"))) TS_ParseError_unexpected_end_of_tagged_fields() {
39772         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39773         *ret_copy = ParseError_unexpected_end_of_tagged_fields();
39774         uint32_t ret_ref = (uintptr_t)ret_copy;
39775         return ret_ref;
39776 }
39777
39778 uint32_t  __attribute__((export_name("TS_ParseError_description_decode_error"))) TS_ParseError_description_decode_error(int32_t a) {
39779         
39780         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39781         *ret_copy = ParseError_description_decode_error((LDKError){ ._dummy = 0 });
39782         uint32_t ret_ref = (uintptr_t)ret_copy;
39783         return ret_ref;
39784 }
39785
39786 uint32_t  __attribute__((export_name("TS_ParseError_padding_error"))) TS_ParseError_padding_error() {
39787         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39788         *ret_copy = ParseError_padding_error();
39789         uint32_t ret_ref = (uintptr_t)ret_copy;
39790         return ret_ref;
39791 }
39792
39793 uint32_t  __attribute__((export_name("TS_ParseError_integer_overflow_error"))) TS_ParseError_integer_overflow_error() {
39794         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39795         *ret_copy = ParseError_integer_overflow_error();
39796         uint32_t ret_ref = (uintptr_t)ret_copy;
39797         return ret_ref;
39798 }
39799
39800 uint32_t  __attribute__((export_name("TS_ParseError_invalid_seg_wit_program_length"))) TS_ParseError_invalid_seg_wit_program_length() {
39801         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39802         *ret_copy = ParseError_invalid_seg_wit_program_length();
39803         uint32_t ret_ref = (uintptr_t)ret_copy;
39804         return ret_ref;
39805 }
39806
39807 uint32_t  __attribute__((export_name("TS_ParseError_invalid_pub_key_hash_length"))) TS_ParseError_invalid_pub_key_hash_length() {
39808         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39809         *ret_copy = ParseError_invalid_pub_key_hash_length();
39810         uint32_t ret_ref = (uintptr_t)ret_copy;
39811         return ret_ref;
39812 }
39813
39814 uint32_t  __attribute__((export_name("TS_ParseError_invalid_script_hash_length"))) TS_ParseError_invalid_script_hash_length() {
39815         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39816         *ret_copy = ParseError_invalid_script_hash_length();
39817         uint32_t ret_ref = (uintptr_t)ret_copy;
39818         return ret_ref;
39819 }
39820
39821 uint32_t  __attribute__((export_name("TS_ParseError_invalid_recovery_id"))) TS_ParseError_invalid_recovery_id() {
39822         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39823         *ret_copy = ParseError_invalid_recovery_id();
39824         uint32_t ret_ref = (uintptr_t)ret_copy;
39825         return ret_ref;
39826 }
39827
39828 uint32_t  __attribute__((export_name("TS_ParseError_invalid_slice_length"))) TS_ParseError_invalid_slice_length(jstring a) {
39829         LDKStr a_conv = str_ref_to_owned_c(a);
39830         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39831         *ret_copy = ParseError_invalid_slice_length(a_conv);
39832         uint32_t ret_ref = (uintptr_t)ret_copy;
39833         return ret_ref;
39834 }
39835
39836 uint32_t  __attribute__((export_name("TS_ParseError_skip"))) TS_ParseError_skip() {
39837         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
39838         *ret_copy = ParseError_skip();
39839         uint32_t ret_ref = (uintptr_t)ret_copy;
39840         return ret_ref;
39841 }
39842
39843 void  __attribute__((export_name("TS_ParseOrSemanticError_free"))) TS_ParseOrSemanticError_free(uint32_t this_ptr) {
39844         if ((this_ptr & 1) != 0) return;
39845         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
39846         CHECK_ACCESS(this_ptr_ptr);
39847         LDKParseOrSemanticError this_ptr_conv = *(LDKParseOrSemanticError*)(this_ptr_ptr);
39848         FREE((void*)this_ptr);
39849         ParseOrSemanticError_free(this_ptr_conv);
39850 }
39851
39852 static inline uintptr_t ParseOrSemanticError_clone_ptr(LDKParseOrSemanticError *NONNULL_PTR arg) {
39853         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
39854         *ret_copy = ParseOrSemanticError_clone(arg);
39855 uint32_t ret_ref = (uintptr_t)ret_copy;
39856         return ret_ref;
39857 }
39858 uint32_t  __attribute__((export_name("TS_ParseOrSemanticError_clone_ptr"))) TS_ParseOrSemanticError_clone_ptr(uint32_t arg) {
39859         LDKParseOrSemanticError* arg_conv = (LDKParseOrSemanticError*)arg;
39860         uint32_t ret_conv = ParseOrSemanticError_clone_ptr(arg_conv);
39861         return ret_conv;
39862 }
39863
39864 uint32_t  __attribute__((export_name("TS_ParseOrSemanticError_clone"))) TS_ParseOrSemanticError_clone(uint32_t orig) {
39865         LDKParseOrSemanticError* orig_conv = (LDKParseOrSemanticError*)orig;
39866         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
39867         *ret_copy = ParseOrSemanticError_clone(orig_conv);
39868         uint32_t ret_ref = (uintptr_t)ret_copy;
39869         return ret_ref;
39870 }
39871
39872 uint32_t  __attribute__((export_name("TS_ParseOrSemanticError_parse_error"))) TS_ParseOrSemanticError_parse_error(uint32_t a) {
39873         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
39874         CHECK_ACCESS(a_ptr);
39875         LDKParseError a_conv = *(LDKParseError*)(a_ptr);
39876         a_conv = ParseError_clone((LDKParseError*)(((uintptr_t)a) & ~1));
39877         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
39878         *ret_copy = ParseOrSemanticError_parse_error(a_conv);
39879         uint32_t ret_ref = (uintptr_t)ret_copy;
39880         return ret_ref;
39881 }
39882
39883 uint32_t  __attribute__((export_name("TS_ParseOrSemanticError_semantic_error"))) TS_ParseOrSemanticError_semantic_error(uint32_t a) {
39884         LDKSemanticError a_conv = LDKSemanticError_from_js(a);
39885         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
39886         *ret_copy = ParseOrSemanticError_semantic_error(a_conv);
39887         uint32_t ret_ref = (uintptr_t)ret_copy;
39888         return ret_ref;
39889 }
39890
39891 void  __attribute__((export_name("TS_Invoice_free"))) TS_Invoice_free(uint32_t this_obj) {
39892         LDKInvoice this_obj_conv;
39893         this_obj_conv.inner = (void*)(this_obj & (~1));
39894         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39896         Invoice_free(this_obj_conv);
39897 }
39898
39899 jboolean  __attribute__((export_name("TS_Invoice_eq"))) TS_Invoice_eq(uint32_t a, uint32_t b) {
39900         LDKInvoice a_conv;
39901         a_conv.inner = (void*)(a & (~1));
39902         a_conv.is_owned = false;
39903         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39904         LDKInvoice b_conv;
39905         b_conv.inner = (void*)(b & (~1));
39906         b_conv.is_owned = false;
39907         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39908         jboolean ret_conv = Invoice_eq(&a_conv, &b_conv);
39909         return ret_conv;
39910 }
39911
39912 static inline uintptr_t Invoice_clone_ptr(LDKInvoice *NONNULL_PTR arg) {
39913         LDKInvoice ret_var = Invoice_clone(arg);
39914 uint32_t ret_ref = 0;
39915 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39916 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39917 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39918 ret_ref = (uintptr_t)ret_var.inner;
39919 if (ret_var.is_owned) {
39920         ret_ref |= 1;
39921 }
39922         return ret_ref;
39923 }
39924 uint32_t  __attribute__((export_name("TS_Invoice_clone_ptr"))) TS_Invoice_clone_ptr(uint32_t arg) {
39925         LDKInvoice arg_conv;
39926         arg_conv.inner = (void*)(arg & (~1));
39927         arg_conv.is_owned = false;
39928         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39929         uint32_t ret_conv = Invoice_clone_ptr(&arg_conv);
39930         return ret_conv;
39931 }
39932
39933 uint32_t  __attribute__((export_name("TS_Invoice_clone"))) TS_Invoice_clone(uint32_t orig) {
39934         LDKInvoice orig_conv;
39935         orig_conv.inner = (void*)(orig & (~1));
39936         orig_conv.is_owned = false;
39937         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39938         LDKInvoice ret_var = Invoice_clone(&orig_conv);
39939         uint32_t ret_ref = 0;
39940         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39941         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39942         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39943         ret_ref = (uintptr_t)ret_var.inner;
39944         if (ret_var.is_owned) {
39945                 ret_ref |= 1;
39946         }
39947         return ret_ref;
39948 }
39949
39950 void  __attribute__((export_name("TS_SignedRawInvoice_free"))) TS_SignedRawInvoice_free(uint32_t this_obj) {
39951         LDKSignedRawInvoice this_obj_conv;
39952         this_obj_conv.inner = (void*)(this_obj & (~1));
39953         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39955         SignedRawInvoice_free(this_obj_conv);
39956 }
39957
39958 jboolean  __attribute__((export_name("TS_SignedRawInvoice_eq"))) TS_SignedRawInvoice_eq(uint32_t a, uint32_t b) {
39959         LDKSignedRawInvoice a_conv;
39960         a_conv.inner = (void*)(a & (~1));
39961         a_conv.is_owned = false;
39962         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39963         LDKSignedRawInvoice b_conv;
39964         b_conv.inner = (void*)(b & (~1));
39965         b_conv.is_owned = false;
39966         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39967         jboolean ret_conv = SignedRawInvoice_eq(&a_conv, &b_conv);
39968         return ret_conv;
39969 }
39970
39971 static inline uintptr_t SignedRawInvoice_clone_ptr(LDKSignedRawInvoice *NONNULL_PTR arg) {
39972         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(arg);
39973 uint32_t ret_ref = 0;
39974 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39975 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39976 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39977 ret_ref = (uintptr_t)ret_var.inner;
39978 if (ret_var.is_owned) {
39979         ret_ref |= 1;
39980 }
39981         return ret_ref;
39982 }
39983 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_clone_ptr"))) TS_SignedRawInvoice_clone_ptr(uint32_t arg) {
39984         LDKSignedRawInvoice arg_conv;
39985         arg_conv.inner = (void*)(arg & (~1));
39986         arg_conv.is_owned = false;
39987         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39988         uint32_t ret_conv = SignedRawInvoice_clone_ptr(&arg_conv);
39989         return ret_conv;
39990 }
39991
39992 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_clone"))) TS_SignedRawInvoice_clone(uint32_t orig) {
39993         LDKSignedRawInvoice orig_conv;
39994         orig_conv.inner = (void*)(orig & (~1));
39995         orig_conv.is_owned = false;
39996         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39997         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
39998         uint32_t ret_ref = 0;
39999         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40000         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40001         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40002         ret_ref = (uintptr_t)ret_var.inner;
40003         if (ret_var.is_owned) {
40004                 ret_ref |= 1;
40005         }
40006         return ret_ref;
40007 }
40008
40009 void  __attribute__((export_name("TS_RawInvoice_free"))) TS_RawInvoice_free(uint32_t this_obj) {
40010         LDKRawInvoice this_obj_conv;
40011         this_obj_conv.inner = (void*)(this_obj & (~1));
40012         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40014         RawInvoice_free(this_obj_conv);
40015 }
40016
40017 uint32_t  __attribute__((export_name("TS_RawInvoice_get_data"))) TS_RawInvoice_get_data(uint32_t this_ptr) {
40018         LDKRawInvoice this_ptr_conv;
40019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40020         this_ptr_conv.is_owned = false;
40021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40022         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
40023         uint32_t ret_ref = 0;
40024         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40025         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40026         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40027         ret_ref = (uintptr_t)ret_var.inner;
40028         if (ret_var.is_owned) {
40029                 ret_ref |= 1;
40030         }
40031         return ret_ref;
40032 }
40033
40034 void  __attribute__((export_name("TS_RawInvoice_set_data"))) TS_RawInvoice_set_data(uint32_t this_ptr, uint32_t val) {
40035         LDKRawInvoice this_ptr_conv;
40036         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40037         this_ptr_conv.is_owned = false;
40038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40039         LDKRawDataPart val_conv;
40040         val_conv.inner = (void*)(val & (~1));
40041         val_conv.is_owned = (val & 1) || (val == 0);
40042         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40043         val_conv = RawDataPart_clone(&val_conv);
40044         RawInvoice_set_data(&this_ptr_conv, val_conv);
40045 }
40046
40047 jboolean  __attribute__((export_name("TS_RawInvoice_eq"))) TS_RawInvoice_eq(uint32_t a, uint32_t b) {
40048         LDKRawInvoice a_conv;
40049         a_conv.inner = (void*)(a & (~1));
40050         a_conv.is_owned = false;
40051         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40052         LDKRawInvoice b_conv;
40053         b_conv.inner = (void*)(b & (~1));
40054         b_conv.is_owned = false;
40055         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40056         jboolean ret_conv = RawInvoice_eq(&a_conv, &b_conv);
40057         return ret_conv;
40058 }
40059
40060 static inline uintptr_t RawInvoice_clone_ptr(LDKRawInvoice *NONNULL_PTR arg) {
40061         LDKRawInvoice ret_var = RawInvoice_clone(arg);
40062 uint32_t ret_ref = 0;
40063 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40064 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40065 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40066 ret_ref = (uintptr_t)ret_var.inner;
40067 if (ret_var.is_owned) {
40068         ret_ref |= 1;
40069 }
40070         return ret_ref;
40071 }
40072 uint32_t  __attribute__((export_name("TS_RawInvoice_clone_ptr"))) TS_RawInvoice_clone_ptr(uint32_t arg) {
40073         LDKRawInvoice arg_conv;
40074         arg_conv.inner = (void*)(arg & (~1));
40075         arg_conv.is_owned = false;
40076         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40077         uint32_t ret_conv = RawInvoice_clone_ptr(&arg_conv);
40078         return ret_conv;
40079 }
40080
40081 uint32_t  __attribute__((export_name("TS_RawInvoice_clone"))) TS_RawInvoice_clone(uint32_t orig) {
40082         LDKRawInvoice orig_conv;
40083         orig_conv.inner = (void*)(orig & (~1));
40084         orig_conv.is_owned = false;
40085         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40086         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
40087         uint32_t ret_ref = 0;
40088         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40089         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40090         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40091         ret_ref = (uintptr_t)ret_var.inner;
40092         if (ret_var.is_owned) {
40093                 ret_ref |= 1;
40094         }
40095         return ret_ref;
40096 }
40097
40098 void  __attribute__((export_name("TS_RawDataPart_free"))) TS_RawDataPart_free(uint32_t this_obj) {
40099         LDKRawDataPart this_obj_conv;
40100         this_obj_conv.inner = (void*)(this_obj & (~1));
40101         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40103         RawDataPart_free(this_obj_conv);
40104 }
40105
40106 uint32_t  __attribute__((export_name("TS_RawDataPart_get_timestamp"))) TS_RawDataPart_get_timestamp(uint32_t this_ptr) {
40107         LDKRawDataPart this_ptr_conv;
40108         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40109         this_ptr_conv.is_owned = false;
40110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40111         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
40112         uint32_t ret_ref = 0;
40113         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40114         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40115         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40116         ret_ref = (uintptr_t)ret_var.inner;
40117         if (ret_var.is_owned) {
40118                 ret_ref |= 1;
40119         }
40120         return ret_ref;
40121 }
40122
40123 void  __attribute__((export_name("TS_RawDataPart_set_timestamp"))) TS_RawDataPart_set_timestamp(uint32_t this_ptr, uint32_t val) {
40124         LDKRawDataPart this_ptr_conv;
40125         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40126         this_ptr_conv.is_owned = false;
40127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40128         LDKPositiveTimestamp val_conv;
40129         val_conv.inner = (void*)(val & (~1));
40130         val_conv.is_owned = (val & 1) || (val == 0);
40131         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40132         val_conv = PositiveTimestamp_clone(&val_conv);
40133         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
40134 }
40135
40136 jboolean  __attribute__((export_name("TS_RawDataPart_eq"))) TS_RawDataPart_eq(uint32_t a, uint32_t b) {
40137         LDKRawDataPart a_conv;
40138         a_conv.inner = (void*)(a & (~1));
40139         a_conv.is_owned = false;
40140         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40141         LDKRawDataPart b_conv;
40142         b_conv.inner = (void*)(b & (~1));
40143         b_conv.is_owned = false;
40144         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40145         jboolean ret_conv = RawDataPart_eq(&a_conv, &b_conv);
40146         return ret_conv;
40147 }
40148
40149 static inline uintptr_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
40150         LDKRawDataPart ret_var = RawDataPart_clone(arg);
40151 uint32_t ret_ref = 0;
40152 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40153 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40154 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40155 ret_ref = (uintptr_t)ret_var.inner;
40156 if (ret_var.is_owned) {
40157         ret_ref |= 1;
40158 }
40159         return ret_ref;
40160 }
40161 uint32_t  __attribute__((export_name("TS_RawDataPart_clone_ptr"))) TS_RawDataPart_clone_ptr(uint32_t arg) {
40162         LDKRawDataPart arg_conv;
40163         arg_conv.inner = (void*)(arg & (~1));
40164         arg_conv.is_owned = false;
40165         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40166         uint32_t ret_conv = RawDataPart_clone_ptr(&arg_conv);
40167         return ret_conv;
40168 }
40169
40170 uint32_t  __attribute__((export_name("TS_RawDataPart_clone"))) TS_RawDataPart_clone(uint32_t orig) {
40171         LDKRawDataPart orig_conv;
40172         orig_conv.inner = (void*)(orig & (~1));
40173         orig_conv.is_owned = false;
40174         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40175         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
40176         uint32_t ret_ref = 0;
40177         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40178         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40179         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40180         ret_ref = (uintptr_t)ret_var.inner;
40181         if (ret_var.is_owned) {
40182                 ret_ref |= 1;
40183         }
40184         return ret_ref;
40185 }
40186
40187 void  __attribute__((export_name("TS_PositiveTimestamp_free"))) TS_PositiveTimestamp_free(uint32_t this_obj) {
40188         LDKPositiveTimestamp this_obj_conv;
40189         this_obj_conv.inner = (void*)(this_obj & (~1));
40190         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40192         PositiveTimestamp_free(this_obj_conv);
40193 }
40194
40195 jboolean  __attribute__((export_name("TS_PositiveTimestamp_eq"))) TS_PositiveTimestamp_eq(uint32_t a, uint32_t b) {
40196         LDKPositiveTimestamp a_conv;
40197         a_conv.inner = (void*)(a & (~1));
40198         a_conv.is_owned = false;
40199         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40200         LDKPositiveTimestamp b_conv;
40201         b_conv.inner = (void*)(b & (~1));
40202         b_conv.is_owned = false;
40203         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40204         jboolean ret_conv = PositiveTimestamp_eq(&a_conv, &b_conv);
40205         return ret_conv;
40206 }
40207
40208 static inline uintptr_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
40209         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
40210 uint32_t ret_ref = 0;
40211 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40212 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40213 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40214 ret_ref = (uintptr_t)ret_var.inner;
40215 if (ret_var.is_owned) {
40216         ret_ref |= 1;
40217 }
40218         return ret_ref;
40219 }
40220 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_clone_ptr"))) TS_PositiveTimestamp_clone_ptr(uint32_t arg) {
40221         LDKPositiveTimestamp arg_conv;
40222         arg_conv.inner = (void*)(arg & (~1));
40223         arg_conv.is_owned = false;
40224         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40225         uint32_t ret_conv = PositiveTimestamp_clone_ptr(&arg_conv);
40226         return ret_conv;
40227 }
40228
40229 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_clone"))) TS_PositiveTimestamp_clone(uint32_t orig) {
40230         LDKPositiveTimestamp orig_conv;
40231         orig_conv.inner = (void*)(orig & (~1));
40232         orig_conv.is_owned = false;
40233         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40234         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
40235         uint32_t ret_ref = 0;
40236         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40237         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40238         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40239         ret_ref = (uintptr_t)ret_var.inner;
40240         if (ret_var.is_owned) {
40241                 ret_ref |= 1;
40242         }
40243         return ret_ref;
40244 }
40245
40246 uint32_t  __attribute__((export_name("TS_SiPrefix_clone"))) TS_SiPrefix_clone(uint32_t orig) {
40247         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
40248         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_clone(orig_conv));
40249         return ret_conv;
40250 }
40251
40252 uint32_t  __attribute__((export_name("TS_SiPrefix_milli"))) TS_SiPrefix_milli() {
40253         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_milli());
40254         return ret_conv;
40255 }
40256
40257 uint32_t  __attribute__((export_name("TS_SiPrefix_micro"))) TS_SiPrefix_micro() {
40258         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_micro());
40259         return ret_conv;
40260 }
40261
40262 uint32_t  __attribute__((export_name("TS_SiPrefix_nano"))) TS_SiPrefix_nano() {
40263         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_nano());
40264         return ret_conv;
40265 }
40266
40267 uint32_t  __attribute__((export_name("TS_SiPrefix_pico"))) TS_SiPrefix_pico() {
40268         uint32_t ret_conv = LDKSiPrefix_to_js(SiPrefix_pico());
40269         return ret_conv;
40270 }
40271
40272 jboolean  __attribute__((export_name("TS_SiPrefix_eq"))) TS_SiPrefix_eq(uint32_t a, uint32_t b) {
40273         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
40274         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
40275         jboolean ret_conv = SiPrefix_eq(a_conv, b_conv);
40276         return ret_conv;
40277 }
40278
40279 int64_t  __attribute__((export_name("TS_SiPrefix_multiplier"))) TS_SiPrefix_multiplier(uint32_t this_arg) {
40280         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
40281         int64_t ret_conv = SiPrefix_multiplier(this_arg_conv);
40282         return ret_conv;
40283 }
40284
40285 uint32_t  __attribute__((export_name("TS_Currency_clone"))) TS_Currency_clone(uint32_t orig) {
40286         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
40287         uint32_t ret_conv = LDKCurrency_to_js(Currency_clone(orig_conv));
40288         return ret_conv;
40289 }
40290
40291 uint32_t  __attribute__((export_name("TS_Currency_bitcoin"))) TS_Currency_bitcoin() {
40292         uint32_t ret_conv = LDKCurrency_to_js(Currency_bitcoin());
40293         return ret_conv;
40294 }
40295
40296 uint32_t  __attribute__((export_name("TS_Currency_bitcoin_testnet"))) TS_Currency_bitcoin_testnet() {
40297         uint32_t ret_conv = LDKCurrency_to_js(Currency_bitcoin_testnet());
40298         return ret_conv;
40299 }
40300
40301 uint32_t  __attribute__((export_name("TS_Currency_regtest"))) TS_Currency_regtest() {
40302         uint32_t ret_conv = LDKCurrency_to_js(Currency_regtest());
40303         return ret_conv;
40304 }
40305
40306 uint32_t  __attribute__((export_name("TS_Currency_simnet"))) TS_Currency_simnet() {
40307         uint32_t ret_conv = LDKCurrency_to_js(Currency_simnet());
40308         return ret_conv;
40309 }
40310
40311 uint32_t  __attribute__((export_name("TS_Currency_signet"))) TS_Currency_signet() {
40312         uint32_t ret_conv = LDKCurrency_to_js(Currency_signet());
40313         return ret_conv;
40314 }
40315
40316 int64_t  __attribute__((export_name("TS_Currency_hash"))) TS_Currency_hash(uint32_t o) {
40317         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
40318         int64_t ret_conv = Currency_hash(o_conv);
40319         return ret_conv;
40320 }
40321
40322 jboolean  __attribute__((export_name("TS_Currency_eq"))) TS_Currency_eq(uint32_t a, uint32_t b) {
40323         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
40324         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
40325         jboolean ret_conv = Currency_eq(a_conv, b_conv);
40326         return ret_conv;
40327 }
40328
40329 void  __attribute__((export_name("TS_Sha256_free"))) TS_Sha256_free(uint32_t this_obj) {
40330         LDKSha256 this_obj_conv;
40331         this_obj_conv.inner = (void*)(this_obj & (~1));
40332         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40334         Sha256_free(this_obj_conv);
40335 }
40336
40337 static inline uintptr_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
40338         LDKSha256 ret_var = Sha256_clone(arg);
40339 uint32_t ret_ref = 0;
40340 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40341 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40342 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40343 ret_ref = (uintptr_t)ret_var.inner;
40344 if (ret_var.is_owned) {
40345         ret_ref |= 1;
40346 }
40347         return ret_ref;
40348 }
40349 uint32_t  __attribute__((export_name("TS_Sha256_clone_ptr"))) TS_Sha256_clone_ptr(uint32_t arg) {
40350         LDKSha256 arg_conv;
40351         arg_conv.inner = (void*)(arg & (~1));
40352         arg_conv.is_owned = false;
40353         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40354         uint32_t ret_conv = Sha256_clone_ptr(&arg_conv);
40355         return ret_conv;
40356 }
40357
40358 uint32_t  __attribute__((export_name("TS_Sha256_clone"))) TS_Sha256_clone(uint32_t orig) {
40359         LDKSha256 orig_conv;
40360         orig_conv.inner = (void*)(orig & (~1));
40361         orig_conv.is_owned = false;
40362         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40363         LDKSha256 ret_var = Sha256_clone(&orig_conv);
40364         uint32_t ret_ref = 0;
40365         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40366         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40367         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40368         ret_ref = (uintptr_t)ret_var.inner;
40369         if (ret_var.is_owned) {
40370                 ret_ref |= 1;
40371         }
40372         return ret_ref;
40373 }
40374
40375 int64_t  __attribute__((export_name("TS_Sha256_hash"))) TS_Sha256_hash(uint32_t o) {
40376         LDKSha256 o_conv;
40377         o_conv.inner = (void*)(o & (~1));
40378         o_conv.is_owned = false;
40379         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40380         int64_t ret_conv = Sha256_hash(&o_conv);
40381         return ret_conv;
40382 }
40383
40384 jboolean  __attribute__((export_name("TS_Sha256_eq"))) TS_Sha256_eq(uint32_t a, uint32_t b) {
40385         LDKSha256 a_conv;
40386         a_conv.inner = (void*)(a & (~1));
40387         a_conv.is_owned = false;
40388         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40389         LDKSha256 b_conv;
40390         b_conv.inner = (void*)(b & (~1));
40391         b_conv.is_owned = false;
40392         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40393         jboolean ret_conv = Sha256_eq(&a_conv, &b_conv);
40394         return ret_conv;
40395 }
40396
40397 void  __attribute__((export_name("TS_Description_free"))) TS_Description_free(uint32_t this_obj) {
40398         LDKDescription this_obj_conv;
40399         this_obj_conv.inner = (void*)(this_obj & (~1));
40400         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40402         Description_free(this_obj_conv);
40403 }
40404
40405 static inline uintptr_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
40406         LDKDescription ret_var = Description_clone(arg);
40407 uint32_t ret_ref = 0;
40408 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40409 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40410 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40411 ret_ref = (uintptr_t)ret_var.inner;
40412 if (ret_var.is_owned) {
40413         ret_ref |= 1;
40414 }
40415         return ret_ref;
40416 }
40417 uint32_t  __attribute__((export_name("TS_Description_clone_ptr"))) TS_Description_clone_ptr(uint32_t arg) {
40418         LDKDescription arg_conv;
40419         arg_conv.inner = (void*)(arg & (~1));
40420         arg_conv.is_owned = false;
40421         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40422         uint32_t ret_conv = Description_clone_ptr(&arg_conv);
40423         return ret_conv;
40424 }
40425
40426 uint32_t  __attribute__((export_name("TS_Description_clone"))) TS_Description_clone(uint32_t orig) {
40427         LDKDescription orig_conv;
40428         orig_conv.inner = (void*)(orig & (~1));
40429         orig_conv.is_owned = false;
40430         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40431         LDKDescription ret_var = Description_clone(&orig_conv);
40432         uint32_t ret_ref = 0;
40433         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40434         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40435         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40436         ret_ref = (uintptr_t)ret_var.inner;
40437         if (ret_var.is_owned) {
40438                 ret_ref |= 1;
40439         }
40440         return ret_ref;
40441 }
40442
40443 int64_t  __attribute__((export_name("TS_Description_hash"))) TS_Description_hash(uint32_t o) {
40444         LDKDescription o_conv;
40445         o_conv.inner = (void*)(o & (~1));
40446         o_conv.is_owned = false;
40447         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40448         int64_t ret_conv = Description_hash(&o_conv);
40449         return ret_conv;
40450 }
40451
40452 jboolean  __attribute__((export_name("TS_Description_eq"))) TS_Description_eq(uint32_t a, uint32_t b) {
40453         LDKDescription a_conv;
40454         a_conv.inner = (void*)(a & (~1));
40455         a_conv.is_owned = false;
40456         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40457         LDKDescription b_conv;
40458         b_conv.inner = (void*)(b & (~1));
40459         b_conv.is_owned = false;
40460         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40461         jboolean ret_conv = Description_eq(&a_conv, &b_conv);
40462         return ret_conv;
40463 }
40464
40465 void  __attribute__((export_name("TS_PayeePubKey_free"))) TS_PayeePubKey_free(uint32_t this_obj) {
40466         LDKPayeePubKey this_obj_conv;
40467         this_obj_conv.inner = (void*)(this_obj & (~1));
40468         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40470         PayeePubKey_free(this_obj_conv);
40471 }
40472
40473 int8_tArray  __attribute__((export_name("TS_PayeePubKey_get_a"))) TS_PayeePubKey_get_a(uint32_t this_ptr) {
40474         LDKPayeePubKey this_ptr_conv;
40475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40476         this_ptr_conv.is_owned = false;
40477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40478         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
40479         memcpy(ret_arr->elems, PayeePubKey_get_a(&this_ptr_conv).compressed_form, 33);
40480         return ret_arr;
40481 }
40482
40483 void  __attribute__((export_name("TS_PayeePubKey_set_a"))) TS_PayeePubKey_set_a(uint32_t this_ptr, int8_tArray val) {
40484         LDKPayeePubKey this_ptr_conv;
40485         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40486         this_ptr_conv.is_owned = false;
40487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40488         LDKPublicKey val_ref;
40489         CHECK(val->arr_len == 33);
40490         memcpy(val_ref.compressed_form, val->elems, 33); FREE(val);
40491         PayeePubKey_set_a(&this_ptr_conv, val_ref);
40492 }
40493
40494 uint32_t  __attribute__((export_name("TS_PayeePubKey_new"))) TS_PayeePubKey_new(int8_tArray a_arg) {
40495         LDKPublicKey a_arg_ref;
40496         CHECK(a_arg->arr_len == 33);
40497         memcpy(a_arg_ref.compressed_form, a_arg->elems, 33); FREE(a_arg);
40498         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
40499         uint32_t ret_ref = 0;
40500         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40501         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40502         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40503         ret_ref = (uintptr_t)ret_var.inner;
40504         if (ret_var.is_owned) {
40505                 ret_ref |= 1;
40506         }
40507         return ret_ref;
40508 }
40509
40510 static inline uintptr_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
40511         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
40512 uint32_t ret_ref = 0;
40513 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40514 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40515 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40516 ret_ref = (uintptr_t)ret_var.inner;
40517 if (ret_var.is_owned) {
40518         ret_ref |= 1;
40519 }
40520         return ret_ref;
40521 }
40522 uint32_t  __attribute__((export_name("TS_PayeePubKey_clone_ptr"))) TS_PayeePubKey_clone_ptr(uint32_t arg) {
40523         LDKPayeePubKey arg_conv;
40524         arg_conv.inner = (void*)(arg & (~1));
40525         arg_conv.is_owned = false;
40526         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40527         uint32_t ret_conv = PayeePubKey_clone_ptr(&arg_conv);
40528         return ret_conv;
40529 }
40530
40531 uint32_t  __attribute__((export_name("TS_PayeePubKey_clone"))) TS_PayeePubKey_clone(uint32_t orig) {
40532         LDKPayeePubKey orig_conv;
40533         orig_conv.inner = (void*)(orig & (~1));
40534         orig_conv.is_owned = false;
40535         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40536         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
40537         uint32_t ret_ref = 0;
40538         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40539         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40540         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40541         ret_ref = (uintptr_t)ret_var.inner;
40542         if (ret_var.is_owned) {
40543                 ret_ref |= 1;
40544         }
40545         return ret_ref;
40546 }
40547
40548 int64_t  __attribute__((export_name("TS_PayeePubKey_hash"))) TS_PayeePubKey_hash(uint32_t o) {
40549         LDKPayeePubKey o_conv;
40550         o_conv.inner = (void*)(o & (~1));
40551         o_conv.is_owned = false;
40552         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40553         int64_t ret_conv = PayeePubKey_hash(&o_conv);
40554         return ret_conv;
40555 }
40556
40557 jboolean  __attribute__((export_name("TS_PayeePubKey_eq"))) TS_PayeePubKey_eq(uint32_t a, uint32_t b) {
40558         LDKPayeePubKey a_conv;
40559         a_conv.inner = (void*)(a & (~1));
40560         a_conv.is_owned = false;
40561         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40562         LDKPayeePubKey b_conv;
40563         b_conv.inner = (void*)(b & (~1));
40564         b_conv.is_owned = false;
40565         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40566         jboolean ret_conv = PayeePubKey_eq(&a_conv, &b_conv);
40567         return ret_conv;
40568 }
40569
40570 void  __attribute__((export_name("TS_ExpiryTime_free"))) TS_ExpiryTime_free(uint32_t this_obj) {
40571         LDKExpiryTime this_obj_conv;
40572         this_obj_conv.inner = (void*)(this_obj & (~1));
40573         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40575         ExpiryTime_free(this_obj_conv);
40576 }
40577
40578 static inline uintptr_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
40579         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
40580 uint32_t ret_ref = 0;
40581 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40582 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40583 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40584 ret_ref = (uintptr_t)ret_var.inner;
40585 if (ret_var.is_owned) {
40586         ret_ref |= 1;
40587 }
40588         return ret_ref;
40589 }
40590 uint32_t  __attribute__((export_name("TS_ExpiryTime_clone_ptr"))) TS_ExpiryTime_clone_ptr(uint32_t arg) {
40591         LDKExpiryTime arg_conv;
40592         arg_conv.inner = (void*)(arg & (~1));
40593         arg_conv.is_owned = false;
40594         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40595         uint32_t ret_conv = ExpiryTime_clone_ptr(&arg_conv);
40596         return ret_conv;
40597 }
40598
40599 uint32_t  __attribute__((export_name("TS_ExpiryTime_clone"))) TS_ExpiryTime_clone(uint32_t orig) {
40600         LDKExpiryTime orig_conv;
40601         orig_conv.inner = (void*)(orig & (~1));
40602         orig_conv.is_owned = false;
40603         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40604         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
40605         uint32_t ret_ref = 0;
40606         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40607         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40608         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40609         ret_ref = (uintptr_t)ret_var.inner;
40610         if (ret_var.is_owned) {
40611                 ret_ref |= 1;
40612         }
40613         return ret_ref;
40614 }
40615
40616 int64_t  __attribute__((export_name("TS_ExpiryTime_hash"))) TS_ExpiryTime_hash(uint32_t o) {
40617         LDKExpiryTime o_conv;
40618         o_conv.inner = (void*)(o & (~1));
40619         o_conv.is_owned = false;
40620         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40621         int64_t ret_conv = ExpiryTime_hash(&o_conv);
40622         return ret_conv;
40623 }
40624
40625 jboolean  __attribute__((export_name("TS_ExpiryTime_eq"))) TS_ExpiryTime_eq(uint32_t a, uint32_t b) {
40626         LDKExpiryTime a_conv;
40627         a_conv.inner = (void*)(a & (~1));
40628         a_conv.is_owned = false;
40629         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40630         LDKExpiryTime b_conv;
40631         b_conv.inner = (void*)(b & (~1));
40632         b_conv.is_owned = false;
40633         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40634         jboolean ret_conv = ExpiryTime_eq(&a_conv, &b_conv);
40635         return ret_conv;
40636 }
40637
40638 void  __attribute__((export_name("TS_MinFinalCltvExpiry_free"))) TS_MinFinalCltvExpiry_free(uint32_t this_obj) {
40639         LDKMinFinalCltvExpiry this_obj_conv;
40640         this_obj_conv.inner = (void*)(this_obj & (~1));
40641         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40643         MinFinalCltvExpiry_free(this_obj_conv);
40644 }
40645
40646 int64_t  __attribute__((export_name("TS_MinFinalCltvExpiry_get_a"))) TS_MinFinalCltvExpiry_get_a(uint32_t this_ptr) {
40647         LDKMinFinalCltvExpiry this_ptr_conv;
40648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40649         this_ptr_conv.is_owned = false;
40650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40651         int64_t ret_conv = MinFinalCltvExpiry_get_a(&this_ptr_conv);
40652         return ret_conv;
40653 }
40654
40655 void  __attribute__((export_name("TS_MinFinalCltvExpiry_set_a"))) TS_MinFinalCltvExpiry_set_a(uint32_t this_ptr, int64_t val) {
40656         LDKMinFinalCltvExpiry this_ptr_conv;
40657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
40658         this_ptr_conv.is_owned = false;
40659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40660         MinFinalCltvExpiry_set_a(&this_ptr_conv, val);
40661 }
40662
40663 uint32_t  __attribute__((export_name("TS_MinFinalCltvExpiry_new"))) TS_MinFinalCltvExpiry_new(int64_t a_arg) {
40664         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_new(a_arg);
40665         uint32_t ret_ref = 0;
40666         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40667         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40668         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40669         ret_ref = (uintptr_t)ret_var.inner;
40670         if (ret_var.is_owned) {
40671                 ret_ref |= 1;
40672         }
40673         return ret_ref;
40674 }
40675
40676 static inline uintptr_t MinFinalCltvExpiry_clone_ptr(LDKMinFinalCltvExpiry *NONNULL_PTR arg) {
40677         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(arg);
40678 uint32_t ret_ref = 0;
40679 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40680 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40681 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40682 ret_ref = (uintptr_t)ret_var.inner;
40683 if (ret_var.is_owned) {
40684         ret_ref |= 1;
40685 }
40686         return ret_ref;
40687 }
40688 uint32_t  __attribute__((export_name("TS_MinFinalCltvExpiry_clone_ptr"))) TS_MinFinalCltvExpiry_clone_ptr(uint32_t arg) {
40689         LDKMinFinalCltvExpiry arg_conv;
40690         arg_conv.inner = (void*)(arg & (~1));
40691         arg_conv.is_owned = false;
40692         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40693         uint32_t ret_conv = MinFinalCltvExpiry_clone_ptr(&arg_conv);
40694         return ret_conv;
40695 }
40696
40697 uint32_t  __attribute__((export_name("TS_MinFinalCltvExpiry_clone"))) TS_MinFinalCltvExpiry_clone(uint32_t orig) {
40698         LDKMinFinalCltvExpiry orig_conv;
40699         orig_conv.inner = (void*)(orig & (~1));
40700         orig_conv.is_owned = false;
40701         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40702         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
40703         uint32_t ret_ref = 0;
40704         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40705         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40706         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40707         ret_ref = (uintptr_t)ret_var.inner;
40708         if (ret_var.is_owned) {
40709                 ret_ref |= 1;
40710         }
40711         return ret_ref;
40712 }
40713
40714 int64_t  __attribute__((export_name("TS_MinFinalCltvExpiry_hash"))) TS_MinFinalCltvExpiry_hash(uint32_t o) {
40715         LDKMinFinalCltvExpiry o_conv;
40716         o_conv.inner = (void*)(o & (~1));
40717         o_conv.is_owned = false;
40718         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40719         int64_t ret_conv = MinFinalCltvExpiry_hash(&o_conv);
40720         return ret_conv;
40721 }
40722
40723 jboolean  __attribute__((export_name("TS_MinFinalCltvExpiry_eq"))) TS_MinFinalCltvExpiry_eq(uint32_t a, uint32_t b) {
40724         LDKMinFinalCltvExpiry a_conv;
40725         a_conv.inner = (void*)(a & (~1));
40726         a_conv.is_owned = false;
40727         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40728         LDKMinFinalCltvExpiry b_conv;
40729         b_conv.inner = (void*)(b & (~1));
40730         b_conv.is_owned = false;
40731         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40732         jboolean ret_conv = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
40733         return ret_conv;
40734 }
40735
40736 void  __attribute__((export_name("TS_Fallback_free"))) TS_Fallback_free(uint32_t this_ptr) {
40737         if ((this_ptr & 1) != 0) return;
40738         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
40739         CHECK_ACCESS(this_ptr_ptr);
40740         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
40741         FREE((void*)this_ptr);
40742         Fallback_free(this_ptr_conv);
40743 }
40744
40745 static inline uintptr_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
40746         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
40747         *ret_copy = Fallback_clone(arg);
40748 uint32_t ret_ref = (uintptr_t)ret_copy;
40749         return ret_ref;
40750 }
40751 uint32_t  __attribute__((export_name("TS_Fallback_clone_ptr"))) TS_Fallback_clone_ptr(uint32_t arg) {
40752         LDKFallback* arg_conv = (LDKFallback*)arg;
40753         uint32_t ret_conv = Fallback_clone_ptr(arg_conv);
40754         return ret_conv;
40755 }
40756
40757 uint32_t  __attribute__((export_name("TS_Fallback_clone"))) TS_Fallback_clone(uint32_t orig) {
40758         LDKFallback* orig_conv = (LDKFallback*)orig;
40759         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
40760         *ret_copy = Fallback_clone(orig_conv);
40761         uint32_t ret_ref = (uintptr_t)ret_copy;
40762         return ret_ref;
40763 }
40764
40765 uint32_t  __attribute__((export_name("TS_Fallback_seg_wit_program"))) TS_Fallback_seg_wit_program(int8_t version, int8_tArray program) {
40766         
40767         LDKCVec_u8Z program_ref;
40768         program_ref.datalen = program->arr_len;
40769         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
40770         memcpy(program_ref.data, program->elems, program_ref.datalen); FREE(program);
40771         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
40772         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
40773         uint32_t ret_ref = (uintptr_t)ret_copy;
40774         return ret_ref;
40775 }
40776
40777 uint32_t  __attribute__((export_name("TS_Fallback_pub_key_hash"))) TS_Fallback_pub_key_hash(int8_tArray a) {
40778         LDKTwentyBytes a_ref;
40779         CHECK(a->arr_len == 20);
40780         memcpy(a_ref.data, a->elems, 20); FREE(a);
40781         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
40782         *ret_copy = Fallback_pub_key_hash(a_ref);
40783         uint32_t ret_ref = (uintptr_t)ret_copy;
40784         return ret_ref;
40785 }
40786
40787 uint32_t  __attribute__((export_name("TS_Fallback_script_hash"))) TS_Fallback_script_hash(int8_tArray a) {
40788         LDKTwentyBytes a_ref;
40789         CHECK(a->arr_len == 20);
40790         memcpy(a_ref.data, a->elems, 20); FREE(a);
40791         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
40792         *ret_copy = Fallback_script_hash(a_ref);
40793         uint32_t ret_ref = (uintptr_t)ret_copy;
40794         return ret_ref;
40795 }
40796
40797 int64_t  __attribute__((export_name("TS_Fallback_hash"))) TS_Fallback_hash(uint32_t o) {
40798         LDKFallback* o_conv = (LDKFallback*)o;
40799         int64_t ret_conv = Fallback_hash(o_conv);
40800         return ret_conv;
40801 }
40802
40803 jboolean  __attribute__((export_name("TS_Fallback_eq"))) TS_Fallback_eq(uint32_t a, uint32_t b) {
40804         LDKFallback* a_conv = (LDKFallback*)a;
40805         LDKFallback* b_conv = (LDKFallback*)b;
40806         jboolean ret_conv = Fallback_eq(a_conv, b_conv);
40807         return ret_conv;
40808 }
40809
40810 void  __attribute__((export_name("TS_InvoiceSignature_free"))) TS_InvoiceSignature_free(uint32_t this_obj) {
40811         LDKInvoiceSignature this_obj_conv;
40812         this_obj_conv.inner = (void*)(this_obj & (~1));
40813         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40815         InvoiceSignature_free(this_obj_conv);
40816 }
40817
40818 static inline uintptr_t InvoiceSignature_clone_ptr(LDKInvoiceSignature *NONNULL_PTR arg) {
40819         LDKInvoiceSignature ret_var = InvoiceSignature_clone(arg);
40820 uint32_t ret_ref = 0;
40821 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40822 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40823 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40824 ret_ref = (uintptr_t)ret_var.inner;
40825 if (ret_var.is_owned) {
40826         ret_ref |= 1;
40827 }
40828         return ret_ref;
40829 }
40830 uint32_t  __attribute__((export_name("TS_InvoiceSignature_clone_ptr"))) TS_InvoiceSignature_clone_ptr(uint32_t arg) {
40831         LDKInvoiceSignature arg_conv;
40832         arg_conv.inner = (void*)(arg & (~1));
40833         arg_conv.is_owned = false;
40834         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40835         uint32_t ret_conv = InvoiceSignature_clone_ptr(&arg_conv);
40836         return ret_conv;
40837 }
40838
40839 uint32_t  __attribute__((export_name("TS_InvoiceSignature_clone"))) TS_InvoiceSignature_clone(uint32_t orig) {
40840         LDKInvoiceSignature orig_conv;
40841         orig_conv.inner = (void*)(orig & (~1));
40842         orig_conv.is_owned = false;
40843         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40844         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
40845         uint32_t ret_ref = 0;
40846         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40847         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40848         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40849         ret_ref = (uintptr_t)ret_var.inner;
40850         if (ret_var.is_owned) {
40851                 ret_ref |= 1;
40852         }
40853         return ret_ref;
40854 }
40855
40856 jboolean  __attribute__((export_name("TS_InvoiceSignature_eq"))) TS_InvoiceSignature_eq(uint32_t a, uint32_t b) {
40857         LDKInvoiceSignature a_conv;
40858         a_conv.inner = (void*)(a & (~1));
40859         a_conv.is_owned = false;
40860         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40861         LDKInvoiceSignature b_conv;
40862         b_conv.inner = (void*)(b & (~1));
40863         b_conv.is_owned = false;
40864         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40865         jboolean ret_conv = InvoiceSignature_eq(&a_conv, &b_conv);
40866         return ret_conv;
40867 }
40868
40869 void  __attribute__((export_name("TS_PrivateRoute_free"))) TS_PrivateRoute_free(uint32_t this_obj) {
40870         LDKPrivateRoute this_obj_conv;
40871         this_obj_conv.inner = (void*)(this_obj & (~1));
40872         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40874         PrivateRoute_free(this_obj_conv);
40875 }
40876
40877 static inline uintptr_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
40878         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
40879 uint32_t ret_ref = 0;
40880 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40881 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40882 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40883 ret_ref = (uintptr_t)ret_var.inner;
40884 if (ret_var.is_owned) {
40885         ret_ref |= 1;
40886 }
40887         return ret_ref;
40888 }
40889 uint32_t  __attribute__((export_name("TS_PrivateRoute_clone_ptr"))) TS_PrivateRoute_clone_ptr(uint32_t arg) {
40890         LDKPrivateRoute arg_conv;
40891         arg_conv.inner = (void*)(arg & (~1));
40892         arg_conv.is_owned = false;
40893         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40894         uint32_t ret_conv = PrivateRoute_clone_ptr(&arg_conv);
40895         return ret_conv;
40896 }
40897
40898 uint32_t  __attribute__((export_name("TS_PrivateRoute_clone"))) TS_PrivateRoute_clone(uint32_t orig) {
40899         LDKPrivateRoute orig_conv;
40900         orig_conv.inner = (void*)(orig & (~1));
40901         orig_conv.is_owned = false;
40902         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40903         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
40904         uint32_t ret_ref = 0;
40905         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40906         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40907         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40908         ret_ref = (uintptr_t)ret_var.inner;
40909         if (ret_var.is_owned) {
40910                 ret_ref |= 1;
40911         }
40912         return ret_ref;
40913 }
40914
40915 int64_t  __attribute__((export_name("TS_PrivateRoute_hash"))) TS_PrivateRoute_hash(uint32_t o) {
40916         LDKPrivateRoute o_conv;
40917         o_conv.inner = (void*)(o & (~1));
40918         o_conv.is_owned = false;
40919         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40920         int64_t ret_conv = PrivateRoute_hash(&o_conv);
40921         return ret_conv;
40922 }
40923
40924 jboolean  __attribute__((export_name("TS_PrivateRoute_eq"))) TS_PrivateRoute_eq(uint32_t a, uint32_t b) {
40925         LDKPrivateRoute a_conv;
40926         a_conv.inner = (void*)(a & (~1));
40927         a_conv.is_owned = false;
40928         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
40929         LDKPrivateRoute b_conv;
40930         b_conv.inner = (void*)(b & (~1));
40931         b_conv.is_owned = false;
40932         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
40933         jboolean ret_conv = PrivateRoute_eq(&a_conv, &b_conv);
40934         return ret_conv;
40935 }
40936
40937 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_into_parts"))) TS_SignedRawInvoice_into_parts(uint32_t this_arg) {
40938         LDKSignedRawInvoice this_arg_conv;
40939         this_arg_conv.inner = (void*)(this_arg & (~1));
40940         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
40941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40942         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
40943         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
40944         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
40945         return ((uint32_t)ret_conv);
40946 }
40947
40948 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_raw_invoice"))) TS_SignedRawInvoice_raw_invoice(uint32_t this_arg) {
40949         LDKSignedRawInvoice this_arg_conv;
40950         this_arg_conv.inner = (void*)(this_arg & (~1));
40951         this_arg_conv.is_owned = false;
40952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40953         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
40954         uint32_t ret_ref = 0;
40955         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40956         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40957         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40958         ret_ref = (uintptr_t)ret_var.inner;
40959         if (ret_var.is_owned) {
40960                 ret_ref |= 1;
40961         }
40962         return ret_ref;
40963 }
40964
40965 int8_tArray  __attribute__((export_name("TS_SignedRawInvoice_hash"))) TS_SignedRawInvoice_hash(uint32_t this_arg) {
40966         LDKSignedRawInvoice this_arg_conv;
40967         this_arg_conv.inner = (void*)(this_arg & (~1));
40968         this_arg_conv.is_owned = false;
40969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40970         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
40971         memcpy(ret_arr->elems, *SignedRawInvoice_hash(&this_arg_conv), 32);
40972         return ret_arr;
40973 }
40974
40975 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_signature"))) TS_SignedRawInvoice_signature(uint32_t this_arg) {
40976         LDKSignedRawInvoice this_arg_conv;
40977         this_arg_conv.inner = (void*)(this_arg & (~1));
40978         this_arg_conv.is_owned = false;
40979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40980         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
40981         uint32_t ret_ref = 0;
40982         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40983         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40984         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40985         ret_ref = (uintptr_t)ret_var.inner;
40986         if (ret_var.is_owned) {
40987                 ret_ref |= 1;
40988         }
40989         return ret_ref;
40990 }
40991
40992 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_recover_payee_pub_key"))) TS_SignedRawInvoice_recover_payee_pub_key(uint32_t this_arg) {
40993         LDKSignedRawInvoice this_arg_conv;
40994         this_arg_conv.inner = (void*)(this_arg & (~1));
40995         this_arg_conv.is_owned = false;
40996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40997         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
40998         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
40999         return (uint32_t)ret_conv;
41000 }
41001
41002 jboolean  __attribute__((export_name("TS_SignedRawInvoice_check_signature"))) TS_SignedRawInvoice_check_signature(uint32_t this_arg) {
41003         LDKSignedRawInvoice this_arg_conv;
41004         this_arg_conv.inner = (void*)(this_arg & (~1));
41005         this_arg_conv.is_owned = false;
41006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41007         jboolean ret_conv = SignedRawInvoice_check_signature(&this_arg_conv);
41008         return ret_conv;
41009 }
41010
41011 int8_tArray  __attribute__((export_name("TS_RawInvoice_hash"))) TS_RawInvoice_hash(uint32_t this_arg) {
41012         LDKRawInvoice this_arg_conv;
41013         this_arg_conv.inner = (void*)(this_arg & (~1));
41014         this_arg_conv.is_owned = false;
41015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41016         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
41017         memcpy(ret_arr->elems, RawInvoice_hash(&this_arg_conv).data, 32);
41018         return ret_arr;
41019 }
41020
41021 uint32_t  __attribute__((export_name("TS_RawInvoice_payment_hash"))) TS_RawInvoice_payment_hash(uint32_t this_arg) {
41022         LDKRawInvoice this_arg_conv;
41023         this_arg_conv.inner = (void*)(this_arg & (~1));
41024         this_arg_conv.is_owned = false;
41025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41026         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
41027         uint32_t ret_ref = 0;
41028         if ((uintptr_t)ret_var.inner > 4096) {
41029                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41030                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41031         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41032                 ret_ref = (uintptr_t)ret_var.inner;
41033                 if (ret_var.is_owned) {
41034                         ret_ref |= 1;
41035                 }
41036         }
41037         return ret_ref;
41038 }
41039
41040 uint32_t  __attribute__((export_name("TS_RawInvoice_description"))) TS_RawInvoice_description(uint32_t this_arg) {
41041         LDKRawInvoice this_arg_conv;
41042         this_arg_conv.inner = (void*)(this_arg & (~1));
41043         this_arg_conv.is_owned = false;
41044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41045         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
41046         uint32_t ret_ref = 0;
41047         if ((uintptr_t)ret_var.inner > 4096) {
41048                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41049                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41050         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41051                 ret_ref = (uintptr_t)ret_var.inner;
41052                 if (ret_var.is_owned) {
41053                         ret_ref |= 1;
41054                 }
41055         }
41056         return ret_ref;
41057 }
41058
41059 uint32_t  __attribute__((export_name("TS_RawInvoice_payee_pub_key"))) TS_RawInvoice_payee_pub_key(uint32_t this_arg) {
41060         LDKRawInvoice this_arg_conv;
41061         this_arg_conv.inner = (void*)(this_arg & (~1));
41062         this_arg_conv.is_owned = false;
41063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41064         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
41065         uint32_t ret_ref = 0;
41066         if ((uintptr_t)ret_var.inner > 4096) {
41067                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41068                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41069         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41070                 ret_ref = (uintptr_t)ret_var.inner;
41071                 if (ret_var.is_owned) {
41072                         ret_ref |= 1;
41073                 }
41074         }
41075         return ret_ref;
41076 }
41077
41078 uint32_t  __attribute__((export_name("TS_RawInvoice_description_hash"))) TS_RawInvoice_description_hash(uint32_t this_arg) {
41079         LDKRawInvoice this_arg_conv;
41080         this_arg_conv.inner = (void*)(this_arg & (~1));
41081         this_arg_conv.is_owned = false;
41082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41083         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
41084         uint32_t ret_ref = 0;
41085         if ((uintptr_t)ret_var.inner > 4096) {
41086                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41087                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41088         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41089                 ret_ref = (uintptr_t)ret_var.inner;
41090                 if (ret_var.is_owned) {
41091                         ret_ref |= 1;
41092                 }
41093         }
41094         return ret_ref;
41095 }
41096
41097 uint32_t  __attribute__((export_name("TS_RawInvoice_expiry_time"))) TS_RawInvoice_expiry_time(uint32_t this_arg) {
41098         LDKRawInvoice this_arg_conv;
41099         this_arg_conv.inner = (void*)(this_arg & (~1));
41100         this_arg_conv.is_owned = false;
41101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41102         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
41103         uint32_t ret_ref = 0;
41104         if ((uintptr_t)ret_var.inner > 4096) {
41105                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41106                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41107         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41108                 ret_ref = (uintptr_t)ret_var.inner;
41109                 if (ret_var.is_owned) {
41110                         ret_ref |= 1;
41111                 }
41112         }
41113         return ret_ref;
41114 }
41115
41116 uint32_t  __attribute__((export_name("TS_RawInvoice_min_final_cltv_expiry"))) TS_RawInvoice_min_final_cltv_expiry(uint32_t this_arg) {
41117         LDKRawInvoice this_arg_conv;
41118         this_arg_conv.inner = (void*)(this_arg & (~1));
41119         this_arg_conv.is_owned = false;
41120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41121         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
41122         uint32_t ret_ref = 0;
41123         if ((uintptr_t)ret_var.inner > 4096) {
41124                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41125                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41126         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41127                 ret_ref = (uintptr_t)ret_var.inner;
41128                 if (ret_var.is_owned) {
41129                         ret_ref |= 1;
41130                 }
41131         }
41132         return ret_ref;
41133 }
41134
41135 int8_tArray  __attribute__((export_name("TS_RawInvoice_payment_secret"))) TS_RawInvoice_payment_secret(uint32_t this_arg) {
41136         LDKRawInvoice this_arg_conv;
41137         this_arg_conv.inner = (void*)(this_arg & (~1));
41138         this_arg_conv.is_owned = false;
41139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41140         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
41141         memcpy(ret_arr->elems, RawInvoice_payment_secret(&this_arg_conv).data, 32);
41142         return ret_arr;
41143 }
41144
41145 uint32_t  __attribute__((export_name("TS_RawInvoice_features"))) TS_RawInvoice_features(uint32_t this_arg) {
41146         LDKRawInvoice this_arg_conv;
41147         this_arg_conv.inner = (void*)(this_arg & (~1));
41148         this_arg_conv.is_owned = false;
41149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41150         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
41151         uint32_t ret_ref = 0;
41152         if ((uintptr_t)ret_var.inner > 4096) {
41153                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41154                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41155         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41156                 ret_ref = (uintptr_t)ret_var.inner;
41157                 if (ret_var.is_owned) {
41158                         ret_ref |= 1;
41159                 }
41160         }
41161         return ret_ref;
41162 }
41163
41164 uint32_tArray  __attribute__((export_name("TS_RawInvoice_private_routes"))) TS_RawInvoice_private_routes(uint32_t this_arg) {
41165         LDKRawInvoice this_arg_conv;
41166         this_arg_conv.inner = (void*)(this_arg & (~1));
41167         this_arg_conv.is_owned = false;
41168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41169         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
41170         uint32_tArray ret_arr = NULL;
41171         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
41172         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
41173         for (size_t o = 0; o < ret_var.datalen; o++) {
41174                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
41175                 uint32_t ret_conv_14_ref = 0;
41176                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41177                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41178                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
41179                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
41180                 if (ret_conv_14_var.is_owned) {
41181                         ret_conv_14_ref |= 1;
41182                 }
41183                 ret_arr_ptr[o] = ret_conv_14_ref;
41184         }
41185         
41186         FREE(ret_var.data);
41187         return ret_arr;
41188 }
41189
41190 uint32_t  __attribute__((export_name("TS_RawInvoice_amount_pico_btc"))) TS_RawInvoice_amount_pico_btc(uint32_t this_arg) {
41191         LDKRawInvoice this_arg_conv;
41192         this_arg_conv.inner = (void*)(this_arg & (~1));
41193         this_arg_conv.is_owned = false;
41194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41195         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
41196         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
41197         uint32_t ret_ref = (uintptr_t)ret_copy;
41198         return ret_ref;
41199 }
41200
41201 uint32_t  __attribute__((export_name("TS_RawInvoice_currency"))) TS_RawInvoice_currency(uint32_t this_arg) {
41202         LDKRawInvoice this_arg_conv;
41203         this_arg_conv.inner = (void*)(this_arg & (~1));
41204         this_arg_conv.is_owned = false;
41205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41206         uint32_t ret_conv = LDKCurrency_to_js(RawInvoice_currency(&this_arg_conv));
41207         return ret_conv;
41208 }
41209
41210 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_from_unix_timestamp"))) TS_PositiveTimestamp_from_unix_timestamp(int64_t unix_seconds) {
41211         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
41212         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
41213         return (uint32_t)ret_conv;
41214 }
41215
41216 uint32_t  __attribute__((export_name("TS_PositiveTimestamp_from_duration_since_epoch"))) TS_PositiveTimestamp_from_duration_since_epoch(int64_t duration) {
41217         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
41218         *ret_conv = PositiveTimestamp_from_duration_since_epoch(duration);
41219         return (uint32_t)ret_conv;
41220 }
41221
41222 int64_t  __attribute__((export_name("TS_PositiveTimestamp_as_unix_timestamp"))) TS_PositiveTimestamp_as_unix_timestamp(uint32_t this_arg) {
41223         LDKPositiveTimestamp this_arg_conv;
41224         this_arg_conv.inner = (void*)(this_arg & (~1));
41225         this_arg_conv.is_owned = false;
41226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41227         int64_t ret_conv = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
41228         return ret_conv;
41229 }
41230
41231 int64_t  __attribute__((export_name("TS_PositiveTimestamp_as_duration_since_epoch"))) TS_PositiveTimestamp_as_duration_since_epoch(uint32_t this_arg) {
41232         LDKPositiveTimestamp this_arg_conv;
41233         this_arg_conv.inner = (void*)(this_arg & (~1));
41234         this_arg_conv.is_owned = false;
41235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41236         int64_t ret_conv = PositiveTimestamp_as_duration_since_epoch(&this_arg_conv);
41237         return ret_conv;
41238 }
41239
41240 uint32_t  __attribute__((export_name("TS_Invoice_into_signed_raw"))) TS_Invoice_into_signed_raw(uint32_t this_arg) {
41241         LDKInvoice this_arg_conv;
41242         this_arg_conv.inner = (void*)(this_arg & (~1));
41243         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
41244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41245         this_arg_conv = Invoice_clone(&this_arg_conv);
41246         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
41247         uint32_t ret_ref = 0;
41248         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41249         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41250         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41251         ret_ref = (uintptr_t)ret_var.inner;
41252         if (ret_var.is_owned) {
41253                 ret_ref |= 1;
41254         }
41255         return ret_ref;
41256 }
41257
41258 uint32_t  __attribute__((export_name("TS_Invoice_check_signature"))) TS_Invoice_check_signature(uint32_t this_arg) {
41259         LDKInvoice this_arg_conv;
41260         this_arg_conv.inner = (void*)(this_arg & (~1));
41261         this_arg_conv.is_owned = false;
41262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41263         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
41264         *ret_conv = Invoice_check_signature(&this_arg_conv);
41265         return (uint32_t)ret_conv;
41266 }
41267
41268 uint32_t  __attribute__((export_name("TS_Invoice_from_signed"))) TS_Invoice_from_signed(uint32_t signed_invoice) {
41269         LDKSignedRawInvoice signed_invoice_conv;
41270         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
41271         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
41272         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
41273         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
41274         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
41275         *ret_conv = Invoice_from_signed(signed_invoice_conv);
41276         return (uint32_t)ret_conv;
41277 }
41278
41279 int64_t  __attribute__((export_name("TS_Invoice_duration_since_epoch"))) TS_Invoice_duration_since_epoch(uint32_t this_arg) {
41280         LDKInvoice this_arg_conv;
41281         this_arg_conv.inner = (void*)(this_arg & (~1));
41282         this_arg_conv.is_owned = false;
41283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41284         int64_t ret_conv = Invoice_duration_since_epoch(&this_arg_conv);
41285         return ret_conv;
41286 }
41287
41288 int8_tArray  __attribute__((export_name("TS_Invoice_payment_hash"))) TS_Invoice_payment_hash(uint32_t this_arg) {
41289         LDKInvoice this_arg_conv;
41290         this_arg_conv.inner = (void*)(this_arg & (~1));
41291         this_arg_conv.is_owned = false;
41292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41293         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
41294         memcpy(ret_arr->elems, *Invoice_payment_hash(&this_arg_conv), 32);
41295         return ret_arr;
41296 }
41297
41298 int8_tArray  __attribute__((export_name("TS_Invoice_payee_pub_key"))) TS_Invoice_payee_pub_key(uint32_t this_arg) {
41299         LDKInvoice this_arg_conv;
41300         this_arg_conv.inner = (void*)(this_arg & (~1));
41301         this_arg_conv.is_owned = false;
41302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41303         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
41304         memcpy(ret_arr->elems, Invoice_payee_pub_key(&this_arg_conv).compressed_form, 33);
41305         return ret_arr;
41306 }
41307
41308 int8_tArray  __attribute__((export_name("TS_Invoice_payment_secret"))) TS_Invoice_payment_secret(uint32_t this_arg) {
41309         LDKInvoice this_arg_conv;
41310         this_arg_conv.inner = (void*)(this_arg & (~1));
41311         this_arg_conv.is_owned = false;
41312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41313         int8_tArray ret_arr = init_int8_tArray(32, __LINE__);
41314         memcpy(ret_arr->elems, *Invoice_payment_secret(&this_arg_conv), 32);
41315         return ret_arr;
41316 }
41317
41318 uint32_t  __attribute__((export_name("TS_Invoice_features"))) TS_Invoice_features(uint32_t this_arg) {
41319         LDKInvoice this_arg_conv;
41320         this_arg_conv.inner = (void*)(this_arg & (~1));
41321         this_arg_conv.is_owned = false;
41322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41323         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
41324         uint32_t ret_ref = 0;
41325         if ((uintptr_t)ret_var.inner > 4096) {
41326                 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41327                 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41328         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41329                 ret_ref = (uintptr_t)ret_var.inner;
41330                 if (ret_var.is_owned) {
41331                         ret_ref |= 1;
41332                 }
41333         }
41334         return ret_ref;
41335 }
41336
41337 int8_tArray  __attribute__((export_name("TS_Invoice_recover_payee_pub_key"))) TS_Invoice_recover_payee_pub_key(uint32_t this_arg) {
41338         LDKInvoice this_arg_conv;
41339         this_arg_conv.inner = (void*)(this_arg & (~1));
41340         this_arg_conv.is_owned = false;
41341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41342         int8_tArray ret_arr = init_int8_tArray(33, __LINE__);
41343         memcpy(ret_arr->elems, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form, 33);
41344         return ret_arr;
41345 }
41346
41347 int64_t  __attribute__((export_name("TS_Invoice_expiry_time"))) TS_Invoice_expiry_time(uint32_t this_arg) {
41348         LDKInvoice this_arg_conv;
41349         this_arg_conv.inner = (void*)(this_arg & (~1));
41350         this_arg_conv.is_owned = false;
41351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41352         int64_t ret_conv = Invoice_expiry_time(&this_arg_conv);
41353         return ret_conv;
41354 }
41355
41356 jboolean  __attribute__((export_name("TS_Invoice_would_expire"))) TS_Invoice_would_expire(uint32_t this_arg, int64_t at_time) {
41357         LDKInvoice this_arg_conv;
41358         this_arg_conv.inner = (void*)(this_arg & (~1));
41359         this_arg_conv.is_owned = false;
41360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41361         jboolean ret_conv = Invoice_would_expire(&this_arg_conv, at_time);
41362         return ret_conv;
41363 }
41364
41365 int64_t  __attribute__((export_name("TS_Invoice_min_final_cltv_expiry"))) TS_Invoice_min_final_cltv_expiry(uint32_t this_arg) {
41366         LDKInvoice this_arg_conv;
41367         this_arg_conv.inner = (void*)(this_arg & (~1));
41368         this_arg_conv.is_owned = false;
41369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41370         int64_t ret_conv = Invoice_min_final_cltv_expiry(&this_arg_conv);
41371         return ret_conv;
41372 }
41373
41374 uint32_tArray  __attribute__((export_name("TS_Invoice_private_routes"))) TS_Invoice_private_routes(uint32_t this_arg) {
41375         LDKInvoice this_arg_conv;
41376         this_arg_conv.inner = (void*)(this_arg & (~1));
41377         this_arg_conv.is_owned = false;
41378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41379         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
41380         uint32_tArray ret_arr = NULL;
41381         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
41382         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
41383         for (size_t o = 0; o < ret_var.datalen; o++) {
41384                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
41385                 uint32_t ret_conv_14_ref = 0;
41386                 CHECK((((uintptr_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41387                 CHECK((((uintptr_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41388                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
41389                 ret_conv_14_ref = (uintptr_t)ret_conv_14_var.inner;
41390                 if (ret_conv_14_var.is_owned) {
41391                         ret_conv_14_ref |= 1;
41392                 }
41393                 ret_arr_ptr[o] = ret_conv_14_ref;
41394         }
41395         
41396         FREE(ret_var.data);
41397         return ret_arr;
41398 }
41399
41400 uint32_tArray  __attribute__((export_name("TS_Invoice_route_hints"))) TS_Invoice_route_hints(uint32_t this_arg) {
41401         LDKInvoice this_arg_conv;
41402         this_arg_conv.inner = (void*)(this_arg & (~1));
41403         this_arg_conv.is_owned = false;
41404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41405         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
41406         uint32_tArray ret_arr = NULL;
41407         ret_arr = init_uint32_tArray(ret_var.datalen, __LINE__);
41408         uint32_t *ret_arr_ptr = (uint32_t*)(((uint8_t*)ret_arr) + 4);
41409         for (size_t l = 0; l < ret_var.datalen; l++) {
41410                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
41411                 uint32_t ret_conv_11_ref = 0;
41412                 CHECK((((uintptr_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41413                 CHECK((((uintptr_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41414                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
41415                 ret_conv_11_ref = (uintptr_t)ret_conv_11_var.inner;
41416                 if (ret_conv_11_var.is_owned) {
41417                         ret_conv_11_ref |= 1;
41418                 }
41419                 ret_arr_ptr[l] = ret_conv_11_ref;
41420         }
41421         
41422         FREE(ret_var.data);
41423         return ret_arr;
41424 }
41425
41426 uint32_t  __attribute__((export_name("TS_Invoice_currency"))) TS_Invoice_currency(uint32_t this_arg) {
41427         LDKInvoice this_arg_conv;
41428         this_arg_conv.inner = (void*)(this_arg & (~1));
41429         this_arg_conv.is_owned = false;
41430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41431         uint32_t ret_conv = LDKCurrency_to_js(Invoice_currency(&this_arg_conv));
41432         return ret_conv;
41433 }
41434
41435 uint32_t  __attribute__((export_name("TS_Invoice_amount_milli_satoshis"))) TS_Invoice_amount_milli_satoshis(uint32_t this_arg) {
41436         LDKInvoice this_arg_conv;
41437         this_arg_conv.inner = (void*)(this_arg & (~1));
41438         this_arg_conv.is_owned = false;
41439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41440         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
41441         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
41442         uint32_t ret_ref = (uintptr_t)ret_copy;
41443         return ret_ref;
41444 }
41445
41446 uint32_t  __attribute__((export_name("TS_Description_new"))) TS_Description_new(jstring description) {
41447         LDKStr description_conv = str_ref_to_owned_c(description);
41448         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
41449         *ret_conv = Description_new(description_conv);
41450         return (uint32_t)ret_conv;
41451 }
41452
41453 jstring  __attribute__((export_name("TS_Description_into_inner"))) TS_Description_into_inner(uint32_t this_arg) {
41454         LDKDescription this_arg_conv;
41455         this_arg_conv.inner = (void*)(this_arg & (~1));
41456         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
41457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41458         this_arg_conv = Description_clone(&this_arg_conv);
41459         LDKStr ret_str = Description_into_inner(this_arg_conv);
41460         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
41461         Str_free(ret_str);
41462         return ret_conv;
41463 }
41464
41465 uint32_t  __attribute__((export_name("TS_ExpiryTime_from_seconds"))) TS_ExpiryTime_from_seconds(int64_t seconds) {
41466         LDKExpiryTime ret_var = ExpiryTime_from_seconds(seconds);
41467         uint32_t ret_ref = 0;
41468         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41469         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41470         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41471         ret_ref = (uintptr_t)ret_var.inner;
41472         if (ret_var.is_owned) {
41473                 ret_ref |= 1;
41474         }
41475         return ret_ref;
41476 }
41477
41478 uint32_t  __attribute__((export_name("TS_ExpiryTime_from_duration"))) TS_ExpiryTime_from_duration(int64_t duration) {
41479         LDKExpiryTime ret_var = ExpiryTime_from_duration(duration);
41480         uint32_t ret_ref = 0;
41481         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41482         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41483         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41484         ret_ref = (uintptr_t)ret_var.inner;
41485         if (ret_var.is_owned) {
41486                 ret_ref |= 1;
41487         }
41488         return ret_ref;
41489 }
41490
41491 int64_t  __attribute__((export_name("TS_ExpiryTime_as_seconds"))) TS_ExpiryTime_as_seconds(uint32_t this_arg) {
41492         LDKExpiryTime this_arg_conv;
41493         this_arg_conv.inner = (void*)(this_arg & (~1));
41494         this_arg_conv.is_owned = false;
41495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41496         int64_t ret_conv = ExpiryTime_as_seconds(&this_arg_conv);
41497         return ret_conv;
41498 }
41499
41500 int64_t  __attribute__((export_name("TS_ExpiryTime_as_duration"))) TS_ExpiryTime_as_duration(uint32_t this_arg) {
41501         LDKExpiryTime this_arg_conv;
41502         this_arg_conv.inner = (void*)(this_arg & (~1));
41503         this_arg_conv.is_owned = false;
41504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41505         int64_t ret_conv = ExpiryTime_as_duration(&this_arg_conv);
41506         return ret_conv;
41507 }
41508
41509 uint32_t  __attribute__((export_name("TS_PrivateRoute_new"))) TS_PrivateRoute_new(uint32_t hops) {
41510         LDKRouteHint hops_conv;
41511         hops_conv.inner = (void*)(hops & (~1));
41512         hops_conv.is_owned = (hops & 1) || (hops == 0);
41513         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
41514         hops_conv = RouteHint_clone(&hops_conv);
41515         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
41516         *ret_conv = PrivateRoute_new(hops_conv);
41517         return (uint32_t)ret_conv;
41518 }
41519
41520 uint32_t  __attribute__((export_name("TS_PrivateRoute_into_inner"))) TS_PrivateRoute_into_inner(uint32_t this_arg) {
41521         LDKPrivateRoute this_arg_conv;
41522         this_arg_conv.inner = (void*)(this_arg & (~1));
41523         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
41524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41525         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
41526         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
41527         uint32_t ret_ref = 0;
41528         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41529         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41530         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41531         ret_ref = (uintptr_t)ret_var.inner;
41532         if (ret_var.is_owned) {
41533                 ret_ref |= 1;
41534         }
41535         return ret_ref;
41536 }
41537
41538 uint32_t  __attribute__((export_name("TS_CreationError_clone"))) TS_CreationError_clone(uint32_t orig) {
41539         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
41540         uint32_t ret_conv = LDKCreationError_to_js(CreationError_clone(orig_conv));
41541         return ret_conv;
41542 }
41543
41544 uint32_t  __attribute__((export_name("TS_CreationError_description_too_long"))) TS_CreationError_description_too_long() {
41545         uint32_t ret_conv = LDKCreationError_to_js(CreationError_description_too_long());
41546         return ret_conv;
41547 }
41548
41549 uint32_t  __attribute__((export_name("TS_CreationError_route_too_long"))) TS_CreationError_route_too_long() {
41550         uint32_t ret_conv = LDKCreationError_to_js(CreationError_route_too_long());
41551         return ret_conv;
41552 }
41553
41554 uint32_t  __attribute__((export_name("TS_CreationError_timestamp_out_of_bounds"))) TS_CreationError_timestamp_out_of_bounds() {
41555         uint32_t ret_conv = LDKCreationError_to_js(CreationError_timestamp_out_of_bounds());
41556         return ret_conv;
41557 }
41558
41559 uint32_t  __attribute__((export_name("TS_CreationError_invalid_amount"))) TS_CreationError_invalid_amount() {
41560         uint32_t ret_conv = LDKCreationError_to_js(CreationError_invalid_amount());
41561         return ret_conv;
41562 }
41563
41564 uint32_t  __attribute__((export_name("TS_CreationError_missing_route_hints"))) TS_CreationError_missing_route_hints() {
41565         uint32_t ret_conv = LDKCreationError_to_js(CreationError_missing_route_hints());
41566         return ret_conv;
41567 }
41568
41569 jboolean  __attribute__((export_name("TS_CreationError_eq"))) TS_CreationError_eq(uint32_t a, uint32_t b) {
41570         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
41571         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
41572         jboolean ret_conv = CreationError_eq(a_conv, b_conv);
41573         return ret_conv;
41574 }
41575
41576 jstring  __attribute__((export_name("TS_CreationError_to_str"))) TS_CreationError_to_str(uint32_t o) {
41577         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
41578         LDKStr ret_str = CreationError_to_str(o_conv);
41579         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
41580         Str_free(ret_str);
41581         return ret_conv;
41582 }
41583
41584 uint32_t  __attribute__((export_name("TS_SemanticError_clone"))) TS_SemanticError_clone(uint32_t orig) {
41585         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
41586         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_clone(orig_conv));
41587         return ret_conv;
41588 }
41589
41590 uint32_t  __attribute__((export_name("TS_SemanticError_no_payment_hash"))) TS_SemanticError_no_payment_hash() {
41591         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_payment_hash());
41592         return ret_conv;
41593 }
41594
41595 uint32_t  __attribute__((export_name("TS_SemanticError_multiple_payment_hashes"))) TS_SemanticError_multiple_payment_hashes() {
41596         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_hashes());
41597         return ret_conv;
41598 }
41599
41600 uint32_t  __attribute__((export_name("TS_SemanticError_no_description"))) TS_SemanticError_no_description() {
41601         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_description());
41602         return ret_conv;
41603 }
41604
41605 uint32_t  __attribute__((export_name("TS_SemanticError_multiple_descriptions"))) TS_SemanticError_multiple_descriptions() {
41606         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_descriptions());
41607         return ret_conv;
41608 }
41609
41610 uint32_t  __attribute__((export_name("TS_SemanticError_no_payment_secret"))) TS_SemanticError_no_payment_secret() {
41611         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_no_payment_secret());
41612         return ret_conv;
41613 }
41614
41615 uint32_t  __attribute__((export_name("TS_SemanticError_multiple_payment_secrets"))) TS_SemanticError_multiple_payment_secrets() {
41616         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_multiple_payment_secrets());
41617         return ret_conv;
41618 }
41619
41620 uint32_t  __attribute__((export_name("TS_SemanticError_invalid_features"))) TS_SemanticError_invalid_features() {
41621         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_features());
41622         return ret_conv;
41623 }
41624
41625 uint32_t  __attribute__((export_name("TS_SemanticError_invalid_recovery_id"))) TS_SemanticError_invalid_recovery_id() {
41626         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_recovery_id());
41627         return ret_conv;
41628 }
41629
41630 uint32_t  __attribute__((export_name("TS_SemanticError_invalid_signature"))) TS_SemanticError_invalid_signature() {
41631         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_invalid_signature());
41632         return ret_conv;
41633 }
41634
41635 uint32_t  __attribute__((export_name("TS_SemanticError_imprecise_amount"))) TS_SemanticError_imprecise_amount() {
41636         uint32_t ret_conv = LDKSemanticError_to_js(SemanticError_imprecise_amount());
41637         return ret_conv;
41638 }
41639
41640 jboolean  __attribute__((export_name("TS_SemanticError_eq"))) TS_SemanticError_eq(uint32_t a, uint32_t b) {
41641         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
41642         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
41643         jboolean ret_conv = SemanticError_eq(a_conv, b_conv);
41644         return ret_conv;
41645 }
41646
41647 jstring  __attribute__((export_name("TS_SemanticError_to_str"))) TS_SemanticError_to_str(uint32_t o) {
41648         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
41649         LDKStr ret_str = SemanticError_to_str(o_conv);
41650         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
41651         Str_free(ret_str);
41652         return ret_conv;
41653 }
41654
41655 void  __attribute__((export_name("TS_SignOrCreationError_free"))) TS_SignOrCreationError_free(uint32_t this_ptr) {
41656         if ((this_ptr & 1) != 0) return;
41657         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
41658         CHECK_ACCESS(this_ptr_ptr);
41659         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
41660         FREE((void*)this_ptr);
41661         SignOrCreationError_free(this_ptr_conv);
41662 }
41663
41664 static inline uintptr_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
41665         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
41666         *ret_copy = SignOrCreationError_clone(arg);
41667 uint32_t ret_ref = (uintptr_t)ret_copy;
41668         return ret_ref;
41669 }
41670 uint32_t  __attribute__((export_name("TS_SignOrCreationError_clone_ptr"))) TS_SignOrCreationError_clone_ptr(uint32_t arg) {
41671         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)arg;
41672         uint32_t ret_conv = SignOrCreationError_clone_ptr(arg_conv);
41673         return ret_conv;
41674 }
41675
41676 uint32_t  __attribute__((export_name("TS_SignOrCreationError_clone"))) TS_SignOrCreationError_clone(uint32_t orig) {
41677         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
41678         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
41679         *ret_copy = SignOrCreationError_clone(orig_conv);
41680         uint32_t ret_ref = (uintptr_t)ret_copy;
41681         return ret_ref;
41682 }
41683
41684 uint32_t  __attribute__((export_name("TS_SignOrCreationError_sign_error"))) TS_SignOrCreationError_sign_error() {
41685         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
41686         *ret_copy = SignOrCreationError_sign_error();
41687         uint32_t ret_ref = (uintptr_t)ret_copy;
41688         return ret_ref;
41689 }
41690
41691 uint32_t  __attribute__((export_name("TS_SignOrCreationError_creation_error"))) TS_SignOrCreationError_creation_error(uint32_t a) {
41692         LDKCreationError a_conv = LDKCreationError_from_js(a);
41693         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
41694         *ret_copy = SignOrCreationError_creation_error(a_conv);
41695         uint32_t ret_ref = (uintptr_t)ret_copy;
41696         return ret_ref;
41697 }
41698
41699 jboolean  __attribute__((export_name("TS_SignOrCreationError_eq"))) TS_SignOrCreationError_eq(uint32_t a, uint32_t b) {
41700         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
41701         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
41702         jboolean ret_conv = SignOrCreationError_eq(a_conv, b_conv);
41703         return ret_conv;
41704 }
41705
41706 jstring  __attribute__((export_name("TS_SignOrCreationError_to_str"))) TS_SignOrCreationError_to_str(uint32_t o) {
41707         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
41708         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
41709         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
41710         Str_free(ret_str);
41711         return ret_conv;
41712 }
41713
41714 void  __attribute__((export_name("TS_InvoicePayer_free"))) TS_InvoicePayer_free(uint32_t this_obj) {
41715         LDKInvoicePayer this_obj_conv;
41716         this_obj_conv.inner = (void*)(this_obj & (~1));
41717         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41719         InvoicePayer_free(this_obj_conv);
41720 }
41721
41722 void  __attribute__((export_name("TS_Payer_free"))) TS_Payer_free(uint32_t this_ptr) {
41723         if ((this_ptr & 1) != 0) return;
41724         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
41725         CHECK_ACCESS(this_ptr_ptr);
41726         LDKPayer this_ptr_conv = *(LDKPayer*)(this_ptr_ptr);
41727         FREE((void*)this_ptr);
41728         Payer_free(this_ptr_conv);
41729 }
41730
41731 void  __attribute__((export_name("TS_Router_free"))) TS_Router_free(uint32_t this_ptr) {
41732         if ((this_ptr & 1) != 0) return;
41733         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
41734         CHECK_ACCESS(this_ptr_ptr);
41735         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
41736         FREE((void*)this_ptr);
41737         Router_free(this_ptr_conv);
41738 }
41739
41740 void  __attribute__((export_name("TS_RetryAttempts_free"))) TS_RetryAttempts_free(uint32_t this_obj) {
41741         LDKRetryAttempts this_obj_conv;
41742         this_obj_conv.inner = (void*)(this_obj & (~1));
41743         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
41744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41745         RetryAttempts_free(this_obj_conv);
41746 }
41747
41748 uint32_t  __attribute__((export_name("TS_RetryAttempts_get_a"))) TS_RetryAttempts_get_a(uint32_t this_ptr) {
41749         LDKRetryAttempts this_ptr_conv;
41750         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41751         this_ptr_conv.is_owned = false;
41752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41753         uint32_t ret_conv = RetryAttempts_get_a(&this_ptr_conv);
41754         return ret_conv;
41755 }
41756
41757 void  __attribute__((export_name("TS_RetryAttempts_set_a"))) TS_RetryAttempts_set_a(uint32_t this_ptr, uint32_t val) {
41758         LDKRetryAttempts this_ptr_conv;
41759         this_ptr_conv.inner = (void*)(this_ptr & (~1));
41760         this_ptr_conv.is_owned = false;
41761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41762         RetryAttempts_set_a(&this_ptr_conv, val);
41763 }
41764
41765 uint32_t  __attribute__((export_name("TS_RetryAttempts_new"))) TS_RetryAttempts_new(uint32_t a_arg) {
41766         LDKRetryAttempts ret_var = RetryAttempts_new(a_arg);
41767         uint32_t ret_ref = 0;
41768         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41769         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41770         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41771         ret_ref = (uintptr_t)ret_var.inner;
41772         if (ret_var.is_owned) {
41773                 ret_ref |= 1;
41774         }
41775         return ret_ref;
41776 }
41777
41778 static inline uintptr_t RetryAttempts_clone_ptr(LDKRetryAttempts *NONNULL_PTR arg) {
41779         LDKRetryAttempts ret_var = RetryAttempts_clone(arg);
41780 uint32_t ret_ref = 0;
41781 CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41782 CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41783 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41784 ret_ref = (uintptr_t)ret_var.inner;
41785 if (ret_var.is_owned) {
41786         ret_ref |= 1;
41787 }
41788         return ret_ref;
41789 }
41790 uint32_t  __attribute__((export_name("TS_RetryAttempts_clone_ptr"))) TS_RetryAttempts_clone_ptr(uint32_t arg) {
41791         LDKRetryAttempts arg_conv;
41792         arg_conv.inner = (void*)(arg & (~1));
41793         arg_conv.is_owned = false;
41794         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41795         uint32_t ret_conv = RetryAttempts_clone_ptr(&arg_conv);
41796         return ret_conv;
41797 }
41798
41799 uint32_t  __attribute__((export_name("TS_RetryAttempts_clone"))) TS_RetryAttempts_clone(uint32_t orig) {
41800         LDKRetryAttempts orig_conv;
41801         orig_conv.inner = (void*)(orig & (~1));
41802         orig_conv.is_owned = false;
41803         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41804         LDKRetryAttempts ret_var = RetryAttempts_clone(&orig_conv);
41805         uint32_t ret_ref = 0;
41806         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41807         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41808         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41809         ret_ref = (uintptr_t)ret_var.inner;
41810         if (ret_var.is_owned) {
41811                 ret_ref |= 1;
41812         }
41813         return ret_ref;
41814 }
41815
41816 jboolean  __attribute__((export_name("TS_RetryAttempts_eq"))) TS_RetryAttempts_eq(uint32_t a, uint32_t b) {
41817         LDKRetryAttempts a_conv;
41818         a_conv.inner = (void*)(a & (~1));
41819         a_conv.is_owned = false;
41820         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41821         LDKRetryAttempts b_conv;
41822         b_conv.inner = (void*)(b & (~1));
41823         b_conv.is_owned = false;
41824         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41825         jboolean ret_conv = RetryAttempts_eq(&a_conv, &b_conv);
41826         return ret_conv;
41827 }
41828
41829 int64_t  __attribute__((export_name("TS_RetryAttempts_hash"))) TS_RetryAttempts_hash(uint32_t o) {
41830         LDKRetryAttempts o_conv;
41831         o_conv.inner = (void*)(o & (~1));
41832         o_conv.is_owned = false;
41833         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
41834         int64_t ret_conv = RetryAttempts_hash(&o_conv);
41835         return ret_conv;
41836 }
41837
41838 void  __attribute__((export_name("TS_PaymentError_free"))) TS_PaymentError_free(uint32_t this_ptr) {
41839         if ((this_ptr & 1) != 0) return;
41840         void* this_ptr_ptr = (void*)(((uintptr_t)this_ptr) & ~1);
41841         CHECK_ACCESS(this_ptr_ptr);
41842         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
41843         FREE((void*)this_ptr);
41844         PaymentError_free(this_ptr_conv);
41845 }
41846
41847 static inline uintptr_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
41848         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
41849         *ret_copy = PaymentError_clone(arg);
41850 uint32_t ret_ref = (uintptr_t)ret_copy;
41851         return ret_ref;
41852 }
41853 uint32_t  __attribute__((export_name("TS_PaymentError_clone_ptr"))) TS_PaymentError_clone_ptr(uint32_t arg) {
41854         LDKPaymentError* arg_conv = (LDKPaymentError*)arg;
41855         uint32_t ret_conv = PaymentError_clone_ptr(arg_conv);
41856         return ret_conv;
41857 }
41858
41859 uint32_t  __attribute__((export_name("TS_PaymentError_clone"))) TS_PaymentError_clone(uint32_t orig) {
41860         LDKPaymentError* orig_conv = (LDKPaymentError*)orig;
41861         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
41862         *ret_copy = PaymentError_clone(orig_conv);
41863         uint32_t ret_ref = (uintptr_t)ret_copy;
41864         return ret_ref;
41865 }
41866
41867 uint32_t  __attribute__((export_name("TS_PaymentError_invoice"))) TS_PaymentError_invoice(jstring a) {
41868         LDKStr a_conv = str_ref_to_owned_c(a);
41869         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
41870         *ret_copy = PaymentError_invoice(a_conv);
41871         uint32_t ret_ref = (uintptr_t)ret_copy;
41872         return ret_ref;
41873 }
41874
41875 uint32_t  __attribute__((export_name("TS_PaymentError_routing"))) TS_PaymentError_routing(uint32_t a) {
41876         LDKLightningError a_conv;
41877         a_conv.inner = (void*)(a & (~1));
41878         a_conv.is_owned = (a & 1) || (a == 0);
41879         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41880         a_conv = LightningError_clone(&a_conv);
41881         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
41882         *ret_copy = PaymentError_routing(a_conv);
41883         uint32_t ret_ref = (uintptr_t)ret_copy;
41884         return ret_ref;
41885 }
41886
41887 uint32_t  __attribute__((export_name("TS_PaymentError_sending"))) TS_PaymentError_sending(uint32_t a) {
41888         void* a_ptr = (void*)(((uintptr_t)a) & ~1);
41889         CHECK_ACCESS(a_ptr);
41890         LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
41891         a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uintptr_t)a) & ~1));
41892         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
41893         *ret_copy = PaymentError_sending(a_conv);
41894         uint32_t ret_ref = (uintptr_t)ret_copy;
41895         return ret_ref;
41896 }
41897
41898 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) {
41899         void* payer_ptr = (void*)(((uintptr_t)payer) & ~1);
41900         CHECK_ACCESS(payer_ptr);
41901         LDKPayer payer_conv = *(LDKPayer*)(payer_ptr);
41902         if (payer_conv.free == LDKPayer_JCalls_free) {
41903                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41904                 LDKPayer_JCalls_cloned(&payer_conv);
41905         }
41906         void* router_ptr = (void*)(((uintptr_t)router) & ~1);
41907         CHECK_ACCESS(router_ptr);
41908         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
41909         if (router_conv.free == LDKRouter_JCalls_free) {
41910                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41911                 LDKRouter_JCalls_cloned(&router_conv);
41912         }
41913         LDKMultiThreadedLockableScore scorer_conv;
41914         scorer_conv.inner = (void*)(scorer & (~1));
41915         scorer_conv.is_owned = false;
41916         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
41917         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
41918         CHECK_ACCESS(logger_ptr);
41919         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
41920         if (logger_conv.free == LDKLogger_JCalls_free) {
41921                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41922                 LDKLogger_JCalls_cloned(&logger_conv);
41923         }
41924         void* event_handler_ptr = (void*)(((uintptr_t)event_handler) & ~1);
41925         CHECK_ACCESS(event_handler_ptr);
41926         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
41927         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
41928                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41929                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
41930         }
41931         LDKRetryAttempts retry_attempts_conv;
41932         retry_attempts_conv.inner = (void*)(retry_attempts & (~1));
41933         retry_attempts_conv.is_owned = (retry_attempts & 1) || (retry_attempts == 0);
41934         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_attempts_conv);
41935         retry_attempts_conv = RetryAttempts_clone(&retry_attempts_conv);
41936         LDKInvoicePayer ret_var = InvoicePayer_new(payer_conv, router_conv, &scorer_conv, logger_conv, event_handler_conv, retry_attempts_conv);
41937         uint32_t ret_ref = 0;
41938         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
41939         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
41940         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41941         ret_ref = (uintptr_t)ret_var.inner;
41942         if (ret_var.is_owned) {
41943                 ret_ref |= 1;
41944         }
41945         return ret_ref;
41946 }
41947
41948 uint32_t  __attribute__((export_name("TS_InvoicePayer_pay_invoice"))) TS_InvoicePayer_pay_invoice(uint32_t this_arg, uint32_t invoice) {
41949         LDKInvoicePayer this_arg_conv;
41950         this_arg_conv.inner = (void*)(this_arg & (~1));
41951         this_arg_conv.is_owned = false;
41952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41953         LDKInvoice invoice_conv;
41954         invoice_conv.inner = (void*)(invoice & (~1));
41955         invoice_conv.is_owned = false;
41956         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
41957         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
41958         *ret_conv = InvoicePayer_pay_invoice(&this_arg_conv, &invoice_conv);
41959         return (uint32_t)ret_conv;
41960 }
41961
41962 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) {
41963         LDKInvoicePayer this_arg_conv;
41964         this_arg_conv.inner = (void*)(this_arg & (~1));
41965         this_arg_conv.is_owned = false;
41966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41967         LDKInvoice invoice_conv;
41968         invoice_conv.inner = (void*)(invoice & (~1));
41969         invoice_conv.is_owned = false;
41970         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
41971         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
41972         *ret_conv = InvoicePayer_pay_zero_value_invoice(&this_arg_conv, &invoice_conv, amount_msats);
41973         return (uint32_t)ret_conv;
41974 }
41975
41976 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) {
41977         LDKInvoicePayer this_arg_conv;
41978         this_arg_conv.inner = (void*)(this_arg & (~1));
41979         this_arg_conv.is_owned = false;
41980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41981         LDKPublicKey pubkey_ref;
41982         CHECK(pubkey->arr_len == 33);
41983         memcpy(pubkey_ref.compressed_form, pubkey->elems, 33); FREE(pubkey);
41984         LDKThirtyTwoBytes payment_preimage_ref;
41985         CHECK(payment_preimage->arr_len == 32);
41986         memcpy(payment_preimage_ref.data, payment_preimage->elems, 32); FREE(payment_preimage);
41987         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
41988         *ret_conv = InvoicePayer_pay_pubkey(&this_arg_conv, pubkey_ref, payment_preimage_ref, amount_msats, final_cltv_expiry_delta);
41989         return (uint32_t)ret_conv;
41990 }
41991
41992 void  __attribute__((export_name("TS_InvoicePayer_remove_cached_payment"))) TS_InvoicePayer_remove_cached_payment(uint32_t this_arg, int8_tArray payment_hash) {
41993         LDKInvoicePayer this_arg_conv;
41994         this_arg_conv.inner = (void*)(this_arg & (~1));
41995         this_arg_conv.is_owned = false;
41996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41997         unsigned char payment_hash_arr[32];
41998         CHECK(payment_hash->arr_len == 32);
41999         memcpy(payment_hash_arr, payment_hash->elems, 32); FREE(payment_hash);
42000         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
42001         InvoicePayer_remove_cached_payment(&this_arg_conv, payment_hash_ref);
42002 }
42003
42004 uint32_t  __attribute__((export_name("TS_InvoicePayer_as_EventHandler"))) TS_InvoicePayer_as_EventHandler(uint32_t this_arg) {
42005         LDKInvoicePayer this_arg_conv;
42006         this_arg_conv.inner = (void*)(this_arg & (~1));
42007         this_arg_conv.is_owned = false;
42008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42009         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
42010         *ret_ret = InvoicePayer_as_EventHandler(&this_arg_conv);
42011         return (uint32_t)ret_ret;
42012 }
42013
42014 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) {
42015         LDKChannelManager channelmanager_conv;
42016         channelmanager_conv.inner = (void*)(channelmanager & (~1));
42017         channelmanager_conv.is_owned = false;
42018         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
42019         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
42020         CHECK_ACCESS(keys_manager_ptr);
42021         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
42022         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
42023                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42024                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
42025         }
42026         LDKCurrency network_conv = LDKCurrency_from_js(network);
42027         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
42028         CHECK_ACCESS(amt_msat_ptr);
42029         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
42030         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
42031         LDKSha256 description_hash_conv;
42032         description_hash_conv.inner = (void*)(description_hash & (~1));
42033         description_hash_conv.is_owned = (description_hash & 1) || (description_hash == 0);
42034         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
42035         description_hash_conv = Sha256_clone(&description_hash_conv);
42036         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
42037         *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);
42038         return (uint32_t)ret_conv;
42039 }
42040
42041 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) {
42042         LDKChannelManager channelmanager_conv;
42043         channelmanager_conv.inner = (void*)(channelmanager & (~1));
42044         channelmanager_conv.is_owned = false;
42045         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
42046         void* keys_manager_ptr = (void*)(((uintptr_t)keys_manager) & ~1);
42047         CHECK_ACCESS(keys_manager_ptr);
42048         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
42049         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
42050                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42051                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
42052         }
42053         LDKCurrency network_conv = LDKCurrency_from_js(network);
42054         void* amt_msat_ptr = (void*)(((uintptr_t)amt_msat) & ~1);
42055         CHECK_ACCESS(amt_msat_ptr);
42056         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
42057         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uintptr_t)amt_msat) & ~1));
42058         LDKStr description_conv = str_ref_to_owned_c(description);
42059         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
42060         *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);
42061         return (uint32_t)ret_conv;
42062 }
42063
42064 void  __attribute__((export_name("TS_DefaultRouter_free"))) TS_DefaultRouter_free(uint32_t this_obj) {
42065         LDKDefaultRouter this_obj_conv;
42066         this_obj_conv.inner = (void*)(this_obj & (~1));
42067         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
42068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42069         DefaultRouter_free(this_obj_conv);
42070 }
42071
42072 uint32_t  __attribute__((export_name("TS_DefaultRouter_new"))) TS_DefaultRouter_new(uint32_t network_graph, uint32_t logger, int8_tArray random_seed_bytes) {
42073         LDKNetworkGraph network_graph_conv;
42074         network_graph_conv.inner = (void*)(network_graph & (~1));
42075         network_graph_conv.is_owned = false;
42076         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
42077         void* logger_ptr = (void*)(((uintptr_t)logger) & ~1);
42078         CHECK_ACCESS(logger_ptr);
42079         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
42080         if (logger_conv.free == LDKLogger_JCalls_free) {
42081                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
42082                 LDKLogger_JCalls_cloned(&logger_conv);
42083         }
42084         LDKThirtyTwoBytes random_seed_bytes_ref;
42085         CHECK(random_seed_bytes->arr_len == 32);
42086         memcpy(random_seed_bytes_ref.data, random_seed_bytes->elems, 32); FREE(random_seed_bytes);
42087         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv, random_seed_bytes_ref);
42088         uint32_t ret_ref = 0;
42089         CHECK((((uintptr_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
42090         CHECK((((uintptr_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
42091         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42092         ret_ref = (uintptr_t)ret_var.inner;
42093         if (ret_var.is_owned) {
42094                 ret_ref |= 1;
42095         }
42096         return ret_ref;
42097 }
42098
42099 uint32_t  __attribute__((export_name("TS_DefaultRouter_as_Router"))) TS_DefaultRouter_as_Router(uint32_t this_arg) {
42100         LDKDefaultRouter this_arg_conv;
42101         this_arg_conv.inner = (void*)(this_arg & (~1));
42102         this_arg_conv.is_owned = false;
42103         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42104         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
42105         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
42106         return (uint32_t)ret_ret;
42107 }
42108
42109 uint32_t  __attribute__((export_name("TS_ChannelManager_as_Payer"))) TS_ChannelManager_as_Payer(uint32_t this_arg) {
42110         LDKChannelManager this_arg_conv;
42111         this_arg_conv.inner = (void*)(this_arg & (~1));
42112         this_arg_conv.is_owned = false;
42113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42114         LDKPayer* ret_ret = MALLOC(sizeof(LDKPayer), "LDKPayer");
42115         *ret_ret = ChannelManager_as_Payer(&this_arg_conv);
42116         return (uint32_t)ret_ret;
42117 }
42118
42119 uint32_t  __attribute__((export_name("TS_SiPrefix_from_str"))) TS_SiPrefix_from_str(jstring s) {
42120         LDKStr s_conv = str_ref_to_owned_c(s);
42121         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
42122         *ret_conv = SiPrefix_from_str(s_conv);
42123         return (uint32_t)ret_conv;
42124 }
42125
42126 uint32_t  __attribute__((export_name("TS_Invoice_from_str"))) TS_Invoice_from_str(jstring s) {
42127         LDKStr s_conv = str_ref_to_owned_c(s);
42128         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
42129         *ret_conv = Invoice_from_str(s_conv);
42130         return (uint32_t)ret_conv;
42131 }
42132
42133 uint32_t  __attribute__((export_name("TS_SignedRawInvoice_from_str"))) TS_SignedRawInvoice_from_str(jstring s) {
42134         LDKStr s_conv = str_ref_to_owned_c(s);
42135         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
42136         *ret_conv = SignedRawInvoice_from_str(s_conv);
42137         return (uint32_t)ret_conv;
42138 }
42139
42140 jstring  __attribute__((export_name("TS_ParseError_to_str"))) TS_ParseError_to_str(uint32_t o) {
42141         LDKParseError* o_conv = (LDKParseError*)o;
42142         LDKStr ret_str = ParseError_to_str(o_conv);
42143         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
42144         Str_free(ret_str);
42145         return ret_conv;
42146 }
42147
42148 jstring  __attribute__((export_name("TS_ParseOrSemanticError_to_str"))) TS_ParseOrSemanticError_to_str(uint32_t o) {
42149         LDKParseOrSemanticError* o_conv = (LDKParseOrSemanticError*)o;
42150         LDKStr ret_str = ParseOrSemanticError_to_str(o_conv);
42151         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
42152         Str_free(ret_str);
42153         return ret_conv;
42154 }
42155
42156 jstring  __attribute__((export_name("TS_Invoice_to_str"))) TS_Invoice_to_str(uint32_t o) {
42157         LDKInvoice o_conv;
42158         o_conv.inner = (void*)(o & (~1));
42159         o_conv.is_owned = false;
42160         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42161         LDKStr ret_str = Invoice_to_str(&o_conv);
42162         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
42163         Str_free(ret_str);
42164         return ret_conv;
42165 }
42166
42167 jstring  __attribute__((export_name("TS_SignedRawInvoice_to_str"))) TS_SignedRawInvoice_to_str(uint32_t o) {
42168         LDKSignedRawInvoice o_conv;
42169         o_conv.inner = (void*)(o & (~1));
42170         o_conv.is_owned = false;
42171         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
42172         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
42173         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
42174         Str_free(ret_str);
42175         return ret_conv;
42176 }
42177
42178 jstring  __attribute__((export_name("TS_Currency_to_str"))) TS_Currency_to_str(uint32_t o) {
42179         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
42180         LDKStr ret_str = Currency_to_str(o_conv);
42181         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
42182         Str_free(ret_str);
42183         return ret_conv;
42184 }
42185
42186 jstring  __attribute__((export_name("TS_SiPrefix_to_str"))) TS_SiPrefix_to_str(uint32_t o) {
42187         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
42188         LDKStr ret_str = SiPrefix_to_str(o_conv);
42189         jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
42190         Str_free(ret_str);
42191         return ret_conv;
42192 }
42193